1
+ import { initialize } from './Logger.js' ;
1
2
/**
2
3
* Countly SDK React Native Bridge
3
4
* https://github.com/Countly/countly-sdk-react-native-bridge
11
12
* @param {String } serverURL server url
12
13
* @param {String } appKey application key
13
14
*/
14
- import CountlyInternal from './Countly.js' ;
15
-
16
15
class CountlyConfig {
17
16
constructor ( serverURL , appKey ) {
18
17
this . serverURL = serverURL ;
19
18
this . appKey = appKey ;
20
19
}
21
20
22
21
/**
23
- * Method to set the server url
24
- *
25
- * @param {String } serverURL server url
26
- */
22
+ * Method to set the server url
23
+ *
24
+ * @param {String } serverURL server url
25
+ */
27
26
setServerURL ( serverURL ) {
28
27
this . serverURL = serverURL ;
29
28
return this ;
30
29
}
31
30
32
31
/**
33
- * Method to set the app key
34
- *
35
- * @param {String } appKey application key
36
- */
32
+ * Method to set the app key
33
+ *
34
+ * @param {String } appKey application key
35
+ */
37
36
setAppKey ( appKey ) {
38
37
this . appKey = appKey ;
39
38
return this ;
40
39
}
41
40
42
41
/**
43
- * Method to set the device id
44
- *
45
- * @param {String } deviceID device id
46
- */
42
+ * Method to set the device id
43
+ *
44
+ * @param {String } deviceID device id
45
+ */
47
46
setDeviceID ( deviceID ) {
48
47
this . deviceID = deviceID ;
49
48
return this ;
50
49
}
51
50
52
51
/**
53
- * Method to enable countly internal debugging logs
54
- *
55
- * @param {bool } loggingEnabled enable
56
- * if true, countly sdk would log to console.
57
- */
52
+ * Method to enable countly internal debugging logs
53
+ *
54
+ * @param {bool } loggingEnabled enable
55
+ * if true, countly sdk would log to console.
56
+ */
58
57
setLoggingEnabled ( loggingEnabled ) {
59
58
this . loggingEnabled = loggingEnabled ;
60
- CountlyInternal . setLoggingEnabled ( loggingEnabled ) ;
59
+ initialize ( loggingEnabled ) ; // initialize React Native SDK logger
61
60
return this ;
62
61
}
63
62
64
63
/**
65
- * Method to enable crash reporting to report unhandled crashes to Countly
66
- */
64
+ * Method to enable crash reporting to report unhandled crashes to Countly
65
+ */
67
66
enableCrashReporting ( ) {
68
67
this . crashReporting = true ;
69
68
return this ;
70
69
}
71
70
72
71
/**
73
- * Method to set if the consent feature is enabled.
74
- *
75
- * If set to true, no feature will work without consent being given.
76
- *
77
- * @param {bool } shouldRequireConsent required. True: It is enabled. False:
78
- * It is disabled.
79
- */
72
+ * Method to set if the consent feature is enabled.
73
+ *
74
+ * If set to true, no feature will work without consent being given.
75
+ *
76
+ * @param {bool } shouldRequireConsent required. True: It is enabled. False:
77
+ * It is disabled.
78
+ */
80
79
setRequiresConsent ( shouldRequireConsent ) {
81
80
this . shouldRequireConsent = shouldRequireConsent ;
82
81
return this ;
83
82
}
84
83
85
84
/**
86
- * Method to give consent for specific features before init
87
- *
88
- * @param {String[] } consents consents e.g ['location', 'sessions',
89
- * 'attribution', 'push', 'events', 'views', 'crashes', 'users', 'push',
90
- * 'star-rating', 'apm', 'feedback', 'remote-config']
91
- */
85
+ * Method to give consent for specific features before init
86
+ *
87
+ * @param {String[] } consents consents e.g ['location', 'sessions',
88
+ * 'attribution', 'push', 'events', 'views', 'crashes', 'users', 'push',
89
+ * 'star-rating', 'apm', 'feedback', 'remote-config']
90
+ */
92
91
giveConsent ( consents ) {
93
92
this . consents = consents ;
94
93
return this ;
95
94
}
96
95
97
96
/**
98
- * Method to set the user initial location
99
- *
100
- * @param {String } locationCountryCode country code e.g 'TR'
101
- * @param {String } locationCity city e.g 'Istanbul'
102
- * @param {String } locationGpsCoordinates gps coordinates e.g '41.0082,28.9784'
103
- * @param {String } locationIpAddress ip address e.g '10.2.33.12'
104
- */
97
+ * Method to set the user initial location
98
+ *
99
+ * @param {String } locationCountryCode country code e.g 'TR'
100
+ * @param {String } locationCity city e.g 'Istanbul'
101
+ * @param {String } locationGpsCoordinates gps coordinates e.g '41.0082,28.9784'
102
+ * @param {String } locationIpAddress ip address e.g '10.2.33.12'
103
+ */
105
104
setLocation ( locationCountryCode , locationCity , locationGpsCoordinates , locationIpAddress ) {
106
105
this . locationCountryCode = locationCountryCode ;
107
106
this . locationCity = locationCity ;
@@ -111,35 +110,35 @@ class CountlyConfig {
111
110
}
112
111
113
112
/**
114
- * Method to enable tamper protection. This sets the optional salt to be
115
- * used for calculating the checksum of requested data which will be sent
116
- * with each request
117
- *
118
- * @param {String } tamperingProtectionSalt salt
119
- */
113
+ * Method to enable tamper protection. This sets the optional salt to be
114
+ * used for calculating the checksum of requested data which will be sent
115
+ * with each request
116
+ *
117
+ * @param {String } tamperingProtectionSalt salt
118
+ */
120
119
enableParameterTamperingProtection ( tamperingProtectionSalt ) {
121
120
this . tamperingProtectionSalt = tamperingProtectionSalt ;
122
121
return this ;
123
122
}
124
123
125
124
/**
126
- * Method to enable application performance monitoring which includes the recording of app start time.
127
- */
125
+ * Method to enable application performance monitoring which includes the recording of app start time.
126
+ */
128
127
enableApm ( ) {
129
128
this . enableApm = true ;
130
129
return this ;
131
130
}
132
131
133
132
/**
134
- * Method to set the push token type
135
- * @deprecated
136
- * Use setPushTokenType() instead to set pushToken
137
- * Use setPushNotificationChannelInformation() instead to set channel information
138
- *
139
- * @param {TokenType } tokenType token type
140
- * @param {String } channelName channel name
141
- * @param {String } channelDescription channel description
142
- */
133
+ * Method to set the push token type
134
+ * @deprecated
135
+ * Use setPushTokenType() instead to set pushToken
136
+ * Use setPushNotificationChannelInformation() instead to set channel information
137
+ *
138
+ * @param {TokenType } tokenType token type
139
+ * @param {String } channelName channel name
140
+ * @param {String } channelDescription channel description
141
+ */
143
142
pushTokenType ( tokenType , channelName , channelDescription ) {
144
143
this . tokenType = tokenType ;
145
144
this . channelName = channelName ;
@@ -148,61 +147,61 @@ class CountlyConfig {
148
147
}
149
148
150
149
/**
151
- * Method to set the push token type
152
- * NB: ONLY FOR iOS
153
- *
154
- * @param {Countly.messagingMode } tokenType token type
155
- * Possible values include 'DEVELOPMENT', 'PRODUCTION', 'ADHOC'.
156
- */
150
+ * Method to set the push token type
151
+ * NB: ONLY FOR iOS
152
+ *
153
+ * @param {Countly.messagingMode } tokenType token type
154
+ * Possible values include 'DEVELOPMENT', 'PRODUCTION', 'ADHOC'.
155
+ */
157
156
setPushTokenType ( tokenType ) {
158
157
this . tokenType = tokenType ;
159
158
return this ;
160
159
}
161
160
162
161
/**
163
- * Method to set the push channel name and description
164
- * NB: ONLY FOR ANDROID
165
- *
166
- * @param {String } name channel name
167
- * @param {String } description channel description
168
- */
162
+ * Method to set the push channel name and description
163
+ * NB: ONLY FOR ANDROID
164
+ *
165
+ * @param {String } name channel name
166
+ * @param {String } description channel description
167
+ */
169
168
setPushNotificationChannelInformation ( name , description ) {
170
169
this . channelName = name ;
171
170
this . channelDescription = description ;
172
171
return this ;
173
172
}
174
173
175
174
/**
176
- * Method to set the push notification accent color
177
- * NB: ONLY FOR ANDROID
178
- *
179
- * @param {String } accentColor notification accent color
180
- * example '#000000'
181
- */
175
+ * Method to set the push notification accent color
176
+ * NB: ONLY FOR ANDROID
177
+ *
178
+ * @param {String } accentColor notification accent color
179
+ * example '#000000'
180
+ */
182
181
setPushNotificationAccentColor ( accentColor ) {
183
182
this . accentColor = accentColor ;
184
183
return this ;
185
184
}
186
185
187
186
/**
188
- * Method to configure intent redirection check
189
- *
190
- * @param {String[] } allowedIntentClassNames allowed intent class names
191
- * @param {String[] } allowedIntentPackageNames allowed intent package name
192
- */
187
+ * Method to configure intent redirection check
188
+ *
189
+ * @param {String[] } allowedIntentClassNames allowed intent class names
190
+ * @param {String[] } allowedIntentPackageNames allowed intent package name
191
+ */
193
192
configureIntentRedirectionCheck ( allowedIntentClassNames , allowedIntentPackageNames ) {
194
193
this . allowedIntentClassNames = allowedIntentClassNames ;
195
194
this . allowedIntentPackageNames = allowedIntentPackageNames ;
196
195
return this ;
197
196
}
198
197
199
198
/**
200
- * Method to set star rating dialog text
201
- *
202
- * @param {String } starRatingTextTitle title
203
- * @param {String } starRatingTextMessage message
204
- * @param {String } starRatingTextDismiss dismiss
205
- */
199
+ * Method to set star rating dialog text
200
+ *
201
+ * @param {String } starRatingTextTitle title
202
+ * @param {String } starRatingTextMessage message
203
+ * @param {String } starRatingTextDismiss dismiss
204
+ */
206
205
setStarRatingDialogTexts ( starRatingTextTitle , starRatingTextMessage , starRatingTextDismiss ) {
207
206
this . starRatingTextTitle = starRatingTextTitle ;
208
207
this . starRatingTextMessage = starRatingTextMessage ;
@@ -211,25 +210,25 @@ class CountlyConfig {
211
210
}
212
211
213
212
/**
214
- * Report direct user attribution
215
- *
216
- * @param {String } campaignType campaign type
217
- * @param {Object } campaignData campaign data
218
- */
213
+ * Report direct user attribution
214
+ *
215
+ * @param {String } campaignType campaign type
216
+ * @param {Object } campaignData campaign data
217
+ */
219
218
recordDirectAttribution ( campaignType , campaignData ) {
220
- this . campaignType = campaignType ;
221
- this . campaignData = campaignData ;
222
- return this ;
219
+ this . campaignType = campaignType ;
220
+ this . campaignData = campaignData ;
221
+ return this ;
223
222
}
224
223
225
224
/**
226
- * Report indirect user attribution
227
- *
228
- * @param {Object } attributionValues attribution values
229
- */
225
+ * Report indirect user attribution
226
+ *
227
+ * @param {Object } attributionValues attribution values
228
+ */
230
229
recordIndirectAttribution ( attributionValues ) {
231
- this . attributionValues = attributionValues ;
232
- return this ;
230
+ this . attributionValues = attributionValues ;
231
+ return this ;
233
232
}
234
233
}
235
234
0 commit comments