@layers/react-native 1.3.0 → 1.4.2

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 (51) hide show
  1. package/dist/TrackingTransparency-D6ybvQzE.js +328 -0
  2. package/dist/{TrackingTransparency-CMedp3bh.js → TrackingTransparency-DunpgkgS.mjs} +1 -1
  3. package/dist/TrackingTransparency-DunpgkgS.mjs.map +1 -0
  4. package/dist/{att-DaUoQWpj.js → att-B6KTrEU7.mjs} +2 -2
  5. package/dist/att-B6KTrEU7.mjs.map +1 -0
  6. package/dist/att-BDPyE-Gs.d.mts +10 -0
  7. package/dist/att-BDPyE-Gs.d.mts.map +1 -0
  8. package/dist/{att-BlUZv4_u.d.ts → att-BFy6dcWE.d.ts} +1 -1
  9. package/dist/{att-BlUZv4_u.d.ts.map → att-BFy6dcWE.d.ts.map} +1 -1
  10. package/dist/att-CauvkIKr.js +69 -0
  11. package/dist/att.d.mts +2 -0
  12. package/dist/att.d.ts +1 -1
  13. package/dist/att.js +6 -2
  14. package/dist/att.mjs +3 -0
  15. package/dist/chunk-nOFOJqeH.js +30 -0
  16. package/dist/index-Ct99z5MX.d.mts +187 -0
  17. package/dist/index-Ct99z5MX.d.mts.map +1 -0
  18. package/dist/{index-CSCJSzRS.d.ts → index-DtN6DP29.d.ts} +9 -3
  19. package/dist/index-DtN6DP29.d.ts.map +1 -0
  20. package/dist/index.d.mts +4 -0
  21. package/dist/index.d.ts +3 -3
  22. package/dist/index.js +27 -4
  23. package/dist/index.mjs +5 -0
  24. package/dist/react.d.mts +108 -0
  25. package/dist/react.d.mts.map +1 -0
  26. package/dist/react.d.ts +4 -4
  27. package/dist/react.js +25 -18
  28. package/dist/react.mjs +146 -0
  29. package/dist/react.mjs.map +1 -0
  30. package/dist/skan-CAN-v1eU.d.mts +50 -0
  31. package/dist/skan-CAN-v1eU.d.mts.map +1 -0
  32. package/dist/{skan-DFFAN4wu.js → skan-CBE6_mjp.mjs} +2 -2
  33. package/dist/skan-CBE6_mjp.mjs.map +1 -0
  34. package/dist/skan-DqDVGZkX.js +256 -0
  35. package/dist/{skan-DvnRgJo1.d.ts → skan-DupmPyTn.d.ts} +1 -1
  36. package/dist/{skan-DvnRgJo1.d.ts.map → skan-DupmPyTn.d.ts.map} +1 -1
  37. package/dist/skan.d.mts +2 -0
  38. package/dist/skan.d.ts +1 -1
  39. package/dist/skan.js +2 -2
  40. package/dist/skan.mjs +3 -0
  41. package/dist/{src-DTBDULvf.js → src-DFnL34cK.mjs} +38 -7
  42. package/dist/src-DFnL34cK.mjs.map +1 -0
  43. package/dist/src-DQCNfyUc.js +825 -0
  44. package/package.json +12 -5
  45. package/dist/TrackingTransparency-CMedp3bh.js.map +0 -1
  46. package/dist/att-DaUoQWpj.js.map +0 -1
  47. package/dist/index-CSCJSzRS.d.ts.map +0 -1
  48. package/dist/react.js.map +0 -1
  49. package/dist/skan-DFFAN4wu.js.map +0 -1
  50. package/dist/src-DTBDULvf.js.map +0 -1
  51. /package/dist/{chunk-DyChAoct.js → chunk-DmmLNhcN.mjs} +0 -0
