countly-sdk-web 22.2.2 → 22.2.3
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/.eslintignore +17 -17
- package/.eslintrc.js +215 -215
- package/.github/dependabot.yml +20 -20
- package/.github/workflows/codeql-analysis.yml +71 -71
- package/.github/workflows/documentation.yml +24 -0
- package/.github/workflows/node.js.yml +25 -41
- package/CHANGELOG.md +241 -237
- package/LICENSE +19 -19
- package/README.md +86 -122
- package/SECURITY.md +3 -3
- package/bower.json +29 -29
- package/cypress/.eslintrc.js +22 -22
- package/cypress/fixtures/base.html +8 -0
- package/cypress/fixtures/scroll_test.html +60 -0
- package/cypress/fixtures/scroll_test_2.html +48 -0
- package/cypress/fixtures/scroll_test_3.html +72 -0
- package/cypress/fixtures/session_test_auto.html +51 -0
- package/cypress/fixtures/session_test_manual_1.html +58 -0
- package/cypress/fixtures/session_test_manual_2.html +54 -0
- package/cypress/fixtures/user_agent.html +20 -0
- package/cypress/integration/consents.js +165 -165
- package/cypress/integration/device_id.js +1085 -830
- package/cypress/integration/events.js +65 -65
- package/cypress/integration/heatmaps.js +52 -0
- package/cypress/integration/internal_limits.js +153 -153
- package/cypress/integration/reponse_validation.js +170 -170
- package/cypress/integration/sessions.js +196 -60
- package/cypress/integration/user_agent.js +63 -0
- package/cypress/integration/user_details.js +40 -40
- package/cypress/integration/utm.js +236 -236
- package/cypress/integration/views.js +62 -62
- package/cypress/plugins/index.js +22 -22
- package/cypress/support/commands.js +322 -298
- package/cypress/support/helper.js +59 -59
- package/cypress/support/index.js +2 -2
- package/cypress/support/integration_helper.js +17 -0
- package/cypress.json +3 -1
- package/examples/example_apm.html +51 -51
- package/examples/example_fb.html +50 -50
- package/examples/example_formdata.html +47 -47
- package/examples/example_ga_adapter.html +173 -173
- package/examples/example_gdpr.html +82 -82
- package/examples/example_internal_limits.html +184 -184
- package/examples/example_multiple_instances.html +52 -52
- package/examples/example_rating_widgets.html +80 -80
- package/examples/example_remote_config.html +38 -38
- package/examples/example_sync.html +36 -36
- package/examples/examples_feedback_widgets.html +81 -81
- package/examples/mpa/boomerang/boomerang-1.0.0.js +22871 -22871
- package/examples/mpa/boomerang/countly_boomerang.js +138 -138
- package/examples/mpa/index.html +816 -816
- package/examples/react/README.md +35 -35
- package/examples/react/package.json +37 -37
- package/examples/react/public/index.html +19 -19
- package/examples/react/public/manifest.json +25 -25
- package/examples/react/public/robots.txt +3 -3
- package/examples/react/src/App-WithEffect.js +33 -33
- package/examples/react/src/App-WithRouter.js +46 -46
- package/examples/react/src/App.test.js +9 -9
- package/examples/react/src/Components/Contact.js +28 -28
- package/examples/react/src/Components/Header.js +88 -88
- package/examples/react/src/Components/Home.js +23 -23
- package/examples/react/src/Components/Users.js +43 -43
- package/examples/react/src/Components/styles.css +25 -25
- package/examples/react/src/ErrorBoundary.js +28 -28
- package/examples/react/src/Location-WithEffect.js +27 -27
- package/examples/react/src/Location-WithRouter.js +23 -23
- package/examples/react/src/index.css +5 -5
- package/examples/react/src/index.js +68 -68
- package/examples/react/src/serviceWorker.js +141 -141
- package/examples/react/src/setupTests.js +5 -5
- package/examples/symbolication/.babelrc +11 -11
- package/examples/symbolication/.editorconfig +8 -8
- package/examples/symbolication/.yo-rc.json +53 -53
- package/examples/symbolication/README.md +33 -33
- package/examples/symbolication/package.json +22 -22
- package/examples/symbolication/src/index.js +47 -47
- package/examples/symbolication/static/index.html +21 -21
- package/examples/symbolication/webpack.config.js +27 -27
- package/generateDocs.sh +80 -79
- package/inch.json +6 -6
- package/jsdoc_conf.json +4 -2
- package/lib/countly.js +4625 -4416
- package/lib/countly.min.js +126 -117
- package/package.json +57 -57
- package/plugin/boomerang/boomerang.min.js +10 -10
- package/plugin/boomerang/countly_boomerang.js +150 -150
- package/plugin/ga_adapter/doc.md +73 -73
- package/plugin/ga_adapter/ga_adapter.js +451 -451
- package/webpack.config.js +12 -12
- package/countly-sdk-web-22.2.2.tgz +0 -0
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
2
|
-
/* eslint-disable require-jsdoc */
|
|
3
|
-
var Countly = require("../../lib/countly");
|
|
4
|
-
var hp = require("../support/helper");
|
|
5
|
-
|
|
6
|
-
function initMain() {
|
|
7
|
-
Countly.init({
|
|
8
|
-
app_key: "YOUR_APP_KEY",
|
|
9
|
-
url: "https://try.count.ly",
|
|
10
|
-
session_update: 3,
|
|
11
|
-
|
|
12
|
-
max_events: -1,
|
|
13
|
-
debug: true
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
// an event object to use
|
|
17
|
-
const eventObj = {
|
|
18
|
-
key: "in_app_purchase",
|
|
19
|
-
count: 3,
|
|
20
|
-
sum: 2.97,
|
|
21
|
-
dur: 1000,
|
|
22
|
-
segmentation: {
|
|
23
|
-
app_version: "1.0",
|
|
24
|
-
country: "Tahiti",
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
// a timed event object
|
|
28
|
-
const timedEventObj = {
|
|
29
|
-
key: "timed",
|
|
30
|
-
count: 1,
|
|
31
|
-
segmentation: {
|
|
32
|
-
app_version: "1.0",
|
|
33
|
-
country: "Tahiti",
|
|
34
|
-
},
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
describe("Events tests ", () => {
|
|
38
|
-
it("Checks if adding events works", () => {
|
|
39
|
-
hp.haltAndClearStorage(() => {
|
|
40
|
-
initMain();
|
|
41
|
-
Countly.add_event(eventObj);
|
|
42
|
-
cy.fetch_local_event_queue().then((eq) => {
|
|
43
|
-
expect(eq.length).to.equal(1);
|
|
44
|
-
cy.check_event(eq[0], eventObj);
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
it("Checks if timed events works", () => {
|
|
49
|
-
hp.haltAndClearStorage(() => {
|
|
50
|
-
initMain();
|
|
51
|
-
// start the timer
|
|
52
|
-
Countly.start_event("timed");
|
|
53
|
-
// wait for a while
|
|
54
|
-
cy.wait(3000).then(() => {
|
|
55
|
-
// end the event and check duration
|
|
56
|
-
Countly.end_event(timedEventObj);
|
|
57
|
-
cy.fetch_local_event_queue().then((eq) => {
|
|
58
|
-
expect(eq.length).to.equal(1);
|
|
59
|
-
// we waited 3000 milliseconds so duration must be 3 to 4
|
|
60
|
-
cy.check_event(eq[0], timedEventObj, 3);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
});
|
|
1
|
+
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
2
|
+
/* eslint-disable require-jsdoc */
|
|
3
|
+
var Countly = require("../../lib/countly");
|
|
4
|
+
var hp = require("../support/helper");
|
|
5
|
+
|
|
6
|
+
function initMain() {
|
|
7
|
+
Countly.init({
|
|
8
|
+
app_key: "YOUR_APP_KEY",
|
|
9
|
+
url: "https://try.count.ly",
|
|
10
|
+
session_update: 3,
|
|
11
|
+
test_mode: true,
|
|
12
|
+
max_events: -1,
|
|
13
|
+
debug: true
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
// an event object to use
|
|
17
|
+
const eventObj = {
|
|
18
|
+
key: "in_app_purchase",
|
|
19
|
+
count: 3,
|
|
20
|
+
sum: 2.97,
|
|
21
|
+
dur: 1000,
|
|
22
|
+
segmentation: {
|
|
23
|
+
app_version: "1.0",
|
|
24
|
+
country: "Tahiti",
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
// a timed event object
|
|
28
|
+
const timedEventObj = {
|
|
29
|
+
key: "timed",
|
|
30
|
+
count: 1,
|
|
31
|
+
segmentation: {
|
|
32
|
+
app_version: "1.0",
|
|
33
|
+
country: "Tahiti",
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
describe("Events tests ", () => {
|
|
38
|
+
it("Checks if adding events works", () => {
|
|
39
|
+
hp.haltAndClearStorage(() => {
|
|
40
|
+
initMain();
|
|
41
|
+
Countly.add_event(eventObj);
|
|
42
|
+
cy.fetch_local_event_queue().then((eq) => {
|
|
43
|
+
expect(eq.length).to.equal(1);
|
|
44
|
+
cy.check_event(eq[0], eventObj);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
it("Checks if timed events works", () => {
|
|
49
|
+
hp.haltAndClearStorage(() => {
|
|
50
|
+
initMain();
|
|
51
|
+
// start the timer
|
|
52
|
+
Countly.start_event("timed");
|
|
53
|
+
// wait for a while
|
|
54
|
+
cy.wait(3000).then(() => {
|
|
55
|
+
// end the event and check duration
|
|
56
|
+
Countly.end_event(timedEventObj);
|
|
57
|
+
cy.fetch_local_event_queue().then((eq) => {
|
|
58
|
+
expect(eq.length).to.equal(1);
|
|
59
|
+
// we waited 3000 milliseconds so duration must be 3 to 4
|
|
60
|
+
cy.check_event(eq[0], timedEventObj, 3);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// TODO: click and scrolls tests but scrolls first, with html files
|
|
2
|
+
|
|
3
|
+
/* eslint-disable require-jsdoc */
|
|
4
|
+
var hp = require("../support/helper");
|
|
5
|
+
|
|
6
|
+
describe("Browser heatmap tests", () => {
|
|
7
|
+
it("Check if scrolls are sent if page url changes", () => {
|
|
8
|
+
cy.visit("./cypress/fixtures/scroll_test.html");
|
|
9
|
+
cy.scrollTo("bottom");
|
|
10
|
+
cy.visit("./cypress/fixtures/scroll_test_2.html");
|
|
11
|
+
cy.fetch_local_request_queue(hp.appKey).then((rq) => {
|
|
12
|
+
cy.log(rq);
|
|
13
|
+
// 2 session and 1 orientation 1 event
|
|
14
|
+
expect(rq.length).to.equal(4);
|
|
15
|
+
// first object of the queue should be about begin session, second is orientation
|
|
16
|
+
cy.check_session(rq[0], undefined, undefined, hp.appKey);
|
|
17
|
+
// third object of the queue should be about session extension, also input the expected duration range, we expect 0 here so we enter a value lower than that but not deviated more than 1
|
|
18
|
+
cy.check_session(rq[2], -0.5, undefined);
|
|
19
|
+
// fourth object of the queue should be events in the queue, there must be 4 of them
|
|
20
|
+
cy.check_view_event(JSON.parse(rq[3].events)[0], "/cypress/fixtures/scroll_test.html", 0);
|
|
21
|
+
cy.check_scroll_event(JSON.parse(rq[3].events)[1]);
|
|
22
|
+
// number 3 is orientation
|
|
23
|
+
cy.check_view_event(JSON.parse(rq[3].events)[3], "/cypress/fixtures/scroll_test_2.html");
|
|
24
|
+
});
|
|
25
|
+
});
|
|
26
|
+
it("Check if scrolls are sent if for single page apps/sites", () => {
|
|
27
|
+
cy.visit("./cypress/fixtures/scroll_test_3.html");
|
|
28
|
+
// TODO: gave exact coordinates and check those exact coordinates are recorded or not for scrolls
|
|
29
|
+
cy.scrollTo("bottom");
|
|
30
|
+
// click button that triggers view change
|
|
31
|
+
cy.get("#b1").click();
|
|
32
|
+
cy.scrollTo("bottom");
|
|
33
|
+
// click button that triggers view change
|
|
34
|
+
cy.get("#b2").click();
|
|
35
|
+
// 2 request with 1 session and 1 events
|
|
36
|
+
cy.fetch_local_request_queue(hp.appKey).then((rq) => {
|
|
37
|
+
cy.log(rq);
|
|
38
|
+
expect(rq.length).to.equal(2);
|
|
39
|
+
cy.check_session(rq[0], undefined, undefined, hp.appKey);
|
|
40
|
+
});
|
|
41
|
+
// 6 events with 4 views and 2 scrolls must be here
|
|
42
|
+
cy.fetch_local_event_queue(hp.appKey).then((eq) => {
|
|
43
|
+
cy.log(eq);
|
|
44
|
+
cy.check_scroll_event(eq[0]);
|
|
45
|
+
cy.check_view_event(eq[1], "/cypress/fixtures/scroll_test_3.html", 0);
|
|
46
|
+
cy.check_view_event(eq[2], "v1");
|
|
47
|
+
cy.check_scroll_event(eq[3]);
|
|
48
|
+
cy.check_view_event(eq[4], "v1", 0);
|
|
49
|
+
cy.check_view_event(eq[5], "v2");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -1,154 +1,154 @@
|
|
|
1
|
-
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
2
|
-
/* eslint-disable require-jsdoc */
|
|
3
|
-
var Countly = require("../../lib/countly");
|
|
4
|
-
var hp = require("../support/helper");
|
|
5
|
-
|
|
6
|
-
const limits = {
|
|
7
|
-
key: 8,
|
|
8
|
-
value: 8,
|
|
9
|
-
segment: 3,
|
|
10
|
-
breadcrumb: 2,
|
|
11
|
-
line_thread: 3,
|
|
12
|
-
line_length: 10
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function initMain() {
|
|
16
|
-
Countly.init({
|
|
17
|
-
app_key: "YOUR_APP_KEY",
|
|
18
|
-
url: "https://try.count.ly",
|
|
19
|
-
max_events: -1,
|
|
20
|
-
|
|
21
|
-
debug: true,
|
|
22
|
-
max_key_length: limits.key, // set maximum key length here
|
|
23
|
-
max_value_size: limits.value, // set maximum value length here
|
|
24
|
-
max_segmentation_values: limits.segment, // set maximum segmentation number here
|
|
25
|
-
max_breadcrumb_count: limits.breadcrumb, // set maximum number of logs that will be stored before erasing old ones
|
|
26
|
-
max_stack_trace_lines_per_thread: limits.line_thread, // set maximum number of lines for stack trace
|
|
27
|
-
max_stack_trace_line_length: limits.line_length, // set maximum length of a line for stack
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
const error = {
|
|
31
|
-
stack: "Lorem ipsum dolor sit amet,\n consectetur adipiscing elit, sed do eiusmod tempor\n incididunt ut labore et dolore magna\n aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n Duis aute irure dolor in reprehenderit in voluptate\n velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia\n deserunt mollit anim id\n est laborum.",
|
|
32
|
-
};
|
|
33
|
-
const bread = {
|
|
34
|
-
one: "log1",
|
|
35
|
-
two: "log2",
|
|
36
|
-
three: "log3",
|
|
37
|
-
four: "log4",
|
|
38
|
-
five: "log5 too many",
|
|
39
|
-
six: "log6",
|
|
40
|
-
seven: "log7",
|
|
41
|
-
};
|
|
42
|
-
const customEvent = {
|
|
43
|
-
key: "Enter your key here",
|
|
44
|
-
count: 1,
|
|
45
|
-
segmentation: {
|
|
46
|
-
"key of 1st seg": "Value of 1st seg",
|
|
47
|
-
"key of 2nd seg": "Value of 2nd seg",
|
|
48
|
-
"key of 3rd seg": "Value of 3rd seg",
|
|
49
|
-
"key of 4th seg": "Value of 4th seg",
|
|
50
|
-
"key of 5th seg": "Value of 5th seg",
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
const viewName = "a very long page name";
|
|
54
|
-
|
|
55
|
-
const userDetail = {
|
|
56
|
-
name: "Gottlob Frege",
|
|
57
|
-
username: "Grundgesetze",
|
|
58
|
-
email: "test@isatest.com",
|
|
59
|
-
organization: "Bialloblotzsky",
|
|
60
|
-
phone: "+4555999423",
|
|
61
|
-
// Web URL pointing to user picture
|
|
62
|
-
picture:
|
|
63
|
-
"https://ih0.redbubble.net/image.276305970.7419/flat,550x550,075,f.u3.jpg",
|
|
64
|
-
gender: "M",
|
|
65
|
-
byear: 1848, // birth year
|
|
66
|
-
custom: {
|
|
67
|
-
"SEGkey 1st one": "SEGVal 1st one",
|
|
68
|
-
"SEGkey 2st one": "SEGVal 2st one",
|
|
69
|
-
"SEGkey 3st one": "SEGVal 3st one",
|
|
70
|
-
"SEGkey 4st one": "SEGVal 4st one",
|
|
71
|
-
"SEGkey 5st one": "SEGVal 5st one",
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const customProperties = {
|
|
76
|
-
set: ["name of a character", "Bertrand Arthur William Russell"],
|
|
77
|
-
set_once: ["A galaxy far far away", "Called B48FF"],
|
|
78
|
-
increment_by: ["byear", 123456789012345],
|
|
79
|
-
multiply: ["byear", 2345678901234567],
|
|
80
|
-
max: ["byear", 3456789012345678],
|
|
81
|
-
min: ["byear", 4567890123456789],
|
|
82
|
-
push: ["gender", "II Fernando Valdez"],
|
|
83
|
-
push_unique: ["gender", "III Fernando Valdez"],
|
|
84
|
-
pull: ["gender", "III Fernando Valdez"],
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
describe("Internal limit tests ", () => {
|
|
88
|
-
it("Checks if custom event limits works", () => {
|
|
89
|
-
hp.haltAndClearStorage(() => {
|
|
90
|
-
initMain();
|
|
91
|
-
Countly.add_event(customEvent);
|
|
92
|
-
cy.fetch_local_event_queue().then((eq) => {
|
|
93
|
-
expect(eq.length).to.equal(1);
|
|
94
|
-
cy.check_custom_event_limit(eq[0], customEvent, limits);
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
it("Checks if view event limits works", () => {
|
|
99
|
-
hp.haltAndClearStorage(() => {
|
|
100
|
-
initMain();
|
|
101
|
-
Countly.track_pageview(viewName);
|
|
102
|
-
cy.fetch_local_event_queue().then((eq) => {
|
|
103
|
-
expect(eq.length).to.equal(1);
|
|
104
|
-
cy.check_view_event_limit(eq[0], viewName, limits);
|
|
105
|
-
});
|
|
106
|
-
});
|
|
107
|
-
});
|
|
108
|
-
it("Checks if view event limits works", () => {
|
|
109
|
-
hp.haltAndClearStorage(() => {
|
|
110
|
-
initMain();
|
|
111
|
-
Countly.add_log(bread.one);
|
|
112
|
-
Countly.add_log(bread.two);
|
|
113
|
-
Countly.add_log(bread.three);
|
|
114
|
-
Countly.add_log(bread.four);
|
|
115
|
-
Countly.add_log(bread.five);
|
|
116
|
-
Countly.add_log(bread.six);
|
|
117
|
-
Countly.add_log(bread.seven);
|
|
118
|
-
Countly.log_error(error);
|
|
119
|
-
cy.fetch_local_request_queue().then((rq) => {
|
|
120
|
-
expect(rq.length).to.equal(1);
|
|
121
|
-
cy.check_error_limit(rq[0], limits);
|
|
122
|
-
});
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
it("Checks if user detail limits works", () => {
|
|
126
|
-
hp.haltAndClearStorage(() => {
|
|
127
|
-
initMain();
|
|
128
|
-
Countly.user_details(userDetail);
|
|
129
|
-
cy.fetch_local_request_queue().then((rq) => {
|
|
130
|
-
expect(rq.length).to.equal(1);
|
|
131
|
-
cy.check_user_details(rq[0], userDetail, limits);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
it("Checks if custom property limits works", () => {
|
|
136
|
-
hp.haltAndClearStorage(() => {
|
|
137
|
-
initMain();
|
|
138
|
-
Countly.userData.set(customProperties.set[0], customProperties.set[1]); // set custom property
|
|
139
|
-
Countly.userData.set_once(customProperties.set_once[0], customProperties.set_once[1]); // set custom property only if property does not exist
|
|
140
|
-
Countly.userData.increment_by(customProperties.increment_by[0], customProperties.increment_by[1]); // increment value in key by provided value
|
|
141
|
-
Countly.userData.multiply(customProperties.multiply[0], customProperties.multiply[1]); // multiply value in key by provided value
|
|
142
|
-
Countly.userData.max(customProperties.max[0], customProperties.max[1]); // save max value between current and provided
|
|
143
|
-
Countly.userData.min(customProperties.min[0], customProperties.min[1]); // save min value between current and provided
|
|
144
|
-
Countly.userData.push(customProperties.push[0], customProperties.push[1]); // add value to key as array element
|
|
145
|
-
Countly.userData.push_unique(customProperties.push_unique[0], customProperties.push_unique[1]); // add value to key as array element, but only store unique values in array
|
|
146
|
-
Countly.userData.pull(customProperties.pull[0], customProperties.pull[1]); // remove value from array under property with key as name
|
|
147
|
-
Countly.userData.save();
|
|
148
|
-
cy.fetch_local_request_queue().then((rq) => {
|
|
149
|
-
expect(rq.length).to.equal(1);
|
|
150
|
-
cy.check_custom_properties(rq[0], customProperties, limits);
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
});
|
|
1
|
+
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
2
|
+
/* eslint-disable require-jsdoc */
|
|
3
|
+
var Countly = require("../../lib/countly");
|
|
4
|
+
var hp = require("../support/helper");
|
|
5
|
+
|
|
6
|
+
const limits = {
|
|
7
|
+
key: 8,
|
|
8
|
+
value: 8,
|
|
9
|
+
segment: 3,
|
|
10
|
+
breadcrumb: 2,
|
|
11
|
+
line_thread: 3,
|
|
12
|
+
line_length: 10
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
function initMain() {
|
|
16
|
+
Countly.init({
|
|
17
|
+
app_key: "YOUR_APP_KEY",
|
|
18
|
+
url: "https://try.count.ly",
|
|
19
|
+
max_events: -1,
|
|
20
|
+
test_mode: true,
|
|
21
|
+
debug: true,
|
|
22
|
+
max_key_length: limits.key, // set maximum key length here
|
|
23
|
+
max_value_size: limits.value, // set maximum value length here
|
|
24
|
+
max_segmentation_values: limits.segment, // set maximum segmentation number here
|
|
25
|
+
max_breadcrumb_count: limits.breadcrumb, // set maximum number of logs that will be stored before erasing old ones
|
|
26
|
+
max_stack_trace_lines_per_thread: limits.line_thread, // set maximum number of lines for stack trace
|
|
27
|
+
max_stack_trace_line_length: limits.line_length, // set maximum length of a line for stack
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
const error = {
|
|
31
|
+
stack: "Lorem ipsum dolor sit amet,\n consectetur adipiscing elit, sed do eiusmod tempor\n incididunt ut labore et dolore magna\n aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\n Duis aute irure dolor in reprehenderit in voluptate\n velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia\n deserunt mollit anim id\n est laborum.",
|
|
32
|
+
};
|
|
33
|
+
const bread = {
|
|
34
|
+
one: "log1",
|
|
35
|
+
two: "log2",
|
|
36
|
+
three: "log3",
|
|
37
|
+
four: "log4",
|
|
38
|
+
five: "log5 too many",
|
|
39
|
+
six: "log6",
|
|
40
|
+
seven: "log7",
|
|
41
|
+
};
|
|
42
|
+
const customEvent = {
|
|
43
|
+
key: "Enter your key here",
|
|
44
|
+
count: 1,
|
|
45
|
+
segmentation: {
|
|
46
|
+
"key of 1st seg": "Value of 1st seg",
|
|
47
|
+
"key of 2nd seg": "Value of 2nd seg",
|
|
48
|
+
"key of 3rd seg": "Value of 3rd seg",
|
|
49
|
+
"key of 4th seg": "Value of 4th seg",
|
|
50
|
+
"key of 5th seg": "Value of 5th seg",
|
|
51
|
+
},
|
|
52
|
+
};
|
|
53
|
+
const viewName = "a very long page name";
|
|
54
|
+
|
|
55
|
+
const userDetail = {
|
|
56
|
+
name: "Gottlob Frege",
|
|
57
|
+
username: "Grundgesetze",
|
|
58
|
+
email: "test@isatest.com",
|
|
59
|
+
organization: "Bialloblotzsky",
|
|
60
|
+
phone: "+4555999423",
|
|
61
|
+
// Web URL pointing to user picture
|
|
62
|
+
picture:
|
|
63
|
+
"https://ih0.redbubble.net/image.276305970.7419/flat,550x550,075,f.u3.jpg",
|
|
64
|
+
gender: "M",
|
|
65
|
+
byear: 1848, // birth year
|
|
66
|
+
custom: {
|
|
67
|
+
"SEGkey 1st one": "SEGVal 1st one",
|
|
68
|
+
"SEGkey 2st one": "SEGVal 2st one",
|
|
69
|
+
"SEGkey 3st one": "SEGVal 3st one",
|
|
70
|
+
"SEGkey 4st one": "SEGVal 4st one",
|
|
71
|
+
"SEGkey 5st one": "SEGVal 5st one",
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const customProperties = {
|
|
76
|
+
set: ["name of a character", "Bertrand Arthur William Russell"],
|
|
77
|
+
set_once: ["A galaxy far far away", "Called B48FF"],
|
|
78
|
+
increment_by: ["byear", 123456789012345],
|
|
79
|
+
multiply: ["byear", 2345678901234567],
|
|
80
|
+
max: ["byear", 3456789012345678],
|
|
81
|
+
min: ["byear", 4567890123456789],
|
|
82
|
+
push: ["gender", "II Fernando Valdez"],
|
|
83
|
+
push_unique: ["gender", "III Fernando Valdez"],
|
|
84
|
+
pull: ["gender", "III Fernando Valdez"],
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
describe("Internal limit tests ", () => {
|
|
88
|
+
it("Checks if custom event limits works", () => {
|
|
89
|
+
hp.haltAndClearStorage(() => {
|
|
90
|
+
initMain();
|
|
91
|
+
Countly.add_event(customEvent);
|
|
92
|
+
cy.fetch_local_event_queue().then((eq) => {
|
|
93
|
+
expect(eq.length).to.equal(1);
|
|
94
|
+
cy.check_custom_event_limit(eq[0], customEvent, limits);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
it("Checks if view event limits works", () => {
|
|
99
|
+
hp.haltAndClearStorage(() => {
|
|
100
|
+
initMain();
|
|
101
|
+
Countly.track_pageview(viewName);
|
|
102
|
+
cy.fetch_local_event_queue().then((eq) => {
|
|
103
|
+
expect(eq.length).to.equal(1);
|
|
104
|
+
cy.check_view_event_limit(eq[0], viewName, limits);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
it("Checks if view event limits works", () => {
|
|
109
|
+
hp.haltAndClearStorage(() => {
|
|
110
|
+
initMain();
|
|
111
|
+
Countly.add_log(bread.one);
|
|
112
|
+
Countly.add_log(bread.two);
|
|
113
|
+
Countly.add_log(bread.three);
|
|
114
|
+
Countly.add_log(bread.four);
|
|
115
|
+
Countly.add_log(bread.five);
|
|
116
|
+
Countly.add_log(bread.six);
|
|
117
|
+
Countly.add_log(bread.seven);
|
|
118
|
+
Countly.log_error(error);
|
|
119
|
+
cy.fetch_local_request_queue().then((rq) => {
|
|
120
|
+
expect(rq.length).to.equal(1);
|
|
121
|
+
cy.check_error_limit(rq[0], limits);
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
it("Checks if user detail limits works", () => {
|
|
126
|
+
hp.haltAndClearStorage(() => {
|
|
127
|
+
initMain();
|
|
128
|
+
Countly.user_details(userDetail);
|
|
129
|
+
cy.fetch_local_request_queue().then((rq) => {
|
|
130
|
+
expect(rq.length).to.equal(1);
|
|
131
|
+
cy.check_user_details(rq[0], userDetail, limits);
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
it("Checks if custom property limits works", () => {
|
|
136
|
+
hp.haltAndClearStorage(() => {
|
|
137
|
+
initMain();
|
|
138
|
+
Countly.userData.set(customProperties.set[0], customProperties.set[1]); // set custom property
|
|
139
|
+
Countly.userData.set_once(customProperties.set_once[0], customProperties.set_once[1]); // set custom property only if property does not exist
|
|
140
|
+
Countly.userData.increment_by(customProperties.increment_by[0], customProperties.increment_by[1]); // increment value in key by provided value
|
|
141
|
+
Countly.userData.multiply(customProperties.multiply[0], customProperties.multiply[1]); // multiply value in key by provided value
|
|
142
|
+
Countly.userData.max(customProperties.max[0], customProperties.max[1]); // save max value between current and provided
|
|
143
|
+
Countly.userData.min(customProperties.min[0], customProperties.min[1]); // save min value between current and provided
|
|
144
|
+
Countly.userData.push(customProperties.push[0], customProperties.push[1]); // add value to key as array element
|
|
145
|
+
Countly.userData.push_unique(customProperties.push_unique[0], customProperties.push_unique[1]); // add value to key as array element, but only store unique values in array
|
|
146
|
+
Countly.userData.pull(customProperties.pull[0], customProperties.pull[1]); // remove value from array under property with key as name
|
|
147
|
+
Countly.userData.save();
|
|
148
|
+
cy.fetch_local_request_queue().then((rq) => {
|
|
149
|
+
expect(rq.length).to.equal(1);
|
|
150
|
+
cy.check_custom_properties(rq[0], customProperties, limits);
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
|
154
154
|
});
|