This repository has been archived by the owner on Mar 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
975 lines (829 loc) · 36.1 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
import {
DeviceEventEmitter,
NativeAppEventEmitter,
NativeModules,
Platform,
} from 'react-native';
const { ReactNativeFlurry } = NativeModules;
export default class Flurry {
/**
* Android (2:VERBOSE, 3:DEBUG, 4:INFO, 5:WARN, 6:ERROR, 7:ASSERT), iOS (2:All, 3-5:Debug, 6-7:Critical)
*/
static LogLevel = Object.freeze({
VERBOSE: 2,
DEBUG: 3,
INFO: 4,
WARN: 5,
ERROR: 6,
ASSERT: 7
});
static Gender = Object.freeze({
MALE: 'm',
FEMALE: 'f'
});
static SKAdNetworkEvent = Object.freeze({
NO_EVENT: 0,
REGISTRATION: 1,
LOGIN: 2,
SUBSCRIPTION: 3,
IN_APP_PURCHASE: 4
});
static ConfigStatus = Object.freeze({
SUCCESS: 'FetchSuccess',
UNCHANGED: 'FetchNoChange',
ERROR: 'FetchError',
ACTIVATED: 'ActivateComplete'
});
static MessageType = Object.freeze({
RECEIVED: 'NotificationReceived',
CLICKED: 'NotificationClicked',
CANCELLED: 'NotificationCancelled',
REFRESH: 'TokenRefresh'
});
static Builder = class {
constructor() {
ReactNativeFlurry.initBuilder();
}
build(...apiKeys) {
if (apiKeys.length === 0) {
console.error('Flurry.Builder.build: apiKey(string) is required');
return;
} else if (apiKeys.length === 1) {
if (typeof apiKeys[0] !== 'string') {
console.error('Flurry.Builder.build: apiKey1(string) is required');
return;
}
ReactNativeFlurry.build(apiKeys[0]);
} else if (apiKeys.length === 2) {
if (Platform.OS === 'android') {
if (typeof apiKeys[0] !== 'string') {
console.error('Flurry.Builder.build: apiKey1(string) is required');
return;
}
ReactNativeFlurry.build(apiKeys[0]);
} else if (Platform.OS === 'ios') {
if (typeof apiKeys[1] !== 'string') {
console.error('Flurry.Builder.build: apiKey2(string) is required');
return;
}
ReactNativeFlurry.build(apiKeys[1]);
}
}
}
withAppVersion(versionName = '1.0') {
if (Platform.OS === 'ios') {
if (typeof versionName !== 'string') {
console.error(`Flurry.Builder.withAppVersion: versionName must be string. Got ${versionName}`);
return this;
}
ReactNativeFlurry.withAppVersion(versionName);
}
return this;
}
withCrashReporting(crashReporting = true) {
if (typeof crashReporting !== 'boolean') {
console.error(`Flurry.Builder.withCrashReporting: crashReporting must be one of [true, false]. Got ${crashReporting}`);
return this;
}
ReactNativeFlurry.withCrashReporting(crashReporting);
return this;
}
withContinueSessionMillis(sessionMillis = 10000) {
if (typeof sessionMillis !== 'number' || sessionMillis < 5000) {
console.error('Flurry.Builder.withContinueSessionMillis: the minimum timeout for a session is 5,000 ms.');
return this;
}
ReactNativeFlurry.withContinueSessionMillis(sessionMillis);
return this;
}
withGppConsent(gppString, gppSectionIds) {
if (typeof gppString !== 'string') {
console.error(`Flurry.Builder.withGppConsent: gppString must be string. Got ${gppString}`);
return this;
}
if (!Array.isArray(gppSectionIds)) {
console.error(`Flurry.Builder.withGppConsent: gppSectionIds must be array. Got ${gppSectionIds}`);
return this;
}
ReactNativeFlurry.withGppConsent(gppString, gppSectionIds);
return this;
}
withDataSaleOptOut(isOptOut = false) {
if (typeof isOptOut !== 'boolean') {
console.error(`Flurry.Builder.withDataSaleOptOut: isOptOut must be one of [true, false]. Got ${isOptOut}`);
return this;
}
ReactNativeFlurry.withDataSaleOptOut(isOptOut);
return this;
}
withIAPReportingEnabled(enableIAP = true) {
if (Platform.OS === 'ios') {
if (typeof enableIAP !== 'boolean') {
console.error(`Flurry.Builder.withIAPReportingEnabled: enableIAP must be one of [true, false]. Got ${enableIAP}`);
return this;
}
ReactNativeFlurry.withIAPReportingEnabled(enableIAP);
}
return this;
}
withIncludeBackgroundSessionsInMetrics(includeBackgroundSessionsInMetrics = true) {
if (typeof includeBackgroundSessionsInMetrics !== 'boolean') {
console.error(`Flurry.Builder.withIncludeBackgroundSessionsInMetrics: includeBackgroundSessionsInMetrics must be one of [true, false]. Got ${includeBackgroundSessionsInMetrics}`);
return this;
}
ReactNativeFlurry.withIncludeBackgroundSessionsInMetrics(includeBackgroundSessionsInMetrics);
return this;
}
withLogEnabled(enableLog = true) {
if (typeof enableLog !== 'boolean') {
console.error(`Flurry.Builder.withLogEnabled: enableLog must be one of [true, false]. Got ${enableLog}`);
return this;
}
ReactNativeFlurry.withLogEnabled(enableLog);
return this;
}
withLogLevel(logLevel = Flurry.LogLevel.WARN) {
if (typeof logLevel !== 'number') {
console.error(`Flurry.Builder.withLogLevel: logLevel must be number. Got ${logLevel}`);
return this;
}
ReactNativeFlurry.withLogLevel(logLevel);
return this;
}
withReportLocation(reportLocation = true) {
if (Platform.OS === 'android') {
if (typeof reportLocation !== 'boolean') {
console.error(`Flurry.Builder.withReportLocation: reportLocation must be one of [true, false]. Got ${reportLocation}`);
return this;
}
ReactNativeFlurry.withReportLocation(reportLocation);
}
return this;
}
withPerformanceMetrics(performanceMetrics = Flurry.Performance.ALL) {
if (Platform.OS === 'android') {
if (typeof performanceMetrics !== 'number') {
console.error(`Flurry.Builder.withPerformanceMetrics: performanceMetrics must be number. Got ${performanceMetrics}`);
return this;
}
ReactNativeFlurry.withPerformanceMetrics(performanceMetrics);
}
return this;
}
withSslPinningEnabled(sslPinningEnabled = false) {
if (Platform.OS === 'android') {
if (typeof sslPinningEnabled !== 'boolean') {
console.error(`Flurry.Builder.withSslPinningEnabled: sslPinningEnabled must be one of [true, false]. Got ${sslPinningEnabled}`);
return this;
}
ReactNativeFlurry.withSslPinningEnabled(sslPinningEnabled);
}
return this;
}
withMessaging(enableMessaging = true) {
if (typeof enableMessaging !== 'boolean') {
console.error(`Flurry.Builder.withMessaging: enableMessaging must be one of [true, false]. Got ${enableMessaging}`);
return this;
}
ReactNativeFlurry.withMessaging(enableMessaging);
return this;
}
withTVSessionReportingInterval(interval = 5) {
if (Platform.OS === 'ios' && Platform.isTVOS) {
if (typeof interval !== 'number') {
console.error(`Flurry.Builder.withTVSessionReportingInterval: interval must be number. Got ${interval}`);
return this;
}
ReactNativeFlurry.withTVSessionReportingInterval(interval);
}
return this;
}
withTVEventCountThreshold(threshold = 10) {
if (Platform.OS === 'ios' && Platform.isTVOS) {
if (typeof threshold !== 'number') {
console.error(`Flurry.Builder.withTVEventCountThreshold: threshold must be number. Got ${threshold}`);
return this;
}
ReactNativeFlurry.withTVEventCountThreshold(threshold);
}
return this;
}
};
static Event = Object.freeze({
AD_CLICK: 0,
AD_IMPRESSION: 1,
AD_REWARDED: 2,
AD_SKIPPED: 3,
CREDITS_SPENT: 4,
CREDITS_PURCHASED: 5,
CREDITS_EARNED: 6,
ACHIEVEMENT_UNLOCKED: 7,
LEVEL_COMPLETED: 8,
LEVEL_FAILED: 9,
LEVEL_UP: 10,
LEVEL_STARTED: 11,
LEVEL_SKIP: 12,
SCORE_POSTED: 13,
CONTENT_RATED: 14,
CONTENT_VIEWED: 15,
CONTENT_SAVED: 16,
PRODUCT_CUSTOMIZED: 17,
APP_ACTIVATED: 18,
APPLICATION_SUBMITTED: 19,
ADD_ITEM_TO_CART: 20,
ADD_ITEM_TO_WISH_LIST: 21,
COMPLETED_CHECKOUT: 22,
PAYMENT_INFO_ADDED: 23,
ITEM_VIEWED: 24,
ITEM_LIST_VIEWED: 25,
PURCHASED: 26,
PURCHASE_REFUNDED: 27,
REMOVE_ITEM_FROM_CART: 28,
CHECKOUT_INITIATED: 29,
FUNDS_DONATED: 30,
USER_SCHEDULED: 31,
OFFER_PRESENTED: 32,
SUBSCRIPTION_STARTED: 33,
SUBSCRIPTION_ENDED: 34,
GROUP_JOINED: 35,
GROUP_LEFT: 36,
TUTORIAL_STARTED: 37,
TUTORIAL_COMPLETED: 38,
TUTORIAL_STEP_COMPLETED: 39,
TUTORIAL_SKIPPED: 40,
LOGIN: 41,
LOGOUT: 42,
USER_REGISTERED: 43,
SEARCH_RESULT_VIEWED: 44,
KEYWORD_SEARCHED: 45,
LOCATION_SEARCHED: 46,
INVITE: 47,
SHARE: 48,
LIKE: 49,
COMMENT: 50,
MEDIA_CAPTURED: 51,
MEDIA_STARTED: 52,
MEDIA_STOPPED: 53,
MEDIA_PAUSED: 54,
PRIVACY_PROMPT_DISPLAYED: 55,
PRIVACY_OPT_IN: 56,
PRIVACY_OPT_OUT: 57,
_LAST: 57
});
static EventParam = Object.freeze({
AD_TYPE: 'fl.ad.type',
LEVEL_NAME: 'fl.level.name',
LEVEL_NUMBER: 'fl.level.number',
CONTENT_NAME: 'fl.content.name',
CONTENT_TYPE: 'fl.content.type',
CONTENT_ID: 'fl.content.id',
CREDIT_NAME: 'fl.credit.name',
CREDIT_TYPE: 'fl.credit.type',
CREDIT_ID: 'fl.credit.id',
IS_CURRENCY_SOFT: 'fl.is.currency.soft',
CURRENCY_TYPE: 'fl.currency.type',
PAYMENT_TYPE: 'fl.payment.type',
ITEM_NAME: 'fl.item.name',
ITEM_TYPE: 'fl.item.type',
ITEM_ID: 'fl.item.id',
ITEM_COUNT: 'fl.item.count',
ITEM_CATEGORY: 'fl.item.category',
ITEM_LIST_TYPE: 'fl.item.list.type',
PRICE: 'fl.price',
TOTAL_AMOUNT: 'fl.total.amount',
ACHIEVEMENT_ID: 'fl.achievement.id',
SCORE: 'fl.score',
RATING: 'fl.rating',
TRANSACTION_ID: 'fl.transaction.id',
SUCCESS: 'fl.success',
IS_ANNUAL_SUBSCRIPTION: 'fl.is.annual.subscription',
SUBSCRIPTION_COUNTRY: 'fl.subscription.country',
TRIAL_DAYS: 'fl.trial.days',
PREDICTED_LTV: 'fl.predicted.ltv',
GROUP_NAME: 'fl.group.name',
TUTORIAL_NAME: 'fl.tutorial.name',
STEP_NUMBER: 'fl.step.number',
USER_ID: 'fl.user.id',
METHOD: 'fl.method',
QUERY: 'fl.query',
SEARCH_TYPE: 'fl.search.type',
SOCIAL_CONTENT_NAME: 'fl.social.content.name',
SOCIAL_CONTENT_ID: 'fl.social.content.id',
LIKE_TYPE: 'fl.like.type',
MEDIA_NAME: 'fl.media.name',
MEDIA_TYPE: 'fl.media.type',
MEDIA_ID: 'fl.media.id',
DURATION: 'fl.duration'
});
static UserProperties = Object.freeze({
PROPERTY_CURRENCY_PREFERENCE: 'Flurry.CurrencyPreference',
PROPERTY_PURCHASER: 'Flurry.Purchaser',
PROPERTY_REGISTERED_USER: 'Flurry.RegisteredUser',
PROPERTY_SUBSCRIBER: 'Flurry.Subscriber',
set(propertyName, propertyValue) {
if (typeof propertyName !== 'string') {
console.error(`Flurry.UserProperties.set: propertyName must be string. Got ${propertyName}`);
return;
}
if (typeof propertyValue === 'string') {
ReactNativeFlurry.UserPropertiesSet(propertyName, propertyValue);
} else if (Array.isArray(propertyValue)) {
ReactNativeFlurry.UserPropertiesSetList(propertyName, propertyValue);
}
},
add(propertyName, propertyValue) {
if (typeof propertyName !== 'string') {
console.error(`Flurry.UserProperties.add: propertyName must be string. Got ${propertyName}`);
return;
}
if (typeof propertyValue === 'string') {
ReactNativeFlurry.UserPropertiesAdd(propertyName, propertyValue);
} else if (Array.isArray(propertyValue)) {
ReactNativeFlurry.UserPropertiesAddList(propertyName, propertyValue);
}
},
remove(...properties) {
if (typeof properties[0] !== 'string') {
console.error(`Flurry.UserProperties.remove: propertyName must be string. Got ${properties[0]}`);
return;
}
if (properties.length === 1) {
ReactNativeFlurry.UserPropertiesRemoveAll(properties[0]);
} else if (typeof properties[1] === 'string') {
ReactNativeFlurry.UserPropertiesRemove(properties[0], properties[1]);
} else if (Array.isArray(properties[1])) {
ReactNativeFlurry.UserPropertiesRemoveList(properties[0], properties[1]);
}
},
flag(propertyName) {
if (typeof propertyName !== 'string') {
console.error(`Flurry.UserProperties.flag: propertyName must be string. Got ${propertyName}`);
return;
}
ReactNativeFlurry.UserPropertiesFlag(propertyName);
}
});
static Performance = Object.freeze({
NONE: 0,
COLD_START: 1,
SCREEN_TIME: 2,
ALL: 3, // 1 | 2
reportFullyDrawn() {
if (Platform.OS === 'android') {
ReactNativeFlurry.reportFullyDrawn();
}
},
startResourceLogger() {
if (Platform.OS === 'android') {
ReactNativeFlurry.startPerformanceResourceLogger();
}
},
logResourceLogger(id) {
if (Platform.OS === 'android') {
if (typeof id !== 'string') {
console.error(`Flurry.Performance.logResourceLogger: id must be string. Got ${id}`);
return;
}
ReactNativeFlurry.logPerformanceResourceLogger(id);
}
}
});
static setContinueSessionMillis(sessionMillis = 10000) {
if (typeof sessionMillis !== 'number' || sessionMillis < 5000) {
console.error('Flurry.setContinueSessionMillis: the minimum timeout for a session is 5,000 ms.');
return;
}
ReactNativeFlurry.setContinueSessionMillis(sessionMillis);
}
static setCrashReporting(crashReporting = true) {
if (Platform.OS === 'android') {
if (typeof crashReporting !== 'boolean') {
console.error(`Flurry.setCrashReporting: crashReporting must be one of [true, false]. Got ${crashReporting}`);
return;
}
ReactNativeFlurry.setCrashReporting(crashReporting);
}
}
static setIncludeBackgroundSessionsInMetrics(includeBackgroundSessionsInMetrics = true) {
if (typeof includeBackgroundSessionsInMetrics !== 'boolean') {
console.error(`Flurry.setIncludeBackgroundSessionsInMetrics: includeBackgroundSessionsInMetrics must be one of [true, false]. Got ${includeBackgroundSessionsInMetrics}`);
return;
}
ReactNativeFlurry.setIncludeBackgroundSessionsInMetrics(includeBackgroundSessionsInMetrics);
}
static setLogEnabled(enableLog = true) {
if (Platform.OS === 'android') {
if (typeof enableLog !== 'boolean') {
console.error(`Flurry.setLogEnabled: enableLog must be one of [true, false]. Got ${enableLog}`);
return;
}
ReactNativeFlurry.setLogEnabled(enableLog);
}
}
static setLogLevel(logLevel = Flurry.LogLevel.WARN) {
if (Platform.OS === 'android') {
if (typeof logLevel !== 'number') {
console.error(`Flurry.setLogLevel: logLevel must be number. Got ${logLevel}`);
return;
}
ReactNativeFlurry.setLogLevel(logLevel);
}
}
static setSslPinningEnabled(sslPinningEnabled = false) {
if (Platform.OS === 'android') {
if (typeof sslPinningEnabled !== 'boolean') {
console.error(`Flurry.setSslPinningEnabled: sslPinningEnabled must be one of [true, false]. Got ${sslPinningEnabled}`);
return;
}
ReactNativeFlurry.setSslPinningEnabled(sslPinningEnabled);
}
}
static setAge(age) {
if (typeof age !== 'number' || age <= 0 || age >= 110) {
console.error(`Flurry.setAge: age must be a valid positive number between 0 and 110. Got ${age}`);
return;
}
ReactNativeFlurry.setAge(age);
}
static setGender(gender) {
if (typeof gender !== 'string' || !['m', 'f'].includes(gender)) {
console.error(`Flurry.setGender: gender must be type of Flurry.Gender. Got ${gender}`);
return;
}
ReactNativeFlurry.setGender(gender);
}
static setReportLocation(reportLocation) {
if (typeof reportLocation !== 'boolean') {
console.error(`Flurry.setReportLocation: reportLocation must be one of [true, false]. Got ${reportLocation}`);
return;
}
ReactNativeFlurry.setReportLocation(reportLocation);
}
static setSessionOrigin(originName, deepLink) {
if (typeof originName !== 'string') {
console.error(`Flurry.setSessionOrigin: originName must be string. Got ${originName}`);
return;
}
if (typeof deepLink !== 'string') {
console.error(`Flurry.setSessionOrigin: deepLink must be string. Got ${deepLink}`);
return;
}
ReactNativeFlurry.setSessionOrigin(originName, deepLink);
}
static setUserId(userId) {
if (typeof userId !== 'string') {
console.error(`Flurry.setUserId: userId must be a string. Got ${userId}`);
return;
}
ReactNativeFlurry.setUserId(userId);
}
static setVersionName(versionName = '1.0') {
if (typeof versionName !== 'string') {
console.error(`Flurry.setVersionName: versionName must be a string. Got ${versionName}`);
return;
}
ReactNativeFlurry.setVersionName(versionName);
}
static setIAPReportingEnabled(enableIAP = true) {
if (typeof enableIAP !== 'boolean') {
console.error(`Flurry.setIAPReportingEnabled: enableIAP must be one of [true, false]. Got ${enableIAP}`);
return;
}
ReactNativeFlurry.setIAPReportingEnabled(enableIAP);
}
static setGppConsent(gppString, gppSectionIds) {
if (typeof gppString !== 'string') {
console.error(`Flurry.setGppConsent: gppString must be string. Got ${gppString}`);
return;
}
if (!Array.isArray(gppSectionIds)) {
console.error(`Flurry.setGppConsent: gppSectionIds must be array. Got ${gppSectionIds}`);
return;
}
ReactNativeFlurry.setGppConsent(gppString, gppSectionIds);
}
static setDataSaleOptOut(isOptOut = false) {
if (typeof isOptOut !== 'boolean') {
console.error(`Flurry.setDataSaleOptOut: isOptOut must be one of [true, false]. Got ${isOptOut}`);
return;
}
ReactNativeFlurry.setDataSaleOptOut(isOptOut);
}
static deleteData() {
ReactNativeFlurry.deleteData();
}
static openPrivacyDashboard() {
ReactNativeFlurry.openPrivacyDashboard();
}
/**
* There are 2 overloads
* - addOrigin(originName, originVersion)
* - addOrigin(originName, originVersion, originParameters)
*/
static addOrigin(originName, originVersion, originParameters) {
if (typeof originName !== 'string') {
console.error(`Flurry.addOrigin: originName must be string. Got ${originName}`);
return;
}
if (typeof originVersion !== 'string') {
console.error(`Flurry.addOrigin: originVersion must be string. Got ${originVersion}`);
return;
}
if (arguments.length === 2) {
ReactNativeFlurry.addOrigin(originName, originVersion);
} else if (arguments.length === 3) {
if (Object.prototype.toString.call(originParameters).includes('Object')) {
ReactNativeFlurry.addOriginParams(originName, originVersion, originParameters);
} else if (Object.prototype.toString.call(originParameters).includes('Map')) {
ReactNativeFlurry.addOriginParams(originName, originVersion, Object.fromEntries(originParameters));
}
}
}
static addSessionProperty(name, value) {
if (typeof name !== 'string') {
console.error(`Flurry.addSessionProperty: name must be string. Got ${name}`);
return;
}
if (typeof value !== 'string') {
console.error(`Flurry.addSessionProperty: value must be string. Got ${value}`);
return;
}
ReactNativeFlurry.addSessionProperty(name, value);
}
static getVersions(errorCallback, successCallback) {
if (arguments.length === 0) {
return ReactNativeFlurry.getVersionsPromise();
}
ReactNativeFlurry.getVersions(errorCallback, successCallback);
}
static getPublisherSegmentation(refresh) {
if (arguments.length === 0) {
return ReactNativeFlurry.getPublisherSegmentation(false);
} else {
if (typeof refresh !== 'boolean') {
console.error(`Flurry.getPublisherSegmentation: refresh must be one of [true, false]. Got ${refresh}`);
return ReactNativeFlurry.getPublisherSegmentation(false);
}
return ReactNativeFlurry.getPublisherSegmentation(refresh);
}
}
static fetchPublisherSegmentation() {
ReactNativeFlurry.fetchPublisherSegmentation();
}
static logBreadcrumb(crashBreadcrumb) {
if (typeof crashBreadcrumb !== 'string') {
console.error(`Flurry.logBreadcrumb: crashBreadcrumb must be a string. Got ${crashBreadcrumb}`);
return;
}
ReactNativeFlurry.logBreadcrumb(crashBreadcrumb);
}
/**
* There are four overloads
* - logEvent(eventId)
* - logEvent(eventId, timed)
* - logEvent(eventId, timedId)
* - logEvent(eventId, parameters)
* - logEvent(eventId, parameters, timed)
* - logEvent(eventId, parameters, timedId)
*/
static logEvent(eventId, timedOrParameters, timed) {
if (typeof eventId !== 'string') {
console.error(`Flurry.logEvent: eventId must be a string. Got ${eventId}`);
return;
}
if (arguments.length === 1) {
ReactNativeFlurry.logEvent(eventId);
} else if (arguments.length === 2) {
if (typeof timedOrParameters === 'boolean') {
ReactNativeFlurry.logEventTimed(eventId, timedOrParameters);
} else if (typeof timedOrParameters === 'string') {
ReactNativeFlurry.logEventTimedId(eventId, timedOrParameters);
} else if (Object.prototype.toString.call(timedOrParameters).includes('Object')) {
ReactNativeFlurry.logEventParams(eventId, timedOrParameters);
} else if (Object.prototype.toString.call(timedOrParameters).includes('Map')) {
ReactNativeFlurry.logEventParams(eventId, Object.fromEntries(timedOrParameters));
}
} else if (arguments.length === 3) {
if (Object.prototype.toString.call(timedOrParameters).includes('Object')) {
if (typeof timed === 'boolean') {
ReactNativeFlurry.logEventParamsTimed(eventId, timedOrParameters, timed);
} else if (typeof timed === 'string') {
ReactNativeFlurry.logEventParamsTimedId(eventId, timedOrParameters, timed);
}
} else if (Object.prototype.toString.call(timedOrParameters).includes('Map')) {
if (typeof timed === 'boolean') {
ReactNativeFlurry.logEventParamsTimed(eventId, Object.fromEntries(timedOrParameters), timed);
} else if (typeof timed === 'string') {
ReactNativeFlurry.logEventParamsTimedId(eventId, Object.fromEntries(timedOrParameters), timed);
}
}
}
}
/**
* There are two overloads
* - endTimedEvent(eventId)
* - endTimedEvent(eventId, timedId)
* - endTimedEvent(eventId, parameters)
* - endTimedEvent(eventId, parameters, timedId)
*/
static endTimedEvent(eventId, timedIdOrParameters, timedId) {
if (typeof eventId !== 'string') {
console.error(`Flurry.logEvent: endTimedEvent must be a string. Got ${eventId}`);
return;
}
if (arguments.length === 1) {
ReactNativeFlurry.endTimedEvent(eventId);
} else if (arguments.length === 2) {
if (typeof timedIdOrParameters === 'string') {
ReactNativeFlurry.endTimedEventId(eventId, timedIdOrParameters);
} else if (Object.prototype.toString.call(timedIdOrParameters).includes('Object')) {
ReactNativeFlurry.endTimedEventParams(eventId, timedIdOrParameters);
} else if (Object.prototype.toString.call(timedIdOrParameters).includes('Map')) {
ReactNativeFlurry.endTimedEventParams(eventId, Object.fromEntries(timedIdOrParameters));
}
} else if (arguments.length === 3) {
if (typeof timedId === 'string') {
if (Object.prototype.toString.call(timedIdOrParameters).includes('Object')) {
ReactNativeFlurry.endTimedEventParamsId(eventId, timedIdOrParameters, timedId);
} else if (Object.prototype.toString.call(timedIdOrParameters).includes('Map')) {
ReactNativeFlurry.endTimedEventParamsId(eventId, Object.fromEntries(timedIdOrParameters), timedId);
}
}
}
}
static logStandardEvent(eventId, parameters) {
if (typeof eventId !== 'number') {
console.error(`Flurry.logStandardEvent: eventId must be a number. Got ${eventId}`);
return;
}
if (eventId < 0 || eventId > Flurry.Event._LAST) {
console.error(`Flurry.logStandardEvent: eventId is out of range. Got ${eventId}`);
return;
}
if (arguments.length === 1) {
ReactNativeFlurry.logStandardEvent(eventId, null);
} else if (arguments.length === 2) {
if (Object.prototype.toString.call(parameters).includes('Object')) {
ReactNativeFlurry.logStandardEvent(eventId, parameters);
} else if (Object.prototype.toString.call(parameters).includes('Map')) {
ReactNativeFlurry.logStandardEvent(eventId, Object.fromEntries(parameters));
}
}
}
static logPayment(productName, productId, quantity, price, currency, transactionId, parameters) {
if (typeof productName !== 'string') {
console.error(`Flurry.logPayment: productName must be a string. Got ${productName}`);
return;
}
if (typeof productId !== 'string') {
console.error(`Flurry.logPayment: productId must be a string. Got ${productId}`);
return;
}
if (typeof quantity !== 'number') {
console.error(`Flurry.logPayment: quantity must be a number. Got ${quantity}`);
return;
}
if (typeof price !== 'number') {
console.error(`Flurry.logPayment: price must be a number. Got ${price}`);
return;
}
if (typeof currency !== 'string') {
console.error(`Flurry.logPayment: currency must be a string. Got ${currency}`);
return;
}
if (typeof transactionId !== 'string') {
console.error(`Flurry.logPayment: transactionId must be a string. Got ${transactionId}`);
return;
}
if (Object.prototype.toString.call(parameters).includes('Object')) {
ReactNativeFlurry.logPayment(productName, productId, quantity, price, currency, transactionId, parameters);
} else if (Object.prototype.toString.call(parameters).includes('Map')) {
ReactNativeFlurry.logPayment(productName, productId, quantity, price, currency, transactionId, Object.fromEntries(parameters));
}
}
/**
* There are two overloads
* - onError(errorId, message, errorClass)
* - onError(errorId, message, errorClass, errorParams)
*/
static onError(errorId, message, errorClass, errorParams) {
if (typeof errorId !== 'string') {
console.error(`Flurry.onError: errorId must be a string. Got ${errorId}`);
return;
}
if (typeof message !== 'string') {
console.error(`Flurry.onError: message must be a string. Got ${message}`);
return;
}
if (typeof errorClass !== 'string') {
console.error(`Flurry.onError: errorClass must be a string. Got ${errorClass}`);
return;
}
if (arguments.length === 3) {
ReactNativeFlurry.onError(errorId, message, errorClass);
} else if (arguments.length === 4) {
if (Object.prototype.toString.call(errorParams).includes('Object')) {
ReactNativeFlurry.onErrorParams(errorId, message, errorClass, errorParams);
} else if (Object.prototype.toString.call(errorParams).includes('Map')) {
ReactNativeFlurry.onErrorParams(errorId, message, errorClass, Object.fromEntries(errorParams));
}
}
}
static onPageView() {
console.warn(`Flurry.onPageView method is deprecated. API removed, no longer supported by Flurry.`);
ReactNativeFlurry.onPageView();
}
static updateConversionValue(conversionValue) {
if (Platform.OS === 'ios') {
if (typeof conversionValue !== 'number') {
console.error(`Flurry.updateConversionValue: conversionValue must be a number. Got ${conversionValue}`);
return;
}
ReactNativeFlurry.updateConversionValue(conversionValue);
}
}
static updateConversionValueWithEvent(flurryEvent) {
if (Platform.OS === 'ios') {
if (typeof flurryEvent !== 'number') {
console.error(`Flurry.updateConversionValueWithEvent: flurryEvent must be a number. Got ${flurryEvent}`);
return;
}
ReactNativeFlurry.updateConversionValueWithEvent(flurryEvent);
}
}
static addConfigListener(callback) {
if (typeof callback !== 'function') {
console.error(`Flurry.addConfigListener: callback must be a function. Got ${callback}`);
return;
}
var Emitter = (Platform.OS === 'android') ? DeviceEventEmitter : NativeAppEventEmitter;
Emitter.addListener('FlurryConfigEvent', callback);
ReactNativeFlurry.registerConfigListener();
}
static removeConfigListener(callback) {
if (typeof callback !== 'function') {
console.error(`Flurry.removeConfigListener: callback must be a function. Got ${callback}`);
return;
}
var Emitter = (Platform.OS === 'android') ? DeviceEventEmitter : NativeAppEventEmitter;
Emitter.removeListener('FlurryConfigEvent', callback);
ReactNativeFlurry.unregisterConfigListener();
}
static fetchConfig() {
ReactNativeFlurry.fetchConfig();
}
static activateConfig() {
ReactNativeFlurry.activateConfig();
}
static getConfigString(keyOrDefaults, defaultValue) {
if (arguments.length === 1) {
return ReactNativeFlurry.getConfigStringMap(keyOrDefaults);
} else if (arguments.length === 2) {
if (typeof keyOrDefaults !== 'string') {
console.error(`Flurry.getConfigString: key must be a string. Got ${keyOrDefaults}`);
return;
}
if (typeof defaultValue !== 'string') {
console.error(`Flurry.getConfigString: defaultValue must be a string. Got ${defaultValue}`);
return;
}
return ReactNativeFlurry.getConfigString(keyOrDefaults, defaultValue);
}
}
static addMessagingListener(callback) {
if (typeof callback !== 'function') {
console.error(`Flurry.addMessagingListener: callback must be a function. Got ${callback}`);
return;
}
var Emitter = (Platform.OS === 'android') ? DeviceEventEmitter : NativeAppEventEmitter;
Emitter.addListener('FlurryMessagingEvent', callback);
ReactNativeFlurry.enableMessagingListener(true);
}
static removeMessagingListener(callback) {
if (typeof callback !== 'function') {
console.error(`Flurry.removeMessagingListener: callback must be a function. Got ${callback}`);
return;
}
var Emitter = (Platform.OS === 'android') ? DeviceEventEmitter : NativeAppEventEmitter;
Emitter.removeListener('FlurryMessagingEvent', callback);
}
static willHandleMessage(handled) {
ReactNativeFlurry.willHandleMessage(handled);
}
static printMessage(message) {
if (message.Type === Flurry.MessageType.REFRESH) {
console.log('Flurry Messaging Type: ' + message.Type +
'\n Token: ' + message.Token);
return;
}
var data = '';
for (var prop in message.Data) {
data += '\n\t' + prop + ': ' + message.Data[prop];
}
console.log('Flurry Messaging Type: ' + message.Type +
'\n Title: ' + message.Title +
'\n Body: ' + message.Body +
'\n ClickAction: ' + message.ClickAction +
'\n Data:' + data);
}
}