@attryio/react-native 0.1.10 → 0.1.13
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/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -10
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -59,5 +59,5 @@ export declare function attachReactNativeLifecycleTracking(client: Attry, rn: Re
|
|
|
59
59
|
sessionTimeoutMs?: number;
|
|
60
60
|
}): Promise<void>;
|
|
61
61
|
export declare function attachDeepLinkTracking(client: Attry, rn?: ReactNativeLike): Promise<void>;
|
|
62
|
-
export declare function collectInstallAttribution(client: Attry, rn?: ReactNativeLike): Promise<
|
|
62
|
+
export declare function collectInstallAttribution(client: Attry, rn?: ReactNativeLike): Promise<boolean>;
|
|
63
63
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAGL,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,EAGL,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,YAAY,EAEjB,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAE3B,KAAK,eAAe,GAAG;IACrB,QAAQ,CAAC,EAAE;QACT,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,gBAAgB,CAAC,EAAE,CACjB,KAAK,EAAE,QAAQ,EACf,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,KAC9B;YAAE,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;SAAE,CAAC;KAC9B,CAAC;IACF,UAAU,CAAC,EAAE;QACX,GAAG,CAAC,E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WAAW,EAAE,UAAU,GAAG,SAAS,CAAC;IACjD,OAAO,CAAC,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;IACjC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,wBAAwB,CAAC,EAAE,OAAO,CAAC;IACnC,6BAA6B,CAAC,EAAE,OAAO,CAAC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAKD,OAAO,EAAE,aAAa,EAAE,CAAC;AAEzB,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,sBAAsB,kBAiC1E;AAED,wBAAsB,yBAAyB,CAC7C,EAAE,CAAC,EAAE,eAAe,EACpB,iBAAiB,GAAE,WAAW,CAAC,SAAS,CAAM,GAC7C,OAAO,CAAC,YAAY,CAAC,CA6HvB;AAED,wBAAsB,kCAAkC,CACtD,MAAM,EAAE,KAAK,EACb,EAAE,EAAE,eAAe,GAAG,SAAS,EAC/B,OAAO,EAAE,YAAY,YAAsB,EAC3C,OAAO,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAAE,iBAsFtD;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,KAAK,EACb,EAAE,CAAC,EAAE,eAAe,iBAWrB;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,KAAK,EACb,EAAE,CAAC,EAAE,eAAe,GACnB,OAAO,CAAC,OAAO,CAAC,CAuClB"}
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Attry, ATTRY_EVENTS, MemoryStorage, parseAttryUrl } from "@attryio/sdk-core";
|
|
2
2
|
const SDK_NAME = "attry-react-native";
|
|
3
|
-
const SDK_VERSION = "0.1.
|
|
3
|
+
const SDK_VERSION = "0.1.13";
|
|
4
4
|
export { parseAttryUrl };
|
|
5
5
|
export async function createAttryReactNative(config) {
|
|
6
6
|
const rn = loadReactNative();
|
|
@@ -16,7 +16,7 @@ export async function createAttryReactNative(config) {
|
|
|
16
16
|
context
|
|
17
17
|
}).init();
|
|
18
18
|
if (config.autoCollectInstallAttribution ?? true) {
|
|
19
|
-
await
|
|
19
|
+
await collectInstallAttributionOnce(client, rn, storage, config.appId);
|
|
20
20
|
}
|
|
21
21
|
if (config.autoTrackLifecycleEvents ?? true) {
|
|
22
22
|
await attachReactNativeLifecycleTracking(client, rn, storage, {
|
|
@@ -222,17 +222,14 @@ export async function attachDeepLinkTracking(client, rn) {
|
|
|
222
222
|
export async function collectInstallAttribution(client, rn) {
|
|
223
223
|
const native = rn ?? loadReactNative();
|
|
224
224
|
if (native?.Platform?.OS === "ios") {
|
|
225
|
-
const token = await native.NativeModules?.AttryAppleAds?.attributionToken?.();
|
|
225
|
+
const token = await native.NativeModules?.AttryAppleAds?.attributionToken?.().catch(() => null);
|
|
226
226
|
if (token) {
|
|
227
227
|
const response = await client.submitAppleAdsToken(token);
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
attributed: Boolean(response?.attribution)
|
|
232
|
-
}
|
|
233
|
-
});
|
|
228
|
+
if (hasResolvedInstallAttribution(response)) {
|
|
229
|
+
return true;
|
|
230
|
+
}
|
|
234
231
|
}
|
|
235
|
-
return;
|
|
232
|
+
return hasResolvedInstallAttribution(await client.resolveInstall());
|
|
236
233
|
}
|
|
237
234
|
if (native?.Platform?.OS === "android") {
|
|
238
235
|
const payload = await native.NativeModules?.AttryInstallReferrer?.getInstallReferrer?.();
|
|
@@ -248,7 +245,31 @@ export async function collectInstallAttribution(client, rn) {
|
|
|
248
245
|
confidence: "deterministic"
|
|
249
246
|
}
|
|
250
247
|
});
|
|
248
|
+
return true;
|
|
251
249
|
}
|
|
250
|
+
return hasResolvedInstallAttribution(await client.resolveInstall());
|
|
251
|
+
}
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
function hasResolvedInstallAttribution(response) {
|
|
255
|
+
const attribution = response?.attribution;
|
|
256
|
+
if (!attribution) {
|
|
257
|
+
return false;
|
|
258
|
+
}
|
|
259
|
+
const source = typeof attribution.source === "string" ? attribution.source.trim() : "";
|
|
260
|
+
const confidence = typeof attribution.confidence === "string"
|
|
261
|
+
? attribution.confidence.trim()
|
|
262
|
+
: "";
|
|
263
|
+
return Boolean(source && source !== "unknown" && confidence !== "unknown");
|
|
264
|
+
}
|
|
265
|
+
async function collectInstallAttributionOnce(client, rn, storage, appId) {
|
|
266
|
+
const attributionKey = `attry.${appId}.install_attribution_resolved.v2`;
|
|
267
|
+
if (await storage.getItem(attributionKey)) {
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
const collected = await collectInstallAttribution(client, rn);
|
|
271
|
+
if (collected) {
|
|
272
|
+
await storage.setItem(attributionKey, new Date().toISOString());
|
|
252
273
|
}
|
|
253
274
|
}
|
|
254
275
|
async function trackDeepLinkOpen(client, url, openType, rn) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@attryio/react-native",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "React Native SDK for Attry mobile app analytics, attribution, deep links, deferred deep links, and revenue events.",
|
|
5
5
|
"private": false,
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,12 +36,6 @@
|
|
|
36
36
|
"import": "./dist/index.js"
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
"scripts": {
|
|
40
|
-
"build": "tsc -p tsconfig.json",
|
|
41
|
-
"lint": "eslint .",
|
|
42
|
-
"test": "vitest run",
|
|
43
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
44
|
-
},
|
|
45
39
|
"files": [
|
|
46
40
|
"dist",
|
|
47
41
|
"ios",
|
|
@@ -55,10 +49,16 @@
|
|
|
55
49
|
"access": "public"
|
|
56
50
|
},
|
|
57
51
|
"dependencies": {
|
|
58
|
-
"@attryio/sdk-core": "0.1.
|
|
52
|
+
"@attryio/sdk-core": "0.1.6",
|
|
59
53
|
"@react-native-async-storage/async-storage": "^2.2.0"
|
|
60
54
|
},
|
|
61
55
|
"peerDependencies": {
|
|
62
56
|
"react-native": ">=0.72"
|
|
57
|
+
},
|
|
58
|
+
"scripts": {
|
|
59
|
+
"build": "tsc -p tsconfig.json",
|
|
60
|
+
"lint": "eslint .",
|
|
61
|
+
"test": "vitest run",
|
|
62
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
63
63
|
}
|
|
64
|
-
}
|
|
64
|
+
}
|