@layers/react-native 3.2.9 → 3.2.11
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 +27 -14
- package/android/src/main/java/io/layers/sdk/reactnative/LayersInstallReferrerModule.java +47 -0
- package/dist/debug-overlay.d.mts +1 -1
- package/dist/debug-overlay.d.ts +1 -1
- package/dist/{index-BaCWtOOT.d.mts → index-BOpYg0_t.d.mts} +61 -2
- package/dist/{index-BaCWtOOT.d.mts.map → index-BOpYg0_t.d.mts.map} +1 -1
- package/dist/{index-BNM5Q_2v.d.ts → index-DDvxoi4_.d.ts} +61 -2
- package/dist/{index-BNM5Q_2v.d.ts.map → index-DDvxoi4_.d.ts.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-C-R3kpFn.js → src-BWlZe6w2.js} +132 -23
- package/dist/{src-QOgOUX34.mjs → src-DWe1Tv-R.mjs} +128 -25
- package/dist/src-DWe1Tv-R.mjs.map +1 -0
- package/ios/PrivacyInfo.xcprivacy +153 -0
- package/layers-react-native.podspec +12 -0
- package/package.json +2 -2
- package/dist/src-QOgOUX34.mjs.map +0 -1
package/dist/react.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "./att-CnlG_CuV.mjs";
|
|
2
2
|
import "./skan-B0F6AX7g.mjs";
|
|
3
|
-
import { r as LayersReactNative } from "./src-
|
|
3
|
+
import { r as LayersReactNative } from "./src-DWe1Tv-R.mjs";
|
|
4
4
|
import { createContext, useCallback, useContext, useEffect, useRef } from "react";
|
|
5
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
6
|
|
|
@@ -937,7 +937,7 @@ function hostAppIsRegisteredOn(rn) {
|
|
|
937
937
|
}
|
|
938
938
|
}
|
|
939
939
|
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'.";
|
|
940
|
-
const SDK_VERSION = "3.2.
|
|
940
|
+
const SDK_VERSION = "3.2.11";
|
|
941
941
|
var LayersReactNative = class LayersReactNative {
|
|
942
942
|
core;
|
|
943
943
|
eagerPersistence;
|
|
@@ -1158,9 +1158,9 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1158
1158
|
...this.config.bootstrap != null && { bootstrap: this.config.bootstrap }
|
|
1159
1159
|
},
|
|
1160
1160
|
httpClient,
|
|
1161
|
-
persistence
|
|
1161
|
+
persistence,
|
|
1162
|
+
migration: migrationState
|
|
1162
1163
|
});
|
|
1163
|
-
this.core.applyMigrationState(migrationState);
|
|
1164
1164
|
this._runtimeGeneration = generation;
|
|
1165
1165
|
require_skan.setSkanCore(this.core);
|
|
1166
1166
|
if (this.appUserId) this.core.identify(this.appUserId);
|
|
@@ -1176,19 +1176,24 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1176
1176
|
await this.configureSkanFromRemoteConfig();
|
|
1177
1177
|
if (this.initAborted(generation)) return;
|
|
1178
1178
|
this.startConfigPolling();
|
|
1179
|
+
let clipboardEnabled = false;
|
|
1180
|
+
let fingerprintResolveEnabled = false;
|
|
1181
|
+
try {
|
|
1182
|
+
const configJson = this.core.getRemoteConfigJson?.();
|
|
1183
|
+
if (configJson) {
|
|
1184
|
+
const config = JSON.parse(configJson);
|
|
1185
|
+
clipboardEnabled = config?.clipboard_attribution_enabled === true;
|
|
1186
|
+
fingerprintResolveEnabled = config?.fingerprint_resolve_enabled === true;
|
|
1187
|
+
}
|
|
1188
|
+
} catch {}
|
|
1179
1189
|
let clipboardData = null;
|
|
1180
1190
|
try {
|
|
1181
1191
|
const { Platform } = require("react-native");
|
|
1182
|
-
if (Platform.OS === "ios")
|
|
1183
|
-
let clipboardEnabled = false;
|
|
1184
|
-
try {
|
|
1185
|
-
const configJson = this.core.getRemoteConfigJson?.();
|
|
1186
|
-
if (configJson) clipboardEnabled = JSON.parse(configJson)?.clipboard_attribution_enabled === true;
|
|
1187
|
-
} catch {}
|
|
1188
|
-
if (clipboardEnabled) clipboardData = await readClipboardAttribution();
|
|
1189
|
-
}
|
|
1192
|
+
if (Platform.OS === "ios" && clipboardEnabled) clipboardData = await readClipboardAttribution();
|
|
1190
1193
|
} catch {}
|
|
1191
1194
|
if (this.initAborted(generation)) return;
|
|
1195
|
+
await this.emitInstallReferrerEvent();
|
|
1196
|
+
if (this.initAborted(generation)) return;
|
|
1192
1197
|
if (this.config.autoTrackAppOpen !== false) {
|
|
1193
1198
|
const appOpenProps = {};
|
|
1194
1199
|
let isFirstLaunchByFlag = true;
|
|
@@ -1215,7 +1220,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1215
1220
|
const isFirstLaunch = await shouldTreatAsNewInstall(isFirstLaunchByFlag, this._hadPriorSdkState, this.enableDebug);
|
|
1216
1221
|
appOpenProps.is_first_launch = isFirstLaunch;
|
|
1217
1222
|
let hasAttribution = this._attributionFbclid != null || this._attributionGclid != null || this._attributionTtclid != null || this._attributionMsclkid != null;
|
|
1218
|
-
if (isFirstLaunch && !hasAttribution) try {
|
|
1223
|
+
if (fingerprintResolveEnabled && isFirstLaunch && !hasAttribution) try {
|
|
1219
1224
|
await this.resolveClickFromFingerprint();
|
|
1220
1225
|
} catch {}
|
|
1221
1226
|
if (clipboardData) {
|
|
@@ -1743,8 +1748,19 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1743
1748
|
* (sideload, Amazon Appstore, testing).
|
|
1744
1749
|
*
|
|
1745
1750
|
* Best-effort: all errors are swallowed — this must never block app_open.
|
|
1751
|
+
*
|
|
1752
|
+
* Two gates, both required. The caller checks the `fingerprint_resolve_enabled`
|
|
1753
|
+
* remote-config switch; this method checks the core's delivery policy via
|
|
1754
|
+
* `shouldAttemptSideRequest()`, so a device that denied analytics consent, is
|
|
1755
|
+
* sending DNT, is inside a server Retry-After window, or is behind an open
|
|
1756
|
+
* circuit breaker sends no fingerprint. The gate lives HERE, not only at the
|
|
1757
|
+
* call site, so a future caller inherits it.
|
|
1746
1758
|
*/
|
|
1747
1759
|
async resolveClickFromFingerprint() {
|
|
1760
|
+
if (!this.core.shouldAttemptSideRequest()) {
|
|
1761
|
+
if (this.enableDebug) console.log("[Layers] /clicks/resolve skipped — core delivery gate closed");
|
|
1762
|
+
return;
|
|
1763
|
+
}
|
|
1748
1764
|
const baseUrl = (this.config.baseUrl ?? "https://in.layers.com").replace(/\/$/, "");
|
|
1749
1765
|
const deviceContext = this.core.getDeviceContext();
|
|
1750
1766
|
let platform;
|
|
@@ -2112,17 +2128,61 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2112
2128
|
const token = await getAdServicesToken();
|
|
2113
2129
|
if (token) this._adServicesToken = token;
|
|
2114
2130
|
} catch {}
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
}
|
|
2125
|
-
}
|
|
2131
|
+
} catch {}
|
|
2132
|
+
try {
|
|
2133
|
+
const referrer = await this.collectInstallReferrer();
|
|
2134
|
+
if (referrer) {
|
|
2135
|
+
this._installReferrer = referrer;
|
|
2136
|
+
const parsed = parseInstallReferrerUrl(referrer.referrerUrl);
|
|
2137
|
+
this._installReferrerParams = Object.keys(parsed).length > 0 ? parsed : null;
|
|
2138
|
+
if (parsed.fbclid || parsed.gclid || parsed.ttclid || parsed.msclkid) try {
|
|
2139
|
+
await this.setAttributionData(this._attributionDeeplinkId, parsed.gclid ?? this._attributionGclid, parsed.fbclid ?? this._attributionFbclid, parsed.ttclid ?? this._attributionTtclid, parsed.msclkid ?? this._attributionMsclkid);
|
|
2140
|
+
} catch {}
|
|
2141
|
+
}
|
|
2142
|
+
} catch {}
|
|
2143
|
+
}
|
|
2144
|
+
/**
|
|
2145
|
+
* Read the Google Play install referrer.
|
|
2146
|
+
*
|
|
2147
|
+
* A method rather than a direct call to `getInstallReferrer()` so tests can
|
|
2148
|
+
* drive the Android branch: the SDK reaches React Native through a real CJS
|
|
2149
|
+
* `require('react-native')`, which no module mock intercepts — that is why
|
|
2150
|
+
* this path had no test coverage until now. Same seam
|
|
2151
|
+
* `requireReactNative()` provides for the AppState listener.
|
|
2152
|
+
*/
|
|
2153
|
+
collectInstallReferrer() {
|
|
2154
|
+
return getInstallReferrer();
|
|
2155
|
+
}
|
|
2156
|
+
/**
|
|
2157
|
+
* Emit the canonical `install_referrer` event (Android only).
|
|
2158
|
+
*
|
|
2159
|
+
* Wire parity with Kotlin (`InstallReferrerTracker`) and Unity
|
|
2160
|
+
* (`AndroidModule.GetInstallReferrer`): one dedicated event carrying the raw
|
|
2161
|
+
* referrer under `referrer`, the ReferrerDetails timestamps/version/instant
|
|
2162
|
+
* flag, and every parsed attribution param — pinned by
|
|
2163
|
+
* `schema/fixtures/install-referrer-event.json`.
|
|
2164
|
+
*
|
|
2165
|
+
* Emitted at most once per install (see `installReferrerTrackedKey`), before
|
|
2166
|
+
* `app_install` / `app_open`, so the attribution signal reaches the server
|
|
2167
|
+
* ahead of the events it explains.
|
|
2168
|
+
*
|
|
2169
|
+
* The click-ID hand-off to `setAttributionData` that Kotlin performs after
|
|
2170
|
+
* emitting already happens in `initializeDeviceInfo`, which must run before
|
|
2171
|
+
* `restoreAttributionData`'s values are consumed by any event.
|
|
2172
|
+
*/
|
|
2173
|
+
async emitInstallReferrerEvent() {
|
|
2174
|
+
const referrer = this._installReferrer;
|
|
2175
|
+
if (!referrer?.referrerUrl) return;
|
|
2176
|
+
let AsyncStorage = null;
|
|
2177
|
+
try {
|
|
2178
|
+
AsyncStorage = await loadAsyncStorage();
|
|
2179
|
+
if (AsyncStorage) {
|
|
2180
|
+
if (await AsyncStorage.getItem(installReferrerTrackedKey(this.config.appId)) === "true") return;
|
|
2181
|
+
}
|
|
2182
|
+
} catch {}
|
|
2183
|
+
this.track("install_referrer", buildInstallReferrerProperties(referrer));
|
|
2184
|
+
try {
|
|
2185
|
+
if (AsyncStorage) await AsyncStorage.setItem(installReferrerTrackedKey(this.config.appId), "true");
|
|
2126
2186
|
} catch {}
|
|
2127
2187
|
}
|
|
2128
2188
|
/**
|
|
@@ -2420,6 +2480,21 @@ function firstLaunchTrackedKey(appId) {
|
|
|
2420
2480
|
return `@layers/first_launch_tracked_${appId}`;
|
|
2421
2481
|
}
|
|
2422
2482
|
/**
|
|
2483
|
+
* Once-only guard for the `install_referrer` event, scoped by `appId` like the
|
|
2484
|
+
* first-launch flag above.
|
|
2485
|
+
*
|
|
2486
|
+
* Kotlin and Unity persist the equivalent flag in SharedPreferences
|
|
2487
|
+
* (`layers_referrer_collected`) and skip the whole fetch once set, because the
|
|
2488
|
+
* Play referrer describes the install and is the same string on every launch.
|
|
2489
|
+
* The React Native native module has no such guard — it re-fetches every init —
|
|
2490
|
+
* so the guard lives here, on the emit. Without it the SDK would post an
|
|
2491
|
+
* `install_referrer` event on every single app launch for the life of the
|
|
2492
|
+
* install.
|
|
2493
|
+
*/
|
|
2494
|
+
function installReferrerTrackedKey(appId) {
|
|
2495
|
+
return `@layers/install_referrer_tracked_${appId}`;
|
|
2496
|
+
}
|
|
2497
|
+
/**
|
|
2423
2498
|
* Last-known app_version persisted across launches. Used to detect
|
|
2424
2499
|
* `$app_update` (version increment) vs. `$first_open` (no prior value).
|
|
2425
2500
|
*/
|
|
@@ -2694,6 +2769,34 @@ function parseInstallReferrerUrl(referrer) {
|
|
|
2694
2769
|
return out;
|
|
2695
2770
|
}
|
|
2696
2771
|
/**
|
|
2772
|
+
* Build the canonical `install_referrer` event properties.
|
|
2773
|
+
*
|
|
2774
|
+
* This is the same shape Kotlin's `InstallReferrerTracker.buildReferrerProperties`
|
|
2775
|
+
* and Unity's `InstallReferrerResult.ToEventProperties` produce: seven base
|
|
2776
|
+
* fields from `ReferrerDetails`, then every recognized attribution param parsed
|
|
2777
|
+
* out of the raw referrer merged on top.
|
|
2778
|
+
*
|
|
2779
|
+
* All seven base fields are always present, with the same defaults the Android
|
|
2780
|
+
* API hands back when a value is absent (`0`, `""`, `false`) — an SDK that
|
|
2781
|
+
* omitted a key on one install and included it on the next would give the
|
|
2782
|
+
* server two shapes for one event, which is the drift this unification exists
|
|
2783
|
+
* to end. `schema/fixtures/install-referrer-event.json` pins it, and the Kotlin
|
|
2784
|
+
* contract test asserts against the same file.
|
|
2785
|
+
*/
|
|
2786
|
+
function buildInstallReferrerProperties(referrer) {
|
|
2787
|
+
const props = {
|
|
2788
|
+
referrer: referrer.referrerUrl,
|
|
2789
|
+
referrer_click_timestamp: referrer.referrerClickTimestamp ?? 0,
|
|
2790
|
+
install_begin_timestamp: referrer.installBeginTimestamp ?? 0,
|
|
2791
|
+
referrer_click_timestamp_server: referrer.referrerClickTimestampServer ?? 0,
|
|
2792
|
+
install_begin_timestamp_server: referrer.installBeginTimestampServer ?? 0,
|
|
2793
|
+
install_version: referrer.installVersion ?? "",
|
|
2794
|
+
google_play_instant: referrer.googlePlayInstant ?? false
|
|
2795
|
+
};
|
|
2796
|
+
Object.assign(props, parseInstallReferrerUrl(referrer.referrerUrl));
|
|
2797
|
+
return props;
|
|
2798
|
+
}
|
|
2799
|
+
/**
|
|
2697
2800
|
* Fetch the Google Play install referrer on Android via NativeModules.
|
|
2698
2801
|
* Requires the `com.android.installreferrer` library on the native side.
|
|
2699
2802
|
* Returns null on iOS or when the native module is not available.
|
|
@@ -2849,6 +2952,12 @@ Object.defineProperty(exports, 'addToWishlistEvent', {
|
|
|
2849
2952
|
return addToWishlistEvent;
|
|
2850
2953
|
}
|
|
2851
2954
|
});
|
|
2955
|
+
Object.defineProperty(exports, 'buildInstallReferrerProperties', {
|
|
2956
|
+
enumerable: true,
|
|
2957
|
+
get: function () {
|
|
2958
|
+
return buildInstallReferrerProperties;
|
|
2959
|
+
}
|
|
2960
|
+
});
|
|
2852
2961
|
Object.defineProperty(exports, 'connectRevenueCat', {
|
|
2853
2962
|
enumerable: true,
|
|
2854
2963
|
get: function () {
|
|
@@ -936,7 +936,7 @@ function hostAppIsRegisteredOn(rn) {
|
|
|
936
936
|
}
|
|
937
937
|
}
|
|
938
938
|
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.2.
|
|
939
|
+
const SDK_VERSION = "3.2.11";
|
|
940
940
|
var LayersReactNative = class LayersReactNative {
|
|
941
941
|
core;
|
|
942
942
|
eagerPersistence;
|
|
@@ -1157,9 +1157,9 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1157
1157
|
...this.config.bootstrap != null && { bootstrap: this.config.bootstrap }
|
|
1158
1158
|
},
|
|
1159
1159
|
httpClient,
|
|
1160
|
-
persistence
|
|
1160
|
+
persistence,
|
|
1161
|
+
migration: migrationState
|
|
1161
1162
|
});
|
|
1162
|
-
this.core.applyMigrationState(migrationState);
|
|
1163
1163
|
this._runtimeGeneration = generation;
|
|
1164
1164
|
setSkanCore(this.core);
|
|
1165
1165
|
if (this.appUserId) this.core.identify(this.appUserId);
|
|
@@ -1175,19 +1175,24 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1175
1175
|
await this.configureSkanFromRemoteConfig();
|
|
1176
1176
|
if (this.initAborted(generation)) return;
|
|
1177
1177
|
this.startConfigPolling();
|
|
1178
|
+
let clipboardEnabled = false;
|
|
1179
|
+
let fingerprintResolveEnabled = false;
|
|
1180
|
+
try {
|
|
1181
|
+
const configJson = this.core.getRemoteConfigJson?.();
|
|
1182
|
+
if (configJson) {
|
|
1183
|
+
const config = JSON.parse(configJson);
|
|
1184
|
+
clipboardEnabled = config?.clipboard_attribution_enabled === true;
|
|
1185
|
+
fingerprintResolveEnabled = config?.fingerprint_resolve_enabled === true;
|
|
1186
|
+
}
|
|
1187
|
+
} catch {}
|
|
1178
1188
|
let clipboardData = null;
|
|
1179
1189
|
try {
|
|
1180
1190
|
const { Platform } = __require("react-native");
|
|
1181
|
-
if (Platform.OS === "ios")
|
|
1182
|
-
let clipboardEnabled = false;
|
|
1183
|
-
try {
|
|
1184
|
-
const configJson = this.core.getRemoteConfigJson?.();
|
|
1185
|
-
if (configJson) clipboardEnabled = JSON.parse(configJson)?.clipboard_attribution_enabled === true;
|
|
1186
|
-
} catch {}
|
|
1187
|
-
if (clipboardEnabled) clipboardData = await readClipboardAttribution();
|
|
1188
|
-
}
|
|
1191
|
+
if (Platform.OS === "ios" && clipboardEnabled) clipboardData = await readClipboardAttribution();
|
|
1189
1192
|
} catch {}
|
|
1190
1193
|
if (this.initAborted(generation)) return;
|
|
1194
|
+
await this.emitInstallReferrerEvent();
|
|
1195
|
+
if (this.initAborted(generation)) return;
|
|
1191
1196
|
if (this.config.autoTrackAppOpen !== false) {
|
|
1192
1197
|
const appOpenProps = {};
|
|
1193
1198
|
let isFirstLaunchByFlag = true;
|
|
@@ -1214,7 +1219,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1214
1219
|
const isFirstLaunch = await shouldTreatAsNewInstall(isFirstLaunchByFlag, this._hadPriorSdkState, this.enableDebug);
|
|
1215
1220
|
appOpenProps.is_first_launch = isFirstLaunch;
|
|
1216
1221
|
let hasAttribution = this._attributionFbclid != null || this._attributionGclid != null || this._attributionTtclid != null || this._attributionMsclkid != null;
|
|
1217
|
-
if (isFirstLaunch && !hasAttribution) try {
|
|
1222
|
+
if (fingerprintResolveEnabled && isFirstLaunch && !hasAttribution) try {
|
|
1218
1223
|
await this.resolveClickFromFingerprint();
|
|
1219
1224
|
} catch {}
|
|
1220
1225
|
if (clipboardData) {
|
|
@@ -1742,8 +1747,19 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1742
1747
|
* (sideload, Amazon Appstore, testing).
|
|
1743
1748
|
*
|
|
1744
1749
|
* Best-effort: all errors are swallowed — this must never block app_open.
|
|
1750
|
+
*
|
|
1751
|
+
* Two gates, both required. The caller checks the `fingerprint_resolve_enabled`
|
|
1752
|
+
* remote-config switch; this method checks the core's delivery policy via
|
|
1753
|
+
* `shouldAttemptSideRequest()`, so a device that denied analytics consent, is
|
|
1754
|
+
* sending DNT, is inside a server Retry-After window, or is behind an open
|
|
1755
|
+
* circuit breaker sends no fingerprint. The gate lives HERE, not only at the
|
|
1756
|
+
* call site, so a future caller inherits it.
|
|
1745
1757
|
*/
|
|
1746
1758
|
async resolveClickFromFingerprint() {
|
|
1759
|
+
if (!this.core.shouldAttemptSideRequest()) {
|
|
1760
|
+
if (this.enableDebug) console.log("[Layers] /clicks/resolve skipped — core delivery gate closed");
|
|
1761
|
+
return;
|
|
1762
|
+
}
|
|
1747
1763
|
const baseUrl = (this.config.baseUrl ?? "https://in.layers.com").replace(/\/$/, "");
|
|
1748
1764
|
const deviceContext = this.core.getDeviceContext();
|
|
1749
1765
|
let platform;
|
|
@@ -2111,17 +2127,61 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2111
2127
|
const token = await getAdServicesToken();
|
|
2112
2128
|
if (token) this._adServicesToken = token;
|
|
2113
2129
|
} catch {}
|
|
2114
|
-
|
|
2115
|
-
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
}
|
|
2124
|
-
}
|
|
2130
|
+
} catch {}
|
|
2131
|
+
try {
|
|
2132
|
+
const referrer = await this.collectInstallReferrer();
|
|
2133
|
+
if (referrer) {
|
|
2134
|
+
this._installReferrer = referrer;
|
|
2135
|
+
const parsed = parseInstallReferrerUrl(referrer.referrerUrl);
|
|
2136
|
+
this._installReferrerParams = Object.keys(parsed).length > 0 ? parsed : null;
|
|
2137
|
+
if (parsed.fbclid || parsed.gclid || parsed.ttclid || parsed.msclkid) try {
|
|
2138
|
+
await this.setAttributionData(this._attributionDeeplinkId, parsed.gclid ?? this._attributionGclid, parsed.fbclid ?? this._attributionFbclid, parsed.ttclid ?? this._attributionTtclid, parsed.msclkid ?? this._attributionMsclkid);
|
|
2139
|
+
} catch {}
|
|
2140
|
+
}
|
|
2141
|
+
} catch {}
|
|
2142
|
+
}
|
|
2143
|
+
/**
|
|
2144
|
+
* Read the Google Play install referrer.
|
|
2145
|
+
*
|
|
2146
|
+
* A method rather than a direct call to `getInstallReferrer()` so tests can
|
|
2147
|
+
* drive the Android branch: the SDK reaches React Native through a real CJS
|
|
2148
|
+
* `require('react-native')`, which no module mock intercepts — that is why
|
|
2149
|
+
* this path had no test coverage until now. Same seam
|
|
2150
|
+
* `requireReactNative()` provides for the AppState listener.
|
|
2151
|
+
*/
|
|
2152
|
+
collectInstallReferrer() {
|
|
2153
|
+
return getInstallReferrer();
|
|
2154
|
+
}
|
|
2155
|
+
/**
|
|
2156
|
+
* Emit the canonical `install_referrer` event (Android only).
|
|
2157
|
+
*
|
|
2158
|
+
* Wire parity with Kotlin (`InstallReferrerTracker`) and Unity
|
|
2159
|
+
* (`AndroidModule.GetInstallReferrer`): one dedicated event carrying the raw
|
|
2160
|
+
* referrer under `referrer`, the ReferrerDetails timestamps/version/instant
|
|
2161
|
+
* flag, and every parsed attribution param — pinned by
|
|
2162
|
+
* `schema/fixtures/install-referrer-event.json`.
|
|
2163
|
+
*
|
|
2164
|
+
* Emitted at most once per install (see `installReferrerTrackedKey`), before
|
|
2165
|
+
* `app_install` / `app_open`, so the attribution signal reaches the server
|
|
2166
|
+
* ahead of the events it explains.
|
|
2167
|
+
*
|
|
2168
|
+
* The click-ID hand-off to `setAttributionData` that Kotlin performs after
|
|
2169
|
+
* emitting already happens in `initializeDeviceInfo`, which must run before
|
|
2170
|
+
* `restoreAttributionData`'s values are consumed by any event.
|
|
2171
|
+
*/
|
|
2172
|
+
async emitInstallReferrerEvent() {
|
|
2173
|
+
const referrer = this._installReferrer;
|
|
2174
|
+
if (!referrer?.referrerUrl) return;
|
|
2175
|
+
let AsyncStorage = null;
|
|
2176
|
+
try {
|
|
2177
|
+
AsyncStorage = await loadAsyncStorage();
|
|
2178
|
+
if (AsyncStorage) {
|
|
2179
|
+
if (await AsyncStorage.getItem(installReferrerTrackedKey(this.config.appId)) === "true") return;
|
|
2180
|
+
}
|
|
2181
|
+
} catch {}
|
|
2182
|
+
this.track("install_referrer", buildInstallReferrerProperties(referrer));
|
|
2183
|
+
try {
|
|
2184
|
+
if (AsyncStorage) await AsyncStorage.setItem(installReferrerTrackedKey(this.config.appId), "true");
|
|
2125
2185
|
} catch {}
|
|
2126
2186
|
}
|
|
2127
2187
|
/**
|
|
@@ -2419,6 +2479,21 @@ function firstLaunchTrackedKey(appId) {
|
|
|
2419
2479
|
return `@layers/first_launch_tracked_${appId}`;
|
|
2420
2480
|
}
|
|
2421
2481
|
/**
|
|
2482
|
+
* Once-only guard for the `install_referrer` event, scoped by `appId` like the
|
|
2483
|
+
* first-launch flag above.
|
|
2484
|
+
*
|
|
2485
|
+
* Kotlin and Unity persist the equivalent flag in SharedPreferences
|
|
2486
|
+
* (`layers_referrer_collected`) and skip the whole fetch once set, because the
|
|
2487
|
+
* Play referrer describes the install and is the same string on every launch.
|
|
2488
|
+
* The React Native native module has no such guard — it re-fetches every init —
|
|
2489
|
+
* so the guard lives here, on the emit. Without it the SDK would post an
|
|
2490
|
+
* `install_referrer` event on every single app launch for the life of the
|
|
2491
|
+
* install.
|
|
2492
|
+
*/
|
|
2493
|
+
function installReferrerTrackedKey(appId) {
|
|
2494
|
+
return `@layers/install_referrer_tracked_${appId}`;
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2422
2497
|
* Last-known app_version persisted across launches. Used to detect
|
|
2423
2498
|
* `$app_update` (version increment) vs. `$first_open` (no prior value).
|
|
2424
2499
|
*/
|
|
@@ -2693,6 +2768,34 @@ function parseInstallReferrerUrl(referrer) {
|
|
|
2693
2768
|
return out;
|
|
2694
2769
|
}
|
|
2695
2770
|
/**
|
|
2771
|
+
* Build the canonical `install_referrer` event properties.
|
|
2772
|
+
*
|
|
2773
|
+
* This is the same shape Kotlin's `InstallReferrerTracker.buildReferrerProperties`
|
|
2774
|
+
* and Unity's `InstallReferrerResult.ToEventProperties` produce: seven base
|
|
2775
|
+
* fields from `ReferrerDetails`, then every recognized attribution param parsed
|
|
2776
|
+
* out of the raw referrer merged on top.
|
|
2777
|
+
*
|
|
2778
|
+
* All seven base fields are always present, with the same defaults the Android
|
|
2779
|
+
* API hands back when a value is absent (`0`, `""`, `false`) — an SDK that
|
|
2780
|
+
* omitted a key on one install and included it on the next would give the
|
|
2781
|
+
* server two shapes for one event, which is the drift this unification exists
|
|
2782
|
+
* to end. `schema/fixtures/install-referrer-event.json` pins it, and the Kotlin
|
|
2783
|
+
* contract test asserts against the same file.
|
|
2784
|
+
*/
|
|
2785
|
+
function buildInstallReferrerProperties(referrer) {
|
|
2786
|
+
const props = {
|
|
2787
|
+
referrer: referrer.referrerUrl,
|
|
2788
|
+
referrer_click_timestamp: referrer.referrerClickTimestamp ?? 0,
|
|
2789
|
+
install_begin_timestamp: referrer.installBeginTimestamp ?? 0,
|
|
2790
|
+
referrer_click_timestamp_server: referrer.referrerClickTimestampServer ?? 0,
|
|
2791
|
+
install_begin_timestamp_server: referrer.installBeginTimestampServer ?? 0,
|
|
2792
|
+
install_version: referrer.installVersion ?? "",
|
|
2793
|
+
google_play_instant: referrer.googlePlayInstant ?? false
|
|
2794
|
+
};
|
|
2795
|
+
Object.assign(props, parseInstallReferrerUrl(referrer.referrerUrl));
|
|
2796
|
+
return props;
|
|
2797
|
+
}
|
|
2798
|
+
/**
|
|
2696
2799
|
* Fetch the Google Play install referrer on Android via NativeModules.
|
|
2697
2800
|
* Requires the `com.android.installreferrer` library on the native side.
|
|
2698
2801
|
* Returns null on iOS or when the native module is not available.
|
|
@@ -2806,5 +2909,5 @@ function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchPa
|
|
|
2806
2909
|
}
|
|
2807
2910
|
|
|
2808
2911
|
//#endregion
|
|
2809
|
-
export {
|
|
2810
|
-
//# sourceMappingURL=src-
|
|
2912
|
+
export { addToCartEvent as $, createBackgroundFlushHandler as A, trackPurchase as B, useLayersExpoRouterTracking as C, useLayersNavigationTracking as D, resolveActiveRoute as E, syncRevenueCatAttributes as F, trackViewProduct as G, trackRefund as H, trackRevenueCatPurchase as I, superwallTrackPresentation as J, superwallOnEvent as K, trackAddToCart as L, connectRevenueCat as M, isRevenueCatConnected as N, BACKGROUND_FLUSH_MIN_INTERVAL_MINUTES as O, resetRevenueCatForTesting as P, StandardEvents as Q, trackBeginCheckout as R, shouldTreatAsNewInstall as S, createNavigationListener as T, trackRemoveFromCart as U, trackPurchaseFailed as V, trackSubscription as W, superwallTrackSkip as X, superwallTrackPurchase as Y, superwallUserAttributes as Z, getOrSetInstallId as _, buildBeginCheckoutEvent as a, purchaseEvent as at, readClipboardAttribution as b, buildRefundEvent as c, searchEvent as ct, buildViewItemEvent as d, startTrialEvent as dt, addToWishlistEvent as et, formatFbc as f, subscribeEvent as ft, getInstallReferrer as g, getGoogleAdvertisingId as h, viewItemEvent as ht, buildAddToCartEvent as i, loginEvent as it, registerExpoBackgroundFlush as j, BACKGROUND_FLUSH_TASK_NAME as k, buildStartTrialEvent as l, shareEvent as lt, getFirstInstallTime as m, viewContentEvent as mt, LayersEvent as n, levelCompleteEvent as nt, buildInstallReferrerProperties as o, registerEvent as ot, getAdServicesToken as p, tutorialCompleteEvent as pt, superwallTrackDismiss as q, LayersReactNative as r, levelStartEvent as rt, buildPurchaseEvent as s, screenViewEvent as st, LayersError$1 as t, initiateCheckoutEvent as tt, buildSubscribeEvent as u, signUpEvent as ut, parseDeepLink as v, SurveysModule as w, setupDeepLinkListener as x, parseInstallReferrerUrl as y, trackOrder as z };
|
|
2913
|
+
//# sourceMappingURL=src-DWe1Tv-R.mjs.map
|