Skip analytics init on apps without persistent token store#1336
Conversation
Owned admin apps are constructed with `tokenStore: null`, which caused EventTracker/SessionRecorder flushes to throw from _ensurePersistentTokenStore() after #1331 removed the silencing.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughWalkthroughAnalytics startup in the client app was made conditional on the presence of a persistent token store; several tests were updated to skip specific cases when running against a local emulator. Changes
Sequence Diagram(s)(omitted — changes are minor/control gating and test-condition updates, not a multi-component new flow) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryThis PR fixes a crash in owned admin apps (constructed with Confidence Score: 5/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[StackClientApp Constructor] --> B{isBrowserLike?}
B -- No --> Z[No analytics initialized]
B -- Yes --> C{_hasPersistentTokenStore?}
C -- tokenStore is null --> Z
C -- tokenStore is set --> D{replays.enabled?}
D -- Yes --> E[Create and start SessionRecorder]
D -- No --> F[Skip SessionRecorder]
E --> G[Create and start EventTracker]
F --> G
G --> H[Analytics fully initialized]
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/e2e/tests/backend/endpoints/api/v1/internal/feedback.test.ts`:
- Line 6: The skip predicate is too broad: change the boolean logic around
isLocalEmulator so tests only skip when running a local emulator AND the
feedback mode is NOT forwarding; check process.env.STACK_FEEDBACK_MODE !==
"FORWARD_TO_PRODUCTION" in the same condition (update or create a helper like
shouldSkipLocalEmailAssertions that returns isLocalEmulator &&
process.env.STACK_FEEDBACK_MODE !== "FORWARD_TO_PRODUCTION"). Also add an
it.runIf(shouldSkipLocalEmailAssertions) test case that runs when the emulator
is present but STACK_FEEDBACK_MODE === "FORWARD_TO_PRODUCTION" asserting a
simple 200 { success: true } response to cover the forwarding-mode path.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 96a99466-4d76-4883-9639-56f5ad408978
📒 Files selected for processing (1)
apps/e2e/tests/backend/endpoints/api/v1/internal/feedback.test.ts
Owned admin apps are constructed with
tokenStore: null, which caused EventTracker/SessionRecorder flushes to throw from _ensurePersistentTokenStore() after #1331 removed the silencing.Summary by CodeRabbit