|
8 | 8 | } from 'cleaners' |
9 | 9 | import type { EdgeDataStore } from 'edge-core-js' |
10 | 10 | import type { EdgeAccount } from 'edge-core-js/types' |
| 11 | +import { Platform } from 'react-native' |
11 | 12 |
|
12 | 13 | import { asAppleAdsAttribution } from '../types/AppleAdsAttributionTypes' |
13 | 14 | import type { RootState, ThunkAction } from '../types/reduxTypes' |
@@ -51,19 +52,6 @@ export function loadAccountReferral( |
51 | 52 | const cache = asDiskReferralCache(JSON.parse(cacheText)) |
52 | 53 | const referral = unpackAccountReferral(JSON.parse(referralText)) |
53 | 54 |
|
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 | | - |
67 | 55 | // Reference info server promo data to see if: |
68 | 56 | // 1. Any of these `activePromotions` are no longer valid (e.g. a |
69 | 57 | // promotion expired) |
@@ -124,20 +112,28 @@ function createAccountReferral(): ThunkAction<Promise<void>> { |
124 | 112 | } |
125 | 113 |
|
126 | 114 | // 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 | + } |
141 | 137 | const cache: ReferralCache = { |
142 | 138 | accountMessages: lockStartDates(messages, creationDate), |
143 | 139 | accountPlugins: lockStartDates(plugins, creationDate) |
|
0 commit comments