@layers/react-native 3.2.14 → 3.3.1
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 +41 -21
- package/dist/debug-overlay.d.mts +1 -1
- package/dist/debug-overlay.d.ts +1 -1
- package/dist/{index-DDvxoi4_.d.ts → index-BJbKdiVm.d.ts} +135 -8
- package/dist/index-BJbKdiVm.d.ts.map +1 -0
- package/dist/{index-BOpYg0_t.d.mts → index-CQN7IdfN.d.mts} +135 -8
- package/dist/index-CQN7IdfN.d.mts.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +25 -2
- package/dist/index.mjs +3 -3
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +2 -2
- package/dist/react.mjs +2 -2
- package/dist/{skan-B0F6AX7g.mjs → skan-DO7MLv2w.mjs} +1 -1
- package/dist/{skan-B0F6AX7g.mjs.map → skan-DO7MLv2w.mjs.map} +1 -1
- package/dist/skan.js +1 -1
- package/dist/skan.mjs +1 -1
- package/dist/{src-w1LpkvTi.js → src-B_cCCgWM.js} +314 -39
- package/dist/{src-BByIGgBm.mjs → src-DL5bdg2R.mjs} +287 -42
- package/dist/src-DL5bdg2R.mjs.map +1 -0
- package/ios/LayersATT.m +20 -0
- package/ios/LayersATT.swift +144 -0
- package/ios/PrivacyInfo.xcprivacy +0 -176
- package/layers-react-native.podspec +3 -1
- package/package.json +2 -2
- package/dist/index-BOpYg0_t.d.mts.map +0 -1
- package/dist/index-DDvxoi4_.d.ts.map +0 -1
- package/dist/src-BByIGgBm.mjs.map +0 -1
- /package/dist/{skan-BRhw9sPC.js → skan-qcOYJKzP.js} +0 -0
|
@@ -1,8 +1,148 @@
|
|
|
1
1
|
import { t as __require } from "./chunk-COTuXS2J.mjs";
|
|
2
2
|
import { a as requestTrackingAuthorization, n as getAdvertisingId, r as getVendorId } from "./att-CnlG_CuV.mjs";
|
|
3
|
-
import { r as setSkanCore, t as SKANManager } from "./skan-
|
|
4
|
-
import { FetchHttpClient, LayersCore, LayersError as LayersError$1, LayersEvent, MemoryPersistence, addToCartEvent as buildAddToCartEvent, beginCheckoutEvent as buildBeginCheckoutEvent, initWasm, purchaseEvent as buildPurchaseEvent, refundEvent as buildRefundEvent, startTrialEvent as buildStartTrialEvent, subscribeEvent as buildSubscribeEvent, viewItemEvent as buildViewItemEvent } from "@layers/core-wasm";
|
|
3
|
+
import { r as setSkanCore, t as SKANManager } from "./skan-DO7MLv2w.mjs";
|
|
4
|
+
import { FetchHttpClient, LayersCore, LayersError as LayersError$1, LayersEvent, MemoryPersistence, addToCartEvent as buildAddToCartEvent, beginCheckoutEvent as buildBeginCheckoutEvent, initWasm, onboardingCompleteEvent as buildOnboardingCompleteEvent, onboardingStartEvent as buildOnboardingStartEvent, paywallShowEvent as buildPaywallShowEvent, purchaseEvent as buildPurchaseEvent, refundEvent as buildRefundEvent, startTrialEvent as buildStartTrialEvent, subscribeEvent as buildSubscribeEvent, viewItemEvent as buildViewItemEvent } from "@layers/core-wasm";
|
|
5
5
|
|
|
6
|
+
//#region src/exceptions.ts
|
|
7
|
+
/** Cap on the serialized stack length to keep payloads sane. */
|
|
8
|
+
const MAX_STACK_CHARS = 1e4;
|
|
9
|
+
/** Cap on the serialized message length. */
|
|
10
|
+
const MAX_MESSAGE_CHARS = 4e3;
|
|
11
|
+
/** How long a fatal error waits for `onFatal` before the crash proceeds. */
|
|
12
|
+
const DEFAULT_FATAL_TIMEOUT_MS = 1e3;
|
|
13
|
+
/**
|
|
14
|
+
* Process-wide: `true` while a fatal error is waiting on `onFatal`. Module
|
|
15
|
+
* level on purpose, so two SDK instances cannot each hold the crash open.
|
|
16
|
+
*/
|
|
17
|
+
let fatalInFlight = false;
|
|
18
|
+
function findErrorUtils() {
|
|
19
|
+
const candidate = globalThis.ErrorUtils;
|
|
20
|
+
if (typeof candidate === "object" && candidate !== null && typeof candidate.getGlobalHandler === "function" && typeof candidate.setGlobalHandler === "function") return candidate;
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
function truncate(s, max) {
|
|
24
|
+
return s.length > max ? `${s.slice(0, max)}…` : s;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Describe whatever React Native handed the global handler. Errors carry a
|
|
28
|
+
* name, message and stack; anything else thrown (strings, plain objects) is
|
|
29
|
+
* serialized best-effort. Every field is coerced to a string, since Error
|
|
30
|
+
* subclasses in the wild override `message` with numbers and getters.
|
|
31
|
+
*/
|
|
32
|
+
function buildExceptionProperties(error, isFatal) {
|
|
33
|
+
const props = {
|
|
34
|
+
$exception_type: "Error",
|
|
35
|
+
$exception_message: "",
|
|
36
|
+
$exception_promise_rejection: false
|
|
37
|
+
};
|
|
38
|
+
if (error instanceof Error) {
|
|
39
|
+
props.$exception_type = String(error.name || "Error");
|
|
40
|
+
props.$exception_message = truncate(String(error.message ?? String(error)), MAX_MESSAGE_CHARS);
|
|
41
|
+
if (error.stack) props.$exception_stack = truncate(String(error.stack), MAX_STACK_CHARS);
|
|
42
|
+
} else if (typeof error === "string") props.$exception_message = truncate(error, MAX_MESSAGE_CHARS);
|
|
43
|
+
else {
|
|
44
|
+
let serialized;
|
|
45
|
+
try {
|
|
46
|
+
serialized = JSON.stringify(error);
|
|
47
|
+
} catch {
|
|
48
|
+
serialized = void 0;
|
|
49
|
+
}
|
|
50
|
+
props.$exception_message = truncate(typeof serialized === "string" ? serialized : String(error), MAX_MESSAGE_CHARS);
|
|
51
|
+
}
|
|
52
|
+
if (typeof isFatal === "boolean") props.$exception_fatal = isFatal;
|
|
53
|
+
return props;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Invoke the consumer-supplied `onInternalError` defensively. A throwing
|
|
57
|
+
* callback must never escape the global handler, where it would be reported
|
|
58
|
+
* as a second uncaught error.
|
|
59
|
+
*/
|
|
60
|
+
function reportInternalError(options, message, error) {
|
|
61
|
+
if (!options.onInternalError) return;
|
|
62
|
+
try {
|
|
63
|
+
options.onInternalError(message, error);
|
|
64
|
+
} catch {}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Run `onFatal`, then `chain` exactly once: when `onFatal` settles, when it
|
|
68
|
+
* throws or returns nothing, or when `fatalTimeoutMs` passes. The timer is
|
|
69
|
+
* the guarantee that a crashed app is never kept alive by a hung write.
|
|
70
|
+
*/
|
|
71
|
+
function chainAfterFatalWork(options, chain) {
|
|
72
|
+
let chained = false;
|
|
73
|
+
const chainOnce = () => {
|
|
74
|
+
if (chained) return;
|
|
75
|
+
chained = true;
|
|
76
|
+
fatalInFlight = false;
|
|
77
|
+
try {
|
|
78
|
+
chain();
|
|
79
|
+
} catch (e) {
|
|
80
|
+
reportInternalError(options, "previous global error handler threw", e);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const timer = setTimeout(chainOnce, options.fatalTimeoutMs ?? DEFAULT_FATAL_TIMEOUT_MS);
|
|
84
|
+
const finish = () => {
|
|
85
|
+
clearTimeout(timer);
|
|
86
|
+
chainOnce();
|
|
87
|
+
};
|
|
88
|
+
fatalInFlight = true;
|
|
89
|
+
let pending;
|
|
90
|
+
try {
|
|
91
|
+
pending = options.onFatal?.();
|
|
92
|
+
} catch (e) {
|
|
93
|
+
reportInternalError(options, "onFatal threw", e);
|
|
94
|
+
finish();
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
if (!pending || typeof pending.then !== "function") {
|
|
98
|
+
finish();
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
pending.then(finish, (e) => {
|
|
102
|
+
reportInternalError(options, "onFatal rejected", e);
|
|
103
|
+
finish();
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Install the React Native global error handler.
|
|
108
|
+
*
|
|
109
|
+
* Returns an idempotent uninstall function that restores the previous
|
|
110
|
+
* handler when ours is still the current one. Returns a no-op uninstall when
|
|
111
|
+
* `ErrorUtils` is absent (Node, Jest without the RN preset, web).
|
|
112
|
+
*/
|
|
113
|
+
function installExceptionAutoCapture(sink, options = {}) {
|
|
114
|
+
const errorUtils = findErrorUtils();
|
|
115
|
+
if (!errorUtils) return () => {};
|
|
116
|
+
const previous = errorUtils.getGlobalHandler();
|
|
117
|
+
let uninstalled = false;
|
|
118
|
+
const handler = (error, isFatal) => {
|
|
119
|
+
if (!uninstalled) try {
|
|
120
|
+
sink("$exception", buildExceptionProperties(error, isFatal));
|
|
121
|
+
} catch (e) {
|
|
122
|
+
reportInternalError(options, "exception auto-capture failed", e);
|
|
123
|
+
}
|
|
124
|
+
const chain = () => {
|
|
125
|
+
if (typeof previous === "function") previous(error, isFatal);
|
|
126
|
+
};
|
|
127
|
+
if (isFatal === true && !uninstalled && options.onFatal && !fatalInFlight) {
|
|
128
|
+
chainAfterFatalWork(options, chain);
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
chain();
|
|
132
|
+
};
|
|
133
|
+
errorUtils.setGlobalHandler(handler);
|
|
134
|
+
return () => {
|
|
135
|
+
if (uninstalled) return;
|
|
136
|
+
uninstalled = true;
|
|
137
|
+
if (errorUtils.getGlobalHandler() !== handler) return;
|
|
138
|
+
if (typeof previous === "function") errorUtils.setGlobalHandler(previous);
|
|
139
|
+
else errorUtils.setGlobalHandler((error) => {
|
|
140
|
+
throw error;
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//#endregion
|
|
6
146
|
//#region src/standard-events.ts
|
|
7
147
|
/**
|
|
8
148
|
* Predefined standard event name constants.
|
|
@@ -34,7 +174,10 @@ const StandardEvents = {
|
|
|
34
174
|
VIEW_CONTENT: "view_content",
|
|
35
175
|
SHARE: "share",
|
|
36
176
|
DEEP_LINK: "deep_link_opened",
|
|
37
|
-
SCREEN_VIEW: "screen_view"
|
|
177
|
+
SCREEN_VIEW: "screen_view",
|
|
178
|
+
ONBOARDING_START: "onboarding_start",
|
|
179
|
+
ONBOARDING_COMPLETE: "onboarding_complete",
|
|
180
|
+
PAYWALL_SHOW: "paywall_show"
|
|
38
181
|
};
|
|
39
182
|
/** Build a login event. */
|
|
40
183
|
function loginEvent(method) {
|
|
@@ -202,6 +345,36 @@ function screenViewEvent(name, screenClass) {
|
|
|
202
345
|
properties
|
|
203
346
|
};
|
|
204
347
|
}
|
|
348
|
+
/** Build an onboarding-start event. `screenName` is the first onboarding screen shown. */
|
|
349
|
+
function onboardingStartEvent(screenName) {
|
|
350
|
+
const properties = {};
|
|
351
|
+
if (screenName !== void 0) properties.screen_name = screenName;
|
|
352
|
+
return {
|
|
353
|
+
event: StandardEvents.ONBOARDING_START,
|
|
354
|
+
properties
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
/** Build an onboarding-complete event. `screenName` is the screen the user finished on. */
|
|
358
|
+
function onboardingCompleteEvent(screenName) {
|
|
359
|
+
const properties = {};
|
|
360
|
+
if (screenName !== void 0) properties.screen_name = screenName;
|
|
361
|
+
return {
|
|
362
|
+
event: StandardEvents.ONBOARDING_COMPLETE,
|
|
363
|
+
properties
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Build a paywall-show event. `placement` names where the paywall appeared
|
|
368
|
+
* (e.g. `onboarding`, `settings`); `productIds` lists the products offered.
|
|
369
|
+
*/
|
|
370
|
+
function paywallShowEvent(placement, productIds) {
|
|
371
|
+
const properties = { placement };
|
|
372
|
+
if (productIds !== void 0) properties.product_ids = productIds;
|
|
373
|
+
return {
|
|
374
|
+
event: StandardEvents.PAYWALL_SHOW,
|
|
375
|
+
properties
|
|
376
|
+
};
|
|
377
|
+
}
|
|
205
378
|
|
|
206
379
|
//#endregion
|
|
207
380
|
//#region src/superwall.ts
|
|
@@ -936,7 +1109,7 @@ function hostAppIsRegisteredOn(rn) {
|
|
|
936
1109
|
}
|
|
937
1110
|
}
|
|
938
1111
|
const DUPLICATE_REACT_NATIVE_MESSAGE = "[Layers] The SDK resolved a SECOND copy of react-native, not the one your app runs. React Native delivers native lifecycle events to a single copy, so this listener can never fire: $app_background and $app_foreground will not be emitted and the background crash-safety snapshot will not run, which loses every event queued since the last flush on any launch that ends in a kill. Fix the duplicate in your bundler — in a Metro monorepo set `resolver.disableHierarchicalLookup = true` and list every workspace node_modules in `resolver.nodeModulesPaths` — or hand the SDK your app's module: `new LayersReactNative({ ..., appState: AppState })` with AppState imported from 'react-native'.";
|
|
939
|
-
const SDK_VERSION = "3.
|
|
1112
|
+
const SDK_VERSION = "3.3.1";
|
|
940
1113
|
var LayersReactNative = class LayersReactNative {
|
|
941
1114
|
core;
|
|
942
1115
|
eagerPersistence;
|
|
@@ -944,6 +1117,8 @@ var LayersReactNative = class LayersReactNative {
|
|
|
944
1117
|
isOnline = true;
|
|
945
1118
|
enableDebug;
|
|
946
1119
|
appStateSubscription = null;
|
|
1120
|
+
exceptionUninstall = null;
|
|
1121
|
+
persistenceSettle = null;
|
|
947
1122
|
_lifecycleCheckTimer = null;
|
|
948
1123
|
netInfoUnsubscribe = null;
|
|
949
1124
|
config;
|
|
@@ -1127,8 +1302,9 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1127
1302
|
if (typeof WebAssembly !== "undefined") await initWasm();
|
|
1128
1303
|
if (this.initAborted(generation)) return;
|
|
1129
1304
|
try {
|
|
1130
|
-
const persistence = await createAsyncStoragePersistence(this.config.appId);
|
|
1305
|
+
const { backend: persistence, settle: persistenceSettle } = await createAsyncStoragePersistence(this.config.appId);
|
|
1131
1306
|
if (this.initAborted(generation)) return;
|
|
1307
|
+
this.persistenceSettle = persistenceSettle;
|
|
1132
1308
|
const httpClient = new FetchHttpClient();
|
|
1133
1309
|
const migrationState = this.core.exportMigrationState();
|
|
1134
1310
|
this.core.shutdown();
|
|
@@ -1259,6 +1435,14 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1259
1435
|
}
|
|
1260
1436
|
if (this.initAborted(generation)) return;
|
|
1261
1437
|
if (this.config.autoTrackDeepLinks !== false) this.setupDeepLinkAutoTracking();
|
|
1438
|
+
if (this.config.autoTrackExceptions !== false) this.exceptionUninstall = installExceptionAutoCapture((eventName, properties) => {
|
|
1439
|
+
this.track(eventName, properties);
|
|
1440
|
+
}, {
|
|
1441
|
+
onInternalError: (message, error) => {
|
|
1442
|
+
if (this.enableDebug) console.warn("[Layers]", message, error);
|
|
1443
|
+
},
|
|
1444
|
+
...typeof __DEV__ !== "undefined" && __DEV__ === true ? {} : { onFatal: () => this.persistForCrash() }
|
|
1445
|
+
});
|
|
1262
1446
|
this._isInitialized = true;
|
|
1263
1447
|
const totalDurationMs = Date.now() - initStartTime;
|
|
1264
1448
|
if (this.enableDebug) console.log(`[Layers] Init timing: mainThread=${String(mainThreadDurationMs)}ms, total=${String(totalDurationMs)}ms`);
|
|
@@ -1283,6 +1467,20 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1283
1467
|
}
|
|
1284
1468
|
}
|
|
1285
1469
|
screen(screenName, properties) {
|
|
1470
|
+
this.screenImpl(screenName, properties, true);
|
|
1471
|
+
}
|
|
1472
|
+
/**
|
|
1473
|
+
* @internal Entry point for auto-capture integrations (the Expo provider's
|
|
1474
|
+
* router tracker). Identical to `screen()` except the view is kept out of
|
|
1475
|
+
* the SKAN engine: SKAN preset rules key off `screen_name`, and an
|
|
1476
|
+
* auto-captured stream of route views would otherwise change an app's iOS
|
|
1477
|
+
* conversion values the moment auto-capture turned on. Manual `screen()`
|
|
1478
|
+
* calls keep feeding SKAN exactly as before.
|
|
1479
|
+
*/
|
|
1480
|
+
_screenAutoCaptured(screenName, properties) {
|
|
1481
|
+
this.screenImpl(screenName, properties, false);
|
|
1482
|
+
}
|
|
1483
|
+
screenImpl(screenName, properties, forwardToSkan) {
|
|
1286
1484
|
if (this.enableDebug) console.log(`[Layers] screen("${screenName}", ${Object.keys(properties ?? {}).length} properties)`);
|
|
1287
1485
|
try {
|
|
1288
1486
|
const merged = this.mergeAttributionProperties(properties);
|
|
@@ -1291,7 +1489,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1291
1489
|
const depthAfter = this.core.queueDepth();
|
|
1292
1490
|
if (depthAfter <= depthBefore && this.enableDebug) console.warn(`[Layers] screen("${screenName}") — event may not have been queued (depth before=${String(depthBefore)}, after=${String(depthAfter)})`);
|
|
1293
1491
|
this.recordRecentEvent(`screen:${screenName}`, properties);
|
|
1294
|
-
if (this._skanManager) {
|
|
1492
|
+
if (forwardToSkan && this._skanManager) {
|
|
1295
1493
|
const skanProps = { ...merged };
|
|
1296
1494
|
if (skanProps.screen_name === void 0) skanProps.screen_name = screenName;
|
|
1297
1495
|
this._skanManager.processEvent("screen_view", skanProps).catch(() => {});
|
|
@@ -1503,7 +1701,9 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1503
1701
|
* After the user responds, this method automatically:
|
|
1504
1702
|
* - Collects IDFA if authorized
|
|
1505
1703
|
* - Updates device info with IDFA and ATT status
|
|
1506
|
-
*
|
|
1704
|
+
*
|
|
1705
|
+
* ATT controls IDFA availability only. This method does not change Layers
|
|
1706
|
+
* consent; use setConsent() explicitly when the app wants to do that.
|
|
1507
1707
|
*
|
|
1508
1708
|
* Returns the ATT status string.
|
|
1509
1709
|
*/
|
|
@@ -1531,14 +1731,13 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1531
1731
|
...this.core.getDeviceContext(),
|
|
1532
1732
|
attStatus: status
|
|
1533
1733
|
};
|
|
1734
|
+
delete updates.idfa;
|
|
1534
1735
|
if (status === "authorized") try {
|
|
1535
1736
|
const idfa = await getAdvertisingId();
|
|
1536
1737
|
if (idfa) updates.idfa = idfa;
|
|
1537
1738
|
} catch {}
|
|
1538
1739
|
this.core.setDeviceContext(updates);
|
|
1539
|
-
|
|
1540
|
-
this.core.setConsent({ advertising: advertisingAllowed });
|
|
1541
|
-
if (this.enableDebug) console.log(`[Layers] ATT status: ${status}, advertising consent: ${String(advertisingAllowed)}`);
|
|
1740
|
+
if (this.enableDebug) console.log(`[Layers] ATT status: ${status}; Layers consent unchanged.`);
|
|
1542
1741
|
return status;
|
|
1543
1742
|
}
|
|
1544
1743
|
/**
|
|
@@ -1599,11 +1798,13 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1599
1798
|
return this.core.getConsentState();
|
|
1600
1799
|
}
|
|
1601
1800
|
setDeviceInfo(deviceInfo) {
|
|
1602
|
-
const
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1801
|
+
const next = { ...this.core.getDeviceContext() };
|
|
1802
|
+
for (const key of Object.keys(deviceInfo)) {
|
|
1803
|
+
const value = deviceInfo[key];
|
|
1804
|
+
if (value === void 0) delete next[key];
|
|
1805
|
+
else Object.assign(next, { [key]: value });
|
|
1806
|
+
}
|
|
1807
|
+
this.core.setDeviceContext(next);
|
|
1607
1808
|
}
|
|
1608
1809
|
async flush() {
|
|
1609
1810
|
try {
|
|
@@ -1870,6 +2071,20 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1870
2071
|
setSkanCore(null);
|
|
1871
2072
|
}
|
|
1872
2073
|
/**
|
|
2074
|
+
* Make a fatal error's `$exception` durable before React Native's crash
|
|
2075
|
+
* path ends the process. The core's `flush()` snapshots the queue to the
|
|
2076
|
+
* persistence backend, whose AsyncStorage write is otherwise fire-and-
|
|
2077
|
+
* forget; this waits for that write to land. Delivery is left to the next
|
|
2078
|
+
* launch, which re-hydrates the snapshot and sends it, so the crashed app is
|
|
2079
|
+
* held open only for the write.
|
|
2080
|
+
*/
|
|
2081
|
+
async persistForCrash() {
|
|
2082
|
+
try {
|
|
2083
|
+
this.core.flush();
|
|
2084
|
+
} catch {}
|
|
2085
|
+
if (this.persistenceSettle) await this.persistenceSettle();
|
|
2086
|
+
}
|
|
2087
|
+
/**
|
|
1873
2088
|
* Remove every listener and timer this instance installed, then shut the
|
|
1874
2089
|
* core down. Shared by shutdown() and the mid-init abort path, so it must be
|
|
1875
2090
|
* safe to call twice — every handle is nulled and the core's own shutdown()
|
|
@@ -1890,6 +2105,12 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1890
2105
|
this.deepLinkUnsubscribe();
|
|
1891
2106
|
this.deepLinkUnsubscribe = null;
|
|
1892
2107
|
}
|
|
2108
|
+
if (this.exceptionUninstall) {
|
|
2109
|
+
try {
|
|
2110
|
+
this.exceptionUninstall();
|
|
2111
|
+
} catch {}
|
|
2112
|
+
this.exceptionUninstall = null;
|
|
2113
|
+
}
|
|
1893
2114
|
try {
|
|
1894
2115
|
this.core.shutdown();
|
|
1895
2116
|
} catch {}
|
|
@@ -2317,6 +2538,15 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2317
2538
|
async function createAsyncStoragePersistence(appId) {
|
|
2318
2539
|
const prefix = `layers_sdk_${appId}_`;
|
|
2319
2540
|
const memoryStore = /* @__PURE__ */ new Map();
|
|
2541
|
+
const inFlight = /* @__PURE__ */ new Set();
|
|
2542
|
+
const trackInFlight = (operation) => {
|
|
2543
|
+
const entry = operation.then(() => {
|
|
2544
|
+
inFlight.delete(entry);
|
|
2545
|
+
}, () => {
|
|
2546
|
+
inFlight.delete(entry);
|
|
2547
|
+
});
|
|
2548
|
+
inFlight.add(entry);
|
|
2549
|
+
};
|
|
2320
2550
|
try {
|
|
2321
2551
|
const AsyncStorage = await loadAsyncStorage();
|
|
2322
2552
|
if (AsyncStorage) {
|
|
@@ -2333,23 +2563,26 @@ async function createAsyncStoragePersistence(appId) {
|
|
|
2333
2563
|
warnPersistencePreloadFailed(error);
|
|
2334
2564
|
}
|
|
2335
2565
|
return {
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2566
|
+
backend: {
|
|
2567
|
+
write(key, data) {
|
|
2568
|
+
memoryStore.set(key, new Uint8Array(data));
|
|
2569
|
+
trackInFlight(writeToAsyncStorage(prefix + key, data));
|
|
2570
|
+
},
|
|
2571
|
+
read(key) {
|
|
2572
|
+
return memoryStore.get(key) ?? null;
|
|
2573
|
+
},
|
|
2574
|
+
delete(key) {
|
|
2575
|
+
memoryStore.delete(key);
|
|
2576
|
+
trackInFlight(deleteFromAsyncStorage(prefix + key));
|
|
2577
|
+
},
|
|
2578
|
+
listKeys(keyPrefix) {
|
|
2579
|
+
const keys = [];
|
|
2580
|
+
for (const k of memoryStore.keys()) if (k.startsWith(keyPrefix)) keys.push(k);
|
|
2581
|
+
keys.sort();
|
|
2582
|
+
return keys;
|
|
2583
|
+
}
|
|
2346
2584
|
},
|
|
2347
|
-
|
|
2348
|
-
const keys = [];
|
|
2349
|
-
for (const k of memoryStore.keys()) if (k.startsWith(keyPrefix)) keys.push(k);
|
|
2350
|
-
keys.sort();
|
|
2351
|
-
return keys;
|
|
2352
|
-
}
|
|
2585
|
+
settle: () => Promise.all(Array.from(inFlight)).then(() => void 0)
|
|
2353
2586
|
};
|
|
2354
2587
|
}
|
|
2355
2588
|
const B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -2872,42 +3105,54 @@ function parseDeepLink(url) {
|
|
|
2872
3105
|
const _expoRouterPreviousPath = /* @__PURE__ */ new WeakMap();
|
|
2873
3106
|
const _expoRouterLastTracked = /* @__PURE__ */ new WeakMap();
|
|
2874
3107
|
/**
|
|
2875
|
-
* Hook that emits
|
|
3108
|
+
* Hook that emits `screen_view` for every Expo Router pathname change.
|
|
2876
3109
|
*
|
|
2877
|
-
*
|
|
3110
|
+
* One view per route per SDK instance: the deduplication key is the resolved
|
|
3111
|
+
* pathname alone. A param-only change on the same route (a search box or
|
|
3112
|
+
* filter chips mirrored into the URL) is the same screen and is not
|
|
3113
|
+
* re-tracked, and the Expo provider's auto-captured view and a manual call on
|
|
3114
|
+
* the same route count once, whichever effect runs first.
|
|
3115
|
+
*
|
|
3116
|
+
* The hook also tracks the previous screen name so the emitted event carries
|
|
2878
3117
|
* `previous_screen_name`, matching the React Navigation observer in
|
|
2879
3118
|
* `useLayersNavigationTracking`. This makes funnel analysis trivial
|
|
2880
3119
|
* server-side: every screen event has a self-contained pair `(from, to)`
|
|
2881
3120
|
* — no need to join adjacent rows.
|
|
2882
3121
|
*/
|
|
2883
|
-
function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchParams) {
|
|
3122
|
+
function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchParams, options = {}) {
|
|
3123
|
+
const autoCaptured = options.source === "auto";
|
|
2884
3124
|
if (sdkInstance != null && typeof sdkInstance.screen !== "function") throw new TypeError("useLayersExpoRouterTracking: expected a LayersReactNative instance (or null before init).");
|
|
2885
3125
|
const { useEffect } = __require("react");
|
|
2886
3126
|
const pathname = usePathname();
|
|
2887
3127
|
const params = useGlobalSearchParams();
|
|
2888
|
-
const
|
|
3128
|
+
const routeKey = options.resolvedPath ?? pathname;
|
|
2889
3129
|
useEffect(() => {
|
|
2890
3130
|
if (sdkInstance == null) return;
|
|
2891
3131
|
if (pathname) {
|
|
2892
|
-
const
|
|
2893
|
-
if (
|
|
3132
|
+
const last = _expoRouterLastTracked.get(sdkInstance);
|
|
3133
|
+
if (last && last.resolvedPath === routeKey && (!autoCaptured || last.name === pathname)) return;
|
|
2894
3134
|
const properties = {};
|
|
2895
3135
|
Object.entries(params).forEach(([key, value]) => {
|
|
2896
3136
|
properties[key] = Array.isArray(value) ? value.join(",") : value;
|
|
2897
3137
|
});
|
|
2898
3138
|
const previous = _expoRouterPreviousPath.get(sdkInstance);
|
|
2899
3139
|
if (previous && previous !== pathname) properties.previous_screen_name = previous;
|
|
2900
|
-
sdkInstance.
|
|
3140
|
+
if (autoCaptured && typeof sdkInstance._screenAutoCaptured === "function") sdkInstance._screenAutoCaptured(pathname, properties);
|
|
3141
|
+
else sdkInstance.screen(pathname, properties);
|
|
2901
3142
|
_expoRouterPreviousPath.set(sdkInstance, pathname);
|
|
2902
|
-
_expoRouterLastTracked.set(sdkInstance,
|
|
3143
|
+
_expoRouterLastTracked.set(sdkInstance, {
|
|
3144
|
+
resolvedPath: routeKey,
|
|
3145
|
+
name: pathname
|
|
3146
|
+
});
|
|
2903
3147
|
}
|
|
2904
3148
|
}, [
|
|
2905
3149
|
sdkInstance,
|
|
2906
3150
|
pathname,
|
|
2907
|
-
|
|
3151
|
+
routeKey,
|
|
3152
|
+
autoCaptured
|
|
2908
3153
|
]);
|
|
2909
3154
|
}
|
|
2910
3155
|
|
|
2911
3156
|
//#endregion
|
|
2912
|
-
export {
|
|
2913
|
-
//# sourceMappingURL=src-
|
|
3157
|
+
export { superwallTrackSkip as $, useLayersNavigationTracking as A, trackAddToCart as B, readClipboardAttribution as C, installExceptionAutoCapture as Ct, SurveysModule as D, useLayersExpoRouterTracking as E, connectRevenueCat as F, trackRefund as G, trackOrder as H, isRevenueCatConnected as I, trackViewProduct as J, trackRemoveFromCart as K, resetRevenueCatForTesting as L, BACKGROUND_FLUSH_TASK_NAME as M, createBackgroundFlushHandler as N, createNavigationListener as O, registerExpoBackgroundFlush as P, superwallTrackPurchase as Q, syncRevenueCatAttributes as R, parseInstallReferrerUrl as S, buildExceptionProperties as St, shouldTreatAsNewInstall as T, trackPurchase as U, trackBeginCheckout as V, trackPurchaseFailed as W, superwallTrackDismiss as X, superwallOnEvent as Y, superwallTrackPresentation as Z, getFirstInstallTime as _, startTrialEvent as _t, buildBeginCheckoutEvent as a, levelCompleteEvent as at, getOrSetInstallId as b, viewContentEvent as bt, buildOnboardingStartEvent as c, onboardingCompleteEvent as ct, buildRefundEvent as d, purchaseEvent as dt, superwallUserAttributes as et, buildStartTrialEvent as f, registerEvent as ft, getAdServicesToken as g, signUpEvent as gt, formatFbc as h, shareEvent as ht, buildAddToCartEvent as i, initiateCheckoutEvent as it, BACKGROUND_FLUSH_MIN_INTERVAL_MINUTES as j, resolveActiveRoute as k, buildPaywallShowEvent as l, onboardingStartEvent as lt, buildViewItemEvent as m, searchEvent as mt, LayersEvent as n, addToCartEvent as nt, buildInstallReferrerProperties as o, levelStartEvent as ot, buildSubscribeEvent as p, screenViewEvent as pt, trackSubscription as q, LayersReactNative as r, addToWishlistEvent as rt, buildOnboardingCompleteEvent as s, loginEvent as st, LayersError$1 as t, StandardEvents as tt, buildPurchaseEvent as u, paywallShowEvent as ut, getGoogleAdvertisingId as v, subscribeEvent as vt, setupDeepLinkListener as w, parseDeepLink as x, viewItemEvent as xt, getInstallReferrer as y, tutorialCompleteEvent as yt, trackRevenueCatPurchase as z };
|
|
3158
|
+
//# sourceMappingURL=src-DL5bdg2R.mjs.map
|