@layers/react-native 2.2.0 → 3.1.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.
Files changed (42) hide show
  1. package/android/build.gradle +62 -0
  2. package/android/src/main/AndroidManifest.xml +2 -0
  3. package/android/src/main/java/io/layers/sdk/reactnative/LayersAdvertisingIdModule.java +70 -0
  4. package/android/src/main/java/io/layers/sdk/reactnative/LayersDeviceInfoModule.java +54 -0
  5. package/android/src/main/java/io/layers/sdk/reactnative/LayersInstallReferrerModule.java +116 -0
  6. package/android/src/main/java/io/layers/sdk/reactnative/LayersReactNativePackage.java +36 -0
  7. package/dist/att-BDPyE-Gs.d.mts.map +1 -1
  8. package/dist/debug-overlay.d.mts +3 -3
  9. package/dist/debug-overlay.d.mts.map +1 -1
  10. package/dist/debug-overlay.d.ts +3 -3
  11. package/dist/debug-overlay.d.ts.map +1 -1
  12. package/dist/debug-overlay.js +18 -18
  13. package/dist/debug-overlay.mjs +18 -18
  14. package/dist/debug-overlay.mjs.map +1 -1
  15. package/dist/{index-BlYXUV-h.d.mts → index-BqcbQZEP.d.mts} +323 -47
  16. package/dist/index-BqcbQZEP.d.mts.map +1 -0
  17. package/dist/{index-BaaQSCs5.d.ts → index-fU6euPnq.d.ts} +323 -47
  18. package/dist/index-fU6euPnq.d.ts.map +1 -0
  19. package/dist/index.d.mts +2 -2
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.js +54 -1
  22. package/dist/index.mjs +2 -2
  23. package/dist/react.d.mts +1 -1
  24. package/dist/react.d.ts +1 -1
  25. package/dist/react.js +1 -1
  26. package/dist/react.mjs +1 -1
  27. package/dist/{src-8aNaNJz3.mjs → src-BNoj1E-e.mjs} +677 -90
  28. package/dist/src-BNoj1E-e.mjs.map +1 -0
  29. package/dist/{src-CP6aZ_iI.js → src-ym3bM4JE.js} +704 -87
  30. package/ios/LayersAdServices.m +8 -0
  31. package/ios/LayersAdServices.swift +41 -0
  32. package/ios/LayersDeviceInfo.m +14 -0
  33. package/ios/LayersDeviceInfo.swift +53 -0
  34. package/ios/LayersSKAN.m +45 -0
  35. package/ios/LayersSKAN.swift +188 -0
  36. package/ios/LayersSKANCompat.h +22 -0
  37. package/ios/LayersSKANCompat.m +118 -0
  38. package/layers-react-native.podspec +34 -0
  39. package/package.json +6 -3
  40. package/dist/index-BaaQSCs5.d.ts.map +0 -1
  41. package/dist/index-BlYXUV-h.d.mts.map +0 -1
  42. package/dist/src-8aNaNJz3.mjs.map +0 -1
