@datalyr/react-native 1.7.2 → 1.7.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/README.md CHANGED
@@ -271,6 +271,8 @@ await Datalyr.trackAddPaymentInfo(true);
271
271
 
272
272
  ### Revenue Events
273
273
 
274
+ > **Important:** If you use **Superwall** or **RevenueCat**, do not use `trackPurchase()`, `trackSubscription()`, or `trackRevenue()` for revenue attribution. These fire client-side before payment is confirmed, so trials and failed payments get counted as revenue. Use the [Superwall](https://docs.datalyr.com/integrations/superwall) or [RevenueCat](https://docs.datalyr.com/integrations/revenuecat) webhook integration for revenue events instead — they only fire when real money changes hands. Use the SDK for behavioral events only (`track('paywall_view')`, `track('trial_start')`, `screen()`, `identify()`, etc.).
275
+
274
276
  Track revenue with automatic SKAdNetwork encoding:
275
277
 
276
278
  ```typescript
@@ -845,7 +847,7 @@ A real landing page with a download button. Better ad platform compliance, highe
845
847
  <meta charset="utf-8">
846
848
  <meta name="viewport" content="width=device-width, initial-scale=1">
847
849
  <title>Download Your App</title>
848
- <script src="https://cdn.datalyr.com/dl.js" data-workspace="YOUR_WORKSPACE_ID"></script>
850
+ <script src="https://track.datalyr.com/dl.js" data-workspace-id="YOUR_WORKSPACE_ID"></script>
849
851
  </head>
850
852
  <body>
851
853
  <h1>Download Our App</h1>
@@ -880,7 +882,7 @@ Instant redirect -- no visible content, user goes straight to app store.
880
882
  <!DOCTYPE html>
881
883
  <html>
882
884
  <head>
883
- <script src="https://cdn.datalyr.com/dl.js" data-workspace="YOUR_WORKSPACE_ID"></script>
885
+ <script src="https://track.datalyr.com/dl.js" data-workspace-id="YOUR_WORKSPACE_ID"></script>
884
886
  <script>
885
887
  window.addEventListener('DOMContentLoaded', function() {
886
888
  var isAndroid = /android/i.test(navigator.userAgent);
@@ -16,7 +16,6 @@ export declare class AutoEventsManager {
16
16
  private config;
17
17
  private currentSession;
18
18
  private lastScreenName;
19
- private performanceMarks;
20
19
  private trackEvent;
21
20
  constructor(trackEvent: (eventName: string, properties: Record<string, any>) => Promise<void>, config?: Partial<AutoEventConfig>);
22
21
  /**
@@ -59,17 +58,9 @@ export declare class AutoEventsManager {
59
58
  /**
60
59
  * Track app launch performance
61
60
  */
62
- private trackAppLaunchTime;
63
- /**
64
- * Track automatic app update
65
- */
66
- trackAppUpdate(previousVersion: string, currentVersion: string): Promise<void>;
67
- /**
68
- * Track revenue event (purchases, subscriptions)
69
- */
70
- trackRevenueEvent(eventName: string, properties?: Record<string, any>): Promise<void>;
71
61
  /**
72
62
  * Track custom automatic event (called by SDK)
63
+ * Updates session counters for activity tracking
73
64
  */
74
65
  onEvent(eventName: string): Promise<void>;
75
66
  /**
@@ -3,7 +3,6 @@ export class AutoEventsManager {
3
3
  constructor(trackEvent, config = {}) {
4
4
  this.currentSession = null;
5
5
  this.lastScreenName = null;
6
- this.performanceMarks = new Map();
7
6
  this.trackEvent = trackEvent;
8
7
  this.config = {
9
8
  trackSessions: true,
@@ -25,10 +24,8 @@ export class AutoEventsManager {
25
24
  await this.startSession();
26
25
  this.setupSessionMonitoring();
27
26
  }
28
- // Track app launch performance
29
- if (this.config.trackPerformance) {
30
- this.trackAppLaunchTime();
31
- }
27
+ // Auto events: session_start, session_end only
28
+ // app_install is tracked by the SDK directly, not via AutoEventsManager
32
29
  debugLog('Automatic events manager initialized');
33
30
  }
34
31
  catch (error) {
@@ -195,63 +192,9 @@ export class AutoEventsManager {
195
192
  /**
196
193
  * Track app launch performance
197
194
  */
198
- trackAppLaunchTime() {
199
- try {
200
- // Mark app launch start
201
- this.performanceMarks.set('app_launch_start', Date.now());
202
- // Track when app is fully loaded (after a short delay)
203
- setTimeout(async () => {
204
- const launchStart = this.performanceMarks.get('app_launch_start');
205
- if (launchStart) {
206
- const launchTime = Date.now() - launchStart;
207
- await this.trackEvent('app_launch_performance', {
208
- launch_time_ms: launchTime,
209
- launch_time_seconds: launchTime / 1000,
210
- });
211
- debugLog('App launch time tracked:', launchTime);
212
- }
213
- }, 2000); // Wait 2 seconds for app to fully load
214
- }
215
- catch (error) {
216
- errorLog('Error tracking app launch performance:', error);
217
- }
218
- }
219
- /**
220
- * Track automatic app update
221
- */
222
- async trackAppUpdate(previousVersion, currentVersion) {
223
- try {
224
- await this.trackEvent('app_update', {
225
- previous_version: previousVersion,
226
- current_version: currentVersion,
227
- timestamp: Date.now(),
228
- });
229
- debugLog('App update tracked:', { from: previousVersion, to: currentVersion });
230
- }
231
- catch (error) {
232
- errorLog('Error tracking app update:', error);
233
- }
234
- }
235
- /**
236
- * Track revenue event (purchases, subscriptions)
237
- */
238
- async trackRevenueEvent(eventName, properties) {
239
- var _a;
240
- try {
241
- await this.trackEvent('revenue_event', {
242
- event_name: eventName,
243
- session_id: (_a = this.currentSession) === null || _a === void 0 ? void 0 : _a.sessionId,
244
- timestamp: Date.now(),
245
- ...properties,
246
- });
247
- debugLog('Revenue event tracked:', eventName);
248
- }
249
- catch (error) {
250
- errorLog('Error tracking revenue event:', error);
251
- }
252
- }
253
195
  /**
254
196
  * Track custom automatic event (called by SDK)
197
+ * Updates session counters for activity tracking
255
198
  */
256
199
  async onEvent(eventName) {
257
200
  try {
@@ -259,10 +202,6 @@ export class AutoEventsManager {
259
202
  this.currentSession.events++;
260
203
  this.currentSession.lastActivity = Date.now();
261
204
  }
262
- // Track specific automatic events based on event name
263
- if (eventName === 'purchase' || eventName === 'subscription' || eventName.includes('purchase')) {
264
- await this.trackRevenueEvent(eventName);
265
- }
266
205
  }
267
206
  catch (error) {
268
207
  errorLog('Error handling automatic event:', error);
@@ -108,10 +108,6 @@ export declare class DatalyrSDK {
108
108
  * Track app update manually
109
109
  */
110
110
  trackAppUpdate(previousVersion: string, currentVersion: string): Promise<void>;
111
- /**
112
- * Track revenue event manually (purchases, subscriptions)
113
- */
114
- trackRevenue(eventName: string, properties?: EventData): Promise<void>;
115
111
  /**
116
112
  * Update auto-events configuration
117
113
  */
@@ -276,7 +272,6 @@ export declare class Datalyr {
276
272
  static getCurrentSession(): SessionData | null;
277
273
  static endSession(): Promise<void>;
278
274
  static trackAppUpdate(previousVersion: string, currentVersion: string): Promise<void>;
279
- static trackRevenue(eventName: string, properties?: EventData): Promise<void>;
280
275
  static updateAutoEventsConfig(config: Partial<AutoEventConfig>): void;
281
276
  static trackAddToCart(value: number, currency?: string, productId?: string, productName?: string): Promise<void>;
282
277
  static trackViewContent(contentId?: string, contentName?: string, contentType?: string, value?: number, currency?: string): Promise<void>;
@@ -559,17 +559,10 @@ export class DatalyrSDK {
559
559
  * Track app update manually
560
560
  */
561
561
  async trackAppUpdate(previousVersion, currentVersion) {
562
- if (this.autoEventsManager) {
563
- await this.autoEventsManager.trackAppUpdate(previousVersion, currentVersion);
564
- }
565
- }
566
- /**
567
- * Track revenue event manually (purchases, subscriptions)
568
- */
569
- async trackRevenue(eventName, properties) {
570
- if (this.autoEventsManager) {
571
- await this.autoEventsManager.trackRevenueEvent(eventName, properties);
572
- }
562
+ await this.track('app_update', {
563
+ previous_version: previousVersion,
564
+ current_version: currentVersion,
565
+ });
573
566
  }
574
567
  /**
575
568
  * Update auto-events configuration
@@ -1182,9 +1175,6 @@ export class Datalyr {
1182
1175
  static async trackAppUpdate(previousVersion, currentVersion) {
1183
1176
  await datalyr.trackAppUpdate(previousVersion, currentVersion);
1184
1177
  }
1185
- static async trackRevenue(eventName, properties) {
1186
- await datalyr.trackRevenue(eventName, properties);
1187
- }
1188
1178
  static updateAutoEventsConfig(config) {
1189
1179
  datalyr.updateAutoEventsConfig(config);
1190
1180
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalyr/react-native",
3
- "version": "1.7.2",
3
+ "version": "1.7.3",
4
4
  "description": "Datalyr SDK for React Native & Expo - Server-side attribution tracking for iOS and Android",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -20,8 +20,6 @@ export class AutoEventsManager {
20
20
  private config: AutoEventConfig;
21
21
  private currentSession: SessionData | null = null;
22
22
  private lastScreenName: string | null = null;
23
- private performanceMarks: Map<string, number> = new Map();
24
-
25
23
  // Event tracking callback
26
24
  private trackEvent: (eventName: string, properties: Record<string, any>) => Promise<void>;
27
25
 
@@ -53,10 +51,8 @@ export class AutoEventsManager {
53
51
  this.setupSessionMonitoring();
54
52
  }
55
53
 
56
- // Track app launch performance
57
- if (this.config.trackPerformance) {
58
- this.trackAppLaunchTime();
59
- }
54
+ // Auto events: session_start, session_end only
55
+ // app_install is tracked by the SDK directly, not via AutoEventsManager
60
56
 
61
57
  debugLog('Automatic events manager initialized');
62
58
 
@@ -237,68 +233,9 @@ export class AutoEventsManager {
237
233
  /**
238
234
  * Track app launch performance
239
235
  */
240
- private trackAppLaunchTime(): void {
241
- try {
242
- // Mark app launch start
243
- this.performanceMarks.set('app_launch_start', Date.now());
244
-
245
- // Track when app is fully loaded (after a short delay)
246
- setTimeout(async () => {
247
- const launchStart = this.performanceMarks.get('app_launch_start');
248
- if (launchStart) {
249
- const launchTime = Date.now() - launchStart;
250
-
251
- await this.trackEvent('app_launch_performance', {
252
- launch_time_ms: launchTime,
253
- launch_time_seconds: launchTime / 1000,
254
- });
255
-
256
- debugLog('App launch time tracked:', launchTime);
257
- }
258
- }, 2000); // Wait 2 seconds for app to fully load
259
-
260
- } catch (error) {
261
- errorLog('Error tracking app launch performance:', error as Error);
262
- }
263
- }
264
-
265
- /**
266
- * Track automatic app update
267
- */
268
- async trackAppUpdate(previousVersion: string, currentVersion: string): Promise<void> {
269
- try {
270
- await this.trackEvent('app_update', {
271
- previous_version: previousVersion,
272
- current_version: currentVersion,
273
- timestamp: Date.now(),
274
- });
275
-
276
- debugLog('App update tracked:', { from: previousVersion, to: currentVersion });
277
- } catch (error) {
278
- errorLog('Error tracking app update:', error as Error);
279
- }
280
- }
281
-
282
- /**
283
- * Track revenue event (purchases, subscriptions)
284
- */
285
- async trackRevenueEvent(eventName: string, properties?: Record<string, any>): Promise<void> {
286
- try {
287
- await this.trackEvent('revenue_event', {
288
- event_name: eventName,
289
- session_id: this.currentSession?.sessionId,
290
- timestamp: Date.now(),
291
- ...properties,
292
- });
293
-
294
- debugLog('Revenue event tracked:', eventName);
295
- } catch (error) {
296
- errorLog('Error tracking revenue event:', error as Error);
297
- }
298
- }
299
-
300
236
  /**
301
237
  * Track custom automatic event (called by SDK)
238
+ * Updates session counters for activity tracking
302
239
  */
303
240
  async onEvent(eventName: string): Promise<void> {
304
241
  try {
@@ -306,12 +243,6 @@ export class AutoEventsManager {
306
243
  this.currentSession.events++;
307
244
  this.currentSession.lastActivity = Date.now();
308
245
  }
309
-
310
- // Track specific automatic events based on event name
311
- if (eventName === 'purchase' || eventName === 'subscription' || eventName.includes('purchase')) {
312
- await this.trackRevenueEvent(eventName);
313
- }
314
-
315
246
  } catch (error) {
316
247
  errorLog('Error handling automatic event:', error as Error);
317
248
  }
@@ -489,15 +489,10 @@ export class DatalyrSDKExpo {
489
489
  }
490
490
 
491
491
  async trackAppUpdate(previousVersion: string, currentVersion: string): Promise<void> {
492
- if (this.autoEventsManager) {
493
- await this.autoEventsManager.trackAppUpdate(previousVersion, currentVersion);
494
- }
495
- }
496
-
497
- async trackRevenue(eventName: string, properties?: EventData): Promise<void> {
498
- if (this.autoEventsManager) {
499
- await this.autoEventsManager.trackRevenueEvent(eventName, properties);
500
- }
492
+ await this.track('app_update', {
493
+ previous_version: previousVersion,
494
+ current_version: currentVersion,
495
+ });
501
496
  }
502
497
 
503
498
  updateAutoEventsConfig(config: Partial<AutoEventConfig>): void {
@@ -1011,10 +1006,6 @@ export class DatalyrExpo {
1011
1006
  await datalyrExpo.trackAppUpdate(previousVersion, currentVersion);
1012
1007
  }
1013
1008
 
1014
- static async trackRevenue(eventName: string, properties?: EventData): Promise<void> {
1015
- await datalyrExpo.trackRevenue(eventName, properties);
1016
- }
1017
-
1018
1009
  static updateAutoEventsConfig(config: Partial<AutoEventConfig>): void {
1019
1010
  datalyrExpo.updateAutoEventsConfig(config);
1020
1011
  }
@@ -676,18 +676,10 @@ export class DatalyrSDK {
676
676
  * Track app update manually
677
677
  */
678
678
  async trackAppUpdate(previousVersion: string, currentVersion: string): Promise<void> {
679
- if (this.autoEventsManager) {
680
- await this.autoEventsManager.trackAppUpdate(previousVersion, currentVersion);
681
- }
682
- }
683
-
684
- /**
685
- * Track revenue event manually (purchases, subscriptions)
686
- */
687
- async trackRevenue(eventName: string, properties?: EventData): Promise<void> {
688
- if (this.autoEventsManager) {
689
- await this.autoEventsManager.trackRevenueEvent(eventName, properties);
690
- }
679
+ await this.track('app_update', {
680
+ previous_version: previousVersion,
681
+ current_version: currentVersion,
682
+ });
691
683
  }
692
684
 
693
685
  /**
@@ -1409,10 +1401,6 @@ export class Datalyr {
1409
1401
  await datalyr.trackAppUpdate(previousVersion, currentVersion);
1410
1402
  }
1411
1403
 
1412
- static async trackRevenue(eventName: string, properties?: EventData): Promise<void> {
1413
- await datalyr.trackRevenue(eventName, properties);
1414
- }
1415
-
1416
1404
  static updateAutoEventsConfig(config: Partial<AutoEventConfig>): void {
1417
1405
  datalyr.updateAutoEventsConfig(config);
1418
1406
  }