@@ -0,0 +1,187 @@
1
+ import { t as ATTStatus } from "./att-BDPyE-Gs.mjs";
2
+ import { n as SKANManager } from "./skan-CAN-v1eU.mjs";
3
+ import { ConsentState, ConsentState as ConsentState$1, DeviceContext, DeviceContext as DeviceContext$1, Environment, Environment as Environment$1, EventProperties, EventProperties as EventProperties$1, LayersError, UserProperties, UserProperties as UserProperties$1 } from "@layers/core-wasm";
4
+
5
+ //#region src/index.d.ts
6
+
7
+ interface LayersRNConfig {
8
+ appId: string;
9
+ environment: Environment;
10
+ appUserId?: string;
11
+ enableDebug?: boolean;
12
+ baseUrl?: string;
13
+ flushIntervalMs?: number;
14
+ flushThreshold?: number;
15
+ maxQueueSize?: number;
16
+ /**
17
+ * Whether to automatically fire an `app_open` event during init().
18
+ * Set to `false` if you want to fire the event manually.
19
+ * @default true
20
+ */
21
+ autoTrackAppOpen?: boolean;
22
+ /**
23
+ * Whether to automatically track `deep_link_opened` events when a deep link
24
+ * is received. The tracked event includes the parsed URL components and all
25
+ * query parameters (UTM params, click IDs like fbclid/gclid/ttclid, etc.)
26
+ * as flat top-level properties.
27
+ *
28
+ * This listener runs in addition to any consumer-registered listener via
29
+ * `setupDeepLinkListener()` -- it does not replace it.
30
+ *
31
+ * @default true
32
+ */
33
+ autoTrackDeepLinks?: boolean;
34
+ }
35
+ type ErrorListener = (error: Error) => void;
36
+ declare class LayersReactNative {
37
+ private core;
38
+ private appUserId;
39
+ private isOnline;
40
+ private readonly enableDebug;
41
+ private appStateSubscription;
42
+ private netInfoUnsubscribe;
43
+ private readonly config;
44
+ private userIdLocked;
45
+ private readonly errorListeners;
46
+ private _skanManager;
47
+ private _lastSkanConfigStr;
48
+ private deepLinkUnsubscribe;
49
+ private _configPollTimer;
50
+ private static readonly CONFIG_POLL_INTERVAL_MS;
51
+ private _adServicesToken;
52
+ private _installReferrer;
53
+ constructor(config: LayersRNConfig);
54
+ init(): Promise<void>;
55
+ track(eventName: string, properties?: EventProperties): void;
56
+ screen(screenName: string, properties?: EventProperties): void;
57
+ setUserProperties(properties: UserProperties): Promise<void>;
58
+ setUserPropertiesOnce(properties: UserProperties): Promise<void>;
59
+ setConsent(consent: ConsentState): Promise<void>;
60
+ /**
61
+ * Request App Tracking Transparency authorization (iOS only).
62
+ * After the user responds, this method automatically:
63
+ * - Collects IDFA if authorized
64
+ * - Updates device info with IDFA and ATT status
65
+ * - Sets advertising consent based on ATT result
66
+ *
67
+ * Returns the ATT status string.
68
+ */
69
+ requestTrackingPermission(): Promise<ATTStatus>;
70
+ /**
71
+ * Set the app user ID. Uses set-user-once semantics:
72
+ * once set, subsequent calls are ignored until clearAppUserId() is called.
73
+ */
74
+ setAppUserId(appUserId: string): void;
75
+ clearAppUserId(): void;
76
+ /**
77
+ * Reset the SDK state: clears the user ID, unlocks set-user-once,
78
+ * clears user properties, and starts a new session.
79
+ *
80
+ * After reset(), the SDK behaves as if no user has been identified.
81
+ * A new anonymous session is started. Events tracked after reset()
82
+ * will not carry the previous user's identity.
83
+ */
84
+ reset(): void;
85
+ getAppUserId(): string | undefined;
86
+ getSessionId(): string;
87
+ getConsentState(): ConsentState;
88
+ setDeviceInfo(deviceInfo: DeviceContext): void;
89
+ flush(): Promise<void>;
90
+ /**
91
+ * Flush all queued events synchronously (blocking).
92
+ *
93
+ * Drains all batches from the queue and sends them via HTTP, awaiting
94
+ * each batch before proceeding. Does not return until all batches have
95
+ * been sent or failed.
96
+ *
97
+ * This is useful for AppState background transitions where the app may
98
+ * be suspended shortly after the call returns.
99
+ */
100
+ flushBlocking(): Promise<void>;
101
+ /**
102
+ * Register an error listener. Errors from track/screen/flush
103
+ * that would otherwise be silently dropped are forwarded here.
104
+ */
105
+ on(event: 'error', listener: ErrorListener): this;
106
+ /**
107
+ * Remove a previously registered error listener.
108
+ */
109
+ off(event: 'error', listener: ErrorListener): this;
110
+ /**
111
+ * Returns the AdServices attribution token (iOS only), or null if not
112
+ * available. Collected automatically during init() on iOS 14.3+.
113
+ * Does NOT require ATT consent.
114
+ */
115
+ getAdServicesToken(): string | null;
116
+ /**
117
+ * Returns the Google Play install referrer data (Android only), or null
118
+ * if not available. Collected automatically during init() on Android.
119
+ */
120
+ getInstallReferrer(): InstallReferrerData | null;
121
+ /**
122
+ * Returns the auto-configured SKANManager instance, or null if SKAN was not
123
+ * configured by the server's remote config.
124
+ * On iOS, when remote config contains a `skan` section with `preset` or
125
+ * `customRules`, the SDK automatically creates and configures a SKANManager.
126
+ * Every `track()` call is automatically forwarded to SKAN rule evaluation.
127
+ */
128
+ getSkanManager(): SKANManager | null;
129
+ private emitError;
130
+ shutdown(): void;
131
+ private _trackedDeepLinkUrls;
132
+ private setupDeepLinkAutoTracking;
133
+ private initializeDeviceInfo;
134
+ private setupAppStateListener;
135
+ private configureSkanFromRemoteConfig;
136
+ private startConfigPolling;
137
+ private stopConfigPolling;
138
+ private pollRemoteConfig;
139
+ private setupNetInfoListener;
140
+ }
141
+ declare function getOrSetInstallId(): Promise<string>;
142
+ interface ClipboardAttribution {
143
+ clickUrl: string;
144
+ clickId: string;
145
+ }
146
+ declare function readClipboardAttribution(): Promise<ClipboardAttribution | null>;
147
+ interface GoogleAdvertisingInfo {
148
+ id: string;
149
+ isLimitAdTrackingEnabled: boolean;
150
+ }
151
+ /**
152
+ * Fetch the Google Advertising ID (GAID) on Android via NativeModules.
153
+ * Returns null on iOS or when the native module is not available.
154
+ */
155
+ declare function getGoogleAdvertisingId(): Promise<GoogleAdvertisingInfo | null>;
156
+ /**
157
+ * Request the AdServices attribution token on iOS 14.3+.
158
+ * Uses the LayersAdServices native module which calls AAAttribution.attributionToken().
159
+ * Does NOT require ATT consent.
160
+ * Returns null on Android or when the native module is not available.
161
+ */
162
+ declare function getAdServicesToken(): Promise<string | null>;
163
+ interface InstallReferrerData {
164
+ referrerUrl: string;
165
+ referrerClickTimestamp?: number;
166
+ installBeginTimestamp?: number;
167
+ }
168
+ /**
169
+ * Fetch the Google Play install referrer on Android via NativeModules.
170
+ * Requires the `com.android.installreferrer` library on the native side.
171
+ * Returns null on iOS or when the native module is not available.
172
+ */
173
+ declare function getInstallReferrer(): Promise<InstallReferrerData | null>;
174
+ interface DeepLinkData {
175
+ url: string;
176
+ scheme: string;
177
+ host: string;
178
+ path: string;
179
+ queryParams: Record<string, string>;
180
+ timestamp: number;
181
+ }
182
+ declare function setupDeepLinkListener(onDeepLink: (data: DeepLinkData) => void): () => void;
183
+ declare function parseDeepLink(url: string): DeepLinkData | null;
184
+ declare function useLayersExpoRouterTracking(layersInstance: LayersReactNative, usePathname: () => string, useGlobalSearchParams: () => Record<string, string | string[]>): void;
185
+ //#endregion
186
+ export { getOrSetInstallId as _, Environment$1 as a, setupDeepLinkListener as b, GoogleAdvertisingInfo as c, LayersRNConfig as d, LayersReactNative as f, getInstallReferrer as g, getGoogleAdvertisingId as h, DeviceContext$1 as i, InstallReferrerData as l, getAdServicesToken as m, ConsentState$1 as n, ErrorListener as o, UserProperties$1 as p, DeepLinkData as r, EventProperties$1 as s, ClipboardAttribution as t, LayersError as u, parseDeepLink as v, useLayersExpoRouterTracking as x, readClipboardAttribution as y };
187
+ //# sourceMappingURL=index-Ct99z5MX.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Ct99z5MX.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAmJgB,UAlGC,cAAA,CAkGD;EA4GwB,KAAA,EAAA,MAAA;EAoBE,WAAA,EAhO3B,WAgO2B;EAaJ,SAAA,CAAA,EAAA,MAAA;EAAiB,WAAA,CAAA,EAAA,OAAA;EAIb,OAAA,CAAA,EAAA,MAAA;EAAiB,eAAA,CAAA,EAAA,MAAA;EAI/B,cAAA,CAAA,EAAA,MAAA;EAAe,YAAA,CAAA,EAAA,MAAA;EAaE;;;;;EA0IpB,gBAAA,CAAA,EAAA,OAAA;EAoBM;;;;;AA2gB/B;AA6BA;AAOA;AA2FA;AASA;AAwBA;EAgBiB,kBAAA,CAAA,EAAA,OAAmB;AAWpC;AAkBiB,KAzlCL,aAAA,GAylCiB,CAAA,KAKd,EA9lCqB,KA8lCf,EAAA,GAAA,IAAA;AAIL,cAhmCH,iBAAA,CAgmCwB;EA6BrB,QAAA,IAAA;EAsBA,QAAA,SAAA;;;;;;;;;;;;;;;sBAlnCM;UA8BN;wCA4GwB;0CAoBE;gCAaJ,iBAAiB;oCAIb,iBAAiB;sBAI/B,eAAe;;;;;;;;;;+BAaN,QAAQ;;;;;;;;;;;;;;;;;;qBA+GxB;4BAIO;WAIX;;;;;;;;;;;mBAmBQ;;;;;+BAoBM;;;;gCAQC;;;;;;;;;;;wBAkBR;;;;;;;;oBAWJ;;;;;;;;;;;;;iBAseE,iBAAA,CAAA,GAAqB;UA6B1B,oBAAA;;;;iBAOK,wBAAA,CAAA,GAA4B,QAAQ;UA2FzC,qBAAA;;;;;;;;iBASK,sBAAA,CAAA,GAA0B,QAAQ;;;;;;;iBAwBlC,kBAAA,CAAA,GAAsB;UAgB3B,mBAAA;;;;;;;;;;iBAWK,kBAAA,CAAA,GAAsB,QAAQ;UAkBnC,YAAA;;;;;eAKF;;;iBAIC,qBAAA,oBAAyC;iBA6BzC,aAAA,eAA4B;iBAsB5B,2BAAA,iBACE,2EAEa"}
@@ -1,5 +1,5 @@
1
- import { t as ATTStatus } from "./att-BlUZv4_u.js";
2
- import { n as SKANManager } from "./skan-DvnRgJo1.js";
1
+ import { t as ATTStatus } from "./att-BFy6dcWE.js";
2
+ import { n as SKANManager } from "./skan-DupmPyTn.js";
3
3
  import { ConsentState, ConsentState as ConsentState$1, DeviceContext, DeviceContext as DeviceContext$1, Environment, Environment as Environment$1, EventProperties, EventProperties as EventProperties$1, LayersError, UserProperties, UserProperties as UserProperties$1 } from "@layers/core-wasm";
