@layers/react-native 3.3.2 → 3.3.3
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/dist/debug-overlay.d.mts +1 -1
- package/dist/debug-overlay.d.ts +1 -1
- package/dist/{index-CQN7IdfN.d.mts → index-C3_cxjek.d.mts} +42 -5
- package/dist/index-C3_cxjek.d.mts.map +1 -0
- package/dist/{index-BJbKdiVm.d.ts → index-rqvTp0t7.d.ts} +42 -5
- package/dist/index-rqvTp0t7.d.ts.map +1 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- 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-HL7K6lv5.mjs → src-BhzpYUDb.mjs} +111 -18
- package/dist/src-BhzpYUDb.mjs.map +1 -0
- package/dist/{src-CExoKDAB.js → src-CosCfQaj.js} +110 -17
- package/package.json +2 -2
- package/dist/index-BJbKdiVm.d.ts.map +0 -1
- package/dist/index-CQN7IdfN.d.mts.map +0 -1
- package/dist/src-HL7K6lv5.mjs.map +0 -1
|
@@ -711,8 +711,9 @@ function connectRevenueCat(config, purchases) {
|
|
|
711
711
|
purchases.addCustomerInfoUpdateListener((info) => {
|
|
712
712
|
handleCustomerInfoUpdate(config, info, false);
|
|
713
713
|
});
|
|
714
|
-
purchases.getCustomerInfo().then((
|
|
715
|
-
|
|
714
|
+
purchases.getCustomerInfo().then((result) => {
|
|
715
|
+
const customerInfo = unwrapCustomerInfo(result);
|
|
716
|
+
if (customerInfo) handleCustomerInfoUpdate(config, customerInfo, true);
|
|
716
717
|
}).catch(() => {});
|
|
717
718
|
_isConnected = true;
|
|
718
719
|
} catch {}
|
|
@@ -772,6 +773,18 @@ function resetRevenueCatForTesting() {
|
|
|
772
773
|
function isRevenueCatConnected() {
|
|
773
774
|
return _isConnected;
|
|
774
775
|
}
|
|
776
|
+
/**
|
|
777
|
+
* Accept both shapes `getCustomerInfo()` can resolve to: the `CustomerInfo`
|
|
778
|
+
* object `react-native-purchases` actually returns, and a `{ customerInfo }`
|
|
779
|
+
* wrapper. Destructuring `{ customerInfo }` from the real return read
|
|
780
|
+
* `undefined`, so the first subscriber sync never ran.
|
|
781
|
+
*/
|
|
782
|
+
function unwrapCustomerInfo(result) {
|
|
783
|
+
if (!result || typeof result !== "object") return null;
|
|
784
|
+
const wrapped = result.customerInfo;
|
|
785
|
+
if (wrapped && typeof wrapped === "object") return wrapped;
|
|
786
|
+
return result;
|
|
787
|
+
}
|
|
775
788
|
function handleCustomerInfoUpdate(config, info, isInitialLoad) {
|
|
776
789
|
try {
|
|
777
790
|
const currentSubs = new Set(Array.isArray(info.activeSubscriptions) ? info.activeSubscriptions : []);
|
|
@@ -1109,7 +1122,7 @@ function hostAppIsRegisteredOn(rn) {
|
|
|
1109
1122
|
}
|
|
1110
1123
|
}
|
|
1111
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'.";
|
|
1112
|
-
const SDK_VERSION = "3.3.
|
|
1125
|
+
const SDK_VERSION = "3.3.3";
|
|
1113
1126
|
var LayersReactNative = class LayersReactNative {
|
|
1114
1127
|
core;
|
|
1115
1128
|
eagerPersistence;
|
|
@@ -1137,8 +1150,10 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1137
1150
|
static CONFIG_POLL_INTERVAL_MS = 3e5;
|
|
1138
1151
|
_adServicesToken = null;
|
|
1139
1152
|
_installReferrer = null;
|
|
1153
|
+
_gaid = null;
|
|
1140
1154
|
_installReferrerParams = null;
|
|
1141
1155
|
_hadPriorSdkState = false;
|
|
1156
|
+
_hadPriorAppIdentity = false;
|
|
1142
1157
|
_attributionDeeplinkId = null;
|
|
1143
1158
|
_attributionGclid = null;
|
|
1144
1159
|
_attributionFbclid = null;
|
|
@@ -1301,8 +1316,15 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1301
1316
|
const initStartTime = Date.now();
|
|
1302
1317
|
if (typeof WebAssembly !== "undefined") await initWasm();
|
|
1303
1318
|
if (this.initAborted(generation)) return;
|
|
1319
|
+
this._hadPriorAppIdentity = false;
|
|
1304
1320
|
try {
|
|
1305
1321
|
const { backend: persistence, settle: persistenceSettle } = await createAsyncStoragePersistence(this.config.appId);
|
|
1322
|
+
try {
|
|
1323
|
+
const record = persistence.read("identity_state");
|
|
1324
|
+
this._hadPriorAppIdentity = record != null && record.length > 0;
|
|
1325
|
+
} catch {
|
|
1326
|
+
this._hadPriorAppIdentity = false;
|
|
1327
|
+
}
|
|
1306
1328
|
if (this.initAborted(generation)) return;
|
|
1307
1329
|
this.persistenceSettle = persistenceSettle;
|
|
1308
1330
|
const httpClient = new FetchHttpClient();
|
|
@@ -1372,6 +1394,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1372
1394
|
if (this.config.autoTrackAppOpen !== false) {
|
|
1373
1395
|
const appOpenProps = {};
|
|
1374
1396
|
let isFirstLaunchByFlag = true;
|
|
1397
|
+
let priorLaunchDecided = false;
|
|
1375
1398
|
try {
|
|
1376
1399
|
const AsyncStorage = await loadAsyncStorage();
|
|
1377
1400
|
if (AsyncStorage) {
|
|
@@ -1386,14 +1409,16 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1386
1409
|
}
|
|
1387
1410
|
}
|
|
1388
1411
|
if (flag === "true") isFirstLaunchByFlag = false;
|
|
1412
|
+
if (isFirstLaunchByFlag && this._hadPriorAppIdentity) priorLaunchDecided = await AsyncStorage.getItem(LAST_APP_VERSION_KEY) !== null;
|
|
1389
1413
|
if (adoptLegacy) try {
|
|
1390
1414
|
await AsyncStorage.setItem(scopedKey, "true");
|
|
1391
1415
|
await AsyncStorage.removeItem(FIRST_LAUNCH_TRACKED_KEY_LEGACY);
|
|
1392
1416
|
} catch {}
|
|
1393
1417
|
}
|
|
1394
1418
|
} catch {}
|
|
1395
|
-
const isFirstLaunch = await shouldTreatAsNewInstall(isFirstLaunchByFlag, this._hadPriorSdkState, this.enableDebug);
|
|
1419
|
+
const isFirstLaunch = await shouldTreatAsNewInstall(isFirstLaunchByFlag, this._hadPriorSdkState, this.enableDebug, () => this.readFirstInstallTime(), priorLaunchDecided);
|
|
1396
1420
|
appOpenProps.is_first_launch = isFirstLaunch;
|
|
1421
|
+
if (isFirstLaunchByFlag && !isFirstLaunch) await this.persistFirstLaunchHandled();
|
|
1397
1422
|
let hasAttribution = this._attributionFbclid != null || this._attributionGclid != null || this._attributionTtclid != null || this._attributionMsclkid != null;
|
|
1398
1423
|
if (fingerprintResolveEnabled && isFirstLaunch && !hasAttribution) try {
|
|
1399
1424
|
await this.resolveClickFromFingerprint();
|
|
@@ -1414,10 +1439,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1414
1439
|
if (this.initAborted(generation)) return;
|
|
1415
1440
|
if (isFirstLaunch) this.track("app_install", appOpenProps);
|
|
1416
1441
|
this.track("app_open", appOpenProps);
|
|
1417
|
-
if (isFirstLaunch)
|
|
1418
|
-
const AsyncStorage = await loadAsyncStorage();
|
|
1419
|
-
if (AsyncStorage) await AsyncStorage.setItem(firstLaunchTrackedKey(this.config.appId), "true");
|
|
1420
|
-
} catch {}
|
|
1442
|
+
if (isFirstLaunch) await this.persistFirstLaunchHandled();
|
|
1421
1443
|
if (this.config.autoTrackAppUpdate !== false) try {
|
|
1422
1444
|
const currentVersion = this.core.getDeviceContext().appVersion ?? appOpenProps.app_version;
|
|
1423
1445
|
if (currentVersion && typeof currentVersion === "string") {
|
|
@@ -1508,6 +1530,47 @@ var LayersReactNative = class LayersReactNative {
|
|
|
1508
1530
|
}
|
|
1509
1531
|
async setConsent(consent) {
|
|
1510
1532
|
this.core.setConsent(consent);
|
|
1533
|
+
this.applyGaidConsent();
|
|
1534
|
+
}
|
|
1535
|
+
/**
|
|
1536
|
+
* Whether the app has explicitly denied advertising consent
|
|
1537
|
+
* (`adStorage: false`, or the legacy `advertising: false`). Unset means
|
|
1538
|
+
* allowed, the same default as the engine's ad gate and the Kotlin SDK.
|
|
1539
|
+
*/
|
|
1540
|
+
advertisingConsentDenied() {
|
|
1541
|
+
try {
|
|
1542
|
+
const consent = this.core.getConsentState();
|
|
1543
|
+
return (consent.adStorage ?? consent.advertising) === false;
|
|
1544
|
+
} catch {
|
|
1545
|
+
return false;
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
/**
|
|
1549
|
+
* Keep the Google Advertising ID on the device context unless the app has
|
|
1550
|
+
* explicitly denied advertising consent, and take it off when it has.
|
|
1551
|
+
*
|
|
1552
|
+
* The GAID is sent by default, as mobile measurement partners and the
|
|
1553
|
+
* Kotlin SDK do. It honours two opt-outs: the user's Limit Ad Tracking
|
|
1554
|
+
* setting (applied where the GAID is read) and the app's consent API.
|
|
1555
|
+
* Revoking removes it from later events and re-granting restores it. No
|
|
1556
|
+
* `att_status` is set on Android: that field carries Apple's ATT answer.
|
|
1557
|
+
*/
|
|
1558
|
+
applyGaidConsent() {
|
|
1559
|
+
const gaid = this._gaid;
|
|
1560
|
+
if (!gaid) return;
|
|
1561
|
+
try {
|
|
1562
|
+
const context = this.core.getDeviceContext();
|
|
1563
|
+
const granted = !this.advertisingConsentDenied();
|
|
1564
|
+
if (granted && context.idfa !== gaid) this.core.setDeviceContext({
|
|
1565
|
+
...context,
|
|
1566
|
+
idfa: gaid
|
|
1567
|
+
});
|
|
1568
|
+
else if (!granted && context.idfa === gaid) {
|
|
1569
|
+
const next = { ...context };
|
|
1570
|
+
delete next.idfa;
|
|
1571
|
+
this.core.setDeviceContext(next);
|
|
1572
|
+
}
|
|
1573
|
+
} catch {}
|
|
1511
1574
|
}
|
|
1512
1575
|
/** Evaluate a feature flag. Emits `$feature_flag_called` (deduped per session). */
|
|
1513
1576
|
getFeatureFlag(flagKey) {
|
|
@@ -2276,7 +2339,31 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2276
2339
|
}
|
|
2277
2340
|
});
|
|
2278
2341
|
}
|
|
2342
|
+
/**
|
|
2343
|
+
* Record that this install's first launch has been decided, whichever way.
|
|
2344
|
+
* Best-effort: without AsyncStorage nothing persists anyway.
|
|
2345
|
+
*/
|
|
2346
|
+
async persistFirstLaunchHandled() {
|
|
2347
|
+
try {
|
|
2348
|
+
const AsyncStorage = await loadAsyncStorage();
|
|
2349
|
+
if (AsyncStorage) await AsyncStorage.setItem(firstLaunchTrackedKey(this.config.appId), "true");
|
|
2350
|
+
} catch {}
|
|
2351
|
+
}
|
|
2352
|
+
/**
|
|
2353
|
+
* The package's first install time, for the 24-hour install gate. A method
|
|
2354
|
+
* so tests can drive the gate: the native module sits behind a real CJS
|
|
2355
|
+
* `require('react-native')` (same seam as `collectInstallReferrer`).
|
|
2356
|
+
*/
|
|
2357
|
+
readFirstInstallTime() {
|
|
2358
|
+
return getFirstInstallTime();
|
|
2359
|
+
}
|
|
2279
2360
|
async initializeDeviceInfo() {
|
|
2361
|
+
try {
|
|
2362
|
+
const gaid = await this.collectGoogleAdvertisingId();
|
|
2363
|
+
this._gaid = gaid && !gaid.isLimitAdTrackingEnabled ? gaid.id : null;
|
|
2364
|
+
} catch {
|
|
2365
|
+
this._gaid = null;
|
|
2366
|
+
}
|
|
2280
2367
|
try {
|
|
2281
2368
|
const { Platform, Dimensions, NativeModules } = __require("react-native");
|
|
2282
2369
|
const window = Dimensions.get("window");
|
|
@@ -2310,11 +2397,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2310
2397
|
const idfv = await getVendorId();
|
|
2311
2398
|
if (idfv) context.idfv = idfv;
|
|
2312
2399
|
} catch {}
|
|
2313
|
-
if (
|
|
2314
|
-
const gaid = await getGoogleAdvertisingId();
|
|
2315
|
-
if (gaid) context.idfa = gaid.id;
|
|
2316
|
-
if (gaid && gaid.isLimitAdTrackingEnabled != null) context.attStatus = gaid.isLimitAdTrackingEnabled ? "denied" : "authorized";
|
|
2317
|
-
} catch {}
|
|
2400
|
+
if (this._gaid && !this.advertisingConsentDenied()) context.idfa = this._gaid;
|
|
2318
2401
|
try {
|
|
2319
2402
|
const AsyncStorage = await loadAsyncStorage();
|
|
2320
2403
|
if (AsyncStorage) this._hadPriorSdkState = await AsyncStorage.getItem(INSTALL_ID_KEY) != null;
|
|
@@ -2339,6 +2422,7 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2339
2422
|
const installId = await getOrSetInstallId();
|
|
2340
2423
|
if (installId) context.installId = installId;
|
|
2341
2424
|
} catch {}
|
|
2425
|
+
if (this._gaid && !this.advertisingConsentDenied()) context.idfa = this._gaid;
|
|
2342
2426
|
this.core.setDeviceContext(context);
|
|
2343
2427
|
}
|
|
2344
2428
|
this._installReferrerParams = null;
|
|
@@ -2373,6 +2457,10 @@ var LayersReactNative = class LayersReactNative {
|
|
|
2373
2457
|
collectInstallReferrer() {
|
|
2374
2458
|
return getInstallReferrer();
|
|
2375
2459
|
}
|
|
2460
|
+
/** Read the Google Advertising ID. A method for the same test seam. */
|
|
2461
|
+
collectGoogleAdvertisingId() {
|
|
2462
|
+
return getGoogleAdvertisingId();
|
|
2463
|
+
}
|
|
2376
2464
|
/**
|
|
2377
2465
|
* Emit the canonical `install_referrer` event (Android only).
|
|
2378
2466
|
*
|
|
@@ -2807,8 +2895,11 @@ async function getFirstInstallTime() {
|
|
|
2807
2895
|
* 1. If `isFirstLaunchByFlag` is `false` (flag already tracked), return `false`.
|
|
2808
2896
|
* 2. If the SDK had prior state (`install_id` already existed in
|
|
2809
2897
|
* AsyncStorage), trust the flag — this is a returning user whose
|
|
2810
|
-
* first-launch flag was not yet written (e.g.
|
|
2811
|
-
*
|
|
2898
|
+
* first-launch flag was not yet written (e.g. a first launch that died
|
|
2899
|
+
* before the flag write). Return `true` — UNLESS `priorLaunchDecided`
|
|
2900
|
+
* says an earlier launch already reached the decision and did not record
|
|
2901
|
+
* it (a launch on 3.3.2 or earlier that suppressed `app_install`, see the
|
|
2902
|
+
* caller). Then return `false`.
|
|
2812
2903
|
* 3. If the SDK had NO prior state AND the app was installed more than
|
|
2813
2904
|
* 24 hours ago, this is an existing app getting the SDK for the first
|
|
2814
2905
|
* time — suppress `is_first_launch`. Return `false`.
|
|
@@ -2819,10 +2910,12 @@ async function getFirstInstallTime() {
|
|
|
2819
2910
|
* @param isFirstLaunchByFlag Whether the first_launch flag has NOT been set yet (true = not yet tracked).
|
|
2820
2911
|
* @param hadPriorSdkState Whether `install_id` already existed before init.
|
|
2821
2912
|
* @param enableDebug Whether to log debug info.
|
|
2913
|
+
* @param priorLaunchDecided Whether an earlier launch already made the
|
|
2914
|
+
* install decision without writing the flag.
|
|
2822
2915
|
*/
|
|
2823
|
-
async function shouldTreatAsNewInstall(isFirstLaunchByFlag, hadPriorSdkState, enableDebug = false, _getInstallTime = getFirstInstallTime) {
|
|
2916
|
+
async function shouldTreatAsNewInstall(isFirstLaunchByFlag, hadPriorSdkState, enableDebug = false, _getInstallTime = getFirstInstallTime, priorLaunchDecided = false) {
|
|
2824
2917
|
if (!isFirstLaunchByFlag) return false;
|
|
2825
|
-
if (hadPriorSdkState) return
|
|
2918
|
+
if (hadPriorSdkState) return !priorLaunchDecided;
|
|
2826
2919
|
try {
|
|
2827
2920
|
const firstInstallTime = await _getInstallTime();
|
|
2828
2921
|
if (firstInstallTime != null) {
|
|
@@ -3155,4 +3248,4 @@ function useLayersExpoRouterTracking(sdkInstance, usePathname, useGlobalSearchPa
|
|
|
3155
3248
|
|
|
3156
3249
|
//#endregion
|
|
3157
3250
|
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-
|
|
3251
|
+
//# sourceMappingURL=src-BhzpYUDb.mjs.map
|