countly-sdk-web 23.12.4 → 23.12.5

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/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 23.12.5
2
+ - Mitigated an issue where the SDK was not emptying the async queue explicity when closing a browser
3
+
1
4
  ## 23.12.4
2
5
  - Enhanced userAgentData detection for bot filtering
3
6
 
@@ -0,0 +1,329 @@
1
+ /* eslint-disable cypress/no-unnecessary-waiting */
2
+ /* eslint-disable require-jsdoc */
3
+ var Countly = require("../../lib/countly");
4
+ // import * as Countly from "../../dist/countly_umd.js";
5
+ var hp = require("../support/helper.js");
6
+
7
+ function initMain(clear) {
8
+ Countly.init({
9
+ app_key: "YOUR_APP_KEY",
10
+ url: "https://your.domain.count.ly",
11
+ debug: true,
12
+ test_mode: true,
13
+ clear_stored_id: clear
14
+ });
15
+ }
16
+
17
+ function event(number) {
18
+ return {
19
+ key: `event_${number}`,
20
+ segmentation: {
21
+ id: number
22
+ }
23
+ };
24
+ }
25
+
26
+ // All the tests below checks if the functions are working correctly
27
+ // Currently tests for 'beforeunload' and 'unload' events has to be done manually by using the throttling option of the browser
28
+ describe("Test Countly.q related methods and processes", () => {
29
+ // For this tests we disable the internal heatbeat and use processAsyncQueue and sendEventsForced
30
+ // So we are able to test if those functions work as intented:
31
+ // processAsyncQueue should send events from .q to event queue
32
+ // sendEventsForced should send events from event queue to request queue (it also calls processAsyncQueue)
33
+ it("Check processAsyncQueue and sendEventsForced works as expected", () => {
34
+ hp.haltAndClearStorage(() => {
35
+ // Disable heartbeat and init the SDK
36
+ Countly.noHeartBeat = true;
37
+ initMain();
38
+ cy.wait(1000);
39
+
40
+ // Check that the .q is empty
41
+ expect(Countly.q.length).to.equal(0);
42
+
43
+ // Add 4 events to the .q
44
+ Countly.q.push(["add_event", event(1)]);
45
+ Countly.q.push(["add_event", event(2)]);
46
+ Countly.q.push(["add_event", event(3)]);
47
+ Countly.q.push(["add_event", event(4)]);
48
+ // Check that the .q has 4 events
49
+ expect(Countly.q.length).to.equal(4);
50
+
51
+ cy.fetch_local_event_queue().then((rq) => {
52
+ // Check that events are still in .q
53
+ expect(Countly.q.length).to.equal(4);
54
+
55
+ // Check that the event queue is empty
56
+ expect(rq.length).to.equal(0);
57
+
58
+ // Process the .q (should send things to the event queue)
59
+ Countly._internals.processAsyncQueue();
60
+
61
+ // Check that the .q is empty
62
+ expect(Countly.q.length).to.equal(0);
63
+
64
+ cy.fetch_local_request_queue().then((rq_2) => {
65
+ // Check that nothing sent to request queue
66
+ expect(rq_2.length).to.equal(0);
67
+ cy.fetch_local_event_queue().then((eq) => {
68
+ // Check that events are now in event queue
69
+ expect(eq.length).to.equal(4);
70
+
71
+ // Send events from event queue to request queue
72
+ Countly._internals.sendEventsForced();
73
+ cy.fetch_local_event_queue().then((eq_2) => {
74
+ // Check that event queue is empty
75
+ expect(eq_2.length).to.equal(0);
76
+ cy.fetch_local_request_queue().then((rq_3) => {
77
+ // Check that events are now in request queue
78
+ expect(rq_3.length).to.equal(1);
79
+ const eventsArray = JSON.parse(rq_3[0].events);
80
+ expect(eventsArray[0].key).to.equal("event_1");
81
+ expect(eventsArray[1].key).to.equal("event_2");
82
+ expect(eventsArray[2].key).to.equal("event_3");
83
+ expect(eventsArray[3].key).to.equal("event_4");
84
+ });
85
+ });
86
+ });
87
+ });
88
+ });
89
+ });
90
+ });
91
+ // This test is same with the ones above but this time we use change_id to trigger processAsyncQueue
92
+ it("Check changing device ID without merge empties the .q", () => {
93
+ hp.haltAndClearStorage(() => {
94
+ // Disable heartbeat and init the SDK
95
+ Countly.noHeartBeat = true;
96
+ Countly.q = [];
97
+ initMain();
98
+ cy.wait(1000);
99
+
100
+ // Check that the .q is empty
101
+ expect(Countly.q.length).to.equal(0);
102
+
103
+ // Add 4 events to the .q
104
+ Countly.q.push(["add_event", event(1)]);
105
+ Countly.q.push(["add_event", event(2)]);
106
+ Countly.q.push(["add_event", event(3)]);
107
+ Countly.q.push(["add_event", event(4)]);
108
+ // Check that the .q has 4 events
109
+ expect(Countly.q.length).to.equal(4);
110
+
111
+ cy.fetch_local_event_queue().then((rq) => {
112
+ // Check that the event queue is empty
113
+ expect(rq.length).to.equal(0);
114
+
115
+ // Check that events are still in .q
116
+ expect(Countly.q.length).to.equal(4);
117
+
118
+ // Trigger processAsyncQueue by changing device ID without merge
119
+ Countly.change_id("new_user_id", false);
120
+
121
+ // Check that the .q is empty
122
+ expect(Countly.q.length).to.equal(0);
123
+ cy.fetch_local_event_queue().then((eq) => {
124
+ // Check that event queue has new device ID's orientation event
125
+ expect(eq.length).to.equal(1);
126
+ expect(eq[0].key).to.equal("[CLY]_orientation");
127
+ cy.fetch_local_request_queue().then((rq_2) => {
128
+ // Check that events are now in request queue (second request is begin session for new device ID)
129
+ expect(rq_2.length).to.equal(2);
130
+ const eventsArray = JSON.parse(rq_2[0].events);
131
+ expect(eventsArray[0].key).to.equal("event_1");
132
+ expect(eventsArray[1].key).to.equal("event_2");
133
+ expect(eventsArray[2].key).to.equal("event_3");
134
+ expect(eventsArray[3].key).to.equal("event_4");
135
+ // check begin session
136
+ expect(rq_2[1].begin_session).to.equal(1);
137
+ });
138
+ });
139
+ });
140
+ });
141
+ });
142
+ // This test checks if clear_stored_id set to true during init we call processAsyncQueue (it sends events from .q to event queue and then to request queue)
143
+ it("Check clear_stored_id set to true empties the .q", () => {
144
+ hp.haltAndClearStorage(() => {
145
+ // Disable heartbeat
146
+ Countly.noHeartBeat = true;
147
+ Countly.q = [];
148
+ localStorage.setItem("YOUR_APP_KEY/cly_id", "old_user_id"); // Set old device ID for clear_stored_id to work
149
+
150
+ // Add 4 events to the .q
151
+ Countly.q.push(["add_event", event(1)]);
152
+ Countly.q.push(["add_event", event(2)]);
153
+ Countly.q.push(["add_event", event(3)]);
154
+ Countly.q.push(["add_event", event(4)]);
155
+
156
+ // Check that the .q has 4 events
157
+ expect(Countly.q.length).to.equal(4);
158
+
159
+ // Init the SDK with clear_stored_id set to true
160
+ initMain(true);
161
+ cy.wait(1000);
162
+
163
+ // Check that the .q is empty
164
+ expect(Countly.q.length).to.equal(0);
165
+
166
+ cy.fetch_local_event_queue().then((rq) => {
167
+ // Check that the event queue is empty because processAsyncQueue sends events from .q to event queue and then to request queue
168
+ expect(rq.length).to.equal(0);
169
+
170
+ cy.fetch_local_request_queue().then((rq_2) => {
171
+ // Check that events are now in request queue
172
+ expect(rq_2.length).to.equal(1);
173
+ const eventsArray = JSON.parse(rq_2[0].events);
174
+ expect(eventsArray[0].key).to.equal("event_1");
175
+ expect(eventsArray[1].key).to.equal("event_2");
176
+ expect(eventsArray[2].key).to.equal("event_3");
177
+ expect(eventsArray[3].key).to.equal("event_4");
178
+ });
179
+ });
180
+ });
181
+ });
182
+ // This test checks if calling user_details triggers processAsyncQueue (it sends events from .q to event queue and then to request queue)
183
+ it("Check sending user details empties .q", () => {
184
+ hp.haltAndClearStorage(() => {
185
+ // Disable heartbeat and init the SDK
186
+ Countly.noHeartBeat = true;
187
+ Countly.q = [];
188
+ initMain();
189
+ cy.wait(1000);
190
+
191
+ // Check that the .q is empty
192
+ expect(Countly.q.length).to.equal(0);
193
+
194
+ // Add 4 events to the .q
195
+ Countly.q.push(["add_event", event(1)]);
196
+ Countly.q.push(["add_event", event(2)]);
197
+ Countly.q.push(["add_event", event(3)]);
198
+ Countly.q.push(["add_event", event(4)]);
199
+ // Check that the .q has 4 events
200
+ expect(Countly.q.length).to.equal(4);
201
+
202
+ cy.fetch_local_event_queue().then((rq) => {
203
+ // Check that the event queue is empty
204
+ expect(rq.length).to.equal(0);
205
+
206
+ // Check that events are still in .q
207
+ expect(Countly.q.length).to.equal(4);
208
+
209
+ // Trigger processAsyncQueue by adding user details
210
+ Countly.user_details({ name: "test_user" });
211
+
212
+ // Check that the .q is empty
213
+ expect(Countly.q.length).to.equal(0);
214
+ cy.fetch_local_event_queue().then((eq) => {
215
+ // Check that event queue is empty
216
+ expect(eq.length).to.equal(0);
217
+ cy.fetch_local_request_queue().then((rq_2) => {
218
+ // Check that events are now in request queue (second request is user details)
219
+ expect(rq_2.length).to.equal(2);
220
+ const eventsArray = JSON.parse(rq_2[0].events);
221
+ expect(eventsArray[0].key).to.equal("event_1");
222
+ expect(eventsArray[1].key).to.equal("event_2");
223
+ expect(eventsArray[2].key).to.equal("event_3");
224
+ expect(eventsArray[3].key).to.equal("event_4");
225
+ // check user details
226
+ const user_details = JSON.parse(rq_2[1].user_details);
227
+ expect(user_details.name).to.equal("test_user");
228
+ });
229
+ });
230
+ });
231
+ });
232
+ });
233
+ // This Test checks if calling userData.save triggers processAsyncQueue (it sends events from .q to event queue and then to request queue)
234
+ it("Check sending custom user info empties .q", () => {
235
+ hp.haltAndClearStorage(() => {
236
+ // Disable heartbeat and init the SDK
237
+ Countly.noHeartBeat = true;
238
+ Countly.q = [];
239
+ initMain();
240
+ cy.wait(1000);
241
+
242
+ // Check that the .q is empty
243
+ expect(Countly.q.length).to.equal(0);
244
+
245
+ // Add 4 events to the .q
246
+ Countly.q.push(["add_event", event(1)]);
247
+ Countly.q.push(["add_event", event(2)]);
248
+ Countly.q.push(["add_event", event(3)]);
249
+ Countly.q.push(["add_event", event(4)]);
250
+ // Check that the .q has 4 events
251
+ expect(Countly.q.length).to.equal(4);
252
+
253
+ cy.fetch_local_event_queue().then((rq) => {
254
+ // Check that the event queue is empty
255
+ expect(rq.length).to.equal(0);
256
+
257
+ // Check that events are still in .q
258
+ expect(Countly.q.length).to.equal(4);
259
+
260
+ // Trigger processAsyncQueue by saving UserData
261
+ Countly.userData.set("name", "test_user");
262
+ Countly.userData.save();
263
+
264
+ // Check that the .q is empty
265
+ expect(Countly.q.length).to.equal(0);
266
+ cy.fetch_local_event_queue().then((eq) => {
267
+ // Check that event queue is empty
268
+ expect(eq.length).to.equal(0);
269
+ cy.fetch_local_request_queue().then((rq_2) => {
270
+ // Check that events are now in request queue (second request is user details)
271
+ expect(rq_2.length).to.equal(2);
272
+ const eventsArray = JSON.parse(rq_2[0].events);
273
+ expect(eventsArray[0].key).to.equal("event_1");
274
+ expect(eventsArray[1].key).to.equal("event_2");
275
+ expect(eventsArray[2].key).to.equal("event_3");
276
+ expect(eventsArray[3].key).to.equal("event_4");
277
+ // check user data
278
+ const user_details = JSON.parse(rq_2[1].user_details);
279
+ expect(user_details.custom.name).to.equal("test_user");
280
+ });
281
+ });
282
+ });
283
+ });
284
+ });
285
+ // This test check if the heartbeat is processing the .q (executes processAsyncQueue)
286
+ it("Check if heatbeat is processing .q", () => {
287
+ hp.haltAndClearStorage(() => {
288
+ // init the SDK
289
+ Countly.q = [];
290
+ initMain();
291
+
292
+ // Check that the .q is empty
293
+ expect(Countly.q.length).to.equal(0);
294
+ cy.fetch_local_event_queue().then((eq) => {
295
+ // Check that the event queue is empty
296
+ expect(eq.length).to.equal(0);
297
+ cy.fetch_local_request_queue().then((rq) => {
298
+ // Check that the request queue is empty
299
+ expect(rq.length).to.equal(0);
300
+ // Add 4 events to the .q
301
+ Countly.q.push(["add_event", event(1)]);
302
+ Countly.q.push(["add_event", event(2)]);
303
+ Countly.q.push(["add_event", event(3)]);
304
+ Countly.q.push(["add_event", event(4)]);
305
+ // Check that the .q has 4 events
306
+ expect(Countly.q.length).to.equal(4);
307
+ // Wait for heartBeat to process the .q
308
+ cy.wait(1500).then(() => {
309
+ // Check that the .q is empty
310
+ expect(Countly.q.length).to.equal(0);
311
+ cy.fetch_local_event_queue().then((eq_2) => {
312
+ // Check that event queue is empty as all must be in request queue
313
+ expect(eq_2.length).to.equal(0);
314
+ cy.fetch_local_request_queue().then((rq_2) => {
315
+ // Check that events are now in request queue
316
+ expect(rq_2.length).to.equal(1);
317
+ const eventsArray = JSON.parse(rq_2[0].events);
318
+ expect(eventsArray[0].key).to.equal("event_1");
319
+ expect(eventsArray[1].key).to.equal("event_2");
320
+ expect(eventsArray[2].key).to.equal("event_3");
321
+ expect(eventsArray[3].key).to.equal("event_4");
322
+ });
323
+ });
324
+ });
325
+ });
326
+ });
327
+ });
328
+ });
329
+ });
@@ -16,7 +16,7 @@ function initMain(name, version) {
16
16
  }