4
4
 
5
5
  //#region src/index.d.ts
@@ -44,7 +44,10 @@ declare class LayersReactNative {
44
44
  private userIdLocked;
45
45
  private readonly errorListeners;
46
46
  private _skanManager;
47
+ private _lastSkanConfigStr;
47
48
  private deepLinkUnsubscribe;
49
+ private _configPollTimer;
50
+ private static readonly CONFIG_POLL_INTERVAL_MS;
48
51
  private _adServicesToken;
49
52
  private _installReferrer;
50
53
  constructor(config: LayersRNConfig);
@@ -130,6 +133,9 @@ declare class LayersReactNative {
130
133
  private initializeDeviceInfo;
131
134
  private setupAppStateListener;
132
135
  private configureSkanFromRemoteConfig;
136
+ private startConfigPolling;
137
+ private stopConfigPolling;
138
+ private pollRemoteConfig;
133
139
  private setupNetInfoListener;
134
140
  }
135
141
  declare function getOrSetInstallId(): Promise<string>;
@@ -178,4 +184,4 @@ declare function parseDeepLink(url: string): DeepLinkData | null;
178
184
  declare function useLayersExpoRouterTracking(layersInstance: LayersReactNative, usePathname: () => string, useGlobalSearchParams: () => Record<string, string | string[]>): void;
179
185
  //#endregion
180
186
  export { getOrSetInstallId as _, Environment$1 as a, setupDeepLinkListener as b, GoogleAdvertisingInfo as c, LayersRNConfig as d, LayersReactNative as f, getInstallReferrer as g, getGoogleAdvertisingId as h, DeviceContext$1 as i, InstallReferrerData as l, getAdServicesToken as m, ConsentState$1 as n, ErrorListener as o, UserProperties$1 as p, DeepLinkData as r, EventProperties$1 as s, ClipboardAttribution as t, LayersError as u, parseDeepLink as v, useLayersExpoRouterTracking as x, readClipboardAttribution as y };
181
- //# sourceMappingURL=index-CSCJSzRS.d.ts.map
187
+ //# sourceMappingURL=index-DtN6DP29.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-DtN6DP29.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAmJgB,UAlGC,cAAA,CAkGD;EA4GwB,KAAA,EAAA,MAAA;EAoBE,WAAA,EAhO3B,WAgO2B;EAaJ,SAAA,CAAA,EAAA,MAAA;EAAiB,WAAA,CAAA,EAAA,OAAA;EAIb,OAAA,CAAA,EAAA,MAAA;EAAiB,eAAA,CAAA,EAAA,MAAA;EAI/B,cAAA,CAAA,EAAA,MAAA;EAAe,YAAA,CAAA,EAAA,MAAA;EAaE;;;;;EA0IpB,gBAAA,CAAA,EAAA,OAAA;EAoBM;;;;;AA2gB/B;AA6BA;AAOA;AA2FA;AASA;AAwBA;EAgBiB,kBAAA,CAAA,EAAA,OAAmB;AAWpC;AAkBiB,KAzlCL,aAAA,GAylCiB,CAAA,KAKd,EA9lCqB,KA8lCf,EAAA,GAAA,IAAA;AAIL,cAhmCH,iBAAA,CAgmCwB;EA6BrB,QAAA,IAAA;EAsBA,QAAA,SAAA;;;;;;;;;;;;;;;sBAlnCM;UA8BN;wCA4GwB;0CAoBE;gCAaJ,iBAAiB;oCAIb,iBAAiB;sBAI/B,eAAe;;;;;;;;;;+BAaN,QAAQ;;;;;;;;;;;;;;;;;;qBA+GxB;4BAIO;WAIX;;;;;;;;;;;mBAmBQ;;;;;+BAoBM;;;;gCAQC;;;;;;;;;;;wBAkBR;;;;;;;;oBAWJ;;;;;;;;;;;;;iBAseE,iBAAA,CAAA,GAAqB;UA6B1B,oBAAA;;;;iBAOK,wBAAA,CAAA,GAA4B,QAAQ;UA2FzC,qBAAA;;;;;;;;iBASK,sBAAA,CAAA,GAA0B,QAAQ;;;;;;;iBAwBlC,kBAAA,CAAA,GAAsB;UAgB3B,mBAAA;;;;;;;;;;iBAWK,kBAAA,CAAA,GAAsB,QAAQ;UAkBnC,YAAA;;;;;eAKF;;;iBAIC,qBAAA,oBAAyC;iBA6BzC,aAAA,eAA4B;iBAsB5B,2BAAA,iBACE,2EAEa"}
@@ -0,0 +1,4 @@
1
+ import { a as isATTAvailable, i as getVendorId, n as getATTStatus, o as requestTrackingAuthorization, r as getAdvertisingId, t as ATTStatus } from "./att-BDPyE-Gs.mjs";
2
+ import { i as SKANPresetConfig, n as SKANManager, r as SKANMetrics, t as SKANConversionRule } from "./skan-CAN-v1eU.mjs";
3
+ import { _ as getOrSetInstallId, a as Environment, b as setupDeepLinkListener, c as GoogleAdvertisingInfo, d as LayersRNConfig, f as LayersReactNative, g as getInstallReferrer, h as getGoogleAdvertisingId, i as DeviceContext, l as InstallReferrerData, m as getAdServicesToken, n as ConsentState, o as ErrorListener, p as UserProperties, r as DeepLinkData, s as EventProperties, t as ClipboardAttribution, u as LayersError, v as parseDeepLink, x as useLayersExpoRouterTracking, y as readClipboardAttribution } from "./index-Ct99z5MX.mjs";
4
+ export { ATTStatus, ClipboardAttribution, ConsentState, DeepLinkData, DeviceContext, Environment, ErrorListener, EventProperties, GoogleAdvertisingInfo, InstallReferrerData, LayersError, LayersRNConfig, LayersReactNative, SKANConversionRule, SKANManager, SKANMetrics, SKANPresetConfig, UserProperties, getATTStatus, getAdServicesToken, getAdvertisingId, getGoogleAdvertisingId, getInstallReferrer, getOrSetInstallId, getVendorId, isATTAvailable, parseDeepLink, readClipboardAttribution, requestTrackingAuthorization, setupDeepLinkListener, useLayersExpoRouterTracking };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as isATTAvailable, i as getVendorId, n as getATTStatus, o as requestTrackingAuthorization, r as getAdvertisingId, t as ATTStatus } from "./att-BlUZv4_u.js";
2
- import { i as SKANPresetConfig, n as SKANManager, r as SKANMetrics, t as SKANConversionRule } from "./skan-DvnRgJo1.js";
3
- import { _ as getOrSetInstallId, a as Environment, b as setupDeepLinkListener, c as GoogleAdvertisingInfo, d as LayersRNConfig, f as LayersReactNative, g as getInstallReferrer, h as getGoogleAdvertisingId, i as DeviceContext, l as InstallReferrerData, m as getAdServicesToken, n as ConsentState, o as ErrorListener, p as UserProperties, r as DeepLinkData, s as EventProperties, t as ClipboardAttribution, u as LayersError, v as parseDeepLink, x as useLayersExpoRouterTracking, y as readClipboardAttribution } from "./index-CSCJSzRS.js";
1
+ import { a as isATTAvailable, i as getVendorId, n as getATTStatus, o as requestTrackingAuthorization, r as getAdvertisingId, t as ATTStatus } from "./att-BFy6dcWE.js";
2
+ import { i as SKANPresetConfig, n as SKANManager, r as SKANMetrics, t as SKANConversionRule } from "./skan-DupmPyTn.js";
3
+ import { _ as getOrSetInstallId, a as Environment, b as setupDeepLinkListener, c as GoogleAdvertisingInfo, d as LayersRNConfig, f as LayersReactNative, g as getInstallReferrer, h as getGoogleAdvertisingId, i as DeviceContext, l as InstallReferrerData, m as getAdServicesToken, n as ConsentState, o as ErrorListener, p as UserProperties, r as DeepLinkData, s as EventProperties, t as ClipboardAttribution, u as LayersError, v as parseDeepLink, x as useLayersExpoRouterTracking, y as readClipboardAttribution } from "./index-DtN6DP29.js";
4
4
  export { ATTStatus, ClipboardAttribution, ConsentState, DeepLinkData, DeviceContext, Environment, ErrorListener, EventProperties, GoogleAdvertisingInfo, InstallReferrerData, LayersError, LayersRNConfig, LayersReactNative, SKANConversionRule, SKANManager, SKANMetrics, SKANPresetConfig, UserProperties, getATTStatus, getAdServicesToken, getAdvertisingId, getGoogleAdvertisingId, getInstallReferrer, getOrSetInstallId, getVendorId, isATTAvailable, parseDeepLink, readClipboardAttribution, requestTrackingAuthorization, setupDeepLinkListener, useLayersExpoRouterTracking };
