Listen for an unload event from the viewer
The viewer will send an "unload" event to notify the doc that it is about to be unloaded.
This should cause a visibility state change so that analytics can flush itself.
Eventually this should also return saved state that can be used to restore the doc as described in: https://github.com/ampproject/amphtml/issues/1677
The response can be {'savedState':
The message name we are using is "willUnload"
@ericfs Please advise on priority.
Higher than https://github.com/ampproject/amphtml/issues/1677 Discussed and agreed with @malteubl I think it would be very nice to have for overall stability.
I mean @cramforce
Name was changed to "willLikelyUnload" as there is a small chance the unload won't happen.
@ericfs Is this still needed. I'm going to close assuming it's not, but please let us know if that's not true.