@@ -0,0 +1,62 @@
1
+ // React Native library build config for @layers/react-native.
2
+ //
3
+ // Without this file, React Native's autolinking step silently skips the
4
+ // `android/` directory and none of the native modules defined under
5
+ // LayersReactNativePackage are compiled into consumer apps. That means
6
+ // NativeModules.LayersInstallReferrer / LayersAdServices /
7
+ // LayersDeviceInfo / LayersAdvertisingId all resolve to undefined
8
+ // at runtime, and getInstallReferrer() / getAdServicesToken() / etc. always
9
+ // return null — silently breaking Android install referrer attribution.
10
+
11
+ buildscript {
12
+ repositories {
13
+ google()
14
+ mavenCentral()
15
+ }
16
+ dependencies {
17
+ // Pinned to match React Native 0.73+ toolchain; consumers may override.
18
+ classpath 'com.android.tools.build:gradle:8.1.1'
19
+ }
20
+ }
21
+
22
+ apply plugin: 'com.android.library'
23
+
24
+ def safeExtGet(prop, fallback) {
25
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
26
+ }
27
+
28
+ android {
29
+ namespace 'io.layers.sdk.reactnative'
30
+ compileSdkVersion safeExtGet('compileSdkVersion', 34)
31
+
32
+ defaultConfig {
33
+ // Fallback minSdkVersion matches React Native's historical documented
34
+ // minimum (21). The consumer app's minSdkVersion wins via safeExtGet,
35
+ // so projects that explicitly set 23+ get their choice; projects that
36
+ // don't override it aren't forced past 21, which would break RN apps
37
+ // still targeting API 21/22 at autolinking time.
38
+ minSdkVersion safeExtGet('minSdkVersion', 21)
39
+ targetSdkVersion safeExtGet('targetSdkVersion', 34)
40
+ }
41
+
42
+ compileOptions {
43
+ sourceCompatibility JavaVersion.VERSION_17
44
+ targetCompatibility JavaVersion.VERSION_17
45
+ }
46
+ }
47
+
48
+ repositories {
49
+ google()
50
+ mavenCentral()
51
+ }
52
+
53
+ dependencies {
54
+ implementation "com.facebook.react:react-native:+"
55
+
56
+ // Google Play Install Referrer API — required for LayersInstallReferrerModule
57
+ // to fetch the referrer URL (fbclid, ttclid, gclid, etc.) passed from /c/:appId.
58
+ // Reflection-based lookup in the module means this is technically optional, but
59
+ // without the library the referrer fetch always returns null. Declared here as
60
+ // a first-class dependency so consumers don't have to remember to add it.
61
+ implementation 'com.android.installreferrer:installreferrer:2.2'
62
+ }
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" />
@@ -0,0 +1,70 @@
1
+ package io.layers.sdk.reactnative;
2
+
3
+ import com.facebook.react.bridge.Arguments;
4
+ import com.facebook.react.bridge.Promise;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
7
+ import com.facebook.react.bridge.ReactMethod;
8
+ import com.facebook.react.bridge.WritableMap;
9
+
10
+ import java.util.concurrent.Executors;
11
+
12
+ /**
13
+ * Native module for fetching the Google Advertising ID (GAID).
14
+ *
15
+ * Uses the Google Play Services AdvertisingIdClient API. This requires the
16
+ * host app to include `com.google.android.gms:play-services-ads-identifier`
17
+ * as a dependency. If the library is not present, the module resolves with null.
18
+ */
19
+ public class LayersAdvertisingIdModule extends ReactContextBaseJavaModule {
20
+
21
+ public LayersAdvertisingIdModule(ReactApplicationContext reactContext) {
22
+ super(reactContext);
23
+ }
24
+
25
+ @Override
26
+ public String getName() {
27
+ return "LayersAdvertisingId";
28
+ }
29
+
30
+ @ReactMethod
31
+ public void getAdvertisingInfo(Promise promise) {
32
+ Executors.newSingleThreadExecutor().execute(() -> {
33
+ try {
34
+ // Use reflection to avoid hard dependency on play-services-ads-identifier
35
+ Class<?> adIdClientClass = Class.forName(
36
+ "com.google.android.gms.ads.identifier.AdvertisingIdClient");
37
+ java.lang.reflect.Method getInfoMethod = adIdClientClass.getMethod(
38
+ "getAdvertisingIdInfo", android.content.Context.class);
39
+ Object adInfo = getInfoMethod.invoke(null, getReactApplicationContext());
40
+
41
+ if (adInfo == null) {
42
+ promise.resolve(null);
43
+ return;
44
+ }
45
+
46
+ java.lang.reflect.Method getIdMethod = adInfo.getClass().getMethod("getId");
47
+ java.lang.reflect.Method getLimitMethod = adInfo.getClass()
48
+ .getMethod("isLimitAdTrackingEnabled");
49
+
50
+ String id = (String) getIdMethod.invoke(adInfo);
51
+ boolean limitTracking = (Boolean) getLimitMethod.invoke(adInfo);
52
+
53
+ if (id == null || id.equals("00000000-0000-0000-0000-000000000000")) {
54
+ promise.resolve(null);
55
+ return;
56
+ }
57
+
58
+ WritableMap result = Arguments.createMap();
59
+ result.putString("id", id);
60
+ result.putBoolean("isLimitAdTrackingEnabled", limitTracking);
61
+ promise.resolve(result);
62
+ } catch (ClassNotFoundException e) {
63
+ // play-services-ads-identifier not available
64
+ promise.resolve(null);
65
+ } catch (Exception e) {
66
+ promise.resolve(null);
67
+ }
68
+ });
69
+ }
70
+ }
@@ -0,0 +1,54 @@
1
+ package io.layers.sdk.reactnative;
2
+
3
+ import android.content.pm.PackageInfo;
4
+ import android.content.pm.PackageManager;
5
+
6
+ import com.facebook.react.bridge.Promise;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
9
+ import com.facebook.react.bridge.ReactMethod;
10
+
11
+ /**
12
+ * Native module providing device info that is not accessible from JS.
13
+ */
14
+ public class LayersDeviceInfoModule extends ReactContextBaseJavaModule {
15
+
16
+ public LayersDeviceInfoModule(ReactApplicationContext reactContext) {
17
+ super(reactContext);
18
+ }
19
+
20
+ @Override
21
+ public String getName() {
22
+ return "LayersDeviceInfo";
23
+ }
24
+
25
+ @ReactMethod
26
+ public void getAppVersion(Promise promise) {
27
+ try {
28
+ PackageInfo pInfo = getReactApplicationContext()
29
+ .getPackageManager()
30
+ .getPackageInfo(getReactApplicationContext().getPackageName(), 0);
31
+ promise.resolve(pInfo.versionName);
32
+ } catch (PackageManager.NameNotFoundException e) {
33
+ promise.resolve(null);
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Returns the timestamp (milliseconds since epoch) when the app was first
39
+ * installed, as reported by the package manager. Used for install event
40
+ * gating: if the app was installed more than 24 hours ago and the SDK has
41
+ * never run before, suppress is_first_launch on the first app_open event.
42
+ */
43
+ @ReactMethod
44
+ public void getFirstInstallTime(Promise promise) {
45
+ try {
46
+ PackageInfo pInfo = getReactApplicationContext()
47
+ .getPackageManager()
48
+ .getPackageInfo(getReactApplicationContext().getPackageName(), 0);
49
+ promise.resolve((double) pInfo.firstInstallTime);
50
+ } catch (PackageManager.NameNotFoundException e) {
51
+ promise.resolve(null);
52
+ }
53
+ }
54
+ }
@@ -0,0 +1,116 @@
1
+ package io.layers.sdk.reactnative;
2
+
3
+ import com.facebook.react.bridge.Arguments;
4
+ import com.facebook.react.bridge.Promise;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.bridge.ReactContextBaseJavaModule;
7
+ import com.facebook.react.bridge.ReactMethod;
8
+ import com.facebook.react.bridge.WritableMap;
9
+
10
+ /**
11
+ * Native module for fetching the Google Play install referrer.
12
+ *
13
+ * Uses the Install Referrer API via reflection to avoid a hard dependency on
14
+ * `com.android.installreferrer:installreferrer`. If the library is not present
15
+ * in the host app, the module resolves with null.
16
+ */
17
+ public class LayersInstallReferrerModule extends ReactContextBaseJavaModule {
18
+
19
+ public LayersInstallReferrerModule(ReactApplicationContext reactContext) {
20
+ super(reactContext);
21
+ }
22
+
23
+ @Override
24
+ public String getName() {
25
+ return "LayersInstallReferrer";
26
+ }
27
+
28
+ @ReactMethod
29
+ public void getInstallReferrer(Promise promise) {
30
+ try {
31
+ // Use reflection to avoid hard dependency on installreferrer library
32
+ Class<?> clientClass = Class.forName(
33
+ "com.android.installreferrer.api.InstallReferrerClient");
34
+ java.lang.reflect.Method newBuilder = clientClass.getMethod(
35
+ "newBuilder", android.content.Context.class);
36
+ Object builder = newBuilder.invoke(null, getReactApplicationContext());
37
+
38
+ java.lang.reflect.Method buildMethod = builder.getClass().getMethod("build");
39
+ final Object client = buildMethod.invoke(builder);
40
+
41
+ // Get the listener interface class
42
+ Class<?> listenerClass = Class.forName(
43
+ "com.android.installreferrer.api.InstallReferrerStateListener");
44
+
45
+ // Guard against double-resolve (endConnection can trigger onDisconnected)
46
+ final java.util.concurrent.atomic.AtomicBoolean resolved =
47
+ new java.util.concurrent.atomic.AtomicBoolean(false);
48
+
49
+ // Create a dynamic proxy for the listener
50
+ Object listener = java.lang.reflect.Proxy.newProxyInstance(
51
+ listenerClass.getClassLoader(),
52
+ new Class<?>[]{ listenerClass },
53
+ (proxy, method, args) -> {
54
+ if ("onInstallReferrerSetupFinished".equals(method.getName())) {
55
+ int responseCode = (Integer) args[0];
56
+ if (responseCode == 0) { // OK
57
+ try {
58
+ java.lang.reflect.Method getDetails = client.getClass()
59
+ .getMethod("getInstallReferrer");
60
+ Object details = getDetails.invoke(client);
61
+
62
+ java.lang.reflect.Method getUrl = details.getClass()
63
+ .getMethod("getInstallReferrer");
64
+ java.lang.reflect.Method getClickTs = details.getClass()
65
+ .getMethod("getReferrerClickTimestampSeconds");
66
+ java.lang.reflect.Method getInstallTs = details.getClass()
67
+ .getMethod("getInstallBeginTimestampSeconds");
68
+
69
+ String referrerUrl = (String) getUrl.invoke(details);
70
+ long clickTs = (Long) getClickTs.invoke(details);
71
+ long installTs = (Long) getInstallTs.invoke(details);
72
+
73
+ WritableMap result = Arguments.createMap();
74
+ result.putString("referrerUrl", referrerUrl != null ? referrerUrl : "");
75
+ result.putDouble("referrerClickTimestamp", clickTs);
76
+ result.putDouble("installBeginTimestamp", installTs);
77
+ if (resolved.compareAndSet(false, true)) {
78
+ promise.resolve(result);
79
+ }
80
+ } catch (Exception e) {
81
+ if (resolved.compareAndSet(false, true)) {
82
+ promise.resolve(null);
83
+ }
84
+ } finally {
85
+ try {
86
+ java.lang.reflect.Method endConn = client.getClass()
87
+ .getMethod("endConnection");
88
+ endConn.invoke(client);
89
+ } catch (Exception ignored) {}
90
+ }
91
+ } else {
92
+ if (resolved.compareAndSet(false, true)) {
93
+ promise.resolve(null);
94
+ }
95
+ }
96
+ } else if ("onInstallReferrerServiceDisconnected".equals(method.getName())) {
97
+ // Service disconnected before we could get the referrer
98
+ if (resolved.compareAndSet(false, true)) {
99
+ promise.resolve(null);
100
+ }
101
+ }
102
+ return null;
103
+ }
104
+ );
105
+
106
+ java.lang.reflect.Method startConnection = client.getClass()
107
+ .getMethod("startConnection", listenerClass);
108
+ startConnection.invoke(client, listener);
109
+ } catch (ClassNotFoundException e) {
110
+ // installreferrer library not available
111
+ promise.resolve(null);
112
+ } catch (Exception e) {
113
+ promise.resolve(null);
114
+ }
115
+ }
116
+ }
@@ -0,0 +1,36 @@
1
+ package io.layers.sdk.reactnative;
2
+
3
+ import com.facebook.react.ReactPackage;
4
+ import com.facebook.react.bridge.NativeModule;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.uimanager.ViewManager;
7
+
8
+ import java.util.ArrayList;
9
+ import java.util.Collections;
10
+ import java.util.List;
11
+
12
+ /**
13
+ * React Native package that registers all Layers native modules.
14
+ *
15
+ * Add this package to your MainApplication's getPackages() method:
16
+ *
17
+ * <pre>
18
+ * packages.add(new LayersReactNativePackage());
19
+ * </pre>
20
+ */
21
+ public class LayersReactNativePackage implements ReactPackage {
22
+
23
+ @Override
24
+ public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
25
+ List<NativeModule> modules = new ArrayList<>();
26
+ modules.add(new LayersDeviceInfoModule(reactContext));
27
+ modules.add(new LayersAdvertisingIdModule(reactContext));
28
+ modules.add(new LayersInstallReferrerModule(reactContext));
29
+ return modules;
30
+ }
31
+
32
+ @Override
33
+ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
34
+ return Collections.emptyList();
35
+ }
36
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"att-BDPyE-Gs.d.mts","names":[],"sources":["../src/att.ts"],"sourcesContent":[],"mappings":";KAGY,SAAA;AAAA,iBAsBU,YAAA,CAAA,CAtBD,EAsBiB,OAtBjB,CAsByB,SAtBzB,CAAA;AAsBC,iBAMA,4BAAA,CAAA,CANuB,EAMS,OANT,CAMiB,SANjB,CAAA;AAMvB,iBAUA,cAAA,CAAA,CAV4B,EAUV,OAVsB,CAAA,OAAA,CAAR;AAUhC,iBAMA,gBAAA,CAAA,CANyB,EAML,OANK,CAAA,MAAA,GAAA,IAAA,CAAA;AAMzB,iBAQA,WAAA,CAAA,CARoB,EAQL,OARY,CAAA,MAAA,GAAA,IAAA,CAAA"}
1
+ {"version":3,"file":"att-BDPyE-Gs.d.mts","names":[],"sources":["../src/att.ts"],"sourcesContent":[],"mappings":";KAGY,SAAA;AAAA,iBAsBU,YAAA,CAAA,CAtBD,EAsBiB,OAtBjB,CAsByB,SAtBzB,CAAA;AAsBC,iBAMA,4BAAA,CAAA,CANuB,EAMS,OANT,CAMiB,SANjB,CAAA;AAMvB,iBAUA,cAAA,CAAA,CAV4B,EAUV,OAVsB,CAAA,OAAR,CAAA;AAUhC,iBAMA,gBAAA,CAAA,CANyB,EAML,OANK,CAAA,MAAA,GAAA,IAAA,CAAA;AAMzB,iBAQA,WAAA,CAAA,CARoB,EAQL,OARY,CAAA,MAAA,GAAA,IAAA,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import "./att-BDPyE-Gs.mjs";
2
2
  import "./skan-CAN-v1eU.mjs";
3
- import { p as LayersReactNative } from "./index-BlYXUV-h.mjs";
3
+ import { O as LayersReactNative } from "./index-BqcbQZEP.mjs";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
5
5
 
6
6
  //#region src/debug-overlay.d.ts
@@ -8,11 +8,11 @@ interface LayersDebugOverlayProps {
8
8
  /** Show or hide the overlay. */
9
9
  visible: boolean;
10
10
  /** The LayersReactNative SDK instance to read state from. */
11
- layers: LayersReactNative;
11
+ sdk: LayersReactNative;
12
12
  }
13
13
  declare function LayersDebugOverlay({
14
14
  visible,
15
- layers
15
+ sdk
16
16
  }: LayersDebugOverlayProps): react_jsx_runtime0.JSX.Element | null;
17
17
  //#endregion
18
18
  export { LayersDebugOverlay, LayersDebugOverlayProps };
@@ -1 +1 @@
1
- {"version":3,"file":"debug-overlay.d.mts","names":[],"sources":["../src/debug-overlay.tsx"],"sourcesContent":[],"mappings":";;;;;;UA4CiB,uBAAA;;;;UAIP;AAJV;AAuIgB,iBAAA,kBAAA,CAAkB;EAAA,OAAA;EAAA;AAAA,CAAA,EAAsB,uBAAtB,CAAA,EAA6C,kBAAA,CAAA,GAAA,CAAA,OAAA,GAA7C,IAAA"}
1
+ {"version":3,"file":"debug-overlay.d.mts","names":[],"sources":["../src/debug-overlay.tsx"],"sourcesContent":[],"mappings":";;;;;;UA4CiB,uBAAA;;;;OAIV;AAJP;AAuIgB,iBAAA,kBAAA,CAAkB;EAAA,OAAA;EAAA;AAAA,CAAA,EAAmB,uBAAnB,CAAA,EAA0C,kBAAA,CAAA,GAAA,CAAA,OAAA,GAA1C,IAAA"}
@@ -1,6 +1,6 @@
1
1
  import "./att-BFy6dcWE.js";
2
2
  import "./skan-DupmPyTn.js";
3
- import { p as LayersReactNative } from "./index-BaaQSCs5.js";
3
+ import { O as LayersReactNative } from "./index-fU6euPnq.js";
4
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
5
5
 
6
6
  //#region src/debug-overlay.d.ts
@@ -8,11 +8,11 @@ interface LayersDebugOverlayProps {
8
8
  /** Show or hide the overlay. */
9
9
  visible: boolean;
10
10
  /** The LayersReactNative SDK instance to read state from. */
11
- layers: LayersReactNative;
11
+ sdk: LayersReactNative;
12
12
  }
13
13
  declare function LayersDebugOverlay({
14
14
  visible,
15
- layers
15
+ sdk
16
16
  }: LayersDebugOverlayProps): react_jsx_runtime0.JSX.Element | null;
17
17
  //#endregion
18
18
  export { LayersDebugOverlay, LayersDebugOverlayProps };
@@ -1 +1 @@
1
- {"version":3,"file":"debug-overlay.d.ts","names":[],"sources":["../src/debug-overlay.tsx"],"sourcesContent":[],"mappings":";;;;;;UA4CiB,uBAAA;;;;UAIP;AAJV;AAuIgB,iBAAA,kBAAA,CAAkB;EAAA,OAAA;EAAA;AAAA,CAAA,EAAsB,uBAAtB,CAAA,EAA6C,kBAAA,CAAA,GAAA,CAAA,OAAA,GAA7C,IAAA"}
1
+ {"version":3,"file":"debug-overlay.d.ts","names":[],"sources":["../src/debug-overlay.tsx"],"sourcesContent":[],"mappings":";;;;;;UA4CiB,uBAAA;;;;OAIV;AAJP;AAuIgB,iBAAA,kBAAA,CAAkB;EAAA,OAAA;EAAA;AAAA,CAAA,EAAmB,uBAAnB,CAAA,EAA0C,kBAAA,CAAA,GAAA,CAAA,OAAA,GAA1C,IAAA"}
@@ -11,7 +11,7 @@ const REFRESH_INTERVAL_MS = 1500;
11
11
  const COLLAPSE_CHAR = "▼";
12
12
  const EXPAND_CHAR = "▶";
13
13
  const MAX_VISIBLE_EVENTS = 10;
14
- function collectState(layers) {
14
+ function collectState(sdk) {
15
15
  let sdkVersion = "--";
16
16
  let status = "Not initialized";
17
17
  let environment = "--";
@@ -26,45 +26,45 @@ function collectState(layers) {
26
26
  let osVersion = "--";
27
27
  let recentEvents = [];
28
28
  try {
29
- sdkVersion = layers.getSdkVersion();
29
+ sdkVersion = sdk.getSdkVersion();
30
30
  } catch {}
31
31
  try {
32
- status = layers.isInitialized ? "Initialized" : "Not initialized";
32
+ status = sdk.isInitialized ? "Initialized" : "Not initialized";
33
33
  } catch {}
34
34
  try {
35
- environment = layers.environment;
35
+ environment = sdk.environment;
36
36
  } catch {}
37
37
  try {
38
- appId = layers.appId;
38
+ appId = sdk.appId;
39
39
  } catch {}
40
40
  try {
41
- userId = layers.getAppUserId() ?? "(anonymous)";
41
+ userId = sdk.getAppUserId() ?? "(anonymous)";
42
42
  } catch {}
43
43
  try {
44
- const sid = layers.getSessionId();
44
+ const sid = sdk.getSessionId();
45
45
  sessionId = sid.length > 8 ? `${sid.slice(0, 8)}...` : sid;
46
46
  } catch {}
47
47
  try {
48
- queueDepth = String(layers.getQueueDepth());
48
+ queueDepth = String(sdk.getQueueDepth());
49
49
  } catch {}
50
50
  try {
51
- const ctx = layers.getDeviceContext();
51
+ const ctx = sdk.getDeviceContext();
52
52
  if (ctx.installId) installId = ctx.installId.length > 8 ? `${ctx.installId.slice(0, 8)}...` : ctx.installId;
53
53
  if (ctx.platform) platform = ctx.platform;
54
54
  if (ctx.osVersion) osVersion = ctx.osVersion;
55
55
  } catch {}
56
56
  try {
57
- const cs = layers.getConsentState();
57
+ const cs = sdk.getConsentState();
58
58
  const parts = [];
59
59
  if (cs.analytics != null) parts.push(`analytics:${String(cs.analytics)}`);
60
60
  if (cs.advertising != null) parts.push(`ads:${String(cs.advertising)}`);
61
61
  consent = parts.length > 0 ? parts.join(", ") : "not set";
62
62
  } catch {}
63
63
  try {
64
- network = layers.getNetworkStatus() ? "online" : "offline";
64
+ network = sdk.getNetworkStatus() ? "online" : "offline";
65
65
  } catch {}
66
66
  try {
67
- recentEvents = layers.getRecentEvents();
67
+ recentEvents = sdk.getRecentEvents();
68
68
  } catch {}
69
69
  return {
70
70
  sdkVersion,
@@ -95,9 +95,9 @@ function DataRow({ label, value, valueColor }) {
95
95
  })]
96
96
  });
97
97
  }