17
17
 
18
18
  const SDK_NAME = "javascript_native_web";
19
- const SDK_VERSION = "23.12.4";
19
+ const SDK_VERSION = "23.12.5";
20
20
 
21
21
  // tests
22
22
  describe("Bridged SDK Utilities Tests", () => {
@@ -8,9 +8,16 @@ import Countly from 'countly-sdk-web';
8
8
 
9
9
  window.Countly = Countly;
10
10
 
11
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
12
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
13
+
14
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
15
+ console.warn("Please do not use default set of app key and server url")
16
+ }
17
+ // initializing countly with params
11
18
  Countly.init({
12
- app_key: "YOUR_APP_KEY",
13
- url: "https://your.domain.countly",
19
+ app_key: COUNTLY_APP_KEY,
20
+ url: COUNTLY_SERVER_KEY, //your server goes here
14
21
  debug: true
15
22
  });
16
23
  Countly.track_sessions();
@@ -1,9 +1,16 @@
1
1
  import Countly from "countly-sdk-web";
2
2
 
3
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
4
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
5
+
6
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
7
+ console.warn("Please do not use default set of app key and server url")
8
+ }
9
+ // initializing countly with params
3
10
  Countly.init({
4
- app_key: "YOUR_APP_KEY",
11
+ app_key: COUNTLY_APP_KEY,
12
+ url: COUNTLY_SERVER_KEY, //your server goes here
5
13
  app_version: "1.0",
6
- url: "https://your.domain.countly",
7
14
  debug: true
8
15
  });
