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