Skip to content

Commit 4b6f288

Browse files
Log and Util modules added (#257)
* added: logger and utils * added space --------- Co-authored-by: Artūrs Kadiķis <[email protected]>
1 parent 42bf06d commit 4b6f288

File tree

8 files changed

+566
-451
lines changed

8 files changed

+566
-451
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"root": true,
2222
"rules": {
2323
//JavaScript rules
24-
24+
"prefer-template": "error",
2525
// allow .js files to contain JSX code
2626
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx", ".tsx"] }],
2727

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ android/android.iml
1919
android/.settings/org.eclipse.buildship.core.prefs
2020
android/.classpath
2121
countly-sdk-react-native-bridge-*.tgz
22+
example/AwesomeProject

Countly.js

Lines changed: 227 additions & 333 deletions
Large diffs are not rendered by default.

CountlyConfig.js

Lines changed: 101 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { initialize } from './Logger.js';
12
/**
23
* Countly SDK React Native Bridge
34
* https://github.com/Countly/countly-sdk-react-native-bridge
@@ -11,97 +12,95 @@
1112
* @param {String} serverURL server url
1213
* @param {String} appKey application key
1314
*/
14-
import CountlyInternal from './Countly.js';
15-
1615
class CountlyConfig {
1716
constructor(serverURL, appKey) {
1817
this.serverURL = serverURL;
1918
this.appKey = appKey;
2019
}
2120

2221
/**
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+
*/
2726
setServerURL(serverURL) {
2827
this.serverURL = serverURL;
2928
return this;
3029
}
3130

3231
/**
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+
*/
3736
setAppKey(appKey) {
3837
this.appKey = appKey;
3938
return this;
4039
}
4140

4241
/**
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+
*/
4746
setDeviceID(deviceID) {
4847
this.deviceID = deviceID;
4948
return this;
5049
}
5150

5251
/**
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+
*/
5857
setLoggingEnabled(loggingEnabled) {
5958
this.loggingEnabled = loggingEnabled;
60-
CountlyInternal.setLoggingEnabled(loggingEnabled);
59+
initialize(loggingEnabled); // initialize React Native SDK logger
6160
return this;
6261
}
6362

6463
/**
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+
*/
6766
enableCrashReporting() {
6867
this.crashReporting = true;
6968
return this;
7069
}
7170

7271
/**
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+
*/
8079
setRequiresConsent(shouldRequireConsent) {
8180
this.shouldRequireConsent = shouldRequireConsent;
8281
return this;
8382
}
8483

8584
/**
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+
*/
9291
giveConsent(consents) {
9392
this.consents = consents;
9493
return this;
9594
}
9695

9796
/**
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+
*/
105104
setLocation(locationCountryCode, locationCity, locationGpsCoordinates, locationIpAddress) {
106105
this.locationCountryCode = locationCountryCode;
107106
this.locationCity = locationCity;
@@ -111,35 +110,35 @@ class CountlyConfig {
111110
}
112111

113112
/**
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+
*/
120119
enableParameterTamperingProtection(tamperingProtectionSalt) {
121120
this.tamperingProtectionSalt = tamperingProtectionSalt;
122121
return this;
123122
}
124123

125124
/**
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+
*/
128127
enableApm() {
129128
this.enableApm = true;
130129
return this;
131130
}
132131

133132
/**
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+
*/
143142
pushTokenType(tokenType, channelName, channelDescription) {
144143
this.tokenType = tokenType;
145144
this.channelName = channelName;
@@ -148,61 +147,61 @@ class CountlyConfig {
148147
}
149148

150149
/**
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+
*/
157156
setPushTokenType(tokenType) {
158157
this.tokenType = tokenType;
159158
return this;
160159
}
161160

162161
/**
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+
*/
169168
setPushNotificationChannelInformation(name, description) {
170169
this.channelName = name;
171170
this.channelDescription = description;
172171
return this;
173172
}
174173

175174
/**
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+
*/
182181
setPushNotificationAccentColor(accentColor) {
183182
this.accentColor = accentColor;
184183
return this;
185184
}
186185

187186
/**
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+
*/
193192
configureIntentRedirectionCheck(allowedIntentClassNames, allowedIntentPackageNames) {
194193
this.allowedIntentClassNames = allowedIntentClassNames;
195194
this.allowedIntentPackageNames = allowedIntentPackageNames;
196195
return this;
197196
}
198197

199198
/**
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+
*/
206205
setStarRatingDialogTexts(starRatingTextTitle, starRatingTextMessage, starRatingTextDismiss) {
207206
this.starRatingTextTitle = starRatingTextTitle;
208207
this.starRatingTextMessage = starRatingTextMessage;
@@ -211,25 +210,25 @@ class CountlyConfig {
211210
}
212211

213212
/**
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+
*/
219218
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;
223222
}
224223

225224
/**
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+
*/
230229
recordIndirectAttribution(attributionValues) {
231-
this.attributionValues = attributionValues;
232-
return this;
230+
this.attributionValues = attributionValues;
231+
return this;
233232
}
234233
}
235234

CountlyState.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
const CountlyState = {};
22

3-
CountlyState.isInitialized = false
3+
CountlyState.isInitialized = false;
44
CountlyState.CountlyReactNative = null;
55
CountlyState.eventEmitter = null;
66

@@ -16,4 +16,4 @@ CountlyState.widgetShownCallback;
1616
*/
1717
CountlyState.widgetClosedCallback;
1818

19-
export default CountlyState;
19+
export default CountlyState;

0 commit comments

Comments
 (0)