9
16
 
@@ -26,22 +33,22 @@ Countly.track_forms();
26
33
  Countly.track_errors();
27
34
 
28
35
  //let's cause some errors
29
- function cause_error(){
30
- undefined_function();
36
+ function cause_error() {
37
+ undefined_function();
31
38
  }
32
39
 
33
- window.onload = function() {
34
- document.getElementById("handled_error").onclick = function handled_error(){
35
- Countly.add_log('Pressed handled button');
36
- try {
37
- cause_error();
38
- } catch(err){
39
- Countly.log_error(err)
40
- }
40
+ window.onload = function () {
41
+ document.getElementById("handled_error").onclick = function handled_error() {
42
+ Countly.add_log('Pressed handled button');
43
+ try {
44
+ cause_error();
45
+ } catch (err) {
46
+ Countly.log_error(err)
47
+ }
41
48
  };
42
49
 
43
- document.getElementById("unhandled_error").onclick = function unhandled_error(){
44
- Countly.add_log('Pressed unhandled button');
45
- cause_error();
50
+ document.getElementById("unhandled_error").onclick = function unhandled_error() {
51
+ Countly.add_log('Pressed unhandled button');
52
+ cause_error();
46
53
  };
47
54
  }
@@ -10,10 +10,16 @@
10
10
  <script type='text/javascript' src="../plugin/boomerang/boomerang.min.js"></script>
11
11
  <script type='text/javascript'>
12
12
 
13
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
14
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
15
+
16
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
17
+ console.warn("Please do not use default set of app key and server url")
18
+ }
13
19
  // initializing countly with params
14
20
  Countly.init({
15
- app_key: "YOUR_APP_KEY",
16
- url: "https://your.domain.countly", //your server goes here
21
+ app_key: COUNTLY_APP_KEY,
22
+ url: COUNTLY_SERVER_KEY, //your server goes here
17
23
  debug: true
18
24
  })
19
25
 
@@ -12,14 +12,19 @@
12
12
 
13
13
  //provide countly initialization parameters
14
14
  Countly.app_key = "YOUR_APP_KEY";
15
- Countly.url = "https://your.domain.countly"; //your server goes here
15
+ Countly.url = "https://your.server.ly"; //your server goes here
16
+
17
+ if (Countly.app_key === "YOUR_APP_KEY" || Countly.url === "https://your.server.ly") {
18
+ console.warn("Please do not use default set of app key and server url")
19
+ }
20
+
16
21
  Countly.debug = true;
17
22
  Countly.loadAPMScriptsAsync = true;
18
23
  // Countly.customSourceBoomerang = "../somewhere/boomerang.min.js";
19
24
  // Countly.customSourceCountlyBoomerang = "../somewhere/countly_boomerang.js";
20
25
 
21
26
  //start pushing function calls to queue:
22
-
27
+
23
28
  // track sessions automatically
24
29
  Countly.q.push(['track_sessions']);
25
30
 
@@ -12,7 +12,11 @@
12
12
 
13
13
  //provide countly initialization parameters
14
14
  Countly.app_key = "YOUR_APP_KEY";
15
- Countly.url = "https://your.domain.countly"; //your server goes here
15
+ Countly.url = "https://your.server.ly"; //your server goes here
16
+
17
+ if (Countly.app_key === "YOUR_APP_KEY" || Countly.url === "https://your.server.ly") {
18
+ console.warn("Please do not use default set of app key and server url")
19
+ }
16
20
  Countly.debug = true;
17
21
 
18
22
  //start pushing function calls to queue
@@ -11,10 +11,16 @@ Example on collecting user information from FaceBook
11
11
  <script type='text/javascript' src='../lib/countly.js'></script>
12
12
  <script type='text/javascript'>
13
13
 
14
- //initializing countly with params
14
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
15
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
16
+
17
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
18
+ console.warn("Please do not use default set of app key and server url")
19
+ }
20
+ // initializing countly with params
15
21
  Countly.init({
16
- app_key: "YOUR_APP_KEY",
17
- url: "https://your.domain.countly", //your server goes here
22
+ app_key: COUNTLY_APP_KEY,
23
+ url: COUNTLY_SERVER_KEY, //your server goes here
18
24
  debug: true
19
25
  });
20
26
  Countly.begin_session();
@@ -11,10 +11,16 @@ Example on collecting user information from submitted forms
11
11
  <script type='text/javascript' src='../lib/countly.js'></script>
12
12
  <script type='text/javascript'>
13
13
 
14
- //initializing countly with params
14
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
15
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
16
+
17
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
18
+ console.warn("Please do not use default set of app key and server url")
19
+ }
20
+ // initializing countly with params
15
21
  Countly.init({
16
- app_key: "YOUR_APP_KEY",
17
- url: "https://your.domain.countly", //your server goes here
22
+ app_key: COUNTLY_APP_KEY,
23
+ url: COUNTLY_SERVER_KEY, //your server goes here
18
24
  debug: true
19
25
  });
20
26
  Countly.begin_session();
@@ -11,8 +11,12 @@
11
11
  Countly.onload = Countly.onload || [];
12
12
  //provide countly initialization parameters
13
13
  Countly.app_key = "YOUR_APP_KEY";
14
+ Countly.url = "https://your.server.ly"; //your server goes here
15
+
16
+ if (Countly.app_key === "YOUR_APP_KEY" || Countly.url === "https://your.server.ly") {
17
+ console.warn("Please do not use default set of app key and server url")
18
+ }
14
19
  Countly.debug = true;
15
- Countly.url = "https://your.domain.countly"; //your server goes here
16
20
  window.cly_ga_test_mode = true;
17
21
  Countly.test_logs = [];
18
22
  //start pushing function calls to queue
@@ -9,9 +9,16 @@
9
9
  <script type='text/javascript'>
10
10
 
11
11
  //initializing countly with params and passing require_consent config as true
12
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
13
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
14
+
15
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
16
+ console.warn("Please do not use default set of app key and server url")
17
+ }
18
+ // initializing countly with params
12
19
  Countly.init({
13
- app_key: "YOUR_APP_KEY",
14
- url: "https://your.domain.countly", //your server goes here
20
+ app_key: COUNTLY_APP_KEY,
21
+ url: COUNTLY_SERVER_KEY, //your server goes here
15
22
  debug: true,
16
23
  require_consent: true //this true means consent is required
17
24
  });
