@datalyr/react-native 1.7.1 → 1.7.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.
- package/lib/datalyr-sdk.d.ts +3 -0
- package/lib/datalyr-sdk.js +22 -3
- package/package.json +1 -1
- package/src/datalyr-sdk-expo.ts +21 -3
- package/src/datalyr-sdk.ts +22 -3
package/lib/datalyr-sdk.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export declare class DatalyrSDK {
|
|
|
12
12
|
private cachedAdvertiserInfo;
|
|
13
13
|
private static conversionEncoder?;
|
|
14
14
|
private static debugEnabled;
|
|
15
|
+
/** Events that arrived before initialize() completed. Flushed once init finishes. */
|
|
16
|
+
private preInitQueue;
|
|
17
|
+
private static readonly PRE_INIT_QUEUE_MAX;
|
|
15
18
|
constructor();
|
|
16
19
|
/**
|
|
17
20
|
* Initialize the SDK with configuration
|
package/lib/datalyr-sdk.js
CHANGED
|
@@ -16,6 +16,8 @@ export class DatalyrSDK {
|
|
|
16
16
|
this.appStateSubscription = null;
|
|
17
17
|
this.networkStatusUnsubscribe = null;
|
|
18
18
|
this.cachedAdvertiserInfo = null;
|
|
19
|
+
/** Events that arrived before initialize() completed. Flushed once init finishes. */
|
|
20
|
+
this.preInitQueue = [];
|
|
19
21
|
// Initialize state with defaults
|
|
20
22
|
this.state = {
|
|
21
23
|
initialized: false,
|
|
@@ -167,6 +169,15 @@ export class DatalyrSDK {
|
|
|
167
169
|
});
|
|
168
170
|
// SDK initialized successfully - set state before tracking install event
|
|
169
171
|
this.state.initialized = true;
|
|
172
|
+
// Flush any events that were queued before init completed (e.g. screen tracking)
|
|
173
|
+
if (this.preInitQueue.length > 0) {
|
|
174
|
+
debugLog(`Flushing ${this.preInitQueue.length} pre-init event(s)`);
|
|
175
|
+
const queued = [...this.preInitQueue];
|
|
176
|
+
this.preInitQueue = [];
|
|
177
|
+
for (const { eventName, eventData } of queued) {
|
|
178
|
+
await this.track(eventName, eventData);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
170
181
|
// Check for app install (after SDK is marked as initialized)
|
|
171
182
|
if (attributionManager.isInstall()) {
|
|
172
183
|
// iOS: Attempt deferred web-to-app attribution via IP matching before tracking install
|
|
@@ -177,7 +188,7 @@ export class DatalyrSDK {
|
|
|
177
188
|
const installData = await attributionManager.trackInstall();
|
|
178
189
|
await this.track('app_install', {
|
|
179
190
|
platform: Platform.OS === 'ios' || Platform.OS === 'android' ? Platform.OS : 'android',
|
|
180
|
-
sdk_version: '1.7.
|
|
191
|
+
sdk_version: '1.7.2',
|
|
181
192
|
...installData,
|
|
182
193
|
});
|
|
183
194
|
}
|
|
@@ -199,7 +210,14 @@ export class DatalyrSDK {
|
|
|
199
210
|
async track(eventName, eventData) {
|
|
200
211
|
try {
|
|
201
212
|
if (!this.state.initialized) {
|
|
202
|
-
|
|
213
|
+
// Queue events that arrive before init completes instead of dropping them
|
|
214
|
+
if (this.preInitQueue.length < DatalyrSDK.PRE_INIT_QUEUE_MAX) {
|
|
215
|
+
debugLog(`Queuing pre-init event: ${eventName}`);
|
|
216
|
+
this.preInitQueue.push({ eventName, eventData });
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
errorLog('Pre-init event queue full, dropping event:', eventName);
|
|
220
|
+
}
|
|
203
221
|
return;
|
|
204
222
|
}
|
|
205
223
|
if (!validateEventName(eventName)) {
|
|
@@ -908,7 +926,7 @@ export class DatalyrSDK {
|
|
|
908
926
|
carrier: deviceInfo.carrier,
|
|
909
927
|
network_type: getNetworkType(),
|
|
910
928
|
timestamp: Date.now(),
|
|
911
|
-
sdk_version: '1.7.
|
|
929
|
+
sdk_version: '1.7.2',
|
|
912
930
|
// Advertiser data (IDFA/GAID, ATT status) for server-side postback
|
|
913
931
|
...(advertiserInfo ? {
|
|
914
932
|
idfa: advertiserInfo.idfa,
|
|
@@ -1089,6 +1107,7 @@ export class DatalyrSDK {
|
|
|
1089
1107
|
}
|
|
1090
1108
|
}
|
|
1091
1109
|
DatalyrSDK.debugEnabled = false;
|
|
1110
|
+
DatalyrSDK.PRE_INIT_QUEUE_MAX = 50;
|
|
1092
1111
|
// Create singleton instance
|
|
1093
1112
|
const datalyr = new DatalyrSDK();
|
|
1094
1113
|
// Export enhanced Datalyr class with static methods
|
package/package.json
CHANGED
package/src/datalyr-sdk-expo.ts
CHANGED
|
@@ -47,6 +47,9 @@ export class DatalyrSDKExpo {
|
|
|
47
47
|
private cachedAdvertiserInfo: any = null;
|
|
48
48
|
private static conversionEncoder?: ConversionValueEncoder;
|
|
49
49
|
private static debugEnabled = false;
|
|
50
|
+
/** Events that arrived before initialize() completed. Flushed once init finishes. */
|
|
51
|
+
private preInitQueue: Array<{ eventName: string; eventData?: EventData }> = [];
|
|
52
|
+
private static readonly PRE_INIT_QUEUE_MAX = 50;
|
|
50
53
|
|
|
51
54
|
constructor() {
|
|
52
55
|
this.state = {
|
|
@@ -192,11 +195,21 @@ export class DatalyrSDKExpo {
|
|
|
192
195
|
|
|
193
196
|
this.state.initialized = true;
|
|
194
197
|
|
|
198
|
+
// Flush any events that were queued before init completed (e.g. screen tracking)
|
|
199
|
+
if (this.preInitQueue.length > 0) {
|
|
200
|
+
debugLog(`Flushing ${this.preInitQueue.length} pre-init event(s)`);
|
|
201
|
+
const queued = [...this.preInitQueue];
|
|
202
|
+
this.preInitQueue = [];
|
|
203
|
+
for (const { eventName, eventData } of queued) {
|
|
204
|
+
await this.track(eventName, eventData);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
195
208
|
if (attributionManager.isInstall()) {
|
|
196
209
|
const installData = await attributionManager.trackInstall();
|
|
197
210
|
await this.track('app_install', {
|
|
198
211
|
platform: Platform.OS,
|
|
199
|
-
sdk_version: '1.7.
|
|
212
|
+
sdk_version: '1.7.2',
|
|
200
213
|
sdk_variant: 'expo',
|
|
201
214
|
...installData,
|
|
202
215
|
});
|
|
@@ -218,7 +231,12 @@ export class DatalyrSDKExpo {
|
|
|
218
231
|
async track(eventName: string, eventData?: EventData): Promise<void> {
|
|
219
232
|
try {
|
|
220
233
|
if (!this.state.initialized) {
|
|
221
|
-
|
|
234
|
+
if (this.preInitQueue.length < DatalyrSDKExpo.PRE_INIT_QUEUE_MAX) {
|
|
235
|
+
debugLog(`Queuing pre-init event: ${eventName}`);
|
|
236
|
+
this.preInitQueue.push({ eventName, eventData });
|
|
237
|
+
} else {
|
|
238
|
+
errorLog('Pre-init event queue full, dropping event:', eventName as unknown as Error);
|
|
239
|
+
}
|
|
222
240
|
return;
|
|
223
241
|
}
|
|
224
242
|
|
|
@@ -792,7 +810,7 @@ export class DatalyrSDKExpo {
|
|
|
792
810
|
carrier: deviceInfo.carrier,
|
|
793
811
|
network_type: networkType,
|
|
794
812
|
timestamp: Date.now(),
|
|
795
|
-
sdk_version: '1.7.
|
|
813
|
+
sdk_version: '1.7.2',
|
|
796
814
|
sdk_variant: 'expo',
|
|
797
815
|
// Advertiser data (IDFA/GAID, ATT status) for server-side postback
|
|
798
816
|
...(advertiserInfo ? {
|
package/src/datalyr-sdk.ts
CHANGED
|
@@ -45,6 +45,9 @@ export class DatalyrSDK {
|
|
|
45
45
|
private cachedAdvertiserInfo: any = null;
|
|
46
46
|
private static conversionEncoder?: ConversionValueEncoder;
|
|
47
47
|
private static debugEnabled = false;
|
|
48
|
+
/** Events that arrived before initialize() completed. Flushed once init finishes. */
|
|
49
|
+
private preInitQueue: Array<{ eventName: string; eventData?: EventData }> = [];
|
|
50
|
+
private static readonly PRE_INIT_QUEUE_MAX = 50;
|
|
48
51
|
|
|
49
52
|
constructor() {
|
|
50
53
|
// Initialize state with defaults
|
|
@@ -217,6 +220,16 @@ export class DatalyrSDK {
|
|
|
217
220
|
// SDK initialized successfully - set state before tracking install event
|
|
218
221
|
this.state.initialized = true;
|
|
219
222
|
|
|
223
|
+
// Flush any events that were queued before init completed (e.g. screen tracking)
|
|
224
|
+
if (this.preInitQueue.length > 0) {
|
|
225
|
+
debugLog(`Flushing ${this.preInitQueue.length} pre-init event(s)`);
|
|
226
|
+
const queued = [...this.preInitQueue];
|
|
227
|
+
this.preInitQueue = [];
|
|
228
|
+
for (const { eventName, eventData } of queued) {
|
|
229
|
+
await this.track(eventName, eventData);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
|
|
220
233
|
// Check for app install (after SDK is marked as initialized)
|
|
221
234
|
if (attributionManager.isInstall()) {
|
|
222
235
|
// iOS: Attempt deferred web-to-app attribution via IP matching before tracking install
|
|
@@ -228,7 +241,7 @@ export class DatalyrSDK {
|
|
|
228
241
|
const installData = await attributionManager.trackInstall();
|
|
229
242
|
await this.track('app_install', {
|
|
230
243
|
platform: Platform.OS === 'ios' || Platform.OS === 'android' ? Platform.OS : 'android',
|
|
231
|
-
sdk_version: '1.7.
|
|
244
|
+
sdk_version: '1.7.2',
|
|
232
245
|
...installData,
|
|
233
246
|
});
|
|
234
247
|
}
|
|
@@ -252,7 +265,13 @@ export class DatalyrSDK {
|
|
|
252
265
|
async track(eventName: string, eventData?: EventData): Promise<void> {
|
|
253
266
|
try {
|
|
254
267
|
if (!this.state.initialized) {
|
|
255
|
-
|
|
268
|
+
// Queue events that arrive before init completes instead of dropping them
|
|
269
|
+
if (this.preInitQueue.length < DatalyrSDK.PRE_INIT_QUEUE_MAX) {
|
|
270
|
+
debugLog(`Queuing pre-init event: ${eventName}`);
|
|
271
|
+
this.preInitQueue.push({ eventName, eventData });
|
|
272
|
+
} else {
|
|
273
|
+
errorLog('Pre-init event queue full, dropping event:', eventName as unknown as Error);
|
|
274
|
+
}
|
|
256
275
|
return;
|
|
257
276
|
}
|
|
258
277
|
|
|
@@ -1086,7 +1105,7 @@ export class DatalyrSDK {
|
|
|
1086
1105
|
carrier: deviceInfo.carrier,
|
|
1087
1106
|
network_type: getNetworkType(),
|
|
1088
1107
|
timestamp: Date.now(),
|
|
1089
|
-
sdk_version: '1.7.
|
|
1108
|
+
sdk_version: '1.7.2',
|
|
1090
1109
|
// Advertiser data (IDFA/GAID, ATT status) for server-side postback
|
|
1091
1110
|
...(advertiserInfo ? {
|
|
1092
1111
|
idfa: advertiserInfo.idfa,
|