:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(signals): send one inbox report open per open record (#120779)
posthog[bot]1320379e4736
diff --git a/products/signals/frontend/inbox/inboxSceneLogic.test.ts b/products/signals/frontend/inbox/inboxSceneLogic.test.tsindex b058a8782b91..128fd8dfd793 100644--- a/products/signals/frontend/inbox/inboxSceneLogic.test.ts+++ b/products/signals/frontend/inbox/inboxSceneLogic.test.ts@@ -384,9 +384,14 @@ describe('inboxSceneLogic routing', () => {logic.actions.loadSelectedReportSuccess(report)const afterOpen = Date.now()expect(openedEvents(captureSpy)).toHaveLength(0)+ // kea-disposables runs the poll setup again on a resume, and one without a pause leaves the+ // first interval running. That leftover interval must not send the open again on each tick.+ document.dispatchEvent(new Event('visibilitychange'))+ await waitForOpenRankRetry()await waitForOpenRankRetry()+ expect(openedEvents(captureSpy)).toHaveLength(1)expect(openedEvents(captureSpy)[0]).toMatchObject({rank: 1,list_size: 1,diff --git a/products/signals/frontend/inbox/inboxSceneLogic.ts b/products/signals/frontend/inbox/inboxSceneLogic.tsindex c255b5a4c2bb..efbd1150db2a 100644--- a/products/signals/frontend/inbox/inboxSceneLogic.ts+++ b/products/signals/frontend/inbox/inboxSceneLogic.ts@@ -331,8 +331,13 @@ function captureOpenWhenRanked(): void {const previousReportId = cache.previousReportId ?? nullconst deadline = Date.now() + OPEN_RANK_WAIT_MS+ let sent = falseconst fire = (resolved: ReturnType<typeof findReportRank>, options?: CaptureOptions): void => {+ if (sent) {+ return+ }+ sent = truecache.pendingOpenCapture = undefinedcache.disposables.dispose('openRank')captureInboxReportOpened(@@ -367,11 +372,20 @@ function captureOpenWhenRanked(cache.pendingOpenCapture = (options?: CaptureOptions) => fire(findReportRank(tracking.report.id), options)fireWhenReady(true)- if (!cache.pendingOpenCapture) {+ if (sent) {return}+ // kea-disposables runs this setup again on each resume. A resume without a pause replaces the+ // stored cleanup and leaves the earlier interval running, so each tick checks `sent` and stops+ // itself rather than rely on `dispose` alone.cache.disposables.add(() => {- const interval = setInterval(() => fireWhenReady(false), OPEN_RANK_POLL_MS)+ const interval = setInterval(() => {+ if (sent) {+ clearInterval(interval)+ return+ }+ fireWhenReady(false)+ }, OPEN_RANK_POLL_MS)return () => clearInterval(interval)}, 'openRank')}