@@ -9,9 +9,16 @@
9
9
  <script type='text/javascript'>
10
10
 
11
11
  //initializing countly with params
12
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
13
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
14
+
15
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
16
+ console.warn("Please do not use default set of app key and server url")
17
+ }
18
+ // initializing countly with params
12
19
  Countly.init({
13
- app_key: "YOUR_APP_KEY",
14
- url: "https://your.domain.countly", //your server goes here
20
+ app_key: COUNTLY_APP_KEY,
21
+ url: COUNTLY_SERVER_KEY, //your server goes here
15
22
  debug: true
16
23
  });
17
24
 
@@ -11,12 +11,17 @@
11
11
  Countly = Countly || {};
12
12
  Countly.q = Countly.q || [];
13
13
 
14
-
15
-
16
14
  //initializing first instance, which will be global Countly
15
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
16
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
17
+
18
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
19
+ console.warn("Please do not use default set of app key and server url")
20
+ }
21
+ // initializing countly with params
17
22
  Countly.init({
18
- app_key: "YOUR_APP_KEY1",
19
- url: "https://your.domain.countly", //your server goes here
23
+ app_key: COUNTLY_APP_KEY,
24
+ url: COUNTLY_SERVER_KEY, //your server goes here
20
25
  debug: true
21
26
  })
