Skip to content

fix(analytics): exclude local onboarding traffic - #3069

Open
WcaleNieWolny wants to merge 4 commits into
mainfrom
wolny/fix-onboarding-analytics-host
Open

fix(analytics): exclude local onboarding traffic#3069
WcaleNieWolny wants to merge 4 commits into
mainfrom
wolny/fix-onboarding-analytics-host

Conversation

@WcaleNieWolny

@WcaleNieWolny WcaleNieWolny commented Aug 15, 2026

Copy link
Copy Markdown
Member

Summary

  • restrict frontend onboarding funnel events to console.capgo.app for every supported onboarding version
  • apply the same production-host filter to daily setup/copy outcomes while preserving host-independent CLI attribution
  • exclude previously captured localhost testing retroactively

Verification

  • bun lint
  • bun typecheck
  • bun test:unit (247 files, 1,999 tests)
  • CI console-statement grep

@coderabbitai

coderabbitai Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 6 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 6a8b722a-74bc-43ed-995d-6f8d4096f87b

📥 Commits

Reviewing files that changed from the base of the PR and between c08df92 and e4f38a7.

📒 Files selected for processing (5)
  • supabase/functions/_backend/utils/frontend_onboarding_analytics.ts
  • supabase/functions/_backend/utils/frontend_onboarding_analytics_model.ts
  • supabase/functions/_backend/utils/frontend_onboarding_daily_setup_cli_outcomes.ts
  • tests/frontend-onboarding-analytics.unit.test.ts
  • tests/frontend-onboarding-daily-setup-cli-outcomes.unit.test.ts

Comment @coderabbitai help to get the list of available commands.

@codspeed-hq

codspeed-hq Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 43 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing wolny/fix-onboarding-analytics-host (e4f38a7) with main (c08df92)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 2 files

Confidence score: 4/5

  • In supabase/functions/_backend/utils/frontend_onboarding_analytics.ts, buildFrontendOnboardingDailySetupCliHogql appears to still include localhost events while the aggregate attempts path excludes them, which can skew daily_setup_cli_outcomes metrics and make onboarding performance look worse/better than reality—apply the same localhost exclusion logic to this branch to keep analytics consistent.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="supabase/functions/_backend/utils/frontend_onboarding_analytics.ts">

<violation number="1" location="supabase/functions/_backend/utils/frontend_onboarding_analytics.ts:186">
P2: This filter excludes localhost only from the aggregate attempts, not from the `daily_setup_cli_outcomes` branch of the same function. `buildFrontendOnboardingDailySetupCliHogql` still matches frontend `onboarding_step_viewed` setup events without a `$host` predicate, so localhost test data keeps leaking into the setup-outcomes part of the response. Add the same `$host` filter to the frontend setup-events predicates in `frontend_onboarding_daily_setup_cli_outcomes.ts` to match the stated retroactive localhost-exclusion goal.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

FROM events
WHERE event IN (${eventAllowlist})
AND JSONExtractString(toString(properties), 'flow') = 'pre_org'
AND JSONExtractString(toString(properties), '$host') = 'console.capgo.app'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2: This filter excludes localhost only from the aggregate attempts, not from the daily_setup_cli_outcomes branch of the same function. buildFrontendOnboardingDailySetupCliHogql still matches frontend onboarding_step_viewed setup events without a $host predicate, so localhost test data keeps leaking into the setup-outcomes part of the response. Add the same $host filter to the frontend setup-events predicates in frontend_onboarding_daily_setup_cli_outcomes.ts to match the stated retroactive localhost-exclusion goal.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At supabase/functions/_backend/utils/frontend_onboarding_analytics.ts, line 186:

<comment>This filter excludes localhost only from the aggregate attempts, not from the `daily_setup_cli_outcomes` branch of the same function. `buildFrontendOnboardingDailySetupCliHogql` still matches frontend `onboarding_step_viewed` setup events without a `$host` predicate, so localhost test data keeps leaking into the setup-outcomes part of the response. Add the same `$host` filter to the frontend setup-events predicates in `frontend_onboarding_daily_setup_cli_outcomes.ts` to match the stated retroactive localhost-exclusion goal.</comment>

<file context>
@@ -183,6 +183,7 @@ export function buildFrontendOnboardingHogql(startDate: string, cohortEndDate: s
       FROM events
       WHERE event IN (${eventAllowlist})
         AND JSONExtractString(toString(properties), 'flow') = 'pre_org'
+        AND JSONExtractString(toString(properties), '$host') = 'console.capgo.app'
         AND toIntOrZero(toString(properties.onboarding_version)) IN (${versionAllowlist})
         AND timestamp >= parseDateTimeBestEffort(${sqlStr(startDate)})
</file context>

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in e0ea21f. The production-host predicate now applies to both setup_people and the selected frontend setup/copy branch; CLI-command events remain unfiltered. Regression assertions cover both predicates, and lint, typecheck, and all 1,999 unit tests pass.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread tests/frontend-onboarding-daily-setup-cli-outcomes.unit.test.ts
Comment thread supabase/functions/_backend/utils/frontend_onboarding_daily_setup_cli_outcomes.ts Outdated
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant