-
Notifications
You must be signed in to change notification settings - Fork 134
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
fix: Refactor decide loading #1596
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hey @benjackwhite! 👋 |
Size Change: -8.4 kB (-0.26%) Total Size: 3.2 MB
ℹ️ View Unchanged
|
@@ -33,7 +33,9 @@ export default function App({ Component, pageProps }: AppProps) { | |||
} | |||
}, []) | |||
|
|||
const localhostDomain = process.env.NEXT_PUBLIC_CROSSDOMAIN ? 'https://localhost:8000' : 'http://localhost:8000' | |||
const localhostDomain = process.env.NEXT_PUBLIC_CROSSDOMAIN |
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.
Helper if runnning on localhost:8010
import '../entrypoints/external-scripts-loader' | ||
import { assignableWindow } from '../utils/globals' | ||
|
||
describe('RemoteConfigLoader', () => { |
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 was Decide but now it only handles config loading
@@ -545,6 +548,14 @@ export class PostHog { | |||
} | |||
|
|||
_onRemoteConfig(config: RemoteConfig) { | |||
if (!(document && document.body)) { |
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 was in decide before but should actually be here as this is the lower level call.
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.
seems good by my judgement, thanks for taking the time to dive in and pull things apart!
Co-authored-by: Dylan Martin <[email protected]>
# Conflicts: # src/__tests__/featureflags.test.ts # src/decide.ts # src/posthog-core.ts # src/posthog-featureflags.ts
Changes
This is a beafy refactor that came out of me having issues around how the RemoteConfig was working.
I basically found our code is super buggy around choosing when to load flags because there were two different things calling decide with a lot of bool properties that weren't really accurate to what they were doing
The main improvements here are:
Checklist