22
27
  //report event to first app
@@ -27,26 +32,39 @@
27
32
 
28
33
 
29
34
  //initialize second instance for another app synchronously
35
+ const COUNTLY_SERVER_KEY2 = "https://your.server.ly";
36
+ const COUNTLY_APP_KEY2 = "YOUR_APP_KEY2";
37
+
38
+ if (COUNTLY_APP_KEY2 === "YOUR_APP_KEY2" || COUNTLY_SERVER_KEY2 === "https://your.server.ly") {
39
+ console.warn("Please do not use default set of app key and server url")
40
+ }
41
+ // initializing countly with params
30
42
  var Countly2 = Countly.init({
31
- app_key: "YOUR_APP_KEY2", //must have different APP key
32
- url: "https://your.domain.countly", //your server goes here
43
+ app_key: COUNTLY_APP_KEY2,
44
+ url: COUNTLY_SERVER_KEY2, //your server goes here
33
45
  debug: true
34
46
  });
47
+
35
48
  //report event to second app
36
49
  Countly2.add_event({
37
50
  key: "second_app"
38
51
  });
39
52
 
53
+ const COUNTLY_SERVER_KEY3 = "https://your.server.ly";
54
+ const COUNTLY_APP_KEY3 = "YOUR_APP_KEY3";
40
55
 
