@snowplow/react-native-tracker 1.2.0 → 1.3.0
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/RNSnowplowTracker.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/gradle/wrapper/gradle-wrapper.properties +1 -1
- package/android/src/main/java/com/snowplowanalytics/react/tracker/RNSnowplowTrackerModule.java +63 -32
- package/android/src/main/java/com/snowplowanalytics/react/util/ConfigUtil.java +6 -0
- package/android/src/main/java/com/snowplowanalytics/react/util/TrackerVersion.java +1 -1
- package/dist/index.d.ts +37 -1
- package/dist/index.js +80 -3
- package/dist/index.js.map +1 -1
- package/ios/RNSnowplowTracker.m +111 -100
- package/ios/RNSnowplowTracker.xcodeproj/project.pbxproj +0 -8
- package/ios/Util/NSDictionary+RNSP_TypeMethods.h +33 -0
- package/ios/Util/NSDictionary+RNSP_TypeMethods.m +40 -0
- package/ios/Util/RNConfigUtils.m +33 -31
- package/ios/Util/RNTrackerVersion.m +1 -1
- package/package.json +6 -6
- package/CHANGELOG +0 -140
package/android/build.gradle
CHANGED
|
@@ -50,5 +50,5 @@ dependencies {
|
|
|
50
50
|
// Required Dependency for the Tracker
|
|
51
51
|
implementation "com.squareup.okhttp3:okhttp:4.9.3"
|
|
52
52
|
implementation "com.facebook.react:react-native:+"
|
|
53
|
-
implementation 'com.snowplowanalytics:snowplow-android-tracker:
|
|
53
|
+
implementation 'com.snowplowanalytics:snowplow-android-tracker:4.0.+'
|
|
54
54
|
}
|
|
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
|
|
3
3
|
distributionPath=wrapper/dists
|
|
4
4
|
zipStoreBase=GRADLE_USER_HOME
|
|
5
5
|
zipStorePath=wrapper/dists
|
|
6
|
-
distributionUrl=https\://services.gradle.org/distributions/gradle-
|
|
6
|
+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip
|
package/android/src/main/java/com/snowplowanalytics/react/tracker/RNSnowplowTrackerModule.java
CHANGED
|
@@ -8,12 +8,12 @@ import com.facebook.react.bridge.Promise;
|
|
|
8
8
|
import com.facebook.react.bridge.ReadableArray;
|
|
9
9
|
import com.facebook.react.bridge.ReadableMap;
|
|
10
10
|
|
|
11
|
+
import com.facebook.react.bridge.ReadableMapKeySetIterator;
|
|
11
12
|
import com.snowplowanalytics.snowplow.Snowplow;
|
|
12
13
|
import com.snowplowanalytics.snowplow.configuration.Configuration;
|
|
13
14
|
import com.snowplowanalytics.snowplow.configuration.EmitterConfiguration;
|
|
14
15
|
import com.snowplowanalytics.snowplow.configuration.GdprConfiguration;
|
|
15
16
|
import com.snowplowanalytics.snowplow.configuration.NetworkConfiguration;
|
|
16
|
-
import com.snowplowanalytics.snowplow.configuration.RemoteConfiguration;
|
|
17
17
|
import com.snowplowanalytics.snowplow.configuration.SessionConfiguration;
|
|
18
18
|
import com.snowplowanalytics.snowplow.configuration.TrackerConfiguration;
|
|
19
19
|
import com.snowplowanalytics.snowplow.configuration.SubjectConfiguration;
|
|
@@ -22,6 +22,7 @@ import com.snowplowanalytics.snowplow.event.DeepLinkReceived;
|
|
|
22
22
|
import com.snowplowanalytics.snowplow.event.MessageNotification;
|
|
23
23
|
import com.snowplowanalytics.snowplow.globalcontexts.GlobalContext;
|
|
24
24
|
import com.snowplowanalytics.snowplow.controller.TrackerController;
|
|
25
|
+
import com.snowplowanalytics.snowplow.network.CollectorCookieJar;
|
|
25
26
|
import com.snowplowanalytics.snowplow.payload.SelfDescribingJson;
|
|
26
27
|
import com.snowplowanalytics.snowplow.event.SelfDescribing;
|
|
27
28
|
import com.snowplowanalytics.snowplow.event.ScreenView;
|
|
@@ -30,18 +31,20 @@ import com.snowplowanalytics.snowplow.event.PageView;
|
|
|
30
31
|
import com.snowplowanalytics.snowplow.event.Timing;
|
|
31
32
|
import com.snowplowanalytics.snowplow.event.ConsentGranted;
|
|
32
33
|
import com.snowplowanalytics.snowplow.event.ConsentWithdrawn;
|
|
33
|
-
import com.snowplowanalytics.snowplow.event.EcommerceTransactionItem;
|
|
34
34
|
import com.snowplowanalytics.snowplow.event.EcommerceTransaction;
|
|
35
35
|
import com.snowplowanalytics.snowplow.network.HttpMethod;
|
|
36
|
-
import com.snowplowanalytics.snowplow.internal.utils.Util;
|
|
37
36
|
import com.snowplowanalytics.snowplow.util.Size;
|
|
38
37
|
|
|
39
38
|
import java.util.List;
|
|
40
39
|
import java.util.ArrayList;
|
|
40
|
+
import java.util.concurrent.TimeUnit;
|
|
41
41
|
|
|
42
42
|
import com.snowplowanalytics.react.util.EventUtil;
|
|
43
43
|
import com.snowplowanalytics.react.util.ConfigUtil;
|
|
44
44
|
|
|
45
|
+
import okhttp3.OkHttpClient;
|
|
46
|
+
import okhttp3.Request;
|
|
47
|
+
|
|
45
48
|
public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
46
49
|
|
|
47
50
|
private final ReactApplicationContext reactContext;
|
|
@@ -73,6 +76,30 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
73
76
|
} else {
|
|
74
77
|
networkConfiguration = new NetworkConfiguration(networkConfig.getString("endpoint"));
|
|
75
78
|
}
|
|
79
|
+
if (networkConfig.hasKey("customPostPath") && !networkConfig.isNull("customPostPath")) {
|
|
80
|
+
String customPostPath = networkConfig.getString("customPostPath");
|
|
81
|
+
networkConfiguration.customPostPath = customPostPath;
|
|
82
|
+
}
|
|
83
|
+
if (networkConfig.hasKey("requestHeaders") && !networkConfig.isNull("requestHeaders")) {
|
|
84
|
+
ReadableMap requestHeaders = networkConfig.getMap("requestHeaders");
|
|
85
|
+
if (requestHeaders != null) {
|
|
86
|
+
OkHttpClient client = new OkHttpClient.Builder()
|
|
87
|
+
.connectTimeout(15, TimeUnit.SECONDS)
|
|
88
|
+
.readTimeout(15, TimeUnit.SECONDS)
|
|
89
|
+
.cookieJar(new CollectorCookieJar(reactContext))
|
|
90
|
+
.addInterceptor(chain -> {
|
|
91
|
+
Request.Builder requestBuilder = chain.request().newBuilder();
|
|
92
|
+
ReadableMapKeySetIterator it = requestHeaders.keySetIterator();
|
|
93
|
+
while (it.hasNextKey()) {
|
|
94
|
+
String key = it.nextKey();
|
|
95
|
+
String value = requestHeaders.getString(key);
|
|
96
|
+
if (value != null) { requestBuilder.header(key, value); }
|
|
97
|
+
}
|
|
98
|
+
return chain.proceed(requestBuilder.build());
|
|
99
|
+
}).build();
|
|
100
|
+
networkConfiguration.okHttpClient(client);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
76
103
|
|
|
77
104
|
// Configurations
|
|
78
105
|
List<Configuration> controllers = new ArrayList<Configuration>();
|
|
@@ -137,7 +164,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
137
164
|
Promise promise) {
|
|
138
165
|
try {
|
|
139
166
|
String namespace = details.getString("tracker");
|
|
140
|
-
TrackerController trackerController =
|
|
167
|
+
TrackerController trackerController = getTracker(namespace);
|
|
141
168
|
|
|
142
169
|
promise.resolve(Snowplow.removeTracker(trackerController));
|
|
143
170
|
|
|
@@ -165,7 +192,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
165
192
|
ReadableMap argmap = details.getMap("eventData");
|
|
166
193
|
ReadableArray contexts = details.getArray("contexts");
|
|
167
194
|
|
|
168
|
-
TrackerController trackerController =
|
|
195
|
+
TrackerController trackerController = getTracker(namespace);
|
|
169
196
|
|
|
170
197
|
SelfDescribingJson sdj = EventUtil.createSelfDescribingJson(argmap);
|
|
171
198
|
SelfDescribing event = new SelfDescribing(sdj);
|
|
@@ -189,7 +216,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
189
216
|
ReadableMap argmap = details.getMap("eventData");
|
|
190
217
|
ReadableArray contexts = details.getArray("contexts");
|
|
191
218
|
|
|
192
|
-
TrackerController trackerController =
|
|
219
|
+
TrackerController trackerController = getTracker(namespace);
|
|
193
220
|
|
|
194
221
|
Structured event = EventUtil.createStructuredEvent(argmap);
|
|
195
222
|
|
|
@@ -212,7 +239,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
212
239
|
ReadableMap argmap = details.getMap("eventData");
|
|
213
240
|
ReadableArray contexts = details.getArray("contexts");
|
|
214
241
|
|
|
215
|
-
TrackerController trackerController =
|
|
242
|
+
TrackerController trackerController = getTracker(namespace);
|
|
216
243
|
|
|
217
244
|
ScreenView event = EventUtil.createScreenViewEvent(argmap);
|
|
218
245
|
|
|
@@ -235,7 +262,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
235
262
|
ReadableMap argmap = details.getMap("eventData");
|
|
236
263
|
ReadableArray contexts = details.getArray("contexts");
|
|
237
264
|
|
|
238
|
-
TrackerController trackerController =
|
|
265
|
+
TrackerController trackerController = getTracker(namespace);
|
|
239
266
|
|
|
240
267
|
PageView event = EventUtil.createPageViewEvent(argmap);
|
|
241
268
|
|
|
@@ -258,7 +285,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
258
285
|
ReadableMap argmap = details.getMap("eventData");
|
|
259
286
|
ReadableArray contexts = details.getArray("contexts");
|
|
260
287
|
|
|
261
|
-
TrackerController trackerController =
|
|
288
|
+
TrackerController trackerController = getTracker(namespace);
|
|
262
289
|
|
|
263
290
|
Timing event = EventUtil.createTimingEvent(argmap);
|
|
264
291
|
|
|
@@ -281,7 +308,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
281
308
|
ReadableMap argmap = details.getMap("eventData");
|
|
282
309
|
ReadableArray contexts = details.getArray("contexts");
|
|
283
310
|
|
|
284
|
-
TrackerController trackerController =
|
|
311
|
+
TrackerController trackerController = getTracker(namespace);
|
|
285
312
|
|
|
286
313
|
ConsentGranted event = EventUtil.createConsentGrantedEvent(argmap);
|
|
287
314
|
|
|
@@ -304,7 +331,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
304
331
|
ReadableMap argmap = details.getMap("eventData");
|
|
305
332
|
ReadableArray contexts = details.getArray("contexts");
|
|
306
333
|
|
|
307
|
-
TrackerController trackerController =
|
|
334
|
+
TrackerController trackerController = getTracker(namespace);
|
|
308
335
|
|
|
309
336
|
ConsentWithdrawn event = EventUtil.createConsentWithdrawnEvent(argmap);
|
|
310
337
|
|
|
@@ -327,7 +354,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
327
354
|
ReadableMap argmap = details.getMap("eventData");
|
|
328
355
|
ReadableArray contexts = details.getArray("contexts");
|
|
329
356
|
|
|
330
|
-
TrackerController trackerController =
|
|
357
|
+
TrackerController trackerController = getTracker(namespace);
|
|
331
358
|
|
|
332
359
|
EcommerceTransaction event = EventUtil.createEcommerceTransactionEvent(argmap);
|
|
333
360
|
|
|
@@ -350,7 +377,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
350
377
|
ReadableMap argmap = details.getMap("eventData");
|
|
351
378
|
ReadableArray contexts = details.getArray("contexts");
|
|
352
379
|
|
|
353
|
-
TrackerController trackerController =
|
|
380
|
+
TrackerController trackerController = getTracker(namespace);
|
|
354
381
|
|
|
355
382
|
DeepLinkReceived event = EventUtil.createDeepLinkReceivedEvent(argmap);
|
|
356
383
|
|
|
@@ -373,7 +400,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
373
400
|
ReadableMap argmap = details.getMap("eventData");
|
|
374
401
|
ReadableArray contexts = details.getArray("contexts");
|
|
375
402
|
|
|
376
|
-
TrackerController trackerController =
|
|
403
|
+
TrackerController trackerController = getTracker(namespace);
|
|
377
404
|
|
|
378
405
|
MessageNotification event = EventUtil.createMessageNotificationEvent(argmap);
|
|
379
406
|
|
|
@@ -395,7 +422,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
395
422
|
String namespace = details.getString("tracker");
|
|
396
423
|
String tag = details.getString("removeTag");
|
|
397
424
|
|
|
398
|
-
TrackerController trackerController =
|
|
425
|
+
TrackerController trackerController = getTracker(namespace);
|
|
399
426
|
|
|
400
427
|
trackerController.getGlobalContexts().remove(tag);
|
|
401
428
|
promise.resolve(true);
|
|
@@ -422,7 +449,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
422
449
|
}
|
|
423
450
|
GlobalContext gcStatic = new GlobalContext(staticContexts);
|
|
424
451
|
|
|
425
|
-
TrackerController trackerController =
|
|
452
|
+
TrackerController trackerController = getTracker(namespace);
|
|
426
453
|
|
|
427
454
|
trackerController.getGlobalContexts().add(tag, gcStatic);
|
|
428
455
|
promise.resolve(true);
|
|
@@ -437,7 +464,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
437
464
|
Promise promise) {
|
|
438
465
|
try {
|
|
439
466
|
String namespace = details.getString("tracker");
|
|
440
|
-
TrackerController trackerController =
|
|
467
|
+
TrackerController trackerController = getTracker(namespace);
|
|
441
468
|
|
|
442
469
|
if (details.isNull("userId")) {
|
|
443
470
|
trackerController.getSubject().setUserId(null);
|
|
@@ -456,7 +483,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
456
483
|
Promise promise) {
|
|
457
484
|
try {
|
|
458
485
|
String namespace = details.getString("tracker");
|
|
459
|
-
TrackerController trackerController =
|
|
486
|
+
TrackerController trackerController = getTracker(namespace);
|
|
460
487
|
|
|
461
488
|
if (details.isNull("networkUserId")) {
|
|
462
489
|
trackerController.getSubject().setNetworkUserId(null);
|
|
@@ -475,7 +502,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
475
502
|
Promise promise) {
|
|
476
503
|
try {
|
|
477
504
|
String namespace = details.getString("tracker");
|
|
478
|
-
TrackerController trackerController =
|
|
505
|
+
TrackerController trackerController = getTracker(namespace);
|
|
479
506
|
|
|
480
507
|
if (details.isNull("domainUserId")) {
|
|
481
508
|
trackerController.getSubject().setDomainUserId(null);
|
|
@@ -494,7 +521,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
494
521
|
Promise promise) {
|
|
495
522
|
try {
|
|
496
523
|
String namespace = details.getString("tracker");
|
|
497
|
-
TrackerController trackerController =
|
|
524
|
+
TrackerController trackerController = getTracker(namespace);
|
|
498
525
|
|
|
499
526
|
if (details.isNull("ipAddress")) {
|
|
500
527
|
trackerController.getSubject().setIpAddress(null);
|
|
@@ -513,7 +540,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
513
540
|
Promise promise) {
|
|
514
541
|
try {
|
|
515
542
|
String namespace = details.getString("tracker");
|
|
516
|
-
TrackerController trackerController =
|
|
543
|
+
TrackerController trackerController = getTracker(namespace);
|
|
517
544
|
|
|
518
545
|
if (details.isNull("useragent")) {
|
|
519
546
|
trackerController.getSubject().setUseragent(null);
|
|
@@ -532,7 +559,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
532
559
|
Promise promise) {
|
|
533
560
|
try {
|
|
534
561
|
String namespace = details.getString("tracker");
|
|
535
|
-
TrackerController trackerController =
|
|
562
|
+
TrackerController trackerController = getTracker(namespace);
|
|
536
563
|
|
|
537
564
|
if (details.isNull("timezone")) {
|
|
538
565
|
trackerController.getSubject().setTimezone(null);
|
|
@@ -551,7 +578,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
551
578
|
Promise promise) {
|
|
552
579
|
try {
|
|
553
580
|
String namespace = details.getString("tracker");
|
|
554
|
-
TrackerController trackerController =
|
|
581
|
+
TrackerController trackerController = getTracker(namespace);
|
|
555
582
|
|
|
556
583
|
if (details.isNull("language")) {
|
|
557
584
|
trackerController.getSubject().setLanguage(null);
|
|
@@ -570,7 +597,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
570
597
|
Promise promise) {
|
|
571
598
|
try {
|
|
572
599
|
String namespace = details.getString("tracker");
|
|
573
|
-
TrackerController trackerController =
|
|
600
|
+
TrackerController trackerController = getTracker(namespace);
|
|
574
601
|
|
|
575
602
|
if (details.isNull("screenResolution")) {
|
|
576
603
|
trackerController.getSubject().setScreenResolution(null);
|
|
@@ -594,7 +621,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
594
621
|
Promise promise) {
|
|
595
622
|
try {
|
|
596
623
|
String namespace = details.getString("tracker");
|
|
597
|
-
TrackerController trackerController =
|
|
624
|
+
TrackerController trackerController = getTracker(namespace);
|
|
598
625
|
|
|
599
626
|
if (details.isNull("screenViewport")) {
|
|
600
627
|
trackerController.getSubject().setScreenViewPort(null);
|
|
@@ -618,7 +645,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
618
645
|
Promise promise) {
|
|
619
646
|
try {
|
|
620
647
|
String namespace = details.getString("tracker");
|
|
621
|
-
TrackerController trackerController =
|
|
648
|
+
TrackerController trackerController = getTracker(namespace);
|
|
622
649
|
|
|
623
650
|
if (details.isNull("colorDepth")) {
|
|
624
651
|
trackerController.getSubject().setColorDepth(null);
|
|
@@ -637,7 +664,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
637
664
|
Promise promise) {
|
|
638
665
|
try {
|
|
639
666
|
String namespace = details.getString("tracker");
|
|
640
|
-
TrackerController trackerController =
|
|
667
|
+
TrackerController trackerController = getTracker(namespace);
|
|
641
668
|
|
|
642
669
|
String suid = trackerController.getSession().getUserId();
|
|
643
670
|
promise.resolve(suid);
|
|
@@ -651,7 +678,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
651
678
|
Promise promise) {
|
|
652
679
|
try {
|
|
653
680
|
String namespace = details.getString("tracker");
|
|
654
|
-
TrackerController trackerController =
|
|
681
|
+
TrackerController trackerController = getTracker(namespace);
|
|
655
682
|
|
|
656
683
|
String sid = trackerController.getSession().getSessionId();
|
|
657
684
|
promise.resolve(sid);
|
|
@@ -665,7 +692,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
665
692
|
Promise promise) {
|
|
666
693
|
try {
|
|
667
694
|
String namespace = details.getString("tracker");
|
|
668
|
-
TrackerController trackerController =
|
|
695
|
+
TrackerController trackerController = getTracker(namespace);
|
|
669
696
|
|
|
670
697
|
int sidx = trackerController.getSession().getSessionIndex();
|
|
671
698
|
promise.resolve(sidx);
|
|
@@ -679,7 +706,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
679
706
|
Promise promise) {
|
|
680
707
|
try {
|
|
681
708
|
String namespace = details.getString("tracker");
|
|
682
|
-
TrackerController trackerController =
|
|
709
|
+
TrackerController trackerController = getTracker(namespace);
|
|
683
710
|
|
|
684
711
|
boolean isInBg = trackerController.getSession().isInBackground();
|
|
685
712
|
promise.resolve(isInBg);
|
|
@@ -693,7 +720,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
693
720
|
Promise promise) {
|
|
694
721
|
try {
|
|
695
722
|
String namespace = details.getString("tracker");
|
|
696
|
-
TrackerController trackerController =
|
|
723
|
+
TrackerController trackerController = getTracker(namespace);
|
|
697
724
|
|
|
698
725
|
int bgIdx = trackerController.getSession().getBackgroundIndex();
|
|
699
726
|
promise.resolve(bgIdx);
|
|
@@ -707,7 +734,7 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
707
734
|
Promise promise) {
|
|
708
735
|
try {
|
|
709
736
|
String namespace = details.getString("tracker");
|
|
710
|
-
TrackerController trackerController =
|
|
737
|
+
TrackerController trackerController = getTracker(namespace);
|
|
711
738
|
|
|
712
739
|
int fgIdx = trackerController.getSession().getForegroundIndex();
|
|
713
740
|
promise.resolve(fgIdx);
|
|
@@ -716,4 +743,8 @@ public class RNSnowplowTrackerModule extends ReactContextBaseJavaModule {
|
|
|
716
743
|
}
|
|
717
744
|
}
|
|
718
745
|
|
|
746
|
+
private TrackerController getTracker(String namespace) {
|
|
747
|
+
return namespace == null ? Snowplow.getDefaultTracker() : Snowplow.getTracker(namespace);
|
|
748
|
+
}
|
|
749
|
+
|
|
719
750
|
}
|
|
@@ -161,6 +161,9 @@ public class ConfigUtil {
|
|
|
161
161
|
if (trackerConfig.hasKey("deepLinkContext")) {
|
|
162
162
|
trackerConfiguration.deepLinkContext(trackerConfig.getBoolean("deepLinkContext"));
|
|
163
163
|
}
|
|
164
|
+
if (trackerConfig.hasKey("userAnonymisation")) {
|
|
165
|
+
trackerConfiguration.userAnonymisation(trackerConfig.getBoolean("userAnonymisation"));
|
|
166
|
+
}
|
|
164
167
|
|
|
165
168
|
return trackerConfiguration;
|
|
166
169
|
}
|
|
@@ -200,6 +203,9 @@ public class ConfigUtil {
|
|
|
200
203
|
int byteLimitGet = (int) emitterConfig.getDouble("byteLimitGet");
|
|
201
204
|
emitterConfiguration.byteLimitGet(byteLimitGet);
|
|
202
205
|
}
|
|
206
|
+
if (emitterConfig.hasKey("serverAnonymisation")) {
|
|
207
|
+
emitterConfiguration.serverAnonymisation(emitterConfig.getBoolean("serverAnonymisation"));
|
|
208
|
+
}
|
|
203
209
|
|
|
204
210
|
return emitterConfiguration;
|
|
205
211
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -57,6 +57,17 @@ interface NetworkConfiguration {
|
|
|
57
57
|
* @defaultValue 'post'
|
|
58
58
|
*/
|
|
59
59
|
method?: HttpMethod;
|
|
60
|
+
/**
|
|
61
|
+
* A custom path which will be added to the endpoint URL to specify the
|
|
62
|
+
* complete URL of the collector when paired with the POST method.
|
|
63
|
+
*
|
|
64
|
+
* @defaultValue `com.snowplowanalytics.snowplow/tp2`.
|
|
65
|
+
*/
|
|
66
|
+
customPostPath?: string;
|
|
67
|
+
/**
|
|
68
|
+
* Custom headers for HTTP requests to the Collector.
|
|
69
|
+
*/
|
|
70
|
+
requestHeaders?: Record<string, string>;
|
|
60
71
|
}
|
|
61
72
|
/**
|
|
62
73
|
* TrackerConfiguration
|
|
@@ -136,6 +147,11 @@ interface TrackerConfiguration {
|
|
|
136
147
|
* @defaultValue false
|
|
137
148
|
*/
|
|
138
149
|
diagnosticAutotracking?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* Whether to anonymise client-side user identifiers in session and platform context entities
|
|
152
|
+
* @defaultValue false
|
|
153
|
+
*/
|
|
154
|
+
userAnonymisation?: boolean;
|
|
139
155
|
}
|
|
140
156
|
/**
|
|
141
157
|
* SessionConfiguration
|
|
@@ -181,6 +197,11 @@ interface EmitterConfiguration {
|
|
|
181
197
|
* @defaultValue 40000
|
|
182
198
|
*/
|
|
183
199
|
byteLimitGet?: number;
|
|
200
|
+
/**
|
|
201
|
+
* Whether to anonymise server-side user identifiers including the `network_userid` and `user_ipaddress`
|
|
202
|
+
* @defaultValue false
|
|
203
|
+
*/
|
|
204
|
+
serverAnonymisation?: boolean;
|
|
184
205
|
}
|
|
185
206
|
/**
|
|
186
207
|
* SubjectConfiguration
|
|
@@ -728,6 +749,21 @@ declare type ReactNativeTracker = {
|
|
|
728
749
|
readonly getForegroundIndex: () => Promise<number | undefined>;
|
|
729
750
|
};
|
|
730
751
|
|
|
752
|
+
/**
|
|
753
|
+
* Enables tracking events from apps rendered in react-native-webview components.
|
|
754
|
+
* The apps need to use the Snowplow WebView tracker to track the events.
|
|
755
|
+
*
|
|
756
|
+
* To subscribe for the events, set the `onMessage` attribute:
|
|
757
|
+
* <WebView onMessage={getWebViewCallback()} ... />
|
|
758
|
+
*
|
|
759
|
+
* @returns Callback to subscribe for events from Web views tracked using the Snowplow WebView tracker.
|
|
760
|
+
*/
|
|
761
|
+
declare function getWebViewCallback(): (message: {
|
|
762
|
+
nativeEvent: {
|
|
763
|
+
data: string;
|
|
764
|
+
};
|
|
765
|
+
}) => void;
|
|
766
|
+
|
|
731
767
|
/**
|
|
732
768
|
* Creates a React Native Tracker object
|
|
733
769
|
*
|
|
@@ -751,4 +787,4 @@ declare function removeTracker(trackerNamespace: string): Promise<boolean>;
|
|
|
751
787
|
*/
|
|
752
788
|
declare function removeAllTrackers(): Promise<boolean>;
|
|
753
789
|
|
|
754
|
-
export { Basis, BufferOption, ConsentDocument, ConsentGrantedProps, ConsentWithdrawnProps, DeepLinkReceivedProps, DevicePlatform, EcommerceItem, EcommerceTransactionProps, EmitterConfiguration, EventContext, GCConfiguration, GdprConfiguration, GlobalContext, HttpMethod, LogLevel, MessageNotificationProps, NetworkConfiguration, PageViewProps, ReactNativeTracker, ScreenSize, ScreenViewProps, SelfDescribing, SessionConfiguration, StructuredProps, SubjectConfiguration, TimingProps, TrackerConfiguration, TrackerControllerConfiguration, Trigger, createTracker, removeAllTrackers, removeTracker };
|
|
790
|
+
export { Basis, BufferOption, ConsentDocument, ConsentGrantedProps, ConsentWithdrawnProps, DeepLinkReceivedProps, DevicePlatform, EcommerceItem, EcommerceTransactionProps, EmitterConfiguration, EventContext, GCConfiguration, GdprConfiguration, GlobalContext, HttpMethod, LogLevel, MessageNotificationProps, NetworkConfiguration, PageViewProps, ReactNativeTracker, ScreenSize, ScreenViewProps, SelfDescribing, SessionConfiguration, StructuredProps, SubjectConfiguration, TimingProps, TrackerConfiguration, TrackerControllerConfiguration, Trigger, createTracker, getWebViewCallback, removeAllTrackers, removeTracker };
|
package/dist/index.js
CHANGED
|
@@ -408,7 +408,12 @@ function validateEcommerceTransaction(argmap) {
|
|
|
408
408
|
/**
|
|
409
409
|
* Configuration properties
|
|
410
410
|
*/
|
|
411
|
-
const networkProps = [
|
|
411
|
+
const networkProps = [
|
|
412
|
+
'endpoint',
|
|
413
|
+
'method',
|
|
414
|
+
'customPostPath',
|
|
415
|
+
'requestHeaders',
|
|
416
|
+
];
|
|
412
417
|
const trackerProps = [
|
|
413
418
|
'appId',
|
|
414
419
|
'devicePlatform',
|
|
@@ -424,7 +429,8 @@ const trackerProps = [
|
|
|
424
429
|
'lifecycleAutotracking',
|
|
425
430
|
'installAutotracking',
|
|
426
431
|
'exceptionAutotracking',
|
|
427
|
-
'diagnosticAutotracking'
|
|
432
|
+
'diagnosticAutotracking',
|
|
433
|
+
'userAnonymisation'
|
|
428
434
|
];
|
|
429
435
|
const sessionProps = [
|
|
430
436
|
'foregroundTimeout',
|
|
@@ -436,6 +442,7 @@ const emitterProps = [
|
|
|
436
442
|
'threadPoolSize',
|
|
437
443
|
'byteLimitPost',
|
|
438
444
|
'byteLimitGet',
|
|
445
|
+
'serverAnonymisation',
|
|
439
446
|
];
|
|
440
447
|
const subjectProps = [
|
|
441
448
|
'userId',
|
|
@@ -1453,6 +1460,76 @@ function getForegroundIndex(namespace) {
|
|
|
1453
1460
|
};
|
|
1454
1461
|
}
|
|
1455
1462
|
|
|
1463
|
+
/*
|
|
1464
|
+
* Copyright (c) 2020-2022 Snowplow Analytics Ltd. All rights reserved.
|
|
1465
|
+
*
|
|
1466
|
+
* This program is licensed to you under the Apache License Version 2.0,
|
|
1467
|
+
* and you may not use this file except in compliance with the Apache License Version 2.0.
|
|
1468
|
+
* You may obtain a copy of the Apache License Version 2.0 at http://www.apache.org/licenses/LICENSE-2.0.
|
|
1469
|
+
*
|
|
1470
|
+
* Unless required by applicable law or agreed to in writing,
|
|
1471
|
+
* software distributed under the Apache License Version 2.0 is distributed on an
|
|
1472
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
1473
|
+
* See the Apache License Version 2.0 for the specific language governing permissions and limitations there under.
|
|
1474
|
+
*/
|
|
1475
|
+
function forEachTracker(trackers, iterator) {
|
|
1476
|
+
if (trackers && trackers.length > 0) {
|
|
1477
|
+
trackers.forEach(iterator);
|
|
1478
|
+
}
|
|
1479
|
+
else {
|
|
1480
|
+
iterator(null);
|
|
1481
|
+
}
|
|
1482
|
+
}
|
|
1483
|
+
/**
|
|
1484
|
+
* Enables tracking events from apps rendered in react-native-webview components.
|
|
1485
|
+
* The apps need to use the Snowplow WebView tracker to track the events.
|
|
1486
|
+
*
|
|
1487
|
+
* To subscribe for the events, set the `onMessage` attribute:
|
|
1488
|
+
* <WebView onMessage={getWebViewCallback()} ... />
|
|
1489
|
+
*
|
|
1490
|
+
* @returns Callback to subscribe for events from Web views tracked using the Snowplow WebView tracker.
|
|
1491
|
+
*/
|
|
1492
|
+
function getWebViewCallback() {
|
|
1493
|
+
return (message) => {
|
|
1494
|
+
const data = JSON.parse(message.nativeEvent.data);
|
|
1495
|
+
switch (data.command) {
|
|
1496
|
+
case 'trackSelfDescribingEvent':
|
|
1497
|
+
forEachTracker(data.trackers, (namespace) => {
|
|
1498
|
+
trackSelfDescribingEvent$1(namespace, data.event, data.context || []).catch((error) => {
|
|
1499
|
+
errorHandler(error);
|
|
1500
|
+
});
|
|
1501
|
+
});
|
|
1502
|
+
break;
|
|
1503
|
+
case 'trackStructEvent':
|
|
1504
|
+
forEachTracker(data.trackers, (namespace) => {
|
|
1505
|
+
trackStructuredEvent$1(namespace, data.event, data.context || []).catch((error) => {
|
|
1506
|
+
errorHandler(error);
|
|
1507
|
+
});
|
|
1508
|
+
});
|
|
1509
|
+
break;
|
|
1510
|
+
case 'trackPageView':
|
|
1511
|
+
forEachTracker(data.trackers, (namespace) => {
|
|
1512
|
+
const event = data.event;
|
|
1513
|
+
trackPageViewEvent$1(namespace, {
|
|
1514
|
+
pageTitle: event.title ?? '',
|
|
1515
|
+
pageUrl: event.url ?? '',
|
|
1516
|
+
referrer: event.referrer,
|
|
1517
|
+
}).catch((error) => {
|
|
1518
|
+
errorHandler(error);
|
|
1519
|
+
});
|
|
1520
|
+
});
|
|
1521
|
+
break;
|
|
1522
|
+
case 'trackScreenView':
|
|
1523
|
+
forEachTracker(data.trackers, (namespace) => {
|
|
1524
|
+
trackScreenViewEvent$1(namespace, data.event, data.context || []).catch((error) => {
|
|
1525
|
+
errorHandler(error);
|
|
1526
|
+
});
|
|
1527
|
+
});
|
|
1528
|
+
break;
|
|
1529
|
+
}
|
|
1530
|
+
};
|
|
1531
|
+
}
|
|
1532
|
+
|
|
1456
1533
|
/*
|
|
1457
1534
|
* Copyright (c) 2020-2022 Snowplow Analytics Ltd. All rights reserved.
|
|
1458
1535
|
*
|
|
@@ -1569,5 +1646,5 @@ function removeAllTrackers() {
|
|
|
1569
1646
|
.catch((e) => errorHandler(e));
|
|
1570
1647
|
}
|
|
1571
1648
|
|
|
1572
|
-
export { createTracker, removeAllTrackers, removeTracker };
|
|
1649
|
+
export { createTracker, getWebViewCallback, removeAllTrackers, removeTracker };
|
|
1573
1650
|
//# sourceMappingURL=index.js.map
|