98
- function LayersDebugOverlay({ visible, layers }) {
98
+ function LayersDebugOverlay({ visible, sdk }) {
99
99
  const [collapsed, setCollapsed] = (0, react.useState)(false);
100
- const [state, setState] = (0, react.useState)(() => collectState(layers));
100
+ const [state, setState] = (0, react.useState)(() => collectState(sdk));
101
101
  const [flushing, setFlushing] = (0, react.useState)(false);
102
102
  const pan = (0, react.useRef)(new react_native.Animated.ValueXY({
103
103
  x: 16,
@@ -133,18 +133,18 @@ function LayersDebugOverlay({ visible, layers }) {
133
133
  (0, react.useEffect)(() => {
134
134
  if (!visible) return;
135
135
  const tick = () => {
136
- setState(collectState(layers));
136
+ setState(collectState(sdk));
137
137
  };
138
138
  tick();
139
139
  const id = setInterval(tick, REFRESH_INTERVAL_MS);
140
140
  return () => clearInterval(id);
141
- }, [visible, layers]);
141
+ }, [visible, sdk]);
142
142
  if (!visible) return null;
143
143
  const handleFlush = () => {
144
144
  setFlushing(true);
145
- layers.flush().finally(() => {
145
+ sdk.flush().finally(() => {
146
146
  setFlushing(false);
147
- setState(collectState(layers));
147
+ setState(collectState(sdk));
148
148
  });
149
149
  };
150
150
  const statusColor = state.status === "Initialized" ? "#00ff88" : "#ff453a";
@@ -7,7 +7,7 @@ const REFRESH_INTERVAL_MS = 1500;
7
7
  const COLLAPSE_CHAR = "▼";
8
8
  const EXPAND_CHAR = "▶";
9
9
  const MAX_VISIBLE_EVENTS = 10;
10
- function collectState(layers) {
10
+ function collectState(sdk) {
11
11
  let sdkVersion = "--";
12
12
  let status = "Not initialized";
13
13
  let environment = "--";
@@ -22,45 +22,45 @@ function collectState(layers) {
22
22
  let osVersion = "--";
23
23
  let recentEvents = [];
24
24
  try {
25
- sdkVersion = layers.getSdkVersion();
25
+ sdkVersion = sdk.getSdkVersion();
26
26
  } catch {}
27
27
  try {
28
- status = layers.isInitialized ? "Initialized" : "Not initialized";
28
+ status = sdk.isInitialized ? "Initialized" : "Not initialized";
29
29
  } catch {}
30
30
  try {
31
- environment = layers.environment;
31
+ environment = sdk.environment;
32
32
  } catch {}
33
33
  try {
34
- appId = layers.appId;
34
+ appId = sdk.appId;
35
35
  } catch {}
36
36
  try {
37
- userId = layers.getAppUserId() ?? "(anonymous)";
37
+ userId = sdk.getAppUserId() ?? "(anonymous)";
38
38
  } catch {}
39
39
  try {
40
- const sid = layers.getSessionId();
40
+ const sid = sdk.getSessionId();
41
41
  sessionId = sid.length > 8 ? `${sid.slice(0, 8)}...` : sid;
42
42
  } catch {}
43
43
  try {
44
- queueDepth = String(layers.getQueueDepth());
44
+ queueDepth = String(sdk.getQueueDepth());
45
45
  } catch {}
46
46
  try {
47
- const ctx = layers.getDeviceContext();
47
+ const ctx = sdk.getDeviceContext();
48
48
  if (ctx.installId) installId = ctx.installId.length > 8 ? `${ctx.installId.slice(0, 8)}...` : ctx.installId;
49
49
  if (ctx.platform) platform = ctx.platform;
50
50
  if (ctx.osVersion) osVersion = ctx.osVersion;
51
51
  } catch {}
52
52
  try {
53
- const cs = layers.getConsentState();
53
+ const cs = sdk.getConsentState();
54
54
  const parts = [];
55
55
  if (cs.analytics != null) parts.push(`analytics:${String(cs.analytics)}`);
56
56
  if (cs.advertising != null) parts.push(`ads:${String(cs.advertising)}`);
57
57
  consent = parts.length > 0 ? parts.join(", ") : "not set";
58
58
  } catch {}
59
59
  try {
60
- network = layers.getNetworkStatus() ? "online" : "offline";
60
+ network = sdk.getNetworkStatus() ? "online" : "offline";
61
61
  } catch {}
62
62
  try {
63
- recentEvents = layers.getRecentEvents();
63
+ recentEvents = sdk.getRecentEvents();
64
64
  } catch {}
65
65
  return {
66
66
  sdkVersion,
@@ -91,9 +91,9 @@ function DataRow({ label, value, valueColor }) {
91
91
  })]
92
92
  });
93
93
  }
94
- function LayersDebugOverlay({ visible, layers }) {
94
+ function LayersDebugOverlay({ visible, sdk }) {
95
95
  const [collapsed, setCollapsed] = useState(false);
96
- const [state, setState] = useState(() => collectState(layers));
96
+ const [state, setState] = useState(() => collectState(sdk));
97
97
  const [flushing, setFlushing] = useState(false);
98
98
  const pan = useRef(new Animated.ValueXY({
99
99
  x: 16,
@@ -129,18 +129,18 @@ function LayersDebugOverlay({ visible, layers }) {
129
129
  useEffect(() => {
130
130
  if (!visible) return;
131
131
  const tick = () => {
132
- setState(collectState(layers));
132
+ setState(collectState(sdk));
133
133
  };
134
134
  tick();
135
135
  const id = setInterval(tick, REFRESH_INTERVAL_MS);
136
136
  return () => clearInterval(id);
137
- }, [visible, layers]);
137
+ }, [visible, sdk]);
138
138
  if (!visible) return null;
139
139
  const handleFlush = () => {
140
140
  setFlushing(true);
141
- layers.flush().finally(() => {
141
+ sdk.flush().finally(() => {
142
142
  setFlushing(false);
143
- setState(collectState(layers));
143
+ setState(collectState(sdk));
144
144
  });
145
145
  };
146
146
  const statusColor = state.status === "Initialized" ? "#00ff88" : "#ff453a";