56
+ if (COUNTLY_APP_KEY3 === "YOUR_APP_KEY3" || COUNTLY_SERVER_KEY2 === "https://your.server.ly") {
57
+ console.warn("Please do not use default set of app key and server url")
58
+ }
41
59
 
42
60
  //initialize third instance for another app asynchronously
43
61
  Countly.q.push(["init", {
44
- app_key: "YOUR_APP_KEY3", //must have different APP key
45
- url: "https://your.domain.countly", //your server goes here
62
+ app_key: COUNTLY_APP_KEY3, //must have different APP key
63
+ url: COUNTLY_SERVER_KEY3, //your server goes here
46
64
  debug: true
47
65
  }])
48
66
  //report event to third app asynchronously by passing app key as first arg
49
- Countly.q.push(["YOUR_APP_KEY3", "add_event", {
67
+ Countly.q.push([COUNTLY_APP_KEY3, "add_event", {
50
68
  key: "third_app"
51
69
  }]);
52
70
  </script>
@@ -9,9 +9,16 @@
9
9
  <script type='text/javascript'>
10
10
 
11
11
  //initializing countly with params
12
+ const COUNTLY_SERVER_KEY = "https://your.server.ly";
13
+ const COUNTLY_APP_KEY = "YOUR_APP_KEY";
14
+
15
+ if (COUNTLY_APP_KEY === "YOUR_APP_KEY" || COUNTLY_SERVER_KEY === "https://your.server.ly") {
16
+ console.warn("Please do not use default set of app key and server url")
17
+ }
18
+ // initializing countly with params
12
19
  Countly.init({
13
- app_key: "YOUR_APP_KEY",
14
- url: "https://your.domain.countly", //your server goes here
20
+ app_key: COUNTLY_APP_KEY,
21
+ url: COUNTLY_SERVER_KEY, //your server goes here
15
22
  debug: true
16
23
  })
17
24
  //track sessions automatically