Skip to content

Commit 675602b

Browse files
committed
neat
1 parent 0ee7840 commit 675602b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

playground/nextjs/src/posthog.ts

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ if (typeof window !== 'undefined') {
6767
opt_in_site_apps: true,
6868
__preview_remote_config: true,
6969
__preview_experimental_cookieless_mode: false,
70+
__preview_flags_v2: true,
7071
...configForConsent(),
7172
})
7273
// Help with debugging

src/__tests__/__snapshots__/config-snapshot.test.ts.snap

+5
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,11 @@ exports[`config snapshot for PostHogConfig 1`] = `
502502
\\"false\\",
503503
\\"true\\"
504504
],
505+
\\"__preview_flags_v2\\": [
506+
\\"undefined\\",
507+
\\"false\\",
508+
\\"true\\"
509+
],
505510
\\"api_method\\": [
506511
\\"undefined\\",
507512
\\"string\\"

src/posthog-featureflags.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ export class PostHogFeatureFlags {
390390
data.disable_flags = true
391391
}
392392

393+
// NB: flags v2 requires remote config to be enabled as well, since the idea is that we will skip calling /decide altogether
394+
// (which remote config does) and just use the /flags endpoint. May revisit this if we need to support flags v2 without remote config
395+
// (e.g. we could call `/decide` with flags disabled for the data otherwise returned by remote config, and then still call
396+
// `/flags/` to get the flag evaluation data).
393397
const eligibleForFlagsV2 =
394398
this.instance.config.__preview_flags_v2 && this.instance.config.__preview_remote_config
395399

@@ -415,8 +419,8 @@ export class PostHogFeatureFlags {
415419

416420
this._requestInFlight = false
417421

422+
// NB: this block is only reached if this.instance.config.__preview_remote_config is false
418423
if (!this._decideCalled) {
419-
// NB: this will be true if remote config is enabled, which it is for the default posthog app api key
420424
this._decideCalled = true
421425
this.instance._onRemoteConfig(response.json ?? {})
422426
}

0 commit comments

Comments
 (0)