From 4b30ad4ea01b013661bf78070a60f756ddd96389 Mon Sep 17 00:00:00 2001 From: Tomasz Lesniakiewicz Date: Tue, 25 Nov 2025 14:51:50 +0100 Subject: [PATCH 1/4] add user cohort tag in sentry --- src/CONST/index.ts | 1 + src/libs/telemetry/TelemetrySynchronizer.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/CONST/index.ts b/src/CONST/index.ts index 176143022428..062d49b771b8 100755 --- a/src/CONST/index.ts +++ b/src/CONST/index.ts @@ -1660,6 +1660,7 @@ const CONST = { CONTEXT_FULLSTORY: 'Fullstory', CONTEXT_POLICIES: 'Policies', TAG_ACTIVE_POLICY: 'active_policy_id', + TAG_NUDGE_MIGRATION_COHORT: 'nudge_migration_cohort', // Span names SPAN_OPEN_REPORT: 'ManualOpenReport', SPAN_APP_STARTUP: 'ManualAppStartup', diff --git a/src/libs/telemetry/TelemetrySynchronizer.ts b/src/libs/telemetry/TelemetrySynchronizer.ts index fa1a2aafa913..95e50652dfa1 100644 --- a/src/libs/telemetry/TelemetrySynchronizer.ts +++ b/src/libs/telemetry/TelemetrySynchronizer.ts @@ -9,7 +9,7 @@ import Onyx from 'react-native-onyx'; import {getActivePolicies} from '@libs/PolicyUtils'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; -import type {Policy, Session} from '@src/types/onyx'; +import type {Policy, Session, TryNewDot} from '@src/types/onyx'; /** * Connect to Onyx to retrieve information about the user's active policies. @@ -17,6 +17,7 @@ import type {Policy, Session} from '@src/types/onyx'; let session: OnyxEntry; let activePolicyID: OnyxEntry; let policies: OnyxCollection; +let tryNewDot: OnyxEntry; Onyx.connectWithoutView({ key: ONYXKEYS.NVP_ACTIVE_POLICY_ID, @@ -52,6 +53,14 @@ Onyx.connectWithoutView({ }, }); +Onyx.connectWithoutView({ + key: ONYXKEYS.NVP_TRY_NEW_DOT, + callback: (value) => { + tryNewDot = value; + sendTryNewDotCohortTag(); + }, +}); + function sendPoliciesContext() { if (!policies || !session?.email || !activePolicyID) { return; @@ -60,3 +69,11 @@ function sendPoliciesContext() { Sentry.setTag(CONST.TELEMETRY.TAG_ACTIVE_POLICY, activePolicyID); Sentry.setContext(CONST.TELEMETRY.CONTEXT_POLICIES, {activePolicyID, activePolicies}); } + +function sendTryNewDotCohortTag() { + const cohort = tryNewDot?.nudgeMigration?.cohort; + if (cohort) { + return; + } + Sentry.setTag(CONST.TELEMETRY.TAG_NUDGE_MIGRATION_COHORT, cohort); +} From 840f116d6400e099bc83a7c4d374e3e497ff62b5 Mon Sep 17 00:00:00 2001 From: Tomasz Lesniakiewicz Date: Tue, 25 Nov 2025 14:52:05 +0100 Subject: [PATCH 2/4] add cohort missing type --- src/types/onyx/TryNewDot.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/types/onyx/TryNewDot.ts b/src/types/onyx/TryNewDot.ts index 21ebb2a3800a..13573a00ce9c 100644 --- a/src/types/onyx/TryNewDot.ts +++ b/src/types/onyx/TryNewDot.ts @@ -31,6 +31,8 @@ type TryNewDot = { nudgeMigration?: { /** Indicates timestamp of an action. */ timestamp: Date; + /** Indicates the user cohort type. */ + cohort?: string; }; }; From a57b0b6bec841d80beef561dd5f72e636148d05b Mon Sep 17 00:00:00 2001 From: Tomasz Lesniakiewicz Date: Tue, 25 Nov 2025 14:59:48 +0100 Subject: [PATCH 3/4] adjust comments --- src/types/onyx/TryNewDot.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/types/onyx/TryNewDot.ts b/src/types/onyx/TryNewDot.ts index 13573a00ce9c..ceb9232c8751 100644 --- a/src/types/onyx/TryNewDot.ts +++ b/src/types/onyx/TryNewDot.ts @@ -31,7 +31,7 @@ type TryNewDot = { nudgeMigration?: { /** Indicates timestamp of an action. */ timestamp: Date; - /** Indicates the user cohort type. */ + /** Indicates the user's cohort */ cohort?: string; }; }; From 5452821509c6e296a19ecd8efbd0629dee377c9c Mon Sep 17 00:00:00 2001 From: Tomasz Lesniakiewicz Date: Tue, 25 Nov 2025 15:15:46 +0100 Subject: [PATCH 4/4] fix cohort condition --- src/libs/telemetry/TelemetrySynchronizer.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/telemetry/TelemetrySynchronizer.ts b/src/libs/telemetry/TelemetrySynchronizer.ts index 95e50652dfa1..a8de074dd5d2 100644 --- a/src/libs/telemetry/TelemetrySynchronizer.ts +++ b/src/libs/telemetry/TelemetrySynchronizer.ts @@ -72,7 +72,7 @@ function sendPoliciesContext() { function sendTryNewDotCohortTag() { const cohort = tryNewDot?.nudgeMigration?.cohort; - if (cohort) { + if (!cohort) { return; } Sentry.setTag(CONST.TELEMETRY.TAG_NUDGE_MIGRATION_COHORT, cohort);