From f4903806324f817ca44de057cba6830299a12cbf Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Nov 2026 16:22:28 +0000 Subject: [PATCH] fix(pixels): type the tracker globals for the strict typecheck Touching PixelsContext.tsx put it under typecheck_strict_changed, which failed on the untyped globalThis tracker calls and the seniority lookup with an undefined experience level. Behaviour is unchanged. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01FodmVu1MjgKhW4EZtmBozt --- packages/webapp/context/PixelsContext.tsx | 62 ++++++++++++++--------- 1 file changed, 37 insertions(+), 25 deletions(-) diff --git a/packages/webapp/context/PixelsContext.tsx b/packages/webapp/context/PixelsContext.tsx index aa2c0470be..a4ad7e3f83 100644 --- a/packages/webapp/context/PixelsContext.tsx +++ b/packages/webapp/context/PixelsContext.tsx @@ -9,6 +9,17 @@ import { } from '@dailydotdev/shared/src/lib/ios'; import { EXPERIENCE_TO_SENIORITY, Pixels } from '../components/Pixels'; +type Tracker = (...args: unknown[]) => void; + +const pixels = globalThis as typeof globalThis & { + gtag?: Tracker; + fbq?: Tracker; + updateFbUserData?: (userId: string, email?: string) => void; + twq?: Tracker; + rdt?: Tracker; + ttq?: { track?: Tracker }; +}; + interface PixelsContextProviderProps { children: ReactElement; } @@ -23,65 +34,66 @@ function WebPixelsProvider({ const isEngineer = !!experienceLevel && experienceLevel !== 'NOT_ENGINEER'; - if (typeof globalThis.gtag === 'function') { - globalThis.gtag('event', 'signup'); + if (typeof pixels.gtag === 'function') { + pixels.gtag('event', 'signup'); if (isEngineer) { - globalThis.gtag('event', 'engineer_signup'); + pixels.gtag('event', 'engineer_signup'); } if (isExtension) { - globalThis.gtag('event', 'extension_signup'); + pixels.gtag('event', 'extension_signup'); } } - if (typeof globalThis.fbq === 'function') { - globalThis.updateFbUserData(id, email); - globalThis.fbq('track', 'signup'); - const seniority = EXPERIENCE_TO_SENIORITY[experienceLevel]; + if (typeof pixels.fbq === 'function') { + pixels.updateFbUserData?.(id, email); + pixels.fbq('track', 'signup'); + const seniority = + experienceLevel && EXPERIENCE_TO_SENIORITY[experienceLevel]; if (seniority) { - globalThis.fbq('track', `signup3_${seniority}`); + pixels.fbq('track', `signup3_${seniority}`); } if (isEngineer) { - globalThis.fbq('track', 'engineer signup'); + pixels.fbq('track', 'engineer signup'); } if (isExtension) { - globalThis.fbq('track', 'extension_signup'); + pixels.fbq('track', 'extension_signup'); } } - if (typeof globalThis.twq === 'function') { - globalThis.twq('event', 'tw-o6izs-okoq6', {}); + if (typeof pixels.twq === 'function') { + pixels.twq('event', 'tw-o6izs-okoq6', {}); } - if (typeof globalThis.rdt === 'function') { - globalThis.rdt('track', 'SignUp'); + if (typeof pixels.rdt === 'function') { + pixels.rdt('track', 'SignUp'); } - if (typeof globalThis.ttq?.track === 'function') { - globalThis.ttq.track('CompletePayment', { value: 1 }); + if (typeof pixels.ttq?.track === 'function') { + pixels.ttq.track('CompletePayment', { value: 1 }); } }, trackPayment() { - // if (typeof globalThis.gtag === 'function') { - // globalThis.gtag('event', 'purchase', { + // if (typeof pixels.gtag === 'function') { + // pixels.gtag('event', 'purchase', { // transaction_id: transactionId, // value, // currency, // }); // } // - // if (typeof globalThis.fbq === 'function') { - // globalThis.fbq('track', 'Purchase', { + // if (typeof pixels.fbq === 'function') { + // pixels.fbq('track', 'Purchase', { // value, // currency, // }); // } }, trackEvent(eventName, params, options) { - if (typeof globalThis.gtag === 'function') { - globalThis.gtag('event', eventName.replace(/ /g, '_').toLowerCase()); + if (typeof pixels.gtag === 'function') { + pixels.gtag('event', eventName.replace(/ /g, '_').toLowerCase()); } - if (typeof globalThis.fbq === 'function') { - globalThis.fbq( + if (typeof pixels.fbq === 'function') { + pixels.fbq( 'track', eventName, params,