-
Notifications
You must be signed in to change notification settings - Fork 131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Toolbar loading from state faster #849
Conversation
Size Change: +623 B (0%) Total Size: 723 kB
ℹ️ View Unchanged
|
import { PostHog } from '../posthog-core' | ||
import { DecideResponse, ToolbarParams } from '../types' | ||
import { POSTHOG_MANAGED_HOSTS } from './cloud' | ||
|
||
// TRICKY: Many web frameworks will modify the route on load, potentially before posthog is initialized. | ||
// To get ahead of this we grab it as soon as the posthog-js is parsed | ||
const STATE_FROM_WINDOW = window.location |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sneaky but interesting 😊
@@ -274,6 +274,14 @@ export const _formatDate = function (d: Date): string { | |||
) | |||
} | |||
|
|||
export const _try = function <T>(fn: () => T): T | undefined { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is really lovely
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely worth a try. Or rather this should definitely work...
Ignoring heatmap this is the #1 support load from toolbar so 🏅 for you if this works
Changes
Seems like a lot of web frameworks get in the way of us pulling the state from the location hash. Hacky fix for this is to try and get this info the moment the page loads, rather than after the sdk is initialised.
Checklist