-
Notifications
You must be signed in to change notification settings - Fork 290
Expand file tree
/
Copy pathCountlyConfig.java
More file actions
1131 lines (967 loc) · 38.9 KB
/
CountlyConfig.java
File metadata and controls
1131 lines (967 loc) · 38.9 KB
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
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package ly.count.android.sdk;
import android.app.Application;
import android.content.Context;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class CountlyConfig {
/**
* Internal fields and fields for testing
*/
protected CountlyStore countlyStore = null;
/**
* Used to pass the consent provider to all modules and features
*/
protected ConsentProvider consentProvider = null;
/**
* Used to pass the storage provider to all modules and features
*/
protected StorageProvider storageProvider = null;
protected EventProvider eventProvider = null;
protected EventQueueProvider eventQueueProvider = null;
protected RequestQueueProvider requestQueueProvider = null;
protected DeviceIdProvider deviceIdProvider = null;
protected ViewIdProvider viewIdProvider = null;
protected BaseInfoProvider baseInfoProvider = null;
protected ConfigurationProvider configProvider = null;
protected SafeIDGenerator safeViewIDGenerator = null;
protected SafeIDGenerator safeEventIDGenerator = null;
protected ImmediateRequestGenerator immediateRequestGenerator = null;
protected HealthTracker healthTracker;
protected MetricProvider metricProviderOverride = null;
protected DeviceInfo deviceInfo = null;
protected ModuleBase testModuleListener = null;
protected Map<String, Object> providedUserProperties = null;
protected Countly.LifecycleObserver lifecycleObserver = null;
//used to deliver this object to connection queue
//protected DeviceId deviceIdInstance = null;
// Fields used for SDK configuration during init
/**
* Android context.
* Mandatory field.
*/
protected Context context = null;
/**
* URL of the Countly server to submit data to.
* Mandatory field.
*/
protected String serverURL = null;
/**
* app key for the application being tracked; find in the Countly Dashboard under Management > Applications.
* Mandatory field.
*/
protected String appKey = null;
/**
* unique ID for the device the app is running on; note that null in deviceID means that Countly will fall back to UUID.
*/
protected String deviceID = null;
/**
* sets the limit after how many sessions, for each apps version, the automatic star rating dialog is shown.
*/
protected int starRatingSessionLimit = 5;
/**
* the callback function that will be called from the automatic star rating dialog.
*/
protected StarRatingCallback starRatingCallback = null;
/**
* the shown title text for the star rating dialogs.
*/
protected String starRatingTextTitle = null;
/**
* the shown message text for the star rating dialogs.
*/
protected String starRatingTextMessage = null;
/**
* the shown dismiss button text for the shown star rating dialogs.
*/
protected String starRatingTextDismiss = null;
protected boolean loggingEnabled = false;
protected boolean enableAutomaticViewTracking = false;
protected boolean autoTrackingUseShortName = false;
protected Class[] automaticViewTrackingExceptions = null;
protected Map<String, Object> globalViewSegmentation = null;
protected Map<String, String> customNetworkRequestHeaders = null;
protected boolean pushIntentAddMetadata = false;
protected boolean enableRemoteConfigAutomaticDownloadTriggers = false;
protected boolean enableAutoEnrollFlag = false;
boolean enableRemoteConfigValueCaching = false;
protected RemoteConfigCallback remoteConfigCallbackLegacy = null;
protected List<RCDownloadCallback> remoteConfigGlobalCallbackList = new ArrayList<>(2);
protected boolean shouldRequireConsent = false;
protected boolean enableAllConsents = false;
protected String[] enabledFeatureNames = null;
protected boolean httpPostForced = false;
protected boolean temporaryDeviceIdEnabled = false;
protected String tamperingProtectionSalt = null;
protected Integer eventQueueSizeThreshold = null;
protected boolean trackOrientationChange = true;
protected boolean manualSessionControlEnabled = false;
protected boolean manualSessionControlHybridModeEnabled = false;
protected boolean disableUpdateSessionRequests = false;
protected boolean shouldIgnoreAppCrawlers = false;
protected String[] appCrawlerNames = null;
protected String[] publicKeyPinningCertificates = null;
protected String[] certificatePinningCertificates = null;
protected Integer sessionUpdateTimerDelay = null;
/**
* @deprecated This is deprecated, will be removed in the future
*/
protected CrashFilterCallback crashFilterCallback;
protected boolean starRatingDialogIsCancellable = false;
protected boolean starRatingShownAutomatically = false;
protected boolean starRatingDisableAskingForEachAppVersion = false;
protected Application application = null;
boolean disableLocation = false;
String locationCountyCode = null;
String locationCity = null;
String locationLocation = null;
String locationIpAddress = null;
Map<String, String> metricOverride = null;
int maxRequestQueueSize = 1000;
ModuleLog.LogCallback providedLogCallback;
String daCampaignType = null;
String daCampaignData = null;
Map<String, String> iaAttributionValues = null;
boolean explicitStorageModeEnabled = false;
boolean healthCheckEnabled = true;
// Requests older than this value in hours would be dropped (0 means this feature is disabled)
int dropAgeHours = 0;
String sdkBehaviorSettings;
boolean backOffMechanismEnabled = true;
boolean sdkBehaviorSettingsRequestsDisabled = false;
int requestTimeoutDuration = 30; // in seconds
// If set to true, immediate requests will use serial AsyncTask executor instead of the thread pool
boolean useSerialExecutor = false;
WebViewDisplayOption webViewDisplayOption = WebViewDisplayOption.IMMERSIVE;
// If set to true, request queue cleaner will remove all overflow at once instead of gradually (loop limited) removing
boolean disableGradualRequestCleaner = false;
/**
* THIS VARIABLE SHOULD NOT BE USED
* IT IS ONLY FOR INTERNAL TESTING
* BREAKING CHANGES WILL BE DONE WITHOUT WARNING
*/
public PerformanceCounterCollector pcc;
/**
* Sets how many segmentation values can be recorded when recording an event or view.
* Values exceeding this count will be ignored.
*
* @param maxSegmentationValues to set
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated, use <pre>sdkInternalLimits.setMaxSegmentationValues(int)</pre> instead
*/
public synchronized CountlyConfig setMaxSegmentationValues(int maxSegmentationValues) {
sdkInternalLimits.setMaxSegmentationValues(maxSegmentationValues);
return this;
}
/**
* Set the maximum amount of breadcrumbs that can be recorded.
* After exceeding the limit, the oldest values will be removed.
*
* @param maxBreadcrumbCount to set
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated, use <pre>sdkInternalLimits.setMaxBreadcrumbCount(int)</pre> instead
*/
public synchronized CountlyConfig setMaxBreadcrumbCount(int maxBreadcrumbCount) {
sdkInternalLimits.setMaxBreadcrumbCount(maxBreadcrumbCount);
return this;
}
public CountlyConfig() {
}
/**
* @param context
* @param appKey
* @param serverURL
*/
public CountlyConfig(Context context, String appKey, String serverURL) {
setContext(context);
setAppKey(appKey);
setServerURL(serverURL);
}
public CountlyConfig(Application application, String appKey, String serverURL) {
setAppKey(appKey);
setServerURL(serverURL);
setApplication(application);
}
/**
* Android context.
* Mandatory field.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setContext(Context context) {
this.context = context;
return this;
}
/**
* URL of the Countly server to submit data to.
* Mandatory field.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setServerURL(String serverURL) {
this.serverURL = serverURL;
return this;
}
/**
* app key for the application being tracked; find in the Countly Dashboard under Management > Applications.
* Mandatory field.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setAppKey(String appKey) {
this.appKey = appKey;
return this;
}
/**
* unique ID for the device the app is running on; note that null in deviceID means that Countly will fall back to UUID.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setDeviceId(String deviceID) {
this.deviceID = deviceID;
return this;
}
/**
* sets the limit after how many sessions, for each apps version, the automatic star rating dialog is shown.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setStarRatingSessionLimit(int starRatingLimit) {
this.starRatingSessionLimit = starRatingLimit;
return this;
}
/**
* the callback function that will be called from the automatic star rating dialog.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setStarRatingCallback(StarRatingCallback starRatingCallback) {
this.starRatingCallback = starRatingCallback;
return this;
}
/**
* the shown title text for the star rating dialogs.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setStarRatingTextTitle(String starRatingTextTitle) {
this.starRatingTextTitle = starRatingTextTitle;
return this;
}
/**
* the shown message text for the star rating dialogs.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setStarRatingTextMessage(String starRatingTextMessage) {
this.starRatingTextMessage = starRatingTextMessage;
return this;
}
/**
* the shown dismiss button text for the shown star rating dialogs.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setStarRatingTextDismiss(String starRatingTextDismiss) {
this.starRatingTextDismiss = starRatingTextDismiss;
return this;
}
/**
* Set to true of you want to enable countly internal debugging logs
* Those logs will be printed to the console
*
* @param enabled Set to true of you want to enable countly internal debugging logs
*/
public synchronized CountlyConfig setLoggingEnabled(boolean enabled) {
this.loggingEnabled = enabled;
return this;
}
/**
* Call to enable uncaught crash reporting
*
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated, please use <pre>crashes.enableCrashReporting()</pre> instead
*/
public synchronized CountlyConfig enableCrashReporting() {
crashes.enableCrashReporting();
return this;
}
/**
* Set if automatic view tracking should be enabled
*
* @param enable
* @return Returns the same config object for convenient linking
* @deprecated Use "enableAutomaticViewTracking()"
*/
public synchronized CountlyConfig setViewTracking(boolean enable) {
this.enableAutomaticViewTracking = enable;
return this;
}
/**
* Enable automatic view tracking
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enableAutomaticViewTracking() {
this.enableAutomaticViewTracking = true;
return this;
}
/**
* Enable short names for automatic view tracking
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enableAutomaticViewShortNames() {
this.autoTrackingUseShortName = true;
return this;
}
/**
* Set if automatic activity tracking should use short names
*
* @param enable set true if you want short names
* @return Returns the same config object for convenient linking
* @deprecated use "enableAutomaticViewShortNames()"
*/
public synchronized CountlyConfig setAutoTrackingUseShortName(boolean enable) {
this.autoTrackingUseShortName = enable;
return this;
}
/**
* @param segmentation segmentation values that will be added for all recorded views (manual and automatic)
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setGlobalViewSegmentation(Map<String, Object> segmentation) {
globalViewSegmentation = segmentation;
return this;
}
/**
* @param segmentation
* @return Returns the same config object for convenient linking
* @deprecated please use "setGlobalViewSegmentation(Map<String, Object>)"
*/
public synchronized CountlyConfig setAutomaticViewSegmentation(Map<String, Object> segmentation) {
globalViewSegmentation = segmentation;
return this;
}
/**
* Set which activities should be excluded from automatic view tracking
*
* @param exclusions activities which should be ignored
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setAutomaticViewTrackingExclusions(Class[] exclusions) {
if (exclusions != null) {
for (Class exception : exclusions) {
if (exception == null) {
throw new IllegalArgumentException("setAutomaticViewTrackingExclusions(...) does not accept 'null' activities");
}
}
}
automaticViewTrackingExceptions = exclusions;
return this;
}
/**
* Set which activities should be excluded from automatic view tracking
*
* @param exceptions activities which should be ignored
* @return Returns the same config object for convenient linking
* @deprecated Use "setAutomaticViewTrackingExclusions(Class[])"
*/
public synchronized CountlyConfig setAutoTrackingExceptions(Class[] exceptions) {
return setAutomaticViewTrackingExclusions(exceptions);
}
/**
* Allows you to add custom header key/value pairs to each request
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig addCustomNetworkRequestHeaders(Map<String, String> customHeaderValues) {
this.customNetworkRequestHeaders = customHeaderValues;
return this;
}
/**
* @param enable
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setPushIntentAddMetadata(boolean enable) {
pushIntentAddMetadata = enable;
return this;
}
/**
* If enable, will automatically download newest remote config values.
*
* @param enabled set true for enabling it
* @param callback callback called after the update was done
* @return Returns the same config object for convenient linking
* @deprecated use "enableRemoteConfigAutomaticTriggers" and "RemoteConfigRegisterGlobalCallback" in it's place
*/
public synchronized CountlyConfig setRemoteConfigAutomaticDownload(boolean enabled, RemoteConfigCallback callback) {
enableRemoteConfigAutomaticDownloadTriggers = enabled;
remoteConfigCallbackLegacy = callback;
return this;
}
/**
* Calling this would enable automatic download triggers for remote config.
* This way the SDK would automatically initiate remote config download at specific points.
* For example, those include: the SDK finished initializing, device ID is changed, consent is given
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enableRemoteConfigAutomaticTriggers() {
enableRemoteConfigAutomaticDownloadTriggers = true;
return this;
}
/**
* Calling this would enable automatic enrollment of the user to the available experiments when RC is downloaded.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enrollABOnRCDownload() {
enableAutoEnrollFlag = true;
return this;
}
/**
* This would set a time frame in which the requests older than the given hours would be dropped while sending a request
* Ex: Setting this to 10 would mean any requests created more than 10 hours ago would be dropped if they were in the queue
*
* @param dropAgeHours A positive integer. Requests older than the 'dropAgeHours' (with respect to now) would be dropped
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setRequestDropAgeHours(int dropAgeHours) {
this.dropAgeHours = dropAgeHours;
return this;
}
/**
* If this option is not enabled then when the device ID is changed without merging, remote config values are cleared
* If this option is enabled then the previous values are not cleared but they are marked as not from the current user.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enableRemoteConfigValueCaching() {
enableRemoteConfigValueCaching = true;
return this;
}
/**
* Calling this adds global listeners for remote config download callbacks.
* Calling this multiple times would add multiple listeners
*
* @param callback The callback that needs to be registered
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig RemoteConfigRegisterGlobalCallback(RCDownloadCallback callback) {
remoteConfigGlobalCallbackList.add(callback);
return this;
}
/**
* Set if consent should be required
*
* @param shouldRequireConsent if set to "true" then the SDK will require consent to be used. If consent for features is not given, they would not function
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setRequiresConsent(boolean shouldRequireConsent) {
this.shouldRequireConsent = shouldRequireConsent;
return this;
}
/**
* Sets which features are enabled in case consent is required
*
* @param featureNames
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setConsentEnabled(String[] featureNames) {
enabledFeatureNames = featureNames;
return this;
}
/**
* Give consent to all features
*
* @return
*/
public synchronized CountlyConfig giveAllConsents() {
enableAllConsents = true;
return this;
}
/**
* Set the override for forcing to use HTTP POST for all connections to the server
*
* @param isForced the flag for the new status, set "true" if you want it to be forced
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setHttpPostForced(boolean isForced) {
httpPostForced = isForced;
return this;
}
/**
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enableTemporaryDeviceIdMode() {
temporaryDeviceIdEnabled = true;
return this;
}
/**
* @param callback
* @return Returns the same config object for convenient linking
* @deprecated This call is deprecated, please use <pre>crashes.setGlobalCrashFilterCallback(GlobalCrashFilterCallback)</pre> instead
*/
public synchronized CountlyConfig setCrashFilterCallback(CrashFilterCallback callback) {
crashFilterCallback = callback;
return this;
}
/**
* @param salt
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setParameterTamperingProtectionSalt(String salt) {
tamperingProtectionSalt = salt;
return this;
}
/**
* @param shouldTrackOrientation
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setTrackOrientationChanges(boolean shouldTrackOrientation) {
trackOrientationChange = shouldTrackOrientation;
return this;
}
/**
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated, please use <pre>crashes.enableRecordAllThreadsWithCrash()</pre> instead
*/
public synchronized CountlyConfig setRecordAllThreadsWithCrash() {
crashes.enableRecordAllThreadsWithCrash();
return this;
}
/**
* Set if attribution should be enabled
*
* @param enableAttribution set true if you want to enable it, set false if you want to disable it
* @return Returns the same config object for convenient linking
* @deprecated This call will not do anything anymore. Use 'setDirectAttribution' or 'setIndirectAttribution' for attribution purposes
*/
public synchronized CountlyConfig setEnableAttribution(boolean enableAttribution) {
return this;
}
/**
* Allows public key pinning.
* Supply list of SSL certificates (base64-encoded strings between "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" without end-of-line)
* along with server URL starting with "https://". Countly will only accept connections to the server
* if public key of SSL certificate provided by the server matches one provided to this method.
*
* @param certificates List of SSL public keys
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enablePublicKeyPinning(String[] certificates) {
publicKeyPinningCertificates = certificates;
return this;
}
/**
* Allows certificate pinning.
* Supply list of SSL certificates (base64-encoded strings between "-----BEGIN CERTIFICATE-----" and "-----END CERTIFICATE-----" without end-of-line)
* along with server URL starting with "https://". Countly will only accept connections to the server
* if certificate provided by the server matches one provided to this method.
*
* @param certificates List of SSL certificates
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enableCertificatePinning(String[] certificates) {
certificatePinningCertificates = certificates;
return this;
}
/**
* Set if Countly SDK should ignore app crawlers
*
* @param shouldIgnore if crawlers should be ignored
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setShouldIgnoreAppCrawlers(boolean shouldIgnore) {
shouldIgnoreAppCrawlers = shouldIgnore;
return this;
}
/**
* List of app crawler names that should be ignored
*
* @param appCrawlerNames the names to be ignored
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setAppCrawlerNames(String[] appCrawlerNames) {
this.appCrawlerNames = appCrawlerNames;
return this;
}
/**
* Set the threshold for event grouping. Event count that is bellow the
* threshold will be sent on update ticks.
*
* @param threshold
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setEventQueueSizeToSend(int threshold) {
eventQueueSizeThreshold = threshold;
return this;
}
public synchronized CountlyConfig enableManualSessionControl() {
manualSessionControlEnabled = true;
return this;
}
public synchronized CountlyConfig enableManualSessionControlHybridMode() {
manualSessionControlHybridModeEnabled = true;
return this;
}
/**
* Set custom crash segmentation which will be added to all recorded crashes
*
* @param crashSegment segmentation information. Accepted values are "Integer", "String", "Double", "Boolean"
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated, please use <pre>crashes.setCustomCrashSegmentation(Map<String, Object>)</pre> instead
*/
public synchronized CountlyConfig setCustomCrashSegment(Map<String, Object> crashSegment) {
crashes.setCustomCrashSegmentation(crashSegment);
return this;
}
/**
* For use during testing
*
* @param checkForDumps whether to check for native crash dumps
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated and will always be enabled
*/
protected synchronized CountlyConfig checkForNativeCrashDumps(boolean checkForDumps) {
return this;
}
/**
* Sets the interval for the automatic session update calls
* min value 1 (1 second)
*
* @param delay in seconds
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setUpdateSessionTimerDelay(int delay) {
sessionUpdateTimerDelay = delay;
return this;
}
/**
* For use during testing
*
* @param store
* @return Returns the same config object for convenient linking
*/
protected synchronized CountlyConfig setCountlyStore(CountlyStore store) {
countlyStore = store;
return this;
}
/**
* Disable periodic session time updates.
* By default, Countly will send a request to the server each 60 seconds with a small update
* containing session duration time. This method allows you to disable such behavior.
* Note that event updates will still be sent every 100 events or 60 seconds after event recording.
*
* @param disable whether or not to disable session time updates
* @return Returns the same config object for convenient linking
*/
protected synchronized CountlyConfig setDisableUpdateSessionRequests(boolean disable) {
disableUpdateSessionRequests = disable;
return this;
}
/**
* Set if the star rating dialog is cancellable
*
* @param isCancellable set this true if it should be cancellable
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setIfStarRatingDialogIsCancellable(boolean isCancellable) {
starRatingDialogIsCancellable = isCancellable;
return this;
}
/**
* Set if the star rating should be shown automatically
*
* @param isShownAutomatically set it true if you want to show the app star rating dialog automatically for each new version after the specified session amount
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setIfStarRatingShownAutomatically(boolean isShownAutomatically) {
starRatingShownAutomatically = isShownAutomatically;
return this;
}
/**
* Set if the star rating is shown only once per app lifetime
*
* @param disableAsking set true if you want to disable asking the app rating for each new app version (show it only once per apps lifetime)
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setStarRatingDisableAskingForEachAppVersion(boolean disableAsking) {
starRatingDisableAskingForEachAppVersion = disableAsking;
return this;
}
/**
* Set the link to the application class
*
* @param application
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setApplication(Application application) {
this.application = application;
return this;
}
/**
* Enable the recording of the app start time
*
* @param recordAppStartTime set true if you want to enable the recording of the app start time
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated, use <pre>apm.enableAppStartTracking()</pre> instead
*/
public synchronized CountlyConfig setRecordAppStartTime(boolean recordAppStartTime) {
apm.trackAppStartTime = recordAppStartTime;
return this;
}
/**
* Disable location tracking
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setDisableLocation() {
disableLocation = true;
return this;
}
/**
* Set location parameters.
* This will be ignored if set together with `setDisableLocation`
*
* @param country_code ISO Country code for the user's country
* @param city Name of the user's city
* @param gpsCoordinates comma separate lat and lng values. For example, "56.42345,123.45325"
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setLocation(String country_code, String city, String gpsCoordinates, String ipAddress) {
locationCountyCode = country_code;
locationCity = city;
locationLocation = gpsCoordinates;
locationIpAddress = ipAddress;
return this;
}
/**
* Set the metrics you want to override or additional custom metrics you want to provide
*
* @param providedMetricOverride
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setMetricOverride(Map<String, String> providedMetricOverride) {
metricOverride = providedMetricOverride;
return this;
}
/**
* Override the app start timestamp in case you have a more precise way to measure it
*
* @param appStartTimestampOverride The timestamp to use as the app start timestamp
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated, use <pre>apm.setAppStartTimestampOverride()</pre> instead
*/
public synchronized CountlyConfig setAppStartTimestampOverride(long appStartTimestampOverride) {
apm.setAppStartTimestampOverride(appStartTimestampOverride);
return this;
}
/**
* Set to manually trigger the moment when the app has finished loading
*
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated, use <pre>apm.enableManualAppLoadedTrigger()</pre> instead
*/
public synchronized CountlyConfig enableManualAppLoadedTrigger() {
apm.enableManualAppLoadedTrigger();
return this;
}
/**
* Set this in case you want to control these triggers manually
*
* @return Returns the same config object for convenient linking
* @deprecated this call is deprecated and will be removed in the future
*/
public synchronized CountlyConfig enableManualForegroundBackgroundTriggerAPM() {
apm.manualForegroundBackgroundTrigger = true;
return this;
}
/**
* Add a log callback that will duplicate all logs done by the SDK.
* For each message you will receive the message string and it's targeted log level.
*
* @param logCallback
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setLogListener(ModuleLog.LogCallback logCallback) {
providedLogCallback = logCallback;
return this;
}
/**
* Set's the new maximum size for the request queue.
*
* @param newMaxSize Minimum value is "1".
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setMaxRequestQueueSize(int newMaxSize) {
maxRequestQueueSize = newMaxSize;
return this;
}
/**
* Report direct user attribution
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setDirectAttribution(String campaignType, String campaignData) {
daCampaignType = campaignType;
daCampaignData = campaignData;
return this;
}
/**
* Report indirect user attribution
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setIndirectAttribution(Map<String, String> attributionValues) {
iaAttributionValues = attributionValues;
return this;
}
/**
* Used to provide user properties that would be sent as soon as possible
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig setUserProperties(Map<String, Object> userProperties) {
providedUserProperties = userProperties;
return this;
}
/**
* If this mode is enabled then the SDK not write the request and event queues to disk
* until the explicit write signal is given.
*
* The explicit write signal is given with:
* 'Countly.sharedInstance().requestQueue().esWriteCachesToPersistence();'
*
* If not used properly, this mode will lead to data loss or data duplication.
*
* @return Returns the same config object for convenient linking
*/
public synchronized CountlyConfig enableExplicitStorageMode() {
explicitStorageModeEnabled = true;
return this;
}
/**
* This is an experimental feature and it can have breaking changes
*
* With this mode enable, the SDK will acquire additional configuration from it's Countly server
*