Skip to content

Commit bc4e422

Browse files
authored
Merge pull request #5755 from EdgeApp/jon/fix/aaa-3
Fix mirroring between accountReferral's installerId and accountAppleAdsAttribution Also rename the reported value to start fresh
2 parents 16bcf5c + 21b5340 commit bc4e422

File tree

4 files changed

+33
-31
lines changed

4 files changed

+33
-31
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- changed: `NotificationCard` auto-dismiss in 5s
1010
- changed: `NotificationCard` X button replaced with swipe-to-dismiss gesture
1111
- fixed: Font scaling for displaying long addresses in `RequestScene` and `AddressTile2`
12+
- fixed: Mirroring in logic between `accountReferral`'s `installerId` and `accountAppleAdsAttribution`
1213
- fixed: Currency mapping for `simplexProvider`
1314

1415
## 4.35.2 (2025-09-25)

src/actions/AccountReferralActions.ts

Lines changed: 23 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
} from 'cleaners'
99
import type { EdgeDataStore } from 'edge-core-js'
1010
import type { EdgeAccount } from 'edge-core-js/types'
11+
import { Platform } from 'react-native'
1112

1213
import { asAppleAdsAttribution } from '../types/AppleAdsAttributionTypes'
1314
import type { RootState, ThunkAction } from '../types/reduxTypes'
@@ -51,19 +52,6 @@ export function loadAccountReferral(
5152
const cache = asDiskReferralCache(JSON.parse(cacheText))
5253
const referral = unpackAccountReferral(JSON.parse(referralText))
5354

54-
// Ensure accountAppleAdsAttribution mirrors device-level attribution when missing or empty
55-
const existingAttrib = referral.accountAppleAdsAttribution
56-
const isAttribMissing =
57-
existingAttrib == null ||
58-
(existingAttrib.campaignId == null && existingAttrib.keywordId == null)
59-
if (isAttribMissing) {
60-
const { appleAdsAttribution } = await getFirstOpenInfo()
61-
if (appleAdsAttribution != null) {
62-
referral.accountAppleAdsAttribution =
63-
asAppleAdsAttribution(appleAdsAttribution)
64-
}
65-
}
66-
6755
// Reference info server promo data to see if:
6856
// 1. Any of these `activePromotions` are no longer valid (e.g. a
6957
// promotion expired)
@@ -124,20 +112,28 @@ function createAccountReferral(): ThunkAction<Promise<void>> {
124112
}
125113

126114
// Seed account-level Apple Ads attribution on account creation
127-
try {
128-
const { appleAdsAttribution } = await getFirstOpenInfo()
129-
if (appleAdsAttribution != null) {
130-
const firstOpenAttrib = asAppleAdsAttribution(appleAdsAttribution)
131-
const isFirstOpenEmpty =
132-
firstOpenAttrib.campaignId == null &&
133-
firstOpenAttrib.keywordId == null
134-
referral.accountAppleAdsAttribution = isFirstOpenEmpty
135-
? await getAppleAdsAttribution()
136-
: firstOpenAttrib
137-
} else {
138-
referral.accountAppleAdsAttribution = await getAppleAdsAttribution()
139-
}
140-
} catch (e) {}
115+
if (Platform.OS === 'ios') {
116+
try {
117+
const { appleAdsAttribution } = await getFirstOpenInfo()
118+
if (appleAdsAttribution != null) {
119+
const firstOpenAttrib = asAppleAdsAttribution(appleAdsAttribution)
120+
const isFirstOpenEmpty =
121+
firstOpenAttrib.campaignId == null &&
122+
firstOpenAttrib.keywordId == null
123+
referral.accountAppleAdsAttribution = isFirstOpenEmpty
124+
? await getAppleAdsAttribution()
125+
: firstOpenAttrib
126+
logEvent('AAA_Success')
127+
} else {
128+
referral.accountAppleAdsAttribution = await getAppleAdsAttribution()
129+
if (referral.accountAppleAdsAttribution == null) {
130+
logEvent('AAA_Failed')
131+
} else {
132+
logEvent('AAA_Success')
133+
}
134+
}
135+
} catch (e) {}
136+
}
141137
const cache: ReferralCache = {
142138
accountMessages: lockStartDates(messages, creationDate),
143139
accountPlugins: lockStartDates(plugins, creationDate)

src/actions/FirstOpenActions.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ const readFirstOpenInfoFromDisk = async (): Promise<FirstOpenInfo> => {
9898
* Get Apple Search Ads attribution data using the AdServices framework
9999
* and make an API call to get the actual keywordId.
100100
*/
101-
export async function getAppleAdsAttribution(): Promise<AppleAdsAttribution> {
101+
export async function getAppleAdsAttribution(): Promise<
102+
AppleAdsAttribution | undefined
103+
> {
102104
if (Platform.OS !== 'ios') {
103105
return { campaignId: undefined, keywordId: undefined }
104106
}
@@ -152,10 +154,10 @@ export async function getAppleAdsAttribution(): Promise<AppleAdsAttribution> {
152154
return asAppleAdsAttribution(data)
153155
} catch (apiError) {
154156
console.warn('Error fetching Apple Ads attribution data:', apiError)
155-
break
157+
return undefined
156158
}
157159
}
158160
}
159161

160-
return { campaignId: undefined, keywordId: undefined }
162+
return undefined
161163
}

src/util/tracking.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { makeErrorLog } from './translateError'
1919
import { consify, monthsBetween } from './utils'
2020

2121
export type TrackingEventName =
22+
| 'AAA_Failed'
23+
| 'AAA_Success'
2224
| 'Activate_Wallet_Cancel'
2325
| 'Activate_Wallet_Done'
2426
| 'Activate_Wallet_Select'
@@ -258,7 +260,8 @@ export function logEvent(
258260
: creationDate.toISOString().replace(/-\d\dT.*/, '')
259261
params.refAccountInstallerId = accountReferral.installerId
260262
params.refAccountCurrencyCodes = accountReferral.currencyCodes
261-
params.refAccountAppleAdsAttribution = accountAppleAdsAttribution
263+
264+
params.accountAppleAdsAttribution = accountAppleAdsAttribution
262265

263266
// Get the account age in months:
264267
const { created: accountCreatedDate } = core.account

0 commit comments

Comments
 (0)