Repository navigation
perf(flags): stop PostHog flag requests in every client - #24386
Git-on-my-level wants to merge 12 commits into
Conversation
Both experiment flags already serve one arm at 100%. Reading them is what blocks the release that stops clients loading flags from PostHog. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Disable PostHog flag preloads, explicit and implicit requests while preserving event capture and mobile replay. Keep missing-key defaults and account-bound snapshots; prepare the pending chat and replay store migration. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Preserve the Coordinator-owned #24370 fixed trial and Pocket arms and make their exposure-only role explicit for new builds. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The app has no PosthogObserver survey surface. Disable SDK surveys in Dart and the first native setup so the transport bootstrap cannot install native survey UI in place of Flutter delegation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Normalize trailing slashes in the request-path recorder; pinned SDK capture uses /batch and flag requests use /flags. Exercise both forms of flags and decide locally. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Use the established killSwitchFlag constant convention so the registry checker tracks this Omi-only read after the SDK bypass is removed. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replace the retired PostHog fallback expectation and add a hermetic SDK request-path step covering the new transport while verifying analytics batch delivery. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
PostHog snapshots its SDK context during setup. Seed Flutter attribution before native initialization and pin the declared version to pubspec.lock with a regression test. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
There was a problem hiding this comment.
23 issues found across 38 files
Confidence score: 3/5
LocalCapabilityRemoteKill.swiftno longer enforces the free-tier emergency stop on cold start or after an account reset until a/v1/flagsfetch succeeds. Preserve a fallback that covers those periods.screen-task-jev-gate.yamland its blocker tests don't prove the gate ignores PostHog or that replay and remote config pass through. Add SDK-level assertions for those behaviors.app/build.gradleuses a floating PostHog version range, so builds can pick an SDK version thatposthog_flutter5.28.0 wasn't tested with. Pin the matching native version.- The changelog fragments for
ChatAppsGateand the paywall/onboarding changes are markedkind: nonedespite user-visible behavior changes. Update them to the appropriate user-facing change kind.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="app/android/app/build.gradle">
<violation number="1" location="app/android/app/build.gradle:61">
P2: This configuration-time lookup has no null guards, so a missing `.flutter-plugins-dependencies` or `posthog_flutter` entry fails the whole Gradle configuration with an unhelpful NPE. Add an explicit check with a clear `GradleException` message when the plugin or version line is not found.</violation>
<violation number="2" location="app/android/app/build.gradle:187">
P2: The posthog-android dependency uses a floating range `[3.51.0,4.0.0]`, so builds can silently pick a newer SDK than the one `posthog_flutter` 5.28.0 was tested with. Pin it to the exact native version that matches the Flutter plugin, and bump it deliberately with the plugin.</violation>
</file>
<file name="app/test/unit/onboarding_variant_gate_test.dart">
<violation number="1" location="app/test/unit/onboarding_variant_gate_test.dart:10">
P2: This assertion does not verify the PR’s core no-flag-read guarantee. Add an observable flag-access seam or request-count assertion so a PostHog read cannot regress unnoticed.</violation>
</file>
<file name="desktop/macos/e2e/flows/screen-task-jev-gate.yaml">
<violation number="1" location="desktop/macos/e2e/flows/screen-task-jev-gate.yaml:41">
P2: S1b can pass without proving that PostHog is ignored: it never sets a conflicting PostHog value or asserts zero `/flags`/`/decide` traffic. Make the fixture return false and assert the gate remains enabled with no downstream flag request.</violation>
<violation number="2" location="desktop/macos/e2e/flows/screen-task-jev-gate.yaml:45">
P2: S1c requires replay and remote-config pass-through, but `PostHogFlagRequestBlockerTests` only drives identify/reset/reload/capture; its non-flag checks call `canInit` directly. Add SDK calls and downstream assertions for those paths, or remove them from this flow’s coverage claim.
(Based on your team's feedback about requiring E2E flows to exercise claimed paths.)</violation>
</file>
<file name="app/changelog/unreleased/20261102-omi-flag-authority.json">
<violation number="1" location="app/changelog/unreleased/20261102-omi-flag-authority.json:1">
P2: This file declares `kind: none`, but the PR changes what chat-app channels users see. `ChatAppsGate` now exposes only Telegram on the public `mobile-chat-apps` key, so iMessage and WhatsApp need the new `mobile-chat-apps-all-channels` flag. The existing WhatsApp fragment promises users WhatsApp connects once it is enabled, so this change needs a user-facing fragment or an explicit reason why it is not user-visible.</violation>
</file>
<file name="web/app/src/lib/__tests__/posthogFlags.test.ts">
<violation number="1" location="web/app/src/lib/__tests__/posthogFlags.test.ts:43">
P2: This test can pass when `PostHogManager` omits reads or queries the wrong flag key. Assert four calls and each key so the test verifies Omi is actually the source for every result.</violation>
</file>
<file name="app/test/unit/chat_apps_gate_test.dart">
<violation number="1" location="app/test/unit/chat_apps_gate_test.dart:22">
P2: `readFlag: (_) async => true` makes this test pass regardless of which flag `read` queries, so it cannot catch a regression that treats the public `mobile-chat-apps` flag as the private all-channels gate. Return true only for `ChatAppsGate.allChannelsFlag`; the first test already covers the public-key path.</violation>
</file>
<file name="app/test/unit/paywall_experiment_test.dart">
<violation number="1" location="app/test/unit/paywall_experiment_test.dart:10">
P2: This test does not verify the no-flag-read contract it claims to cover. Add an analytics/flag-reader spy or another injectable seam and assert that neither variant nor payload is requested.</violation>
</file>
<file name="backend/docs/runbooks/omi-flags.md">
<violation number="1" location="backend/docs/runbooks/omi-flags.md:24">
P3: The rewrite drops the server-side absent behavior. Under `OMI_FLAGS_SOURCE=omi`, a key with no rule should resolve to its registry fail value, but the runbook now only describes client defaults. Restore that sentence so operators know what `proactivity_v2` does during rollout.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/LocalInference/LocalCapabilityRemoteKill.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/LocalInference/LocalCapabilityRemoteKill.swift:7">
P3: The ARCHITECTURE.md paragraph on `free-tier-kill-switch-v1` still says the kill reads only the SDK cache and that the SDK refresh owns latency. Update it to say the kill reads `OmiFlagStore`, refreshed on identify and the 30-minute tick.</violation>
<violation number="2" location="desktop/macos/Desktop/Sources/LocalInference/LocalCapabilityRemoteKill.swift:7">
P2: With the SDK-cache fallback removed, the free-tier emergency stop is not enforced from cold start until the first successful `/v1/flags` fetch, and after any account reset. The kill was previously honored from the persisted PostHog cache in that window. Confirm this fail-open window is accepted for an ops cost-stop before merging.</violation>
</file>
<file name="app/changelog/unreleased/fixed-paywall-onboarding-arms.json">
<violation number="1" location="app/changelog/unreleased/fixed-paywall-onboarding-arms.json:1">
P2: This fragment is `kind: none`, which says there is no user-visible change. The code now shows the trial paywall and Pocket onboarding unconditionally, where before any flag failure fell back to control. Use a user-facing `change` entry, or confirm that no user can reach the control path today.</violation>
</file>
<file name="config/feature-flags.yaml">
<violation number="1" location="config/feature-flags.yaml:335">
P2: This row is recorded as a settled `keep` decision, but the notes and PR say it is an unapproved proposal. Set `decision` to `pending` and `terminal` to `undecided`, and add a `review_by` like the other pending rows, until David/Nik approve it.</violation>
<violation number="2" location="config/feature-flags.yaml:610">
P2: The replay flag now documents a proposed 5% cohort, but its rollout ramp still jumps from internal identities to 20% and 50%. Add the 5% cohort to `ramp.cohorts` (then regenerate the registry), or change the proposal text to match the intended ramp.</violation>
</file>
<file name="app/lib/pages/paywall/paywall_router.dart">
<violation number="1" location="app/lib/pages/paywall/paywall_router.dart:32">
P3: With the `await` removed, nothing async runs between the `usage` read and these guards. The `context.mounted` check and the repeated `showSubscriptionUI` check can no longer fire, so delete them.</violation>
</file>
<file name="desktop/macos/Desktop/Tests/PostHogFlagRequestBlockerTests.swift">
<violation number="1" location="desktop/macos/Desktop/Tests/PostHogFlagRequestBlockerTests.swift:25">
P2: This expectation is fulfilled by the first analytics batch, not specifically by the batch caused by `capture("flags-cut-capture")`. If identify/reset or persisted SDK work emits a batch first, the await returns before the capture flush is observed and the test can pass without proving capture still reaches the network; arm a fresh post-setup expectation or assert a batch count increase after the capture flush.</violation>
</file>
<file name="desktop/macos/Desktop/Sources/OmiFlagStore.swift">
<violation number="1" location="desktop/macos/Desktop/Sources/OmiFlagStore.swift:12">
P3: This comment omits the 5-minute poll in `RatingPromptManager` that also calls `reloadFeatureFlags()` while the prompt is visible. Add that cadence or drop the enumeration so the comment matches the actual refresh sources.</violation>
<violation number="2" location="desktop/macos/Desktop/Sources/OmiFlagStore.swift:47">
P3: The new in-flight guard and the `reset()` notification have no test coverage. Add a test that calls `reset()` with flags present and asserts `featureFlagsDidLoad` posts, and one that checks a second `refresh()` at the same generation is suppressed while the first is in flight.</violation>
</file>
<file name="app/lib/services/experiments/session_replay_gate.dart">
<violation number="1" location="app/lib/services/experiments/session_replay_gate.dart:6">
P3: This comment says the internal UIDs are already approved, but replay targeting remains pending approval and real UID inputs. Describe the UID cohort as pending so this gate is not presented as release-authorized.</violation>
</file>
<file name="app/lib/services/experiments/chat_apps_gate.dart">
<violation number="1" location="app/lib/services/experiments/chat_apps_gate.dart:109">
P2: This new allowlist read breaks the existing `messaging_channels_provider_test.dart` test, which still expects the public flag to be used for both reads. Update that test to cover the false/public and true/all-channels branches and their new key sequences.</violation>
</file>
<file name="web/personas-open-source/src/app/layout.tsx">
<violation number="1" location="web/personas-open-source/src/app/layout.tsx:62">
P2: `advanced_disable_feature_flags` disables evaluation but keeps PostHog’s `/flags` request active. Use `advanced_disable_flags: true` so the persona build makes no PostHog flags request.</violation>
</file>
<file name="web/app/src/lib/analytics/posthog.ts">
<violation number="1" location="web/app/src/lib/analytics/posthog.ts:19">
P2: `advanced_disable_feature_flags` disables evaluation but keeps PostHog’s `/flags` request active. Use `advanced_disable_flags: true` so the web app makes no PostHog flags request.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| // Match the Flutter plugin's SDK attribution in our first native setup. | ||
| // Read the resolved package, so dependency upgrades cannot silently stale it. | ||
| def flutterPlugins = new groovy.json.JsonSlurper().parse(rootProject.file('../.flutter-plugins-dependencies')) | ||
| def posthogPlugin = flutterPlugins.plugins.android.find { it.name == 'posthog_flutter' } |
There was a problem hiding this comment.
P2: This configuration-time lookup has no null guards, so a missing .flutter-plugins-dependencies or posthog_flutter entry fails the whole Gradle configuration with an unhelpful NPE. Add an explicit check with a clear GradleException message when the plugin or version line is not found.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/android/app/build.gradle, line 61:
<comment>This configuration-time lookup has no null guards, so a missing `.flutter-plugins-dependencies` or `posthog_flutter` entry fails the whole Gradle configuration with an unhelpful NPE. Add an explicit check with a clear `GradleException` message when the plugin or version line is not found.</comment>
<file context>
@@ -55,6 +55,13 @@ kotlin {
+// Match the Flutter plugin's SDK attribution in our first native setup.
+// Read the resolved package, so dependency upgrades cannot silently stale it.
+def flutterPlugins = new groovy.json.JsonSlurper().parse(rootProject.file('../.flutter-plugins-dependencies'))
+def posthogPlugin = flutterPlugins.plugins.android.find { it.name == 'posthog_flutter' }
+def posthogFlutterVersion = new File(posthogPlugin.path, 'pubspec.yaml').readLines()
+ .find { it.startsWith('version:') }.split(':', 2)[1].trim()
</file context>
| androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
| implementation 'androidx.multidex:multidex:2.0.1' | ||
| implementation 'com.squareup.okhttp3:okhttp:4.12.0' | ||
| implementation 'com.posthog:posthog-android:[3.51.0,4.0.0]' |
There was a problem hiding this comment.
P2: The posthog-android dependency uses a floating range [3.51.0,4.0.0], so builds can silently pick a newer SDK than the one posthog_flutter 5.28.0 was tested with. Pin it to the exact native version that matches the Flutter plugin, and bump it deliberately with the plugin.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/android/app/build.gradle, line 187:
<comment>The posthog-android dependency uses a floating range `[3.51.0,4.0.0]`, so builds can silently pick a newer SDK than the one `posthog_flutter` 5.28.0 was tested with. Pin it to the exact native version that matches the Flutter plugin, and bump it deliberately with the plugin.</comment>
<file context>
@@ -176,6 +184,7 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.squareup.okhttp3:okhttp:4.12.0'
+ implementation 'com.posthog:posthog-android:[3.51.0,4.0.0]'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
implementation 'io.intercom.android:intercom-sdk:latest.release'
</file context>
| implementation 'com.posthog:posthog-android:[3.51.0,4.0.0]' | |
| implementation 'com.posthog:posthog-android:3.51.0' |
|
|
||
| test('flag key is the registered PostHog key', () { | ||
| test('readers get pocket without any flag read; the key stays registered', () { | ||
| expect(OnboardingVariantGate.arm, OnboardingArm.pocket); |
There was a problem hiding this comment.
P2: This assertion does not verify the PR’s core no-flag-read guarantee. Add an observable flag-access seam or request-count assertion so a PostHog read cannot regress unnoticed.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/test/unit/onboarding_variant_gate_test.dart, line 10:
<comment>This assertion does not verify the PR’s core no-flag-read guarantee. Add an observable flag-access seam or request-count assertion so a PostHog read cannot regress unnoticed.</comment>
<file context>
@@ -1,16 +1,13 @@
-
- test('flag key is the registered PostHog key', () {
+ test('readers get pocket without any flag read; the key stays registered', () {
+ expect(OnboardingVariantGate.arm, OnboardingArm.pocket);
expect(OnboardingVariantGate.enabledFlag, 'onboarding-variant');
expect(OnboardingVariantGate.debugOverride, isNull);
</file context>
|
|
||
| - id: S1c | ||
| name: SDK identity changes cannot fetch flags and analytics still captures | ||
| do: "Run the hermetic PostHogFlagRequestBlockerTests with its SDK-scoped URLProtocol fixture (posthog.invalid, no production host or account). Verify both /flags and /decide path forms are answered locally with empty flags. Drive SDK identify, reset and reload; assert the downstream fixture records zero flag paths and receives the analytics /batch request. The same fixture must pass capture, replay and remote-config paths through. Record this unit evidence separately from live named-bundle acceptance; no production analytics request is permitted for this probe." |
There was a problem hiding this comment.
P2: S1c requires replay and remote-config pass-through, but PostHogFlagRequestBlockerTests only drives identify/reset/reload/capture; its non-flag checks call canInit directly. Add SDK calls and downstream assertions for those paths, or remove them from this flow’s coverage claim.
(Based on your team's feedback about requiring E2E flows to exercise claimed paths.)
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/e2e/flows/screen-task-jev-gate.yaml, line 45:
<comment>S1c requires replay and remote-config pass-through, but `PostHogFlagRequestBlockerTests` only drives identify/reset/reload/capture; its non-flag checks call `canInit` directly. Add SDK calls and downstream assertions for those paths, or remove them from this flow’s coverage claim.
(Based on your team's feedback about requiring E2E flows to exercise claimed paths.) </comment>
<file context>
@@ -33,11 +34,15 @@ preconditions:
+
+ - id: S1c
+ name: SDK identity changes cannot fetch flags and analytics still captures
+ do: "Run the hermetic PostHogFlagRequestBlockerTests with its SDK-scoped URLProtocol fixture (posthog.invalid, no production host or account). Verify both /flags and /decide path forms are answered locally with empty flags. Drive SDK identify, reset and reload; assert the downstream fixture records zero flag paths and receives the analytics /batch request. The same fixture must pass capture, replay and remote-config paths through. Record this unit evidence separately from live named-bundle acceptance; no production analytics request is permitted for this probe."
- id: S2
</file context>
| name: An Omi flag-store rule answers ahead of PostHog | ||
| do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} while the PostHog fixture keeps it true, relaunch and verify the gate does not run (the Omi answer wins). Serve an empty flags list and verify the PostHog value decides again after the next reload. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands." | ||
| name: Only the Omi flag-store rule can answer | ||
| do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} relaunch and verify the gate does not run. Serve an empty flags list and verify the gate defaults on after the next successful refresh, without consulting PostHog. A failed refresh keeps the same-account Omi answer. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands." |
There was a problem hiding this comment.
P2: S1b can pass without proving that PostHog is ignored: it never sets a conflicting PostHog value or asserts zero /flags//decide traffic. Make the fixture return false and assert the gate remains enabled with no downstream flag request.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/e2e/flows/screen-task-jev-gate.yaml, line 41:
<comment>S1b can pass without proving that PostHog is ignored: it never sets a conflicting PostHog value or asserts zero `/flags`/`/decide` traffic. Make the fixture return false and assert the gate remains enabled with no downstream flag request.</comment>
<file context>
@@ -33,11 +34,15 @@ preconditions:
- name: An Omi flag-store rule answers ahead of PostHog
- do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} while the PostHog fixture keeps it true, relaunch and verify the gate does not run (the Omi answer wins). Serve an empty flags list and verify the PostHog value decides again after the next reload. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands."
+ name: Only the Omi flag-store rule can answer
+ do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} relaunch and verify the gate does not run. Serve an empty flags list and verify the gate defaults on after the next successful refresh, without consulting PostHog. A failed refresh keeps the same-account Omi answer. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands."
+
+ - id: S1c
</file context>
| do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} relaunch and verify the gate does not run. Serve an empty flags list and verify the gate defaults on after the next successful refresh, without consulting PostHog. A failed refresh keeps the same-account Omi answer. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands." | |
| do: "With the synthetic backend serving GET /v1/flags?surface=macos as {screen_task_jev_gate: enabled=false} relaunch and verify the gate does not run. Serve an empty flags list while the conflicting PostHog fixture returns false, then verify the gate defaults on after the next successful refresh and the downstream fixture records zero /flags and /decide requests. A failed refresh keeps the same-account Omi answer. Sign out and in as another synthetic account and verify the first account's Omi answers are gone before the new fetch lands." |
|
|
||
| static var isDisabled: Bool { | ||
| resolve(OmiFlagStore.shared.value(key) ?? PostHogSDK.shared.getFeatureFlag(key, sendFeatureFlagEvent: false)) | ||
| resolve(OmiFlagStore.shared.value(killSwitchFlag)) |
There was a problem hiding this comment.
P3: The ARCHITECTURE.md paragraph on free-tier-kill-switch-v1 still says the kill reads only the SDK cache and that the SDK refresh owns latency. Update it to say the kill reads OmiFlagStore, refreshed on identify and the 30-minute tick.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/Desktop/Sources/LocalInference/LocalCapabilityRemoteKill.swift, line 7:
<comment>The ARCHITECTURE.md paragraph on `free-tier-kill-switch-v1` still says the kill reads only the SDK cache and that the SDK refresh owns latency. Update it to say the kill reads `OmiFlagStore`, refreshed on identify and the 30-minute tick.</comment>
<file context>
@@ -1,12 +1,10 @@
static var isDisabled: Bool {
- resolve(OmiFlagStore.shared.value(key) ?? PostHogSDK.shared.getFeatureFlag(key, sendFeatureFlagEvent: false))
+ resolve(OmiFlagStore.shared.value(killSwitchFlag))
}
</file context>
| final resolved = config ?? PaywallExperiment.current; | ||
| if (!context.mounted) return false; | ||
| if (!context.read<UsageProvider>().showSubscriptionUI) return false; |
There was a problem hiding this comment.
P3: With the await removed, nothing async runs between the usage read and these guards. The context.mounted check and the repeated showSubscriptionUI check can no longer fire, so delete them.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/pages/paywall/paywall_router.dart, line 32:
<comment>With the `await` removed, nothing async runs between the `usage` read and these guards. The `context.mounted` check and the repeated `showSubscriptionUI` check can no longer fire, so delete them.</comment>
<file context>
@@ -30,7 +29,7 @@ abstract final class PaywallRouter {
if (!usage.showSubscriptionUI) return false;
if (usage.subscription?.subscription.plan.isPaid == true) return false;
- final resolved = config ?? await PaywallExperiment.resolve();
+ final resolved = config ?? PaywallExperiment.current;
if (!context.mounted) return false;
if (!context.read<UsageProvider>().showSubscriptionUI) return false;
</file context>
| final resolved = config ?? PaywallExperiment.current; | |
| if (!context.mounted) return false; | |
| if (!context.read<UsageProvider>().showSubscriptionUI) return false; | |
| final resolved = config ?? PaywallExperiment.current; |
| /// identify and the 30-minute screen-task reload), so this adds one backend call per | ||
| /// PostHog reload and no PostHog requests. Docs: `backend/docs/runbooks/omi-flags.md`. | ||
| /// The only client flag authority. Missing keys are nil so callers retain their | ||
| /// existing defaults. Refreshes ride identify and the 30-minute screen-task tick; |
There was a problem hiding this comment.
P3: This comment omits the 5-minute poll in RatingPromptManager that also calls reloadFeatureFlags() while the prompt is visible. Add that cadence or drop the enumeration so the comment matches the actual refresh sources.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/Desktop/Sources/OmiFlagStore.swift, line 12:
<comment>This comment omits the 5-minute poll in `RatingPromptManager` that also calls `reloadFeatureFlags()` while the prompt is visible. Add that cadence or drop the enumeration so the comment matches the actual refresh sources.</comment>
<file context>
@@ -8,20 +8,16 @@ struct OmiFlag: Sendable, Equatable {
-/// identify and the 30-minute screen-task reload), so this adds one backend call per
-/// PostHog reload and no PostHog requests. Docs: `backend/docs/runbooks/omi-flags.md`.
+/// The only client flag authority. Missing keys are nil so callers retain their
+/// existing defaults. Refreshes ride identify and the 30-minute screen-task tick;
+/// failures keep the last answer for this account.
final class OmiFlagStore: @unchecked Sendable {
</file context>
| /// existing defaults. Refreshes ride identify and the 30-minute screen-task tick; | |
| /// existing defaults. Refreshes ride identify, the 30-minute screen-task tick, and the rating-prompt poll; |
| flags = [:] | ||
| return changed | ||
| } | ||
| if changed { |
There was a problem hiding this comment.
P3: The new in-flight guard and the reset() notification have no test coverage. Add a test that calls reset() with flags present and asserts featureFlagsDidLoad posts, and one that checks a second refresh() at the same generation is suppressed while the first is in flight.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At desktop/macos/Desktop/Sources/OmiFlagStore.swift, line 47:
<comment>The new in-flight guard and the `reset()` notification have no test coverage. Add a test that calls `reset()` with flags present and asserts `featureFlagsDidLoad` posts, and one that checks a second `refresh()` at the same generation is suppressed while the first is in flight.</comment>
<file context>
@@ -42,9 +38,16 @@ final class OmiFlagStore: @unchecked Sendable {
flags = [:]
+ return changed
+ }
+ if changed {
+ Task { @MainActor in
+ NotificationCenter.default.post(name: PostHogManager.featureFlagsDidLoad, object: nil)
</file context>
| /// `lib/utils/analytics/session_replay.dart` acts on it). Lifecycle: rollout; owner: nik; default off. | ||
| abstract final class SessionReplayGate { | ||
| /// PostHog flag key (project 302298). Registered in `config/feature-flags.yaml`. | ||
| /// Omi store boolean: proposed 5% plus approved internal UIDs; no client-side targeting. |
There was a problem hiding this comment.
P3: This comment says the internal UIDs are already approved, but replay targeting remains pending approval and real UID inputs. Describe the UID cohort as pending so this gate is not presented as release-authorized.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At app/lib/services/experiments/session_replay_gate.dart, line 6:
<comment>This comment says the internal UIDs are already approved, but replay targeting remains pending approval and real UID inputs. Describe the UID cohort as pending so this gate is not presented as release-authorized.</comment>
<file context>
@@ -3,7 +3,7 @@ import 'package:flutter/foundation.dart';
/// `lib/utils/analytics/session_replay.dart` acts on it). Lifecycle: rollout; owner: nik; default off.
abstract final class SessionReplayGate {
- /// PostHog flag key (project 302298). Registered in `config/feature-flags.yaml`.
+ /// Omi store boolean: proposed 5% plus approved internal UIDs; no client-side targeting.
static const enabledFlag = 'mobile-session-replay';
</file context>
| /// Omi store boolean: proposed 5% plus approved internal UIDs; no client-side targeting. | |
| /// Omi store boolean: proposed 5% plus an internal UID list pending approval; no client-side targeting. |
# Conflicts: # config/feature-flags.yaml
…t build Read the public mobile-chat-apps switch before the private all-channels key so the allowlist alone can never turn the surface on, and update the gate and provider key-sequence assertions to the new read order. Drop the two redundant URLProtocol @unchecked Sendable conformances that the pinned toolchain rejects as already unavailable, and satisfy the blocker capture expectation only when the decoded batch carries the requested event. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
@kodjima33 UI changes involving Git-on-my-level require your approval. Review the current diff, then comment |
|
Folded into the survivor #24485 (head What carried over: the Omi-store flag authority across Android (OmiPostHogSetup + flag-request blocker + tests), iOS (OmiPostHogSetup, pbxproj), macOS (OmiFlagStore, PostHogFlagRequestBlocker, LocalCapabilityRemoteKill and their tests), the posthog adapter/analytics-manager changes, chat-apps/session-replay gating, and the Union resolutions in |
|
Hey @Git-on-my-level 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
What changed and why
Cut billed PostHog flag HTTP traffic from new mobile, macOS and web builds. Flags now answer only from Omi's store, with existing caller defaults for absent keys; event capture and mobile replay remain in PostHog. Disable startup preloads and explicit SDK reloads, remove the Flutter
/decidefetch and every SDK-cache fallback, and suppress implicit native SDK identify/reset flag requests in SDK-scoped transports. Unused SDK surveys stay disabled (the app has no PosthogObserver survey surface), avoiding native survey UI during the first setup. No rollback flag: rollback is the prior client build or a corrected Omi rule.Dependency / release gate: stacks #24370 at
ba60f92dd9eb17d05e131c0e0ecb18c74a3f97c7, merged into this branch without changing its branch or PR. That draft fixestrialpaywall /pocketonboarding arms in code and stays Coordinator-owned pending Nik (kodjima33). Either PR can merge first with a merge commit. Do not release this cut before Nik's gate and David/Nik's chat/replay targeting ruling plus the approved store rules below. This PR performs no PostHog/store write, upstream merge, release or deploy.Product invariants affected
none
How it was verified
bun run check: typecheck, 6 smoke tests, 160 test files / 909 tests pass, including Omi-only flags and preserved capture/identify.:app:testDevDebugUnitTest --tests com.friend.ios.analytics.PostHogFlagRequestBlockerTest: BUILD SUCCESSFUL, both config/transport tests pass after compiling native app and plugin code.TranscriptionFinalizationStateMachineTests.swift:12andUnsyncedTaskCreateHTTPTests.swift:63(URLProtocolsubclasses inherit an unavailable Sendable conformance). Production app targets compiled/linked before the test-target failure. CI pins Xcode 26.6. All six affected tests pass in an isolated package against symlinked production store/transport sources and the exact PostHog 3.65.0 SDK; only unrelated app dependencies are stubbed. The real SDK sends an analytics batch while zero flag requests reach downstream transport. No tests are skipped in the full target.make preflight: 65 checks pass. PR metadata preflight: 5 checks pass. The complete bounded push hook also passes, including generated-output checks, desktop flow lint and macOS production compilation.UI author approval. The account-scoped path policy includes the stacked UI files and requires Nik (kodjima33) to comment/approve-ui 7cad5adf998f8711fb8806eb3e2b0a5b70e8ecd8on this PR.UI-Evidence: nonedoes not waive that exact-head human approval. Remaining build/test workflows are running; local passes above are separate from hosted CI.ro-prod(no account records). Seven existing client rules plus backendproactivity_v2are present inbased-hardware / omi-flags; the serving backend revision reports this target. PostHog billing/flag definitions read through the existing program helper only, without exposing credentials or person targeting values.Tests
screen-task-jev-gate.yamlstates Omi-only authority and a hermetic SDK request-path/capture step.posthog_adapter_flags_test.dart,chat_apps_gate_test.dart,posthogFlags.test.ts,omiFlags.test.ts,PostHogFlagRequestBlockerTests.swift,PostHogFlagRequestBlockerTest.kt, personasposthog-config.test.mjs. Native transport tests exercise local/flagsand/decideanswers and pass capture/replay/config paths through; Swift also drives real SDK identify/reset/reload and capture.UI evidence
UI-Evidence: none -- This cut changes flag authority and SDK transport, with no view/layout/copy edits. Approved store rules preserve the chat UI's current Telegram / David-only private-channel split; replay targeting changes recording eligibility. The trial/Pocket UI decision and its evidence belong to dependency #24370 and Nik's gate.
Flag inventory and value after the cut
"Unchanged" assumes the seven existing client rules are available; unknown keys retain caller defaults. Failed mobile/macOS refreshes keep only the same-account last-good in-memory snapshot. Account changes clear it. Web fails closed on failure/timeout. Pending writes are not assumed to have happened.
Availability change: there is no persisted SDK-cache fallback on a cold offline/store-unavailable launch. Those clients temporarily use caller defaults even if an old PostHog disk cache held another value: the stable lossless-sync 10% cohort and mobile onboarding-rating 100% rule wait for an Omi response, while unknown watch-copy state conservatively keeps recovery copies. Warm same-account failures retain Omi answers. The store remains the only authority; no new polling or SDK escape hatch is introduced.
clients_refactorclients_from_segments_chunkscustody_capture_committed_releasemobile-capture-recovery-v1saved-pendant-reconnect-killsummary-generation-v2mobile-plan-storefrontmobile-contextual-upsellsmobile-on-device-overflowmobile-speech-analyzer-disabledmobile-local-preview-disabledmobile-wal-delta-index-offwatch_copy_dedupe_offonboarding-setup-rating-promptmobile_store_review_tuningmobile-chat-appsmobile-chat-apps-all-channelsmobile-session-replaypaywall-varianttrialfrom #24370; exposure analytics retained. Live PostHog currently trial 100%; same arm, pending Nikonboarding-variantpocketfrom #24370; exposure analytics retained. Live PostHog currently pocket 100%; same arm, pending Nikonboarding-webviewclients_refactorclients_from_segments_chunksclients_boundary_evidenceclient_telemetry_transport_shadowclient_telemetry_posthog_retirementdesktop-rating-prompt-disabledfree-tier-kill-switch-v1negative_feedback_remediation_killscreen_activity_lossless_syncscreen_activity_lossless_sync_killscreen_task_jev_gateapp_build >= 12552or unset). Only explicit false kills. No store write needed; old <=12551 installations keep their old behavior until upgraded. Backend admission and consent remain separate authoritiesdesktop-plan-storefrontdesktop-contextual-upsellsweb-plan-storefrontweb-contextual-upsellsExact pending store changes (not executed)
Target:
projects/based-hardware/databases/omi-flags, collectionomi_flags. Usebackend/scripts/omi_flags.py, which copies registry surfaces and adds version/timestamp/actor plus the atomic audit/meta write. No--mirror-posthog. The three keys are currently absent, so no allow/deny lists need clearing.mobile-chat-appsactive: true,rollout_percentage: 100,variant: "telegram",payload: "{\"telegram\":{\"provider\":\"telegram\",\"address\":\"omi_chat_bot\"}}",allow_uids: [],deny_uids: [],surfaces: ["mobile"]mobile-chat-apps-all-channelsactive: true,rollout_percentage: 0,variant: "all-channels",payload: exact currentmobile-chat-appsPostHogall-channelspayload,allow_uids: [DAVID_UID],deny_uids: [],surfaces: ["mobile"]mobile-session-replayactive: true,rollout_percentage: 5,variant: null,payload: null,allow_uids: APPROVED_INTERNAL_UIDS,deny_uids: [],surfaces: ["mobile"]DAVID_UIDandAPPROVED_INTERNAL_UIDSare unresolved operator inputs, not runnable placeholders or invented identities. The limit on production account access prevents resolving emails to UIDs in this lane. The existing private-channel payload is configuration, not a new endpoint. David/Nik must approve these exact rules and supply the UID list before a writer prepares its reviewed CLI plan. The store cannot express property targeting or per-group variants; no claim of exact replay cohort parity. Do not write paywall/onboarding arms orscreen_task_jev_gate; do not recreate absent 0% kill switches just to retain false defaults.The cut itself ships on, without a new gate. The separate private-channel key is the requested real-risk boundary preventing exposure of unreleased channel endpoints; it is a persistent explicit allowlist, not a delayed public rollout. Replay proposal keeps 5% plus internal users; Nik owns expansion only after clean stored-frame fidelity, slow-frame/crash metrics and replay-budget checks, by the existing 2026-11-25 review deadline.
Billing / reachable saving (read-only)
The helper's
feature_flagsusage reports Oct 30 139,199, Oct 31 866,324, Nov 1 419,889 requests: 475,137/day mean. 866K is not the run rate. Read-only billing API snapshot on 2026-11-02: 25,492,050 requests / $841.90 posted (usage and tier charges can post asynchronously).The account's actual graduated tiers are first 1M free; 1–2M $0.0001; 2–10M $0.000045; 10–50M $0.000025; above 50M $0.00001. At the rounded 475K/day baseline, 30 days = 14.25M and $566.25/month (31 days $578.13): $100 + $360 + $106.25. The earlier 19.8M / $705 matches this curve. $25/M is only the current marginal tier, not a flat total-bill rate. Pricing.
Attribution is an estimate from activity, not billing attribution: releasable macOS ~30K/day plus mobile <100K/day and small web volume. Full adoption of this PR reaches roughly 30K–130K/day plus web, or $22.50–$97.50/month plus web at 30 days ($23.25–$100.75 at 31). It cannot remove most old-build traffic via a new release. No saving has been realized by this unshipped PR; backend requests remain separate. A separately approved $0 feature-flags billing cap could remove the remaining future flag charge after the free allocation (it cannot undo already-posted spend) (up to the full $566–$578/month baseline), but it changes legacy/backend flag availability and is not part of this release saving.
Can a PostHog-side control reach old macOS builds?
Billing limit: yes for spend, not a reliable client kill. PostHog documents an organization-wide per-product cap, shared across projects. Over-limit flag evaluations return quota-limited defaults; the cap prevents charges above the configured amount. It does not stop HTTP polling and affects old mobile experiments / other projects too. The shared server pipeline returns the quota response before its billing-record step; the limit response contains no evaluated flags, so those blocked requests are not recorded as billable evaluations.
/decideand/flagsshare PostHog's flag handler, including quota handling; build 12551 actually sends/flags/?v=2. No setting was changed. Limits, flag quota response.Pinned-source caveat: tag
v0.12.551+12551-macospins PostHog iOS 3.65.0 (33145b13ffa1135623e6a2624e29234288a52258). ItsPostHogRemoteConfig.swiftexplicitly retains cached flags whenquotaLimitedcontainsfeature_flags; it does not simply empty them as the generic docs suggest. Cachedscreen_task_jev_gate=falseremains off (slow reload), cached true remains on. With genuinely empty valid flags or no cache,ScreenTaskFeatureand the directScreenTaskFreshFlagResponsetreat missing/quota-limited flags as on; backend admission remains required, and the 30-second on-path can continue issuing requests (unbilled after the cap). Active old tagsv0.12.505+12505-macosandv0.12.541+12541-macosalso pin that exact SDK revision; 12505 likewise hard-codes the cloud host and preloads flags. Very old tags/SDKs may differ; this is not an assertion about every historic build. SDK source, old client.Owned proxy: no for the inspected old build. Its
PostHogManagerhard-codeshttps://us.i.posthog.com; there is no Omi-controlled proxy/host setting to cut off. A cap requires a separate David-approved operation and assessment of legacy cached/default behavior after Nik's migration gate. The inspected backend is stillOMI_FLAGS_SOURCE=dual, which serves PostHog (not Omi) forproactivity_v2; quota-empty/error answers therefore deny that backend feature after its cache expires. Move and verify server authority separately before considering a cap.Failure class (fixes)
Failure-Class: none
🤖 Generated with Claude Code