@layers/react-native 3.3.4 → 3.4.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 +36 -0
- package/android/src/main/java/io/layers/sdk/reactnative/LayersInstallReferrerModule.java +99 -51
- package/dist/debug-overlay.d.mts +1 -1
- package/dist/debug-overlay.d.ts +1 -1
- package/dist/{index-COj3aU6z.d.ts → index-CST_jKc5.d.ts} +112 -2
- package/dist/{index-COj3aU6z.d.ts.map → index-CST_jKc5.d.ts.map} +1 -1
- package/dist/{index-BqtKjSvh.d.mts → index-CodK28vr.d.mts} +112 -2
- package/dist/{index-BqtKjSvh.d.mts.map → index-CodK28vr.d.mts.map} +1 -1
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -1
- package/dist/index.mjs +2 -2
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/{src-Ddj4vu7p.js → src-CPouy-K4.js} +302 -15
- package/dist/{src-DnutJ2iZ.mjs → src-DpIIzeHX.mjs} +298 -17
- package/dist/src-DpIIzeHX.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/src-DnutJ2iZ.mjs.map +0 -1
|
@@ -1122,7 +1122,7 @@ function hostAppIsRegisteredOn(rn) {
|
|
|
1122
1122
|
}
|
|
1123
1123
|
}
|
|
1124
1124
|
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'.";
|
|
1125
|
-
const SDK_VERSION = "3.
|
|
1125
|
+
const SDK_VERSION = "3.4.1";
|
|
1126
1126
|
var LayersReactNative = class LayersReactNative {
|
|
1127
1127
|
core;
|
|
1128
1128
|
eager;
|
|
@@ -1160,6 +1160,12 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1160
1160
|
_installReferrerParams = null;
|
|
1161
1161
|
_hadPriorSdkState = false;
|
|
1162
1162
|
_hadPriorAppIdentity = false;
|
|
1163
|
+
_deferredDeepLink = null;
|
|
1164
|
+
_deferredDeepLinkDelivered = false;
|
|
1165
|
+
_deferredDeepLinkRestore = null;
|
|
1166
|
+
_deferredDeepLinkResolve = null;
|
|
1167
|
+
deferredDeepLinkListeners = /* @__PURE__ */ new Set();
|
|
1168
|
+
_clickResolveClaimed = false;
|
|
1163
1169
|
_attributionDeeplinkId = null;
|
|
1164
1170
|
_attributionGclid = null;
|
|
1165
1171
|
_attributionFbclid = null;
|
|
@@ -1375,6 +1381,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1375
1381
|
persistenceSettle().then(() => this.eager.discardMirror()).catch(() => void 0);
|
|
1376
1382
|
} catch {}
|
|
1377
1383
|
await this.restoreAttributionData();
|
|
1384
|
+
await this.ensureDeferredDeepLinkRestored();
|
|
1378
1385
|
await this.initializeDeviceInfo();
|
|
1379
1386
|
if (this.initAborted(generation)) return;
|
|
1380
1387
|
this._runtimeGeneration = generation;
|
|
@@ -1385,16 +1392,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1385
1392
|
await this.configureSkanFromRemoteConfig();
|
|
1386
1393
|
if (this.initAborted(generation)) return;
|
|
1387
1394
|
this.startConfigPolling();
|
|
1388
|
-
|
|
1389
|
-
let fingerprintResolveEnabled = false;
|
|
1390
|
-
try {
|
|
1391
|
-
const configJson = this.core.getRemoteConfigJson?.();
|
|
1392
|
-
if (configJson) {
|
|
1393
|
-
const config = JSON.parse(configJson);
|
|
1394
|
-
clipboardEnabled = config?.clipboard_attribution_enabled === true;
|
|
1395
|
-
fingerprintResolveEnabled = config?.fingerprint_resolve_enabled === true;
|
|
1396
|
-
}
|
|
1397
|
-
} catch {}
|
|
1395
|
+
const { clipboardEnabled, fingerprintResolveEnabled } = this.readPrivacySwitches();
|
|
1398
1396
|
let clipboardData = null;
|
|
1399
1397
|
try {
|
|
1400
1398
|
const { Platform } = __require("react-native");
|
|
@@ -1959,6 +1957,199 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1959
1957
|
return this._installReferrer;
|
|
1960
1958
|
}
|
|
1961
1959
|
/**
|
|
1960
|
+
* The deferred deep link for this install — the payload of the Layers
|
|
1961
|
+
* tracking link (`in.layers.com/l/tlnk_…`) the user tapped before installing —
|
|
1962
|
+
* or null.
|
|
1963
|
+
*
|
|
1964
|
+
* One-shot per install: the first call (or {@link onDeferredDeepLink}
|
|
1965
|
+
* listener) that receives it marks it delivered, persistently, and every
|
|
1966
|
+
* later call on this install returns null. A link found on one launch and
|
|
1967
|
+
* not yet taken stays pending across launches until something takes it.
|
|
1968
|
+
*
|
|
1969
|
+
* Waits for an in-flight `init()` or {@link resolveDeferredDeepLink} first,
|
|
1970
|
+
* so calling it straight after `init()` sees what init found.
|
|
1971
|
+
*/
|
|
1972
|
+
async getDeferredDeepLink() {
|
|
1973
|
+
if (this._initPromise) await this._initPromise.catch(() => {});
|
|
1974
|
+
if (this._deferredDeepLinkResolve) await this._deferredDeepLinkResolve.catch(() => {});
|
|
1975
|
+
await this.ensureDeferredDeepLinkRestored();
|
|
1976
|
+
const link = this._deferredDeepLink;
|
|
1977
|
+
if (!link || this._deferredDeepLinkDelivered) return null;
|
|
1978
|
+
this._deferredDeepLinkDelivered = true;
|
|
1979
|
+
await this.persistDeferredDeepLink();
|
|
1980
|
+
return copyDeferredDeepLink(link);
|
|
1981
|
+
}
|
|
1982
|
+
/**
|
|
1983
|
+
* Call `listener` once, when this install's deferred deep link becomes known
|
|
1984
|
+
* — immediately (asynchronously) if it was already known and not yet
|
|
1985
|
+
* delivered when you subscribed. Fires at most once per install across all
|
|
1986
|
+
* listeners and {@link getDeferredDeepLink}: whichever receives it first
|
|
1987
|
+
* marks it delivered. Returns an unsubscribe function.
|
|
1988
|
+
*/
|
|
1989
|
+
onDeferredDeepLink(listener) {
|
|
1990
|
+
this.deferredDeepLinkListeners.add(listener);
|
|
1991
|
+
this.ensureDeferredDeepLinkRestored().then(() => this.deliverDeferredDeepLinkToListeners());
|
|
1992
|
+
return () => {
|
|
1993
|
+
this.deferredDeepLinkListeners.delete(listener);
|
|
1994
|
+
};
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* Look for this install's deferred deep link, then return it as
|
|
1998
|
+
* {@link getDeferredDeepLink} does (consuming it).
|
|
1999
|
+
*
|
|
2000
|
+
* `init()` already does this work when `autoTrackAppOpen` is on (the
|
|
2001
|
+
* default). Apps that turn `autoTrackAppOpen` off call this after `init()`:
|
|
2002
|
+
*
|
|
2003
|
+
* 1. Android: reads the Play install referrer's `deeplink` param (local, no
|
|
2004
|
+
* network).
|
|
2005
|
+
* 2. Only where the existing gates already allow it: `POST /clicks/resolve`
|
|
2006
|
+
* on a fresh install (installed within 24 hours, no prior probe, no click
|
|
2007
|
+
* id already known). That probe sends device signals, so it runs only when
|
|
2008
|
+
* the server's `fingerprint_resolve_enabled` remote config is `true`
|
|
2009
|
+
* (default off) AND the core's consent / DNT / Retry-After / circuit
|
|
2010
|
+
* breaker gate is open. This method opens neither gate.
|
|
2011
|
+
*
|
|
2012
|
+
* Safe to call more than once; concurrent calls share one run, and the
|
|
2013
|
+
* probe goes out at most once per install.
|
|
2014
|
+
*/
|
|
2015
|
+
async resolveDeferredDeepLink() {
|
|
2016
|
+
if (!this._deferredDeepLinkResolve) {
|
|
2017
|
+
const run = this.runDeferredDeepLinkResolve().finally(() => {
|
|
2018
|
+
if (this._deferredDeepLinkResolve === run) this._deferredDeepLinkResolve = null;
|
|
2019
|
+
});
|
|
2020
|
+
this._deferredDeepLinkResolve = run;
|
|
2021
|
+
}
|
|
2022
|
+
await this._deferredDeepLinkResolve.catch(() => {});
|
|
2023
|
+
return this.getDeferredDeepLink();
|
|
2024
|
+
}
|
|
2025
|
+
async runDeferredDeepLinkResolve() {
|
|
2026
|
+
if (this._initPromise) await this._initPromise.catch(() => {});
|
|
2027
|
+
if (!this._isInitialized) {
|
|
2028
|
+
if (this.enableDebug) console.log("[Layers] resolveDeferredDeepLink: call init() first");
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
await this.ensureDeferredDeepLinkRestored();
|
|
2032
|
+
if (this._deferredDeepLink || this._deferredDeepLinkDelivered) return;
|
|
2033
|
+
try {
|
|
2034
|
+
const referrer = this._installReferrer ?? await this.collectInstallReferrer();
|
|
2035
|
+
if (referrer) await this.recordReferrerDeepLink(referrer);
|
|
2036
|
+
} catch {}
|
|
2037
|
+
if (this._deferredDeepLink) return;
|
|
2038
|
+
const { fingerprintResolveEnabled } = this.readPrivacySwitches();
|
|
2039
|
+
if (!fingerprintResolveEnabled) return;
|
|
2040
|
+
if (this._attributionFbclid != null || this._attributionGclid != null || this._attributionTtclid != null || this._attributionMsclkid != null) return;
|
|
2041
|
+
try {
|
|
2042
|
+
const AsyncStorage = await loadAsyncStorage();
|
|
2043
|
+
if (AsyncStorage) {
|
|
2044
|
+
if (await AsyncStorage.getItem(deferredClickResolveAttemptedKey(this.config.appId)) === "true") return;
|
|
2045
|
+
if (!await shouldTreatAsNewInstall(await AsyncStorage.getItem(firstLaunchTrackedKey(this.config.appId)) !== "true", false, this.enableDebug, () => this.readFirstInstallTime())) return;
|
|
2046
|
+
}
|
|
2047
|
+
await this.resolveClickFromFingerprint();
|
|
2048
|
+
} catch {}
|
|
2049
|
+
}
|
|
2050
|
+
/**
|
|
2051
|
+
* Claim this install's single `/clicks/resolve` probe. The in-memory flag is
|
|
2052
|
+
* taken synchronously, before any await, so two overlapping callers cannot
|
|
2053
|
+
* both pass; the persisted flag carries the claim across launches and is
|
|
2054
|
+
* written before the request, so a timeout or a kill mid-flight cannot earn
|
|
2055
|
+
* the install a second fingerprint.
|
|
2056
|
+
*/
|
|
2057
|
+
async claimClickResolveProbe() {
|
|
2058
|
+
if (this._clickResolveClaimed) return false;
|
|
2059
|
+
this._clickResolveClaimed = true;
|
|
2060
|
+
try {
|
|
2061
|
+
const AsyncStorage = await loadAsyncStorage();
|
|
2062
|
+
if (AsyncStorage) {
|
|
2063
|
+
const key = deferredClickResolveAttemptedKey(this.config.appId);
|
|
2064
|
+
if (await AsyncStorage.getItem(key) === "true") return false;
|
|
2065
|
+
await AsyncStorage.setItem(key, "true");
|
|
2066
|
+
}
|
|
2067
|
+
} catch {}
|
|
2068
|
+
return true;
|
|
2069
|
+
}
|
|
2070
|
+
/** The server-driven privacy switches, read from the core's cached config. */
|
|
2071
|
+
readPrivacySwitches() {
|
|
2072
|
+
let clipboardEnabled = false;
|
|
2073
|
+
let fingerprintResolveEnabled = false;
|
|
2074
|
+
try {
|
|
2075
|
+
const configJson = this.core.getRemoteConfigJson?.();
|
|
2076
|
+
if (configJson) {
|
|
2077
|
+
const config = JSON.parse(configJson);
|
|
2078
|
+
clipboardEnabled = config?.clipboard_attribution_enabled === true;
|
|
2079
|
+
fingerprintResolveEnabled = config?.fingerprint_resolve_enabled === true;
|
|
2080
|
+
}
|
|
2081
|
+
} catch {}
|
|
2082
|
+
return {
|
|
2083
|
+
clipboardEnabled,
|
|
2084
|
+
fingerprintResolveEnabled
|
|
2085
|
+
};
|
|
2086
|
+
}
|
|
2087
|
+
ensureDeferredDeepLinkRestored() {
|
|
2088
|
+
if (!this._deferredDeepLinkRestore) this._deferredDeepLinkRestore = this.restoreDeferredDeepLink();
|
|
2089
|
+
return this._deferredDeepLinkRestore;
|
|
2090
|
+
}
|
|
2091
|
+
async restoreDeferredDeepLink() {
|
|
2092
|
+
try {
|
|
2093
|
+
const raw = await (await loadAsyncStorage())?.getItem(deferredDeepLinkKey(this.config.appId));
|
|
2094
|
+
if (!raw) return;
|
|
2095
|
+
const stored = JSON.parse(raw);
|
|
2096
|
+
if (stored.delivered === true) this._deferredDeepLinkDelivered = true;
|
|
2097
|
+
const payload = normalizeDeferredDeepLinkPayload(stored.payload);
|
|
2098
|
+
const source = DEFERRED_DEEPLINK_SOURCES.find((s) => s === stored.source);
|
|
2099
|
+
if (payload && source && !this._deferredDeepLink) this._deferredDeepLink = {
|
|
2100
|
+
payload,
|
|
2101
|
+
source,
|
|
2102
|
+
...typeof stored.clickId === "string" && stored.clickId ? { clickId: stored.clickId } : {}
|
|
2103
|
+
};
|
|
2104
|
+
} catch {}
|
|
2105
|
+
}
|
|
2106
|
+
async persistDeferredDeepLink() {
|
|
2107
|
+
try {
|
|
2108
|
+
const AsyncStorage = await loadAsyncStorage();
|
|
2109
|
+
if (!AsyncStorage) return;
|
|
2110
|
+
await AsyncStorage.setItem(deferredDeepLinkKey(this.config.appId), JSON.stringify({
|
|
2111
|
+
...this._deferredDeepLink ?? {},
|
|
2112
|
+
delivered: this._deferredDeepLinkDelivered
|
|
2113
|
+
}));
|
|
2114
|
+
} catch {}
|
|
2115
|
+
}
|
|
2116
|
+
/** Record the referrer's `deeplink` payload, if it carries one. Never throws. */
|
|
2117
|
+
async recordReferrerDeepLink(referrer) {
|
|
2118
|
+
try {
|
|
2119
|
+
const payload = parseInstallReferrerDeepLink(referrer.referrerUrl);
|
|
2120
|
+
if (!payload) return;
|
|
2121
|
+
const clickId = parseInstallReferrerUrl(referrer.referrerUrl).click_id;
|
|
2122
|
+
await this.recordDeferredDeepLink({
|
|
2123
|
+
payload,
|
|
2124
|
+
source: "install_referrer",
|
|
2125
|
+
...clickId ? { clickId } : {}
|
|
2126
|
+
});
|
|
2127
|
+
} catch {}
|
|
2128
|
+
}
|
|
2129
|
+
/**
|
|
2130
|
+
* Keep the first deferred deep link this install finds. A later source never
|
|
2131
|
+
* replaces it, and an install that already delivered one records nothing.
|
|
2132
|
+
*/
|
|
2133
|
+
async recordDeferredDeepLink(link) {
|
|
2134
|
+
await this.ensureDeferredDeepLinkRestored();
|
|
2135
|
+
if (this._deferredDeepLink || this._deferredDeepLinkDelivered) return;
|
|
2136
|
+
this._deferredDeepLink = copyDeferredDeepLink(link);
|
|
2137
|
+
if (this.enableDebug) console.log(`[Layers] deferred deep link found source=${link.source} keys=${Object.keys(link.payload).length}`);
|
|
2138
|
+
await this.persistDeferredDeepLink();
|
|
2139
|
+
this.deliverDeferredDeepLinkToListeners();
|
|
2140
|
+
}
|
|
2141
|
+
deliverDeferredDeepLinkToListeners() {
|
|
2142
|
+
const link = this._deferredDeepLink;
|
|
2143
|
+
if (!link || this._deferredDeepLinkDelivered || this.deferredDeepLinkListeners.size === 0) return;
|
|
2144
|
+
this._deferredDeepLinkDelivered = true;
|
|
2145
|
+
this.persistDeferredDeepLink();
|
|
2146
|
+
for (const listener of Array.from(this.deferredDeepLinkListeners)) try {
|
|
2147
|
+
listener(copyDeferredDeepLink(link));
|
|
2148
|
+
} catch (e) {
|
|
2149
|
+
this.emitError(e);
|
|
2150
|
+
}
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
1962
2153
|
* Returns the auto-configured SKANManager instance, or null if SKAN was not
|
|
1963
2154
|
* configured by the server's remote config.
|
|
1964
2155
|
* On iOS, when remote config contains a `skan` section with `preset` or
|
|
@@ -2040,6 +2231,10 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2040
2231
|
if (this.enableDebug) console.log("[Layers] /clicks/resolve skipped — core delivery gate closed");
|
|
2041
2232
|
return;
|
|
2042
2233
|
}
|
|
2234
|
+
if (!await this.claimClickResolveProbe()) {
|
|
2235
|
+
if (this.enableDebug) console.log("[Layers] /clicks/resolve skipped — this install already sent its one probe");
|
|
2236
|
+
return;
|
|
2237
|
+
}
|
|
2043
2238
|
const baseUrl = (this.config.baseUrl ?? "https://in.layers.com").replace(/\/$/, "");
|
|
2044
2239
|
const deviceContext = this.core.getDeviceContext();
|
|
2045
2240
|
let platform;
|
|
@@ -2085,6 +2280,15 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2085
2280
|
return;
|
|
2086
2281
|
}
|
|
2087
2282
|
const { fbclid, gclid, ttclid, msclkid, method, confidence } = body.data;
|
|
2283
|
+
const payload = normalizeDeferredDeepLinkPayload(body.data.deeplink);
|
|
2284
|
+
if (payload) {
|
|
2285
|
+
const clickId = typeof body.data.click_id === "string" ? body.data.click_id : null;
|
|
2286
|
+
await this.recordDeferredDeepLink({
|
|
2287
|
+
payload,
|
|
2288
|
+
source: "click_resolve",
|
|
2289
|
+
...clickId ? { clickId } : {}
|
|
2290
|
+
});
|
|
2291
|
+
}
|
|
2088
2292
|
if (!fbclid && !gclid && !ttclid && !msclkid) return;
|
|
2089
2293
|
try {
|
|
2090
2294
|
await this.setAttributionData(this._attributionDeeplinkId, gclid ?? this._attributionGclid, fbclid ?? this._attributionFbclid, ttclid ?? this._attributionTtclid, msclkid ?? this._attributionMsclkid);
|
|
@@ -2536,6 +2740,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2536
2740
|
this._installReferrer = referrer;
|
|
2537
2741
|
const parsed = parseInstallReferrerUrl(referrer.referrerUrl);
|
|
2538
2742
|
this._installReferrerParams = Object.keys(parsed).length > 0 ? parsed : null;
|
|
2743
|
+
await this.recordReferrerDeepLink(referrer);
|
|
2539
2744
|
if (parsed.fbclid || parsed.gclid || parsed.ttclid || parsed.msclkid) try {
|
|
2540
2745
|
await this.setAttributionData(this._attributionDeeplinkId, parsed.gclid ?? this._attributionGclid, parsed.fbclid ?? this._attributionFbclid, parsed.ttclid ?? this._attributionTtclid, parsed.msclkid ?? this._attributionMsclkid);
|
|
2541
2746
|
} catch {}
|
|
@@ -3226,6 +3431,18 @@ function decodeFormUrlComponent(encoded) {
|
|
|
3226
3431
|
}
|
|
3227
3432
|
}
|
|
3228
3433
|
/**
|
|
3434
|
+
* The query-string part of a raw Play Install Referrer string. Accepts either a
|
|
3435
|
+
* bare query string (`a=1&b=2`) or a full URL. Throws only on a malformed
|
|
3436
|
+
* envelope escape; callers catch.
|
|
3437
|
+
*/
|
|
3438
|
+
function installReferrerQueryString(referrer) {
|
|
3439
|
+
let qs = referrer;
|
|
3440
|
+
const qIdx = qs.indexOf("?");
|
|
3441
|
+
if (qIdx >= 0) qs = qs.slice(qIdx + 1);
|
|
3442
|
+
if (!qs.includes("=") && qs.includes("%3D")) qs = decodeURIComponent(qs);
|
|
3443
|
+
return qs;
|
|
3444
|
+
}
|
|
3445
|
+
/**
|
|
3229
3446
|
* Parse a raw Play Install Referrer string into a map of recognized attribution
|
|
3230
3447
|
* params. Accepts either a bare query string (`a=1&b=2`) or a full URL.
|
|
3231
3448
|
* Returns an empty object on parse failure.
|
|
@@ -3234,10 +3451,7 @@ function parseInstallReferrerUrl(referrer) {
|
|
|
3234
3451
|
const out = {};
|
|
3235
3452
|
if (!referrer) return out;
|
|
3236
3453
|
try {
|
|
3237
|
-
|
|
3238
|
-
const qIdx = qs.indexOf("?");
|
|
3239
|
-
if (qIdx >= 0) qs = qs.slice(qIdx + 1);
|
|
3240
|
-
if (!qs.includes("=") && qs.includes("%3D")) qs = decodeURIComponent(qs);
|
|
3454
|
+
const qs = installReferrerQueryString(referrer);
|
|
3241
3455
|
for (const pair of qs.split("&")) {
|
|
3242
3456
|
const eq = pair.indexOf("=");
|
|
3243
3457
|
if (eq >= 0) {
|
|
@@ -3277,6 +3491,73 @@ function buildInstallReferrerProperties(referrer) {
|
|
|
3277
3491
|
Object.assign(props, parseInstallReferrerUrl(referrer.referrerUrl));
|
|
3278
3492
|
return props;
|
|
3279
3493
|
}
|
|
3494
|
+
const DEFERRED_DEEPLINK_SOURCES = [
|
|
3495
|
+
"install_referrer",
|
|
3496
|
+
"click_resolve",
|
|
3497
|
+
"clipboard"
|
|
3498
|
+
];
|
|
3499
|
+
/**
|
|
3500
|
+
* A tracking-link payload as a flat `Record<string, string>`, or null when it
|
|
3501
|
+
* holds nothing usable.
|
|
3502
|
+
*
|
|
3503
|
+
* Accepts the object `/clicks/resolve` returns or the JSON string the install
|
|
3504
|
+
* referrer carries. The server stores a flat string map; a finite number or a
|
|
3505
|
+
* boolean is kept as its string form, and anything nested is dropped rather
|
|
3506
|
+
* than stringified, so an app never receives a value it has to parse twice.
|
|
3507
|
+
*/
|
|
3508
|
+
function normalizeDeferredDeepLinkPayload(raw) {
|
|
3509
|
+
let value = raw;
|
|
3510
|
+
if (typeof value === "string") try {
|
|
3511
|
+
value = JSON.parse(value);
|
|
3512
|
+
} catch {
|
|
3513
|
+
return null;
|
|
3514
|
+
}
|
|
3515
|
+
if (value === null || typeof value !== "object" || Array.isArray(value)) return null;
|
|
3516
|
+
const out = {};
|
|
3517
|
+
for (const [key, v] of Object.entries(value)) if (typeof v === "string") out[key] = v;
|
|
3518
|
+
else if (typeof v === "number" && Number.isFinite(v)) out[key] = String(v);
|
|
3519
|
+
else if (typeof v === "boolean") out[key] = String(v);
|
|
3520
|
+
return Object.keys(out).length > 0 ? out : null;
|
|
3521
|
+
}
|
|
3522
|
+
/**
|
|
3523
|
+
* The tracking-link payload carried in a Play Install Referrer string's
|
|
3524
|
+
* `deeplink` param (JSON, form-urlencoded, as the Layers click page writes it),
|
|
3525
|
+
* or null when there is none.
|
|
3526
|
+
*
|
|
3527
|
+
* Kept apart from {@link parseInstallReferrerUrl} on purpose: that map feeds
|
|
3528
|
+
* the `install_referrer` event and `app_open` properties, whose shape is pinned
|
|
3529
|
+
* by `schema/fixtures/install-referrer-event.json` across every SDK.
|
|
3530
|
+
*/
|
|
3531
|
+
function parseInstallReferrerDeepLink(referrer) {
|
|
3532
|
+
if (!referrer) return null;
|
|
3533
|
+
try {
|
|
3534
|
+
const qs = installReferrerQueryString(referrer);
|
|
3535
|
+
for (const pair of qs.split("&")) {
|
|
3536
|
+
const eq = pair.indexOf("=");
|
|
3537
|
+
if (eq >= 0 && decodeFormUrlComponent(pair.slice(0, eq)) === "deeplink") return normalizeDeferredDeepLinkPayload(decodeFormUrlComponent(pair.slice(eq + 1)));
|
|
3538
|
+
}
|
|
3539
|
+
} catch {}
|
|
3540
|
+
return null;
|
|
3541
|
+
}
|
|
3542
|
+
/** The persisted deferred deep link for this appId, and whether it was delivered. */
|
|
3543
|
+
function deferredDeepLinkKey(appId) {
|
|
3544
|
+
return `@layers/deferred_deeplink_${appId}`;
|
|
3545
|
+
}
|
|
3546
|
+
/**
|
|
3547
|
+
* Set once a `/clicks/resolve` probe has gone out for this appId, so
|
|
3548
|
+
* `resolveDeferredDeepLink()` never sends a second one for the same install.
|
|
3549
|
+
*/
|
|
3550
|
+
function deferredClickResolveAttemptedKey(appId) {
|
|
3551
|
+
return `@layers/deferred_click_resolve_attempted_${appId}`;
|
|
3552
|
+
}
|
|
3553
|
+
function copyDeferredDeepLink(link) {
|
|
3554
|
+
const out = {
|
|
3555
|
+
payload: { ...link.payload },
|
|
3556
|
+
source: link.source
|
|
3557
|
+
};
|
|
3558
|
+
if (link.clickId) out.clickId = link.clickId;
|
|
3559
|
+
return out;
|
|
3560
|
+
}
|
|
3280
3561
|
/**
|
|
3281
3562
|
* Fetch the Google Play install referrer on Android via NativeModules.
|
|
3282
3563
|
* Requires the `com.android.installreferrer` library on the native side.
|
|
@@ -3403,5 +3684,5 @@ function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchPa
|
|
|
3403
3684
|
}
|
|
3404
3685
|
|
|
3405
3686
|
//#endregion
|
|
3406
|
-
export {
|
|
3407
|
-
//# sourceMappingURL=src-
|
|
3687
|
+
export { superwallTrackPurchase as $, resolveActiveRoute as A, trackRevenueCatPurchase as B, parseInstallReferrerUrl as C, buildExceptionProperties as Ct, useLayersExpoRouterTracking as D, shouldTreatAsNewInstall as E, registerExpoBackgroundFlush as F, trackPurchaseFailed as G, trackBeginCheckout as H, connectRevenueCat as I, trackSubscription as J, trackRefund as K, isRevenueCatConnected as L, BACKGROUND_FLUSH_MIN_INTERVAL_MINUTES as M, BACKGROUND_FLUSH_TASK_NAME as N, SurveysModule as O, createBackgroundFlushHandler as P, superwallTrackPresentation as Q, resetRevenueCatForTesting as R, parseInstallReferrerDeepLink as S, viewItemEvent as St, setupDeepLinkListener as T, trackOrder as U, trackAddToCart as V, trackPurchase as W, superwallOnEvent as X, trackViewProduct as Y, superwallTrackDismiss as Z, getFirstInstallTime as _, signUpEvent as _t, buildBeginCheckoutEvent as a, initiateCheckoutEvent as at, getOrSetInstallId as b, tutorialCompleteEvent as bt, buildOnboardingStartEvent as c, loginEvent as ct, buildRefundEvent as d, paywallShowEvent as dt, superwallTrackSkip as et, buildStartTrialEvent as f, purchaseEvent as ft, getAdServicesToken as g, shareEvent as gt, formatFbc as h, searchEvent as ht, buildAddToCartEvent as i, addToWishlistEvent as it, useLayersNavigationTracking as j, createNavigationListener as k, buildPaywallShowEvent as l, onboardingCompleteEvent as lt, buildViewItemEvent as m, screenViewEvent as mt, LayersEvent as n, StandardEvents as nt, buildInstallReferrerProperties as o, levelCompleteEvent as ot, buildSubscribeEvent as p, registerEvent as pt, trackRemoveFromCart as q, LayersReactNative as r, addToCartEvent as rt, buildOnboardingCompleteEvent as s, levelStartEvent as st, LayersError$1 as t, superwallUserAttributes as tt, buildPurchaseEvent as u, onboardingStartEvent as ut, getGoogleAdvertisingId as v, startTrialEvent as vt, readClipboardAttribution as w, installExceptionAutoCapture as wt, parseDeepLink as x, viewContentEvent as xt, getInstallReferrer as y, subscribeEvent as yt, syncRevenueCatAttributes as z };
|
|
3688
|
+
//# sourceMappingURL=src-DpIIzeHX.mjs.map
|