(retriesRemaining: number)
| 33 | let retryTimeout: ReturnType<typeof setTimeout> | null = null; |
| 34 | |
| 35 | const runIdentify = async (retriesRemaining: number): Promise<void> => { |
| 36 | if (cancelled) return; |
| 37 | |
| 38 | if (typeof window.ire !== 'function') { |
| 39 | if (retriesRemaining <= 0) { |
| 40 | logImpactReferralDebug('Impact UTT identify skipped; window.ire unavailable', { |
| 41 | userId: user?.id ?? null, |
| 42 | }); |
| 43 | return; |
| 44 | } |
| 45 | |
| 46 | retryTimeout = setTimeout(() => { |
| 47 | void runIdentify(retriesRemaining - 1); |
| 48 | }, 250); |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | const customProfileId = user?.id ? `kilo-user:${user.id}` : getStableAnonymousProfileId(); |
| 53 | const customerId = user?.id ?? ''; |
| 54 | const customerEmail = user ? await sha1Hex(user.google_user_email) : ''; |
| 55 | |
| 56 | if (cancelled || typeof window.ire !== 'function') return; |
| 57 | |
| 58 | logImpactReferralDebug('Calling Impact UTT identify', { |
| 59 | userId: user?.id ?? null, |
| 60 | customerIdPresent: Boolean(customerId), |
| 61 | customerEmailHashPresent: Boolean(customerEmail), |
| 62 | customProfileIdPresent: Boolean(customProfileId), |
| 63 | }); |
| 64 | |
| 65 | window.ire('identify', { |
| 66 | customerId, |
| 67 | customerEmail, |
| 68 | customProfileId, |
| 69 | }); |
| 70 | }; |
| 71 | |
| 72 | void runIdentify(10).catch(error => { |
| 73 | console.error('ImpactIdentify failed', error); |
no test coverage detected