package/dist/index.js CHANGED
@@ -1,5 +1,28 @@
1
- import { a as requestTrackingAuthorization, i as isATTAvailable, n as getAdvertisingId, r as getVendorId, t as getATTStatus } from "./att-DaUoQWpj.js";
2
- import { t as SKANManager } from "./skan-DFFAN4wu.js";
3
- import { a as getInstallReferrer, c as readClipboardAttribution, i as getGoogleAdvertisingId, l as setupDeepLinkListener, n as LayersReactNative, o as getOrSetInstallId, r as getAdServicesToken, s as parseDeepLink, t as LayersError, u as useLayersExpoRouterTracking } from "./src-DTBDULvf.js";
1
+ const require_chunk = require('./chunk-nOFOJqeH.js');
2
+ const require_att = require('./att-CauvkIKr.js');
3
+ const require_skan = require('./skan-DqDVGZkX.js');
4
+ const require_src = require('./src-DQCNfyUc.js');
5
+ let __layers_core_wasm = require("@layers/core-wasm");
6
+ __layers_core_wasm = require_chunk.__toESM(__layers_core_wasm);
4
7
 
5
- export { LayersError, LayersReactNative, SKANManager, getATTStatus, getAdServicesToken, getAdvertisingId, getGoogleAdvertisingId, getInstallReferrer, getOrSetInstallId, getVendorId, isATTAvailable, parseDeepLink, readClipboardAttribution, requestTrackingAuthorization, setupDeepLinkListener, useLayersExpoRouterTracking };
8
+ Object.defineProperty(exports, 'LayersError', {
9
+ enumerable: true,
10
+ get: function () {
11
+ return __layers_core_wasm.LayersError;
12
+ }
13
+ });
14
+ exports.LayersReactNative = require_src.LayersReactNative;
15
+ exports.SKANManager = require_skan.SKANManager;
16
+ exports.getATTStatus = require_att.getATTStatus;
17
+ exports.getAdServicesToken = require_src.getAdServicesToken;
18
+ exports.getAdvertisingId = require_att.getAdvertisingId;
19
+ exports.getGoogleAdvertisingId = require_src.getGoogleAdvertisingId;
20
+ exports.getInstallReferrer = require_src.getInstallReferrer;
21
+ exports.getOrSetInstallId = require_src.getOrSetInstallId;
22
+ exports.getVendorId = require_att.getVendorId;
23
+ exports.isATTAvailable = require_att.isATTAvailable;
24
+ exports.parseDeepLink = require_src.parseDeepLink;
25
+ exports.readClipboardAttribution = require_src.readClipboardAttribution;
26
+ exports.requestTrackingAuthorization = require_att.requestTrackingAuthorization;
27
+ exports.setupDeepLinkListener = require_src.setupDeepLinkListener;
28
+ exports.useLayersExpoRouterTracking = require_src.useLayersExpoRouterTracking;
package/dist/index.mjs ADDED
@@ -0,0 +1,5 @@
1
+ import { a as requestTrackingAuthorization, i as isATTAvailable, n as getAdvertisingId, r as getVendorId, t as getATTStatus } from "./att-B6KTrEU7.mjs";
2
+ import { t as SKANManager } from "./skan-CBE6_mjp.mjs";
3
+ import { a as getInstallReferrer, c as readClipboardAttribution, i as getGoogleAdvertisingId, l as setupDeepLinkListener, n as LayersReactNative, o as getOrSetInstallId, r as getAdServicesToken, s as parseDeepLink, t as LayersError, u as useLayersExpoRouterTracking } from "./src-DFnL34cK.mjs";
4
+
5
+ export { LayersError, LayersReactNative, SKANManager, getATTStatus, getAdServicesToken, getAdvertisingId, getGoogleAdvertisingId, getInstallReferrer, getOrSetInstallId, getVendorId, isATTAvailable, parseDeepLink, readClipboardAttribution, requestTrackingAuthorization, setupDeepLinkListener, useLayersExpoRouterTracking };
@@ -0,0 +1,108 @@
1
+ import "./att-BDPyE-Gs.mjs";
2
+ import "./skan-CAN-v1eU.mjs";
3
+ import { d as LayersRNConfig, f as LayersReactNative, n as ConsentState, s as EventProperties } from "./index-Ct99z5MX.mjs";
4
+ import { ReactNode } from "react";
5
+ import * as react_jsx_runtime0 from "react/jsx-runtime";
6
+
7
+ //#region src/react.d.ts
8
+ interface LayersRNProviderProps {
9
+ config: LayersRNConfig;
10
+ children: ReactNode;
11
+ }
12
+ /**
13
+ * Provides a LayersReactNative instance to the React component tree.
14
+ * Initializes the client on mount and shuts it down on unmount.
15
+ *
16
+ * @example
17
+ * ```tsx
18
+ * import { LayersRNProvider } from '@layers/react-native/react';
19
+ *
20
+ * function App() {
21
+ * return (
22
+ * <LayersRNProvider config={{ apiKey: 'key', appId: 'app', environment: 'production' }}>
23
+ * <MyApp />
24
+ * </LayersRNProvider>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ declare function LayersRNProvider({
30
+ config,
31
+ children
32
+ }: LayersRNProviderProps): react_jsx_runtime0.JSX.Element;
33
+ /**
34
+ * Returns the LayersReactNative instance from the nearest LayersRNProvider.
35
+ * Throws if used outside a LayersRNProvider.
36
+ */
37
+ declare function useLayers(): LayersReactNative;
38
+ /**
39
+ * Returns a stable, memoized track function bound to the current LayersReactNative instance.
40
+ *
41
+ * @example
42
+ * ```tsx
43
+ * import { useTrack } from '@layers/react-native/react';
44
+ *
45
+ * function PurchaseButton() {
46
+ * const track = useTrack();
47
+ * return <Button onPress={() => track('purchase_tap', { item: 'premium' })} title="Buy" />;
48
+ * }
49
+ * ```
50
+ */
51
+ declare function useTrack(): (eventName: string, properties?: EventProperties) => void;
52
+ /**
53
+ * Returns a stable, memoized screen function bound to the current LayersReactNative instance.
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * import { useScreen } from '@layers/react-native/react';
58
+ * import { useEffect } from 'react';
59
+ *
60
+ * function HomeScreen() {
61
+ * const screen = useScreen();
62
+ * useEffect(() => { screen('home'); }, [screen]);
63
+ * return <View />;
64
+ * }
65
+ * ```
66
+ */
67
+ declare function useScreen(): (screenName: string, properties?: EventProperties) => void;
68
+ /**
69
+ * Returns a stable, memoized identify function that sets the app user ID.
70
+ * Pass `undefined` to clear the current user ID.
71
+ *
72
+ * @example
73
+ * ```tsx
74
+ * import { useIdentify } from '@layers/react-native/react';
75
+ *
76
+ * function LoginScreen() {
77
+ * const identify = useIdentify();
78
+ * const onLogin = (userId: string) => identify(userId);
79
+ * const onLogout = () => identify(undefined);
80
+ * }
81
+ * ```
82
+ */
83
+ declare function useIdentify(): (userId: string | undefined) => void;
84
+ /**
85
+ * Returns stable, memoized consent functions bound to the current LayersReactNative instance.
86
+ *
87
+ * @example
88
+ * ```tsx
89
+ * import { useConsent } from '@layers/react-native/react';
90
+ *
91
+ * function ConsentScreen() {
92
+ * const { setConsent, getConsentState } = useConsent();
93
+ * return (
94
+ * <Button
95
+ * onPress={() => setConsent({ analytics: true, advertising: false })}
96
+ * title="Accept Analytics Only"
97
+ * />
98
+ * );
99
+ * }
100
+ * ```
101
+ */
102
+ declare function useConsent(): {
103
+ setConsent: (consent: ConsentState) => void;
104
+ getConsentState: () => ConsentState;
105
+ };
106
+ //#endregion
107
+ export { LayersRNProvider, LayersRNProviderProps, useConsent, useIdentify, useLayers, useScreen, useTrack };
108
+ //# sourceMappingURL=react.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react.d.mts","names":[],"sources":["../src/react.tsx"],"sourcesContent":[],"mappings":";;;;;;;UAQiB,qBAAA;UACP;YACE;;AAFZ;AAsBA;;;;;;AA4BA;AAqBA;AAyBA;AAyBA;AAgCA;;;;;;iBAnIgB,gBAAA;;;GAAuC,wBAAqB,kBAAA,CAAA,GAAA,CAAA;;;;;iBA4B5D,SAAA,CAAA,GAAa;;;;;;;;;;;;;;iBAqBb,QAAA,CAAA,oCAA6C;;;;;;;;;;;;;;;;iBAyB7C,SAAA,CAAA,qCAA+C;;;;;;;;;;;;;;;;iBAyB/C,WAAA,CAAA;;;;;;;;;;;;;;;;;;;iBAgCA,UAAA,CAAA;wBACQ;yBACC"}
package/dist/react.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import "./att-BlUZv4_u.js";
2
- import "./skan-DvnRgJo1.js";
3
- import { d as LayersRNConfig, f as LayersReactNative, n as ConsentState, s as EventProperties } from "./index-CSCJSzRS.js";
4
- import { ReactNode } from "react";
1
+ import "./att-BFy6dcWE.js";
2
+ import "./skan-DupmPyTn.js";
3
+ import { d as LayersRNConfig, f as LayersReactNative, n as ConsentState, s as EventProperties } from "./index-DtN6DP29.js";
5
4
  import * as react_jsx_runtime0 from "react/jsx-runtime";
