Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
benjackwhite committed Dec 3, 2024
1 parent 87f2d80 commit 676fdbd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions playground/nextjs/src/posthog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ if (typeof window !== 'undefined') {
persistence: cookieConsentGiven() ? 'localStorage+cookie' : 'memory',
person_profiles: PERSON_PROCESSING_MODE === 'never' ? 'identified_only' : PERSON_PROCESSING_MODE,
persistence_name: `${process.env.NEXT_PUBLIC_POSTHOG_KEY}_nextjs`,
__preview_remote_config: true,
...configForConsent(),
})
// Help with debugging(window as any).posthog = posthog
Expand Down
2 changes: 2 additions & 0 deletions src/decide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ export class Decide {
this.instance._onRemoteConfig(config)

if (config.hasFeatureFlags !== false) {
// TRICKY: This is set in the parent for some reason...
this.instance.featureFlags.setReloadingPaused(false)
// If the config has feature flags, we need to call decide to get the feature flags
// This completely separates it from the config logic which is good in terms of separation of concerns
this.instance.featureFlags.reloadFeatureFlags()
Expand Down
5 changes: 3 additions & 2 deletions src/web-experiments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export class WebExperiments {

constructor(private instance: PostHog) {
this.instance.onFeatureFlags((flags: string[]) => {
this.applyFeatureFlagChanges(flags)
this.onFeatureFlags(flags)
})
}

applyFeatureFlagChanges(flags: string[]) {
onFeatureFlags(flags: string[]) {
if (this._is_bot()) {
WebExperiments.logInfo('Refusing to render web experiment since the viewer is a likely bot')
return
Expand All @@ -49,6 +49,7 @@ export class WebExperiments {
// NOTE: Should this only fire once?
this.loadIfEnabled()
this.previewWebExperiment()
return
}

if (isNullish(this._flagToExperiments) || this.instance.config.disable_web_experiments) {
Expand Down

0 comments on commit 676fdbd

Please sign in to comment.