feat(toolbar): posthog.loadToolbar({ temporaryToken: 'key' })
Changes
Implements
window.posthog.loadToolbar({ temporaryToken: 'key' })
With the aim to
- provide an alternative to the
#__posthog={state}url hash method to load the toolbar - provide users a way to capture the hash themselves in their single page app, and pass it on to posthog
Other params to temporaryToken, if provided, are passed on to the toolbar as well. Ideally they are not needed.
This PR also renames some old Editor identifiers into Toolbar, to better reflect our product. In a backwards compatible way 🤞.
There will be a follow up PR to the main repo with the some other improvements.
Checklist
- [x] Tests for new code (see advice on the tests we use)
- [x] Accounted for the impact of any changes across different browsers
I added one more feature, a source param that gets passed to posthog's toolbar. This will either be "url", "localstorage" or undefined, depending if the toolbar was loaded from the URL, from localstorage, or from any random loadToolbar call that didn't specify this further.
This way, when trying to make posthog.loadToolbar() work, I can avoid showing a big "token expired" warning to users whose tokens genuinely expire when they visit their own website 2 days later. No need to show a cryptic warning then.
EDIT: after 3 extra commits, ready for a look.