@advenue/react-native 0.8.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/android/src/main/java/expo/modules/advenue/AdvenueAndroidModule.kt +118 -347
- package/android/src/main/kotlin/io/advenue/Advenue.kt +549 -0
- package/android/src/main/kotlin/io/advenue/AdvenueConfig.kt +114 -0
- package/android/src/main/kotlin/io/advenue/core/Backoff.kt +28 -0
- package/android/src/main/kotlin/io/advenue/core/ClientEvent.kt +136 -0
- package/android/src/main/kotlin/io/advenue/core/CommandPipe.kt +186 -0
- package/android/src/main/kotlin/io/advenue/core/Consent.kt +52 -0
- package/android/src/main/kotlin/io/advenue/core/Contracts.kt +80 -0
- package/android/src/main/kotlin/io/advenue/core/Conversion.kt +69 -0
- package/android/src/main/kotlin/io/advenue/core/Engine.kt +414 -0
- package/android/src/main/kotlin/io/advenue/core/EventQueue.kt +89 -0
- package/android/src/main/kotlin/io/advenue/core/HmacSigner.kt +31 -0
- package/android/src/main/kotlin/io/advenue/core/InstallReferrer.kt +146 -0
- package/android/src/main/kotlin/io/advenue/core/Json.kt +272 -0
- package/android/src/main/kotlin/io/advenue/core/Limits.kt +47 -0
- package/android/src/main/kotlin/io/advenue/core/MetaReferrer.kt +80 -0
- package/android/src/main/kotlin/io/advenue/core/SessionTracker.kt +189 -0
- package/android/src/main/kotlin/io/advenue/core/SystemServices.kt +58 -0
- package/android/src/main/kotlin/io/advenue/core/Tcf.kt +48 -0
- package/android/src/main/kotlin/io/advenue/core/Time.kt +56 -0
- package/android/src/main/kotlin/io/advenue/platform/Collectors.kt +149 -0
- package/android/src/main/kotlin/io/advenue/platform/CompositeStore.kt +33 -0
- package/android/src/main/kotlin/io/advenue/platform/ConversionFetcher.kt +68 -0
- package/android/src/main/kotlin/io/advenue/platform/ForegroundTracker.kt +90 -0
- package/android/src/main/kotlin/io/advenue/platform/HttpUrlTransport.kt +101 -0
- package/android/src/main/kotlin/io/advenue/platform/Identity.kt +79 -0
- package/android/src/main/kotlin/io/advenue/platform/InstallEnrichment.kt +197 -0
- package/android/src/main/kotlin/io/advenue/platform/InstallScopedStore.kt +91 -0
- package/android/src/main/kotlin/io/advenue/platform/LifecycleBridge.kt +72 -0
- package/android/src/main/kotlin/io/advenue/platform/PreferencesStore.kt +32 -0
- package/android/src/main/kotlin/io/advenue/plugin/Contracts.kt +67 -0
- package/android/src/main/kotlin/io/advenue/plugin/FirebaseAppInstanceIdSource.kt +73 -0
- package/android/src/main/kotlin/io/advenue/plugin/PlayAdvertisingIdSource.kt +47 -0
- package/android/src/main/kotlin/io/advenue/plugin/PlayInstallReferrerSource.kt +85 -0
- package/android/src/main/kotlin/io/advenue/plugin/PlayIntegritySource.kt +86 -0
- package/android/src/main/kotlin/io/advenue/plugin/PluginRegistry.kt +61 -0
- package/dist/index.cjs +183 -655
- package/dist/index.d.cts +199 -331
- package/dist/index.d.ts +199 -331
- package/dist/index.js +182 -661
- package/ios/AdvenueIosModule.swift +144 -432
- package/ios/vendor/Advenue/Advenue.swift +596 -0
- package/ios/vendor/Advenue/AdvenueConfig.swift +77 -0
- package/ios/vendor/AdvenueCore/AdvenueValue.swift +103 -0
- package/ios/vendor/AdvenueCore/Attestation.swift +52 -0
- package/ios/vendor/AdvenueCore/Backoff.swift +28 -0
- package/ios/vendor/AdvenueCore/ClientEvent.swift +154 -0
- package/ios/vendor/AdvenueCore/Consent.swift +40 -0
- package/ios/vendor/AdvenueCore/Contracts.swift +59 -0
- package/ios/vendor/AdvenueCore/Conversion.swift +74 -0
- package/ios/vendor/AdvenueCore/ConversionValue.swift +217 -0
- package/ios/vendor/AdvenueCore/Engine.swift +587 -0
- package/ios/vendor/AdvenueCore/EventQueue.swift +89 -0
- package/ios/vendor/AdvenueCore/Limits.swift +41 -0
- package/ios/vendor/AdvenueCore/PIIScrub.swift +102 -0
- package/ios/vendor/AdvenueCore/SessionTracker.swift +139 -0
- package/ios/vendor/AdvenueCore/SkanConfig.swift +76 -0
- package/ios/vendor/AdvenueCore/SkanReporter.swift +25 -0
- package/ios/vendor/AdvenueCore/SkanState.swift +258 -0
- package/ios/vendor/AdvenueCore/Tcf.swift +48 -0
- package/ios/vendor/AdvenueCore/Transport.swift +14 -0
- package/ios/vendor/AdvenueFirebase/FirebaseAppInstanceId.swift +33 -0
- package/ios/vendor/AdvenuePlatform/AdvertisingIdentity.swift +87 -0
- package/ios/vendor/AdvenuePlatform/ChallengeFetcher.swift +42 -0
- package/ios/vendor/AdvenuePlatform/ConversionFetcher.swift +63 -0
- package/ios/vendor/AdvenuePlatform/CryptoKitSigner.swift +19 -0
- package/ios/vendor/AdvenuePlatform/DeviceCheckAttestation.swift +91 -0
- package/ios/vendor/AdvenuePlatform/DeviceInfo.swift +65 -0
- package/ios/vendor/AdvenuePlatform/ForegroundTracker.swift +55 -0
- package/ios/vendor/AdvenuePlatform/HttpTransport.swift +96 -0
- package/ios/vendor/AdvenuePlatform/Identity.swift +52 -0
- package/ios/vendor/AdvenuePlatform/InstallEnrichment.swift +143 -0
- package/ios/vendor/AdvenuePlatform/KeychainStore.swift +95 -0
- package/ios/vendor/AdvenuePlatform/SearchAdsToken.swift +76 -0
- package/ios/vendor/AdvenuePlatform/SkanConfigFetcher.swift +70 -0
- package/ios/vendor/AdvenuePlatform/StoreKitSkanReporter.swift +140 -0
- package/ios/vendor/AdvenuePlatform/SystemServices.swift +55 -0
- package/ios/vendor/AdvenuePlatform/TcfReader.swift +18 -0
- package/ios/vendor/AdvenuePlatform/UserDefaultsStore.swift +26 -0
- package/package.json +9 -11
- package/scripts/check-dist.mjs +17 -0
- package/scripts/check-vendored-swift.mjs +148 -0
- package/scripts/vendor-natives.mjs +149 -0
- package/scripts/vendor-natives.test.mjs +112 -0
- package/src/deep-links.ts +19 -1
- package/src/index.ts +267 -803
- package/src/native-types.ts +74 -171
- package/src/native.ts +0 -23
- package/src/types.ts +81 -0
- package/src/aem.ts +0 -33
- package/src/mmkv-storage.ts +0 -21
- package/src/native-storage.ts +0 -63
- package/src/secure-store.ts +0 -26
package/dist/index.cjs
CHANGED
|
@@ -55,174 +55,17 @@ var require_native_require = __commonJS({
|
|
|
55
55
|
var index_exports = {};
|
|
56
56
|
__export(index_exports, {
|
|
57
57
|
Advenue: () => Advenue,
|
|
58
|
-
applyAppState: () => applyAppState,
|
|
59
|
-
collectDeviceInfo: () => collectDeviceInfo,
|
|
60
|
-
createMMKVStorage: () => createMMKVStorage,
|
|
61
|
-
createSecureStore: () => createSecureStore,
|
|
62
58
|
getAndroidNative: () => getAndroidNative,
|
|
63
59
|
getIosNative: () => getIosNative,
|
|
64
60
|
parseDirectLink: () => parseDirectLink,
|
|
65
|
-
|
|
66
|
-
resolveDmaConsent: () => resolveDmaConsent,
|
|
67
|
-
trackInstall: () => trackInstall
|
|
61
|
+
platform: () => platform
|
|
68
62
|
});
|
|
69
63
|
module.exports = __toCommonJS(index_exports);
|
|
70
|
-
var import_install_referrer = require("@advenue/install-referrer");
|
|
71
|
-
var import_sdk_core = require("@advenue/sdk-core");
|
|
72
|
-
|
|
73
|
-
// ../signing/src/index.ts
|
|
74
|
-
var K = new Uint32Array([
|
|
75
|
-
1116352408,
|
|
76
|
-
1899447441,
|
|
77
|
-
3049323471,
|
|
78
|
-
3921009573,
|
|
79
|
-
961987163,
|
|
80
|
-
1508970993,
|
|
81
|
-
2453635748,
|
|
82
|
-
2870763221,
|
|
83
|
-
3624381080,
|
|
84
|
-
310598401,
|
|
85
|
-
607225278,
|
|
86
|
-
1426881987,
|
|
87
|
-
1925078388,
|
|
88
|
-
2162078206,
|
|
89
|
-
2614888103,
|
|
90
|
-
3248222580,
|
|
91
|
-
3835390401,
|
|
92
|
-
4022224774,
|
|
93
|
-
264347078,
|
|
94
|
-
604807628,
|
|
95
|
-
770255983,
|
|
96
|
-
1249150122,
|
|
97
|
-
1555081692,
|
|
98
|
-
1996064986,
|
|
99
|
-
2554220882,
|
|
100
|
-
2821834349,
|
|
101
|
-
2952996808,
|
|
102
|
-
3210313671,
|
|
103
|
-
3336571891,
|
|
104
|
-
3584528711,
|
|
105
|
-
113926993,
|
|
106
|
-
338241895,
|
|
107
|
-
666307205,
|
|
108
|
-
773529912,
|
|
109
|
-
1294757372,
|
|
110
|
-
1396182291,
|
|
111
|
-
1695183700,
|
|
112
|
-
1986661051,
|
|
113
|
-
2177026350,
|
|
114
|
-
2456956037,
|
|
115
|
-
2730485921,
|
|
116
|
-
2820302411,
|
|
117
|
-
3259730800,
|
|
118
|
-
3345764771,
|
|
119
|
-
3516065817,
|
|
120
|
-
3600352804,
|
|
121
|
-
4094571909,
|
|
122
|
-
275423344,
|
|
123
|
-
430227734,
|
|
124
|
-
506948616,
|
|
125
|
-
659060556,
|
|
126
|
-
883997877,
|
|
127
|
-
958139571,
|
|
128
|
-
1322822218,
|
|
129
|
-
1537002063,
|
|
130
|
-
1747873779,
|
|
131
|
-
1955562222,
|
|
132
|
-
2024104815,
|
|
133
|
-
2227730452,
|
|
134
|
-
2361852424,
|
|
135
|
-
2428436474,
|
|
136
|
-
2756734187,
|
|
137
|
-
3204031479,
|
|
138
|
-
3329325298
|
|
139
|
-
]);
|
|
140
|
-
function rotr(x, n) {
|
|
141
|
-
return x >>> n | x << 32 - n;
|
|
142
|
-
}
|
|
143
|
-
function sha256Bytes(msg) {
|
|
144
|
-
const h = new Uint32Array([
|
|
145
|
-
1779033703,
|
|
146
|
-
3144134277,
|
|
147
|
-
1013904242,
|
|
148
|
-
2773480762,
|
|
149
|
-
1359893119,
|
|
150
|
-
2600822924,
|
|
151
|
-
528734635,
|
|
152
|
-
1541459225
|
|
153
|
-
]);
|
|
154
|
-
const l = msg.length;
|
|
155
|
-
const bitLen = l * 8;
|
|
156
|
-
const withOne = l + 1;
|
|
157
|
-
const padTo = (56 - withOne % 64 + 64) % 64;
|
|
158
|
-
const padded = new Uint8Array(withOne + padTo + 8);
|
|
159
|
-
padded.set(msg);
|
|
160
|
-
padded[l] = 128;
|
|
161
|
-
const dv = new DataView(padded.buffer);
|
|
162
|
-
dv.setUint32(padded.length - 8, Math.floor(bitLen / 4294967296));
|
|
163
|
-
dv.setUint32(padded.length - 4, bitLen >>> 0);
|
|
164
|
-
const w = new Uint32Array(64);
|
|
165
|
-
for (let i = 0; i < padded.length; i += 64) {
|
|
166
|
-
for (let t = 0; t < 16; t++) w[t] = dv.getUint32(i + t * 4);
|
|
167
|
-
for (let t = 16; t < 64; t++) {
|
|
168
|
-
const w15 = w[t - 15];
|
|
169
|
-
const w2 = w[t - 2];
|
|
170
|
-
const s0 = rotr(w15, 7) ^ rotr(w15, 18) ^ w15 >>> 3;
|
|
171
|
-
const s1 = rotr(w2, 17) ^ rotr(w2, 19) ^ w2 >>> 10;
|
|
172
|
-
w[t] = w[t - 16] + s0 + w[t - 7] + s1 >>> 0;
|
|
173
|
-
}
|
|
174
|
-
let a = h[0];
|
|
175
|
-
let b = h[1];
|
|
176
|
-
let c = h[2];
|
|
177
|
-
let d = h[3];
|
|
178
|
-
let e = h[4];
|
|
179
|
-
let f = h[5];
|
|
180
|
-
let g = h[6];
|
|
181
|
-
let hh = h[7];
|
|
182
|
-
for (let t = 0; t < 64; t++) {
|
|
183
|
-
const S1 = rotr(e, 6) ^ rotr(e, 11) ^ rotr(e, 25);
|
|
184
|
-
const ch = e & f ^ ~e & g;
|
|
185
|
-
const temp1 = hh + S1 + ch + K[t] + w[t] >>> 0;
|
|
186
|
-
const S0 = rotr(a, 2) ^ rotr(a, 13) ^ rotr(a, 22);
|
|
187
|
-
const maj = a & b ^ a & c ^ b & c;
|
|
188
|
-
const temp2 = S0 + maj >>> 0;
|
|
189
|
-
hh = g;
|
|
190
|
-
g = f;
|
|
191
|
-
f = e;
|
|
192
|
-
e = d + temp1 >>> 0;
|
|
193
|
-
d = c;
|
|
194
|
-
c = b;
|
|
195
|
-
b = a;
|
|
196
|
-
a = temp1 + temp2 >>> 0;
|
|
197
|
-
}
|
|
198
|
-
h[0] = h[0] + a >>> 0;
|
|
199
|
-
h[1] = h[1] + b >>> 0;
|
|
200
|
-
h[2] = h[2] + c >>> 0;
|
|
201
|
-
h[3] = h[3] + d >>> 0;
|
|
202
|
-
h[4] = h[4] + e >>> 0;
|
|
203
|
-
h[5] = h[5] + f >>> 0;
|
|
204
|
-
h[6] = h[6] + g >>> 0;
|
|
205
|
-
h[7] = h[7] + hh >>> 0;
|
|
206
|
-
}
|
|
207
|
-
const out = new Uint8Array(32);
|
|
208
|
-
const odv = new DataView(out.buffer);
|
|
209
|
-
for (let i = 0; i < 8; i++) odv.setUint32(i * 4, h[i]);
|
|
210
|
-
return out;
|
|
211
|
-
}
|
|
212
|
-
function toHex(bytes) {
|
|
213
|
-
let s = "";
|
|
214
|
-
for (let i = 0; i < bytes.length; i++) s += bytes[i].toString(16).padStart(2, "0");
|
|
215
|
-
return s;
|
|
216
|
-
}
|
|
217
|
-
var enc = new TextEncoder();
|
|
218
|
-
function sha256Hex(message) {
|
|
219
|
-
return toHex(sha256Bytes(enc.encode(message)));
|
|
220
|
-
}
|
|
221
64
|
|
|
222
65
|
// package.json
|
|
223
66
|
var package_default = {
|
|
224
67
|
name: "@advenue/react-native",
|
|
225
|
-
version: "0.
|
|
68
|
+
version: "1.0.0",
|
|
226
69
|
description: "Advenue MMP React Native SDK \u2014 attribution, install tracking, and deep links (bundled iOS/Android Expo native modules)",
|
|
227
70
|
type: "module",
|
|
228
71
|
license: "MIT",
|
|
@@ -245,20 +88,20 @@ var package_default = {
|
|
|
245
88
|
"ios",
|
|
246
89
|
"android",
|
|
247
90
|
"expo-module.config.json",
|
|
248
|
-
"!**/*.test.ts"
|
|
91
|
+
"!**/*.test.ts",
|
|
92
|
+
"ios/vendor",
|
|
93
|
+
"android/src/main/kotlin"
|
|
249
94
|
],
|
|
250
95
|
publishConfig: {
|
|
251
96
|
access: "public"
|
|
252
97
|
},
|
|
253
98
|
scripts: {
|
|
254
|
-
build: "tsup && node scripts/check-dist.mjs",
|
|
99
|
+
build: "node scripts/vendor-natives.mjs && node scripts/check-vendored-swift.mjs && tsup && node scripts/check-dist.mjs",
|
|
255
100
|
typecheck: "tsc --noEmit",
|
|
256
|
-
test: "vitest run"
|
|
257
|
-
|
|
258
|
-
dependencies: {
|
|
259
|
-
"@advenue/install-referrer": "workspace:*",
|
|
260
|
-
"@advenue/sdk-core": "workspace:*"
|
|
101
|
+
test: "vitest run --minWorkers=1 --maxWorkers=2 && node --test scripts/vendor-natives.test.mjs && node scripts/vendor-natives.mjs && node scripts/check-vendored-swift.mjs",
|
|
102
|
+
vendor: "node scripts/vendor-natives.mjs"
|
|
261
103
|
},
|
|
104
|
+
dependencies: {},
|
|
262
105
|
peerDependencies: {
|
|
263
106
|
"@expo/config-plugins": ">=8",
|
|
264
107
|
react: ">=18.2",
|
|
@@ -274,8 +117,6 @@ var package_default = {
|
|
|
274
117
|
}
|
|
275
118
|
},
|
|
276
119
|
devDependencies: {
|
|
277
|
-
"@advenue/shared": "workspace:*",
|
|
278
|
-
"@advenue/signing": "workspace:*",
|
|
279
120
|
tsup: "^8.5.1",
|
|
280
121
|
typescript: "^5.7.2",
|
|
281
122
|
vitest: "^2.1.8"
|
|
@@ -283,18 +124,15 @@ var package_default = {
|
|
|
283
124
|
"react-native": "./dist/index.cjs"
|
|
284
125
|
};
|
|
285
126
|
|
|
286
|
-
// src/aem.ts
|
|
287
|
-
function extractAemCampaignIds(alApplinkData) {
|
|
288
|
-
try {
|
|
289
|
-
const parsed = JSON.parse(alApplinkData);
|
|
290
|
-
const value = typeof parsed.campaign_ids === "string" && parsed.campaign_ids ? parsed.campaign_ids : typeof parsed.extras?.campaign_ids === "string" && parsed.extras.campaign_ids ? parsed.extras.campaign_ids : null;
|
|
291
|
-
return value && value.length <= 2048 ? value : null;
|
|
292
|
-
} catch {
|
|
293
|
-
return null;
|
|
294
|
-
}
|
|
295
|
-
}
|
|
296
|
-
|
|
297
127
|
// src/deep-links.ts
|
|
128
|
+
var ALLOWED_QUERY_KEYS = /* @__PURE__ */ new Set([
|
|
129
|
+
"ref",
|
|
130
|
+
"campaign",
|
|
131
|
+
"network",
|
|
132
|
+
"influencer_id",
|
|
133
|
+
"influencerId",
|
|
134
|
+
"al_applink_data"
|
|
135
|
+
]);
|
|
298
136
|
function parseDirectLink(url) {
|
|
299
137
|
let deepLinkValue = "";
|
|
300
138
|
let params;
|
|
@@ -304,6 +142,7 @@ function parseDirectLink(url) {
|
|
|
304
142
|
const isHttp = parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
305
143
|
deepLinkValue = isHttp ? path : [parsed.host, path].filter(Boolean).join("/");
|
|
306
144
|
parsed.searchParams.forEach((v, k) => {
|
|
145
|
+
if (!ALLOWED_QUERY_KEYS.has(k)) return;
|
|
307
146
|
params ??= {};
|
|
308
147
|
params[k] = v;
|
|
309
148
|
});
|
|
@@ -339,15 +178,6 @@ function setupDeepLinks(setup) {
|
|
|
339
178
|
return { remove: () => listener.remove(), ready };
|
|
340
179
|
}
|
|
341
180
|
|
|
342
|
-
// src/mmkv-storage.ts
|
|
343
|
-
function createMMKVStorage(mmkv) {
|
|
344
|
-
return {
|
|
345
|
-
getItem: (key) => mmkv.getString(key) ?? null,
|
|
346
|
-
setItem: (key, value) => mmkv.set(key, value),
|
|
347
|
-
removeItem: (key) => mmkv.delete(key)
|
|
348
|
-
};
|
|
349
|
-
}
|
|
350
|
-
|
|
351
181
|
// src/native.ts
|
|
352
182
|
var import_native_require = __toESM(require_native_require(), 1);
|
|
353
183
|
function getIosNative() {
|
|
@@ -374,27 +204,6 @@ function getPlatformOS() {
|
|
|
374
204
|
return null;
|
|
375
205
|
}
|
|
376
206
|
}
|
|
377
|
-
function getOsVersion() {
|
|
378
|
-
try {
|
|
379
|
-
const rn = (0, import_native_require.requireReactNative)();
|
|
380
|
-
if (!rn) return null;
|
|
381
|
-
if (rn.Platform.OS === "android") {
|
|
382
|
-
const release = rn.Platform.constants?.Release;
|
|
383
|
-
return release != null ? String(release) : null;
|
|
384
|
-
}
|
|
385
|
-
return rn.Platform.Version != null ? String(rn.Platform.Version) : null;
|
|
386
|
-
} catch {
|
|
387
|
-
return null;
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
function getAppState() {
|
|
391
|
-
try {
|
|
392
|
-
const rn = (0, import_native_require.requireReactNative)();
|
|
393
|
-
return rn?.AppState ?? null;
|
|
394
|
-
} catch {
|
|
395
|
-
return null;
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
207
|
function getLinking() {
|
|
399
208
|
try {
|
|
400
209
|
const rn = (0, import_native_require.requireReactNative)();
|
|
@@ -404,490 +213,209 @@ function getLinking() {
|
|
|
404
213
|
}
|
|
405
214
|
}
|
|
406
215
|
|
|
407
|
-
// src/native-storage.ts
|
|
408
|
-
function createNativeStorage(mod) {
|
|
409
|
-
const m = mod;
|
|
410
|
-
if (!m || typeof m.storageGetItem !== "function" || typeof m.storageSetItem !== "function" || typeof m.storageRemoveItem !== "function") {
|
|
411
|
-
return null;
|
|
412
|
-
}
|
|
413
|
-
return {
|
|
414
|
-
getItem: (key) => m.storageGetItem?.(key) ?? null,
|
|
415
|
-
setItem: (key, value) => m.storageSetItem?.(key, value),
|
|
416
|
-
removeItem: (key) => m.storageRemoveItem?.(key)
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
function createNativeSecureStore(mod) {
|
|
420
|
-
const m = mod;
|
|
421
|
-
if (!m || typeof m.secureGetItem !== "function" || typeof m.secureSetItem !== "function" || typeof m.secureRemoveItem !== "function") {
|
|
422
|
-
return null;
|
|
423
|
-
}
|
|
424
|
-
return {
|
|
425
|
-
getItemAsync: async (key) => m.secureGetItem?.(key) ?? null,
|
|
426
|
-
setItemAsync: async (key, value) => m.secureSetItem?.(key, value),
|
|
427
|
-
deleteItemAsync: async (key) => m.secureRemoveItem?.(key)
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
// src/secure-store.ts
|
|
432
|
-
function createSecureStore(secureStore2) {
|
|
433
|
-
return {
|
|
434
|
-
getItemAsync: async (key) => await secureStore2.getItemAsync(key) ?? null,
|
|
435
|
-
setItemAsync: (key, value) => secureStore2.setItemAsync(key, value),
|
|
436
|
-
...secureStore2.deleteItemAsync ? {
|
|
437
|
-
deleteItemAsync: (key) => secureStore2.deleteItemAsync?.(key) ?? Promise.resolve()
|
|
438
|
-
} : {}
|
|
439
|
-
};
|
|
440
|
-
}
|
|
441
|
-
|
|
442
216
|
// src/index.ts
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
client.setAdvertisingId({});
|
|
452
|
-
return;
|
|
453
|
-
}
|
|
454
|
-
const ios = getIosNative();
|
|
455
|
-
if (ios) {
|
|
456
|
-
const idfa = ios.getTrackingAuthorizationStatus() === "authorized" ? await ios.getAdvertisingId() : null;
|
|
457
|
-
const vendorId = typeof ios.getIdentifierForVendor === "function" ? ios.getIdentifierForVendor() : null;
|
|
458
|
-
client.setAdvertisingId({ ...idfa ? { idfa } : {}, ...vendorId ? { vendorId } : {} });
|
|
459
|
-
return;
|
|
460
|
-
}
|
|
461
|
-
const android = getAndroidNative();
|
|
462
|
-
if (android && typeof android.getAdvertisingId === "function") {
|
|
463
|
-
const r = await android.getAdvertisingId();
|
|
464
|
-
const vendorId = typeof android.getAppSetId === "function" ? await android.getAppSetId() : null;
|
|
465
|
-
const adFields = r ? r.limitAdTracking ? { limitAdTracking: true } : { gaid: r.id } : {};
|
|
466
|
-
const hasUsableGaid = !!r && !r.limitAdTracking;
|
|
467
|
-
const rawAndroidId = !hasUsableGaid && typeof android.getAndroidId === "function" ? android.getAndroidId() : null;
|
|
468
|
-
const androidId = rawAndroidId && /^[0-9a-fA-F]{8,32}$/.test(rawAndroidId) ? rawAndroidId : null;
|
|
469
|
-
client.setAdvertisingId({
|
|
470
|
-
...adFields,
|
|
471
|
-
...vendorId ? { vendorId } : {},
|
|
472
|
-
...androidId ? { androidId } : {}
|
|
473
|
-
});
|
|
474
|
-
return;
|
|
475
|
-
}
|
|
476
|
-
client.setAdvertisingId({});
|
|
477
|
-
}
|
|
478
|
-
function consentEquals(a, b) {
|
|
479
|
-
return a.isUserSubjectToGDPR === b.isUserSubjectToGDPR && a.hasConsentForDataUsage === b.hasConsentForDataUsage && a.hasConsentForAdsPersonalization === b.hasConsentForAdsPersonalization && a.hasConsentForAdStorage === b.hasConsentForAdStorage;
|
|
217
|
+
var IGNORED_OPTIONS = ["mmkv", "secureStore", "sdkConfigFetcher", "tcfDataCollection"];
|
|
218
|
+
var started = false;
|
|
219
|
+
var deepLinkSub = null;
|
|
220
|
+
var errorSub = null;
|
|
221
|
+
var onErrorHook;
|
|
222
|
+
var consentCache = false;
|
|
223
|
+
function bridge() {
|
|
224
|
+
return { ios: getIosNative(), android: getAndroidNative() };
|
|
480
225
|
}
|
|
481
|
-
function
|
|
482
|
-
|
|
483
|
-
const
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
226
|
+
function call(name, ...args) {
|
|
227
|
+
const { ios, android } = bridge();
|
|
228
|
+
for (const mod of [ios, android]) {
|
|
229
|
+
const fn = mod?.[name];
|
|
230
|
+
if (typeof fn === "function") {
|
|
231
|
+
try {
|
|
232
|
+
return fn(...args);
|
|
233
|
+
} catch (error) {
|
|
234
|
+
report(`bridge.${name}`, error);
|
|
235
|
+
return void 0;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
491
238
|
}
|
|
492
|
-
|
|
493
|
-
const client = active();
|
|
494
|
-
const current = client.getConsentData();
|
|
495
|
-
if (current && consentEquals(current, consent)) return null;
|
|
496
|
-
client.setConsentData(consent);
|
|
497
|
-
void resolveAdvertisingId().catch((err) => reportError("enrich.advertisingId", err));
|
|
498
|
-
return consent;
|
|
239
|
+
return void 0;
|
|
499
240
|
}
|
|
500
|
-
function
|
|
241
|
+
function report(context, cause) {
|
|
501
242
|
try {
|
|
502
|
-
|
|
503
|
-
return natives.android.getDeviceInfo();
|
|
504
|
-
}
|
|
505
|
-
if (natives.platform === "ios" && natives.ios?.getDeviceInfo) {
|
|
506
|
-
return natives.ios.getDeviceInfo();
|
|
507
|
-
}
|
|
243
|
+
onErrorHook?.(context, cause);
|
|
508
244
|
} catch {
|
|
509
245
|
}
|
|
510
|
-
return {};
|
|
511
|
-
}
|
|
512
|
-
function applyAppState(client, status) {
|
|
513
|
-
if (status === "active") {
|
|
514
|
-
client.notifyAppActive();
|
|
515
|
-
} else if (status === "background") {
|
|
516
|
-
client.notifyAppBackground();
|
|
517
|
-
}
|
|
518
|
-
}
|
|
519
|
-
var instance = null;
|
|
520
|
-
var appStateSub = null;
|
|
521
|
-
var deepLinkSub = null;
|
|
522
|
-
var secureStore = null;
|
|
523
|
-
var installFlagStore = null;
|
|
524
|
-
var INSTALL_SENT_KEY = "advenue.install_sent";
|
|
525
|
-
var installInFlight = false;
|
|
526
|
-
var autoInstallPending = false;
|
|
527
|
-
var autoInstallEnabled = true;
|
|
528
|
-
var manualConsentSet = false;
|
|
529
|
-
var tcfCollectionEnabled = false;
|
|
530
|
-
var configuredAppId = null;
|
|
531
|
-
var configuredApiKey = null;
|
|
532
|
-
var configuredEndpoint = import_sdk_core.DEFAULT_ENDPOINT;
|
|
533
|
-
var aemSeenUrlHashes = /* @__PURE__ */ new Set();
|
|
534
|
-
function active() {
|
|
535
|
-
if (!instance) {
|
|
536
|
-
throw new Error("Advenue.initialize() must be called before tracking events.");
|
|
537
|
-
}
|
|
538
|
-
return instance;
|
|
539
|
-
}
|
|
540
|
-
function reportError(context, cause) {
|
|
541
|
-
instance?.report(context, cause);
|
|
542
|
-
}
|
|
543
|
-
function fireAutoInstall() {
|
|
544
|
-
void trackInstall().catch((err) => reportError("install.auto", err));
|
|
545
|
-
}
|
|
546
|
-
function resolvePlatform(explicit) {
|
|
547
|
-
if (explicit) {
|
|
548
|
-
return explicit;
|
|
549
|
-
}
|
|
550
|
-
const os = getPlatformOS();
|
|
551
|
-
if (os === "ios" || os === "android") {
|
|
552
|
-
return os;
|
|
553
|
-
}
|
|
554
|
-
if (os) {
|
|
555
|
-
return "web";
|
|
556
|
-
}
|
|
557
|
-
throw new Error(
|
|
558
|
-
"Advenue.initialize(): platform could not be detected (react-native unavailable) \u2014 pass platform: 'ios' | 'android' | 'web'."
|
|
559
|
-
);
|
|
560
246
|
}
|
|
561
|
-
function
|
|
562
|
-
if (
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
autoInstallPending = false;
|
|
566
|
-
fireAutoInstall();
|
|
247
|
+
function requireStarted() {
|
|
248
|
+
if (started) return true;
|
|
249
|
+
report("sdk.notInitialized", new Error("Advenue.initialize() has not been called"));
|
|
250
|
+
return false;
|
|
567
251
|
}
|
|
568
252
|
var Advenue = {
|
|
253
|
+
/**
|
|
254
|
+
* Starts the SDK. Safe to call from the app's entry point, and safe to call
|
|
255
|
+
* twice: the native side replaces its previous instance.
|
|
256
|
+
*/
|
|
569
257
|
async initialize(config) {
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
...rest
|
|
578
|
-
} = config;
|
|
579
|
-
autoInstallPending = false;
|
|
580
|
-
manualConsentSet = false;
|
|
581
|
-
tcfCollectionEnabled = tcfDataCollection === true;
|
|
582
|
-
autoInstallEnabled = autoTrackInstall !== false;
|
|
583
|
-
const platform = resolvePlatform(rest.platform);
|
|
584
|
-
configuredAppId = appId ?? null;
|
|
585
|
-
configuredApiKey = config.apiKey;
|
|
586
|
-
configuredEndpoint = config.endpoint ?? import_sdk_core.DEFAULT_ENDPOINT;
|
|
587
|
-
appStateSub?.remove();
|
|
588
|
-
appStateSub = null;
|
|
589
|
-
deepLinkSub?.remove();
|
|
590
|
-
deepLinkSub = null;
|
|
591
|
-
instance?.shutdown();
|
|
592
|
-
const iosMod = getIosNative();
|
|
593
|
-
const androidMod = getAndroidNative();
|
|
594
|
-
const storage = mmkv ? createMMKVStorage(mmkv) : createNativeStorage(iosMod ?? androidMod) ?? new import_sdk_core.MemoryStorage();
|
|
595
|
-
installFlagStore = storage;
|
|
596
|
-
secureStore = secureMod ? createSecureStore(secureMod) : createNativeSecureStore(iosMod);
|
|
597
|
-
const deviceId = rest.deviceId ?? await (0, import_sdk_core.resolveDurableDeviceId)(storage, secureStore ?? void 0);
|
|
598
|
-
const osVersion = rest.osVersion ?? getOsVersion() ?? void 0;
|
|
599
|
-
instance = new import_sdk_core.AdvenueClient({
|
|
600
|
-
...rest,
|
|
601
|
-
platform,
|
|
602
|
-
deviceId,
|
|
603
|
-
storage,
|
|
604
|
-
...osVersion ? { osVersion } : {}
|
|
605
|
-
});
|
|
606
|
-
instance.debugLog(`SDK v${package_default.version} \u2014 events -> ${configuredEndpoint}`);
|
|
607
|
-
if (tcfCollectionEnabled) resolveDmaConsent();
|
|
608
|
-
void resolveAdvertisingId().catch((err) => reportError("enrich.advertisingId", err));
|
|
609
|
-
const deviceInfo = collectDeviceInfo({
|
|
610
|
-
platform,
|
|
611
|
-
ios: getIosNative(),
|
|
612
|
-
android: getAndroidNative()
|
|
613
|
-
});
|
|
614
|
-
if (Object.keys(deviceInfo).length > 0) instance.setDeviceInfo(deviceInfo);
|
|
615
|
-
if (!config.disableAutoSessions) {
|
|
616
|
-
const appState = getAppState();
|
|
617
|
-
if (appState) {
|
|
618
|
-
appStateSub?.remove();
|
|
619
|
-
let seenBackground = false;
|
|
620
|
-
const handler = (status) => {
|
|
621
|
-
if (!instance) return;
|
|
622
|
-
if (status === "background") {
|
|
623
|
-
seenBackground = true;
|
|
624
|
-
if (tcfCollectionEnabled) resolveDmaConsent();
|
|
625
|
-
applyAppState(instance, status);
|
|
626
|
-
} else if (status === "active") {
|
|
627
|
-
if (!seenBackground) return;
|
|
628
|
-
seenBackground = false;
|
|
629
|
-
if (tcfCollectionEnabled) resolveDmaConsent();
|
|
630
|
-
applyAppState(instance, status);
|
|
631
|
-
void resolveAdvertisingId().catch((err) => reportError("enrich.advertisingId", err));
|
|
632
|
-
}
|
|
633
|
-
};
|
|
634
|
-
appStateSub = appState.addEventListener("change", handler);
|
|
635
|
-
instance.notifyAppActive();
|
|
636
|
-
} else {
|
|
637
|
-
instance.notifyAppActive();
|
|
258
|
+
onErrorHook = config.onError;
|
|
259
|
+
for (const option of IGNORED_OPTIONS) {
|
|
260
|
+
if (config[option] !== void 0) {
|
|
261
|
+
report(
|
|
262
|
+
`config.ignored:${option}`,
|
|
263
|
+
new Error(`${option} is decided by the native SDK and has no effect`)
|
|
264
|
+
);
|
|
638
265
|
}
|
|
639
266
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
client.track("adv_meta_aem", { campaignIds, sourceUrlHash });
|
|
661
|
-
aemSeenUrlHashes.add(sourceUrlHash);
|
|
662
|
-
}
|
|
267
|
+
Advenue.shutdown();
|
|
268
|
+
call("bridgeInitialize", {
|
|
269
|
+
apiKey: config.apiKey,
|
|
270
|
+
endpoint: config.endpoint,
|
|
271
|
+
appVersion: config.appVersion,
|
|
272
|
+
requireConsent: config.requireConsent ?? false,
|
|
273
|
+
batchSize: config.batchSize,
|
|
274
|
+
flushIntervalMs: config.flushIntervalMs,
|
|
275
|
+
signingSecret: config.signingSecret,
|
|
276
|
+
fbAppId: config.fbAppId,
|
|
277
|
+
autoTrackInstall: config.autoTrackInstall !== false,
|
|
278
|
+
sdkVersion: package_default.version
|
|
279
|
+
});
|
|
280
|
+
started = true;
|
|
281
|
+
const { ios: iosForErrors, android: androidForErrors } = bridge();
|
|
282
|
+
const emitter = iosForErrors ?? androidForErrors;
|
|
283
|
+
if (typeof emitter?.addListener === "function") {
|
|
284
|
+
try {
|
|
285
|
+
errorSub = emitter.addListener("onAdvenueError", (event) => {
|
|
286
|
+
report(event.context, new Error(event.message));
|
|
663
287
|
});
|
|
664
|
-
|
|
288
|
+
} catch (error) {
|
|
289
|
+
report("diagnostics.subscribe", error);
|
|
665
290
|
}
|
|
666
291
|
}
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
292
|
+
consentCache = call("bridgeGetConsent") ?? false;
|
|
293
|
+
if (config.appInstanceIdProvider) {
|
|
294
|
+
try {
|
|
295
|
+
const id = await config.appInstanceIdProvider();
|
|
296
|
+
if (id) call("bridgeSetAppInstanceId", id);
|
|
297
|
+
} catch (error) {
|
|
298
|
+
report("enrich.appInstanceId", error);
|
|
673
299
|
}
|
|
674
300
|
}
|
|
675
|
-
|
|
301
|
+
const linking = getLinking();
|
|
302
|
+
if (linking) {
|
|
303
|
+
deepLinkSub = setupDeepLinks({
|
|
304
|
+
getInitialURL: () => linking.getInitialURL(),
|
|
305
|
+
addUrlListener: (handler) => linking.addEventListener("url", (e) => handler(e.url)),
|
|
306
|
+
resolveDeferred: () => Advenue.resolveDeferredDeepLink(),
|
|
307
|
+
onDeepLink: config.onDeepLink ?? (() => {
|
|
308
|
+
}),
|
|
309
|
+
onDirectUrl: (url) => {
|
|
310
|
+
call("bridgeProcessDeepLink", url);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
deepLinkSub.ready.catch((error) => report("deepLink.resolve", error));
|
|
314
|
+
}
|
|
315
|
+
},
|
|
316
|
+
track(name, properties) {
|
|
317
|
+
if (!requireStarted()) return;
|
|
318
|
+
call("bridgeTrack", name, properties ?? null);
|
|
319
|
+
},
|
|
320
|
+
/** Adds exact local revenue to Apple's conversion-value state. iOS only. */
|
|
321
|
+
async recordSkanRevenue(input) {
|
|
322
|
+
if (!requireStarted()) return;
|
|
323
|
+
call("bridgeRecordSkanRevenue", input.amount, input.currency);
|
|
324
|
+
},
|
|
325
|
+
setAppInstanceId(id) {
|
|
326
|
+
if (!requireStarted()) return;
|
|
327
|
+
call("bridgeSetAppInstanceId", id);
|
|
328
|
+
},
|
|
329
|
+
/**
|
|
330
|
+
* Cross-device linking: associates subsequent events with your user id.
|
|
331
|
+
* Pass null to clear.
|
|
332
|
+
*
|
|
333
|
+
* New on this object. The previous release reached it through the client
|
|
334
|
+
* `initialize()` resolved to, and that client no longer exists — so it is
|
|
335
|
+
* promoted here rather than dropped, which is what an app following the
|
|
336
|
+
* documented cross-device recipe would otherwise hit at runtime.
|
|
337
|
+
*/
|
|
338
|
+
setUserId(id) {
|
|
339
|
+
if (!requireStarted()) return;
|
|
340
|
+
call("bridgeSetUserId", id);
|
|
341
|
+
},
|
|
342
|
+
/**
|
|
343
|
+
* Registers the device's push token for uninstall measurement.
|
|
344
|
+
*
|
|
345
|
+
* Advenue never requests the notification permission and never displays
|
|
346
|
+
* anything: pass the token your push library already produced, on every
|
|
347
|
+
* launch and from its refresh listener. A stale token is the one thing that
|
|
348
|
+
* makes uninstall measurement report churn that did not happen.
|
|
349
|
+
*/
|
|
350
|
+
setPushToken(token, provider) {
|
|
351
|
+
if (!requireStarted()) return;
|
|
352
|
+
call("bridgeSetPushToken", token, provider ?? null);
|
|
676
353
|
},
|
|
677
|
-
track: (name, properties, opts) => active().track(name, properties, opts),
|
|
678
354
|
/**
|
|
679
|
-
* Shows the iOS ATT prompt
|
|
680
|
-
*
|
|
355
|
+
* Shows the iOS ATT prompt. Where ATT does not exist (non-iOS, or the iOS
|
|
356
|
+
* module is absent) there is no prompt to show and no signal to read, so
|
|
357
|
+
* consent is left untouched and the call resolves 'unavailable'.
|
|
681
358
|
*/
|
|
682
359
|
async requestTrackingAuthorization() {
|
|
683
|
-
const ios =
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
if (status === "authorized") {
|
|
688
|
-
fireAutoInstallIfPending();
|
|
689
|
-
}
|
|
360
|
+
const { ios } = bridge();
|
|
361
|
+
if (!ios) return "unavailable";
|
|
362
|
+
const status = await ios.requestTrackingAuthorization();
|
|
363
|
+
Advenue.setTrackingConsent(status === "authorized");
|
|
690
364
|
return status;
|
|
691
365
|
},
|
|
692
366
|
setTrackingConsent(granted) {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
367
|
+
if (!requireStarted()) return;
|
|
368
|
+
consentCache = granted;
|
|
369
|
+
call("bridgeSetConsent", granted);
|
|
370
|
+
},
|
|
371
|
+
getTrackingConsent: () => consentCache,
|
|
372
|
+
setConsentData(consent) {
|
|
373
|
+
if (!requireStarted()) return;
|
|
374
|
+
call("bridgeSetConsentData", consent);
|
|
697
375
|
},
|
|
698
|
-
|
|
699
|
-
/** GDPR/CCPA erasure:
|
|
376
|
+
getConsentData: () => call("bridgeGetConsentData") ?? null,
|
|
377
|
+
/** GDPR/CCPA erasure: stops tracking and wipes local identifiers and queue. */
|
|
700
378
|
forgetMe() {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
} catch (err) {
|
|
705
|
-
reportError("forget.wipe", err);
|
|
706
|
-
}
|
|
707
|
-
const secure = secureStore;
|
|
708
|
-
if (secure?.deleteItemAsync) {
|
|
709
|
-
for (const key of [import_sdk_core.DEVICE_ID_KEY, INSTALL_SENT_KEY]) {
|
|
710
|
-
void secure.deleteItemAsync(key).catch((err) => reportError("forget.secureWipe", err));
|
|
711
|
-
}
|
|
712
|
-
}
|
|
379
|
+
if (!requireStarted()) return;
|
|
380
|
+
call("bridgeForgetMe");
|
|
381
|
+
consentCache = false;
|
|
713
382
|
},
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
383
|
+
flush() {
|
|
384
|
+
if (!requireStarted()) return;
|
|
385
|
+
call("bridgeFlush");
|
|
386
|
+
},
|
|
387
|
+
getDeviceId: () => Promise.resolve(
|
|
388
|
+
call("bridgeDeviceId") ?? null
|
|
389
|
+
),
|
|
390
|
+
/** The Advenue ID — alias of `getDeviceId`. */
|
|
391
|
+
getAdvenueId: () => Advenue.getDeviceId(),
|
|
392
|
+
/** Which app the server resolved this API key to; null until a batch lands. */
|
|
393
|
+
getResolvedAppId: () => call("bridgeResolvedAppId") ?? null,
|
|
394
|
+
/**
|
|
395
|
+
* Resolves the deferred deep link for this install, or null for an organic
|
|
396
|
+
* one — which is most of them.
|
|
397
|
+
*/
|
|
398
|
+
async resolveDeferredDeepLink() {
|
|
399
|
+
if (!requireStarted()) return null;
|
|
400
|
+
const result = call("bridgeResolveDeferredDeepLink");
|
|
401
|
+
return await result ?? null;
|
|
718
402
|
},
|
|
719
|
-
getConsentData: () => active().getConsentData(),
|
|
720
|
-
flush: () => active().flush(),
|
|
721
|
-
getDeviceId: () => active().getDeviceId(),
|
|
722
|
-
/** The Advenue ID — alias of getDeviceId (see AdvenueClient.getAdvenueId). */
|
|
723
|
-
getAdvenueId: () => active().getAdvenueId(),
|
|
724
403
|
shutdown() {
|
|
725
|
-
appStateSub?.remove();
|
|
726
|
-
appStateSub = null;
|
|
727
404
|
deepLinkSub?.remove();
|
|
728
405
|
deepLinkSub = null;
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
autoInstallEnabled = true;
|
|
735
|
-
manualConsentSet = false;
|
|
736
|
-
tcfCollectionEnabled = false;
|
|
737
|
-
configuredAppId = null;
|
|
738
|
-
configuredApiKey = null;
|
|
739
|
-
configuredEndpoint = import_sdk_core.DEFAULT_ENDPOINT;
|
|
740
|
-
aemSeenUrlHashes.clear();
|
|
406
|
+
errorSub?.remove();
|
|
407
|
+
errorSub = null;
|
|
408
|
+
if (started) call("bridgeShutdown");
|
|
409
|
+
started = false;
|
|
410
|
+
consentCache = false;
|
|
741
411
|
}
|
|
742
412
|
};
|
|
743
|
-
|
|
744
|
-
const client = active();
|
|
745
|
-
if (client.getRequireConsent() && !client.getTrackingConsent()) {
|
|
746
|
-
return;
|
|
747
|
-
}
|
|
748
|
-
let sent = installFlagStore?.getItem(INSTALL_SENT_KEY) === "1";
|
|
749
|
-
if (!sent && secureStore) {
|
|
750
|
-
try {
|
|
751
|
-
sent = await secureStore.getItemAsync(INSTALL_SENT_KEY) === "1";
|
|
752
|
-
} catch (err) {
|
|
753
|
-
reportError("install.guardRead", err);
|
|
754
|
-
}
|
|
755
|
-
}
|
|
756
|
-
if (sent) {
|
|
757
|
-
client.debugLog("install skipped (already sent on this device)");
|
|
758
|
-
return;
|
|
759
|
-
}
|
|
760
|
-
if (installInFlight) {
|
|
761
|
-
return;
|
|
762
|
-
}
|
|
763
|
-
installInFlight = true;
|
|
764
|
-
const opts = {};
|
|
765
|
-
const props = {};
|
|
766
|
-
const android = getAndroidNative();
|
|
767
|
-
if (android) {
|
|
768
|
-
try {
|
|
769
|
-
const result = await android.getInstallReferrer();
|
|
770
|
-
if (result) {
|
|
771
|
-
const parsed = (0, import_install_referrer.parseInstallReferrer)(result.referrer);
|
|
772
|
-
if (parsed.network) opts.network = parsed.network;
|
|
773
|
-
if (parsed.campaign) opts.campaign = parsed.campaign;
|
|
774
|
-
if (parsed.gclid) props.gclid = parsed.gclid;
|
|
775
|
-
if (parsed.fbclid) props.fbclid = parsed.fbclid;
|
|
776
|
-
Object.assign(props, (0, import_install_referrer.extractReferrerProperties)(result));
|
|
777
|
-
}
|
|
778
|
-
} catch (err) {
|
|
779
|
-
reportError("enrich.installReferrer", err);
|
|
780
|
-
}
|
|
781
|
-
try {
|
|
782
|
-
const meta = await android.getMetaInstallReferrer();
|
|
783
|
-
const parsedMeta = meta ? (0, import_install_referrer.parseMetaInstallReferrer)(meta) : null;
|
|
784
|
-
if (parsedMeta) {
|
|
785
|
-
props.metaInstallReferrer = parsedMeta.raw;
|
|
786
|
-
if (parsedMeta.encryptedData) props.metaReferrerData = parsedMeta.encryptedData;
|
|
787
|
-
if (parsedMeta.nonce) props.metaReferrerNonce = parsedMeta.nonce;
|
|
788
|
-
if (!opts.network && parsedMeta.isClickThrough) {
|
|
789
|
-
opts.network = "meta";
|
|
790
|
-
if (parsedMeta.campaign) opts.campaign = parsedMeta.campaign;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
} catch (err) {
|
|
794
|
-
reportError("enrich.metaReferrer", err);
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
const ios = getIosNative();
|
|
798
|
-
if (ios) {
|
|
799
|
-
try {
|
|
800
|
-
ios.registerAppForAttribution();
|
|
801
|
-
} catch (err) {
|
|
802
|
-
reportError("enrich.skanRegister", err);
|
|
803
|
-
}
|
|
804
|
-
try {
|
|
805
|
-
const asaToken = await ios.getAttributionToken();
|
|
806
|
-
if (asaToken) {
|
|
807
|
-
opts.adservicesToken = asaToken;
|
|
808
|
-
}
|
|
809
|
-
} catch (err) {
|
|
810
|
-
reportError("enrich.adservicesToken", err);
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
await resolveAdvertisingId();
|
|
814
|
-
const trackOpts = { type: "install", ...opts };
|
|
815
|
-
if (configuredAppId && android && typeof android.getIntegrityToken === "function") {
|
|
816
|
-
try {
|
|
817
|
-
const deviceId = client.getDeviceId();
|
|
818
|
-
const requestHash = sha256Hex(`${configuredAppId}:${deviceId}`);
|
|
819
|
-
const token = await android.getIntegrityToken(requestHash);
|
|
820
|
-
if (token) {
|
|
821
|
-
trackOpts.attestationToken = token;
|
|
822
|
-
trackOpts.attestationType = "play-integrity";
|
|
823
|
-
}
|
|
824
|
-
} catch (err) {
|
|
825
|
-
reportError("attest.playIntegrity", err);
|
|
826
|
-
}
|
|
827
|
-
}
|
|
828
|
-
if (configuredAppId && configuredApiKey && ios && typeof ios.attestKey === "function") {
|
|
829
|
-
try {
|
|
830
|
-
const deviceId = client.getDeviceId();
|
|
831
|
-
const challengeUrl = `${configuredEndpoint}/v1/attest/challenge?deviceId=${encodeURIComponent(deviceId)}`;
|
|
832
|
-
const challengeRes = await fetch(challengeUrl, {
|
|
833
|
-
headers: { "x-api-key": configuredApiKey }
|
|
834
|
-
});
|
|
835
|
-
if (!challengeRes.ok) throw new Error(`challenge HTTP ${challengeRes.status}`);
|
|
836
|
-
const { challenge } = await challengeRes.json();
|
|
837
|
-
const { keyId, attestationObject } = await ios.attestKey(challenge);
|
|
838
|
-
trackOpts.attestationToken = attestationObject;
|
|
839
|
-
trackOpts.attestationType = "app-attest";
|
|
840
|
-
trackOpts.attestationKeyId = keyId;
|
|
841
|
-
trackOpts.attestationChallenge = challenge;
|
|
842
|
-
} catch (err) {
|
|
843
|
-
reportError("attest.appAttest", err);
|
|
844
|
-
}
|
|
845
|
-
}
|
|
846
|
-
if (ios && typeof ios.getDeviceCheckToken === "function") {
|
|
847
|
-
try {
|
|
848
|
-
const token = await ios.getDeviceCheckToken();
|
|
849
|
-
if (token) {
|
|
850
|
-
trackOpts.deviceCheckToken = token;
|
|
851
|
-
}
|
|
852
|
-
} catch (err) {
|
|
853
|
-
reportError("attest.deviceCheck", err);
|
|
854
|
-
}
|
|
855
|
-
}
|
|
856
|
-
const pendingBefore = client.pendingCount;
|
|
857
|
-
client.track("install", props, trackOpts);
|
|
858
|
-
if (client.pendingCount === pendingBefore) {
|
|
859
|
-
installInFlight = false;
|
|
860
|
-
client.debugLog("install dropped (consent revoked mid-flight)");
|
|
861
|
-
if (autoInstallEnabled && client.getRequireConsent() && !client.getTrackingConsent()) {
|
|
862
|
-
autoInstallPending = true;
|
|
863
|
-
}
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
client.debugLog("install fired");
|
|
867
|
-
try {
|
|
868
|
-
installFlagStore?.setItem(INSTALL_SENT_KEY, "1");
|
|
869
|
-
} catch (err) {
|
|
870
|
-
reportError("install.flagPersist", err);
|
|
871
|
-
}
|
|
872
|
-
if (secureStore) {
|
|
873
|
-
try {
|
|
874
|
-
await secureStore.setItemAsync(INSTALL_SENT_KEY, "1");
|
|
875
|
-
} catch (err) {
|
|
876
|
-
reportError("install.flagPersistSecure", err);
|
|
877
|
-
}
|
|
878
|
-
}
|
|
879
|
-
}
|
|
413
|
+
var platform = getPlatformOS;
|
|
880
414
|
// Annotate the CommonJS export names for ESM import in node:
|
|
881
415
|
0 && (module.exports = {
|
|
882
416
|
Advenue,
|
|
883
|
-
applyAppState,
|
|
884
|
-
collectDeviceInfo,
|
|
885
|
-
createMMKVStorage,
|
|
886
|
-
createSecureStore,
|
|
887
417
|
getAndroidNative,
|
|
888
418
|
getIosNative,
|
|
889
419
|
parseDirectLink,
|
|
890
|
-
|
|
891
|
-
resolveDmaConsent,
|
|
892
|
-
trackInstall
|
|
420
|
+
platform
|
|
893
421
|
});
|