@layers/react-native 3.3.0 → 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 +15 -13
- package/dist/debug-overlay.d.mts +1 -1
- package/dist/debug-overlay.d.ts +1 -1
- package/dist/{index-DjLsbUvy.d.ts → index-BJbKdiVm.d.ts} +125 -6
- package/dist/index-BJbKdiVm.d.ts.map +1 -0
- package/dist/{index-v9kql0wu.d.mts → index-CQN7IdfN.d.mts} +125 -6
- 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-oJF9UfKf.js → src-B_cCCgWM.js} +302 -30
- package/dist/{src-Dd76louH.mjs → src-DL5bdg2R.mjs} +275 -33
- package/dist/src-DL5bdg2R.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/index-DjLsbUvy.d.ts.map +0 -1
- package/dist/index-v9kql0wu.d.mts.map +0 -1
- package/dist/src-Dd76louH.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.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(() => {});
|
|
@@ -1873,6 +2071,20 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1873
2071
|
setSkanCore(null);
|
|
1874
2072
|
}
|
|
1875
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
|
+
/**
|
|
1876
2088
|
* Remove every listener and timer this instance installed, then shut the
|
|
1877
2089
|
* core down. Shared by shutdown() and the mid-init abort path, so it must be
|
|
1878
2090
|
* safe to call twice — every handle is nulled and the core's own shutdown()
|
|
@@ -1893,6 +2105,12 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1893
2105
|
this.deepLinkUnsubscribe();
|
|
1894
2106
|
this.deepLinkUnsubscribe = null;
|
|
1895
2107
|
}
|
|
2108
|
+
if (this.exceptionUninstall) {
|
|
2109
|
+
try {
|
|
2110
|
+
this.exceptionUninstall();
|
|
2111
|
+
} catch {}
|
|
2112
|
+
this.exceptionUninstall = null;
|
|
2113
|
+
}
|
|
1896
2114
|
try {
|
|
1897
2115
|
this.core.shutdown();
|
|
1898
2116
|
} catch {}
|
|
@@ -2320,6 +2538,15 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2320
2538
|
async function createAsyncStoragePersistence(appId) {
|
|
2321
2539
|
const prefix = `layers_sdk_${appId}_`;
|
|
2322
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
|
+
};
|
|
2323
2550
|
try {
|
|
2324
2551
|
const AsyncStorage = await loadAsyncStorage();
|
|
2325
2552
|
if (AsyncStorage) {
|
|
@@ -2336,23 +2563,26 @@ async function createAsyncStoragePersistence(appId) {
|
|
|
2336
2563
|
warnPersistencePreloadFailed(error);
|
|
2337
2564
|
}
|
|
2338
2565
|
return {
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
|
|
2348
|
-
|
|
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
|
+
}
|
|
2349
2584
|
},
|
|
2350
|
-
|
|
2351
|
-
const keys = [];
|
|
2352
|
-
for (const k of memoryStore.keys()) if (k.startsWith(keyPrefix)) keys.push(k);
|
|
2353
|
-
keys.sort();
|
|
2354
|
-
return keys;
|
|
2355
|
-
}
|
|
2585
|
+
settle: () => Promise.all(Array.from(inFlight)).then(() => void 0)
|
|
2356
2586
|
};
|
|
2357
2587
|
}
|
|
2358
2588
|
const B64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
@@ -2875,42 +3105,54 @@ function parseDeepLink(url) {
|
|
|
2875
3105
|
const _expoRouterPreviousPath = /* @__PURE__ */ new WeakMap();
|
|
2876
3106
|
const _expoRouterLastTracked = /* @__PURE__ */ new WeakMap();
|
|
2877
3107
|
/**
|
|
2878
|
-
* Hook that emits
|
|
3108
|
+
* Hook that emits `screen_view` for every Expo Router pathname change.
|
|
2879
3109
|
*
|
|
2880
|
-
*
|
|
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
|
|
2881
3117
|
* `previous_screen_name`, matching the React Navigation observer in
|
|
2882
3118
|
* `useLayersNavigationTracking`. This makes funnel analysis trivial
|
|
2883
3119
|
* server-side: every screen event has a self-contained pair `(from, to)`
|
|
2884
3120
|
* — no need to join adjacent rows.
|
|
2885
3121
|
*/
|
|
2886
|
-
function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchParams) {
|
|
3122
|
+
function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchParams, options = {}) {
|
|
3123
|
+
const autoCaptured = options.source === "auto";
|
|
2887
3124
|
if (sdkInstance != null && typeof sdkInstance.screen !== "function") throw new TypeError("useLayersExpoRouterTracking: expected a LayersReactNative instance (or null before init).");
|
|
2888
3125
|
const { useEffect } = __require("react");
|
|
2889
3126
|
const pathname = usePathname();
|
|
2890
3127
|
const params = useGlobalSearchParams();
|
|
2891
|
-
const
|
|
3128
|
+
const routeKey = options.resolvedPath ?? pathname;
|
|
2892
3129
|
useEffect(() => {
|
|
2893
3130
|
if (sdkInstance == null) return;
|
|
2894
3131
|
if (pathname) {
|
|
2895
|
-
const
|
|
2896
|
-
if (
|
|
3132
|
+
const last = _expoRouterLastTracked.get(sdkInstance);
|
|
3133
|
+
if (last && last.resolvedPath === routeKey && (!autoCaptured || last.name === pathname)) return;
|
|
2897
3134
|
const properties = {};
|
|
2898
3135
|
Object.entries(params).forEach(([key, value]) => {
|
|
2899
3136
|
properties[key] = Array.isArray(value) ? value.join(",") : value;
|
|
2900
3137
|
});
|
|
2901
3138
|
const previous = _expoRouterPreviousPath.get(sdkInstance);
|
|
2902
3139
|
if (previous && previous !== pathname) properties.previous_screen_name = previous;
|
|
2903
|
-
sdkInstance.
|
|
3140
|
+
if (autoCaptured && typeof sdkInstance._screenAutoCaptured === "function") sdkInstance._screenAutoCaptured(pathname, properties);
|
|
3141
|
+
else sdkInstance.screen(pathname, properties);
|
|
2904
3142
|
_expoRouterPreviousPath.set(sdkInstance, pathname);
|
|
2905
|
-
_expoRouterLastTracked.set(sdkInstance,
|
|
3143
|
+
_expoRouterLastTracked.set(sdkInstance, {
|
|
3144
|
+
resolvedPath: routeKey,
|
|
3145
|
+
name: pathname
|
|
3146
|
+
});
|
|
2906
3147
|
}
|
|
2907
3148
|
}, [
|
|
2908
3149
|
sdkInstance,
|
|
2909
3150
|
pathname,
|
|
2910
|
-
|
|
3151
|
+
routeKey,
|
|
3152
|
+
autoCaptured
|
|
2911
3153
|
]);
|
|
2912
3154
|
}
|
|
2913
3155
|
|
|
2914
3156
|
//#endregion
|
|
2915
|
-
export {
|
|
2916
|
-
//# 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
|