5
+ import { ReactNode } from "react";
6
6
 
7
7
  //#region src/react.d.ts
8
8
  interface LayersRNProviderProps {
package/dist/react.js CHANGED
@@ -1,11 +1,14 @@
1
- import "./att-DaUoQWpj.js";
2
- import "./skan-DFFAN4wu.js";
3
- import { n as LayersReactNative } from "./src-DTBDULvf.js";
4
- import { createContext, useCallback, useContext, useEffect, useRef } from "react";
5
- import { jsx } from "react/jsx-runtime";
1
+ const require_chunk = require('./chunk-nOFOJqeH.js');
2
+ require('./att-CauvkIKr.js');
3
+ require('./skan-DqDVGZkX.js');
4
+ const require_src = require('./src-DQCNfyUc.js');
5
+ let react = require("react");
6
+ react = require_chunk.__toESM(react);
7
+ let react_jsx_runtime = require("react/jsx-runtime");
8
+ react_jsx_runtime = require_chunk.__toESM(react_jsx_runtime);
6
9
 
7
10
  //#region src/react.tsx
8
- const LayersRNContext = createContext(null);
11
+ const LayersRNContext = (0, react.createContext)(null);
9
12
  /**
10
13
  * Provides a LayersReactNative instance to the React component tree.
11
14
  * Initializes the client on mount and shuts it down on unmount.
@@ -24,9 +27,9 @@ const LayersRNContext = createContext(null);
24
27
  * ```
25
28
  */
26
29
  function LayersRNProvider({ config, children }) {
27
- const clientRef = useRef(null);
28
- if (clientRef.current === null) clientRef.current = new LayersReactNative(config);
29
- useEffect(() => {
30
+ const clientRef = (0, react.useRef)(null);
31
+ if (clientRef.current === null) clientRef.current = new require_src.LayersReactNative(config);
32
+ (0, react.useEffect)(() => {
30
33
  const client = clientRef.current;
31
34
  if (!client) return;
32
35
  client.init();
@@ -35,7 +38,7 @@ function LayersRNProvider({ config, children }) {
35
38
  clientRef.current = null;
36
39
  };
37
40
  }, []);
38
- return /* @__PURE__ */ jsx(LayersRNContext.Provider, {
41
+ return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(LayersRNContext.Provider, {
39
42
  value: clientRef.current,
40
43
  children
41
44
  });
@@ -45,7 +48,7 @@ function LayersRNProvider({ config, children }) {
45
48
  * Throws if used outside a LayersRNProvider.
46
49
  */
47
50
  function useLayers() {
48
- const client = useContext(LayersRNContext);
51
+ const client = (0, react.useContext)(LayersRNContext);
49
52
  if (!client) throw new Error("useLayers must be used within a <LayersRNProvider>");
50
53
  return client;
51
54
  }
@@ -64,7 +67,7 @@ function useLayers() {
64
67
  */
65
68
  function useTrack() {
66
69
  const client = useLayers();
67
- return useCallback((eventName, properties) => {
70
+ return (0, react.useCallback)((eventName, properties) => {
68
71
  client.track(eventName, properties);
69
72
  }, [client]);
70
73
  }
@@ -85,7 +88,7 @@ function useTrack() {
85
88
  */
86
89
  function useScreen() {
87
90
  const client = useLayers();
88
- return useCallback((screenName, properties) => {
91
+ return (0, react.useCallback)((screenName, properties) => {
89
92
  client.screen(screenName, properties);
90
93
  }, [client]);
91
94
  }
@@ -106,7 +109,7 @@ function useScreen() {
106
109
  */
107
110
  function useIdentify() {
108
111
  const client = useLayers();
109
- return useCallback((userId) => {
112
+ return (0, react.useCallback)((userId) => {
110
113
  if (userId) client.setAppUserId(userId);
111
114
  else client.clearAppUserId();
112
115
  }, [client]);
@@ -132,15 +135,19 @@ function useIdentify() {
132
135
  function useConsent() {
133
136
  const client = useLayers();
134
137
  return {
135
- setConsent: useCallback((consent) => {
138
+ setConsent: (0, react.useCallback)((consent) => {
136
139
  client.setConsent(consent);
137
140
  }, [client]),
138
- getConsentState: useCallback(() => {
141
+ getConsentState: (0, react.useCallback)(() => {
139
142
  return client.getConsentState();
140
143
  }, [client])
141
144
  };
142
145
  }
143
146
 
144
147
  //#endregion
145
- export { LayersRNProvider, useConsent, useIdentify, useLayers, useScreen, useTrack };
146
- //# sourceMappingURL=react.js.map
148
+ exports.LayersRNProvider = LayersRNProvider;
149
+ exports.useConsent = useConsent;
150
+ exports.useIdentify = useIdentify;
151
+ exports.useLayers = useLayers;
152
+ exports.useScreen = useScreen;
153
+ exports.useTrack = useTrack;
package/dist/react.mjs ADDED
@@ -0,0 +1,146 @@
1
+ import "./att-B6KTrEU7.mjs";
2
+ import "./skan-CBE6_mjp.mjs";
3
+ import { n as LayersReactNative } from "./src-DFnL34cK.mjs";
4
+ import { createContext, useCallback, useContext, useEffect, useRef } from "react";
5
+ import { jsx } from "react/jsx-runtime";
6
+
7
+ //#region src/react.tsx
8
+ const LayersRNContext = createContext(null);
9
+ /**
10
+ * Provides a LayersReactNative instance to the React component tree.
11
+ * Initializes the client on mount and shuts it down on unmount.
12
+ *
13
+ * @example
14
+ * ```tsx
15
+ * import { LayersRNProvider } from '@layers/react-native/react';
16
+ *
17
+ * function App() {
18
+ * return (
19
+ * <LayersRNProvider config={{ apiKey: 'key', appId: 'app', environment: 'production' }}>
20
+ * <MyApp />
21
+ * </LayersRNProvider>
22
+ * );
23
+ * }
24
+ * ```
25
+ */
26
+ function LayersRNProvider({ config, children }) {
27
+ const clientRef = useRef(null);
28
+ if (clientRef.current === null) clientRef.current = new LayersReactNative(config);
29
+ useEffect(() => {
30
+ const client = clientRef.current;
31
+ if (!client) return;
32
+ client.init();
33
+ return () => {
34
+ client.shutdown();
35
+ clientRef.current = null;
36
+ };
37
+ }, []);
38
+ return /* @__PURE__ */ jsx(LayersRNContext.Provider, {
39
+ value: clientRef.current,
40
+ children
41
+ });
42
+ }
43
+ /**
44
+ * Returns the LayersReactNative instance from the nearest LayersRNProvider.
45
+ * Throws if used outside a LayersRNProvider.
46
+ */
47
+ function useLayers() {
48
+ const client = useContext(LayersRNContext);
49
+ if (!client) throw new Error("useLayers must be used within a <LayersRNProvider>");
50
+ return client;
51
+ }
52
+ /**
53
+ * Returns a stable, memoized track function bound to the current LayersReactNative instance.
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * import { useTrack } from '@layers/react-native/react';
58
+ *
59
+ * function PurchaseButton() {
60
+ * const track = useTrack();
61
+ * return <Button onPress={() => track('purchase_tap', { item: 'premium' })} title="Buy" />;
62
+ * }
63
+ * ```
64
+ */
65
+ function useTrack() {
66
+ const client = useLayers();
67
+ return useCallback((eventName, properties) => {
68
+ client.track(eventName, properties);
69
+ }, [client]);
70
+ }
71
+ /**
72
+ * Returns a stable, memoized screen function bound to the current LayersReactNative instance.
73
+ *
74
+ * @example
75
+ * ```tsx
76
+ * import { useScreen } from '@layers/react-native/react';
77
+ * import { useEffect } from 'react';
78
+ *
79
+ * function HomeScreen() {
80
+ * const screen = useScreen();
81
+ * useEffect(() => { screen('home'); }, [screen]);
82
+ * return <View />;
83
+ * }
84
+ * ```
85
+ */
86
+ function useScreen() {
87
+ const client = useLayers();
88
+ return useCallback((screenName, properties) => {
89
+ client.screen(screenName, properties);
90
+ }, [client]);
91
+ }
92
+ /**
93
+ * Returns a stable, memoized identify function that sets the app user ID.
94
+ * Pass `undefined` to clear the current user ID.
95
+ *
96
+ * @example
97
+ * ```tsx
98
+ * import { useIdentify } from '@layers/react-native/react';
99
+ *
100
+ * function LoginScreen() {
101
+ * const identify = useIdentify();
102
+ * const onLogin = (userId: string) => identify(userId);
103
+ * const onLogout = () => identify(undefined);
104
+ * }
105
+ * ```
106
+ */
107
+ function useIdentify() {
108
+ const client = useLayers();
109
+ return useCallback((userId) => {
110
+ if (userId) client.setAppUserId(userId);
111
+ else client.clearAppUserId();
112
+ }, [client]);
113
+ }
114
+ /**
115
+ * Returns stable, memoized consent functions bound to the current LayersReactNative instance.
116
+ *
117
+ * @example
118
+ * ```tsx
119
+ * import { useConsent } from '@layers/react-native/react';
120
+ *
121
+ * function ConsentScreen() {
122
+ * const { setConsent, getConsentState } = useConsent();
123
+ * return (
124
+ * <Button
125
+ * onPress={() => setConsent({ analytics: true, advertising: false })}
126
+ * title="Accept Analytics Only"
127
+ * />
128
+ * );
129
+ * }
130
+ * ```
131
+ */
132
+ function useConsent() {
133
+ const client = useLayers();
134
+ return {
135
+ setConsent: useCallback((consent) => {
136
+ client.setConsent(consent);
137
+ }, [client]),
138
+ getConsentState: useCallback(() => {
139
+ return client.getConsentState();
140
+ }, [client])
141
+ };
142
+ }
143
+
144
+ //#endregion
145
+ export { LayersRNProvider, useConsent, useIdentify, useLayers, useScreen, useTrack };
146
+ //# sourceMappingURL=react.mjs.map