countly-sdk-web 21.11.0 → 21.11.1

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.
Files changed (75) hide show
  1. package/.eslintignore +16 -2
  2. package/.eslintrc.js +65 -49
  3. package/.github/workflows/node.js.yml +2 -2
  4. package/CHANGELOG.md +7 -0
  5. package/README.md +2 -2
  6. package/cypress/.eslintrc.js +23 -0
  7. package/cypress/fixtures/variables.json +1 -0
  8. package/cypress/integration/consents.js +166 -0
  9. package/cypress/integration/events.js +65 -0
  10. package/cypress/integration/internal_limits.js +154 -0
  11. package/cypress/integration/sessions.js +60 -0
  12. package/cypress/integration/user_details.js +40 -0
  13. package/cypress/integration/views.js +63 -0
  14. package/cypress/plugins/index.js +22 -0
  15. package/cypress/support/commands.js +295 -0
  16. package/cypress/support/helper.js +60 -0
  17. package/cypress/support/index.js +3 -0
  18. package/cypress.json +1 -0
  19. package/examples/example_sync.html +11 -9
  20. package/examples/examples_feedback_widgets.html +81 -0
  21. package/examples/mpa/boomerang/boomerang-1.0.0.js +22871 -0
  22. package/examples/mpa/boomerang/countly_boomerang.js +139 -0
  23. package/examples/mpa/index.html +817 -0
  24. package/{samples/react/src/Components/countly.jpg → examples/mpa/team_countly.jpg} +0 -0
  25. package/{samples → examples}/react/README.md +0 -0
  26. package/{samples → examples}/react/package.json +0 -0
  27. package/{samples → examples}/react/public/favicon.ico +0 -0
  28. package/{samples → examples}/react/public/index.html +0 -0
  29. package/{samples → examples}/react/public/manifest.json +0 -0
  30. package/{samples → examples}/react/public/robots.txt +0 -0
  31. package/{samples → examples}/react/src/App-WithEffect.js +0 -0
  32. package/{samples → examples}/react/src/App-WithRouter.js +0 -0
  33. package/{samples → examples}/react/src/App.test.js +0 -0
  34. package/{samples → examples}/react/src/Components/Contact.js +0 -0
  35. package/{samples → examples}/react/src/Components/Header.js +0 -0
  36. package/{samples → examples}/react/src/Components/Home.js +0 -0
  37. package/{samples → examples}/react/src/Components/Users.js +0 -0
  38. package/examples/react/src/Components/countly.jpg +0 -0
  39. package/{samples → examples}/react/src/Components/styles.css +0 -0
  40. package/{samples → examples}/react/src/ErrorBoundary.js +0 -0
  41. package/{samples → examples}/react/src/Location-WithEffect.js +0 -0
  42. package/{samples → examples}/react/src/Location-WithRouter.js +0 -0
  43. package/{samples → examples}/react/src/index.css +0 -0
  44. package/{samples → examples}/react/src/index.js +0 -0
  45. package/{samples → examples}/react/src/serviceWorker.js +0 -0
  46. package/{samples → examples}/react/src/setupTests.js +0 -0
  47. package/{samples → examples}/symbolication/.babelrc +0 -0
  48. package/{samples → examples}/symbolication/.editorconfig +0 -0
  49. package/{samples → examples}/symbolication/.yo-rc.json +0 -0
  50. package/{samples → examples}/symbolication/README.md +0 -0
  51. package/{samples → examples}/symbolication/package.json +0 -0
  52. package/{samples → examples}/symbolication/src/index.js +0 -0
  53. package/{samples → examples}/symbolication/static/index.html +0 -0
  54. package/{samples → examples}/symbolication/webpack.config.js +0 -0
  55. package/generateDocs.sh +2 -2
  56. package/lib/countly.js +964 -614
  57. package/lib/countly.min.js +110 -91
  58. package/package.json +14 -7
  59. package/.travis.yml +0 -17
  60. package/closure-compiler.jar +0 -0
  61. package/countlyWeb.bat +0 -6
  62. package/samples/react/package-lock.json +0 -13893
  63. package/samples/symbolication/package-lock.json +0 -6713
  64. package/test/files/clear.html +0 -9
  65. package/test/files/example_helpers_old.html +0 -69
  66. package/test/files/example_persistancy.html +0 -22
  67. package/test/tests_async.js +0 -166
  68. package/test/tests_ga_adapter.js +0 -275
  69. package/test/tests_gdpr.js +0 -448
  70. package/test/tests_helpers.js +0 -398
  71. package/test/tests_helpers_old_session.js +0 -448
  72. package/test/tests_multiple_instances.js +0 -120
  73. package/test/tests_persistancy.js +0 -127
  74. package/test/tests_sync.js +0 -153
  75. package/test/utils/clearStorage.js +0 -28
package/.eslintignore CHANGED
@@ -1,4 +1,18 @@
1
1
  lib/countly.min.js
2
2
  lib/countly.pack.js
3
- plugin/boomerang/boomerang*.js
4
- samples
3
+ plugin
4
+ examples
5
+ test
6
+ node_modules
7
+ coverage
8
+ .vscode
9
+ .github
10
+ .gitignore
11
+ bower.json
12
+ CHANGELOG.md
13
+ cypress.json
14
+ generateDocs.sh
15
+ inch.json
16
+ jsdoc_conf.json
17
+ LICENSE
18
+ webpack.config.js
package/.eslintrc.js CHANGED
@@ -1,14 +1,42 @@
1
1
  module.exports = {
2
- "env": {
3
- "browser": true,
4
- "amd": true,
5
- "commonjs": true
2
+ /**
3
+ * By default, ESLint expects ECMAScript 5 syntax. You can override that setting to enable support
4
+ * for other ECMAScript versions as well as JSX by using parser options. However for IE9 compatibility
5
+ * updating it to ECMAScript 6 or above is currently not permitted. -D
6
+ * */
7
+ env: {
8
+ browser: true,
9
+ amd: true,
10
+ commonjs: true
6
11
  },
7
- "extends": "eslint:recommended",
8
- "parserOptions": {
9
- "ecmaVersion": 5
10
- },
11
- "rules": {
12
+ extends: "airbnb/legacy",
13
+ rules: {
14
+ "prefer-arrow-callback": "off",
15
+ "prefer-destructuring": "off",
16
+ "comma-dangle": "off",
17
+ "no-restricted-globals": "off",
18
+ "no-restricted-properties": "off",
19
+ //
20
+ "no-unused-vars": "warn",
21
+ "no-var": "off",
22
+ "func-names": "off",
23
+ "consistent-return": "off",
24
+ "prefer-rest-params": "off",
25
+ radix: "off",
26
+ "prefer-spread": "off",
27
+ "no-plusplus": "off",
28
+ camelcase: "off",
29
+ "no-use-before-define": "off",
30
+ "no-lonely-if": "off",
31
+ "no-restricted-syntax": "off",
32
+ "vars-on-top": "off",
33
+ "no-param-reassign": "off",
34
+ "max-len": "off",
35
+ "guard-for-in": "off",
36
+ "no-underscore-dangle": "off",
37
+ "no-bitwise": "off",
38
+ "no-mixed-operators": "off",
39
+ "object-shorthand": "off",
12
40
  "block-spacing": [
13
41
  "error",
14
42
  "always"
@@ -20,8 +48,8 @@ module.exports = {
20
48
  "comma-spacing": [
21
49
  "error",
22
50
  {
23
- "before": false,
24
- "after": true
51
+ before: false,
52
+ after: true
25
53
  }
26
54
  ],
27
55
  "comma-style": [
@@ -32,7 +60,7 @@ module.exports = {
32
60
  "error",
33
61
  "never"
34
62
  ],
35
- "curly": [
63
+ curly: [
36
64
  "error",
37
65
  "all"
38
66
  ],
@@ -41,22 +69,22 @@ module.exports = {
41
69
  "error",
42
70
  "never"
43
71
  ],
44
- "indent": [
72
+ indent: [
45
73
  "error",
46
74
  4
47
75
  ],
48
76
  "key-spacing": [
49
77
  "error",
50
78
  {
51
- "beforeColon": false,
52
- "afterColon": true
79
+ beforeColon: false,
80
+ afterColon: true
53
81
  }
54
82
  ],
55
83
  "keyword-spacing": [
56
84
  "error",
57
85
  {
58
- "before": true,
59
- "after": true
86
+ before: true,
87
+ after: true
60
88
  }
61
89
  ],
62
90
  "lines-between-class-members": [
@@ -69,7 +97,7 @@ module.exports = {
69
97
  "no-trailing-spaces": [
70
98
  "error",
71
99
  {
72
- "ignoreComments": true
100
+ ignoreComments: true
73
101
  }
74
102
  ],
75
103
  "no-whitespace-before-property": [
@@ -78,17 +106,17 @@ module.exports = {
78
106
  "object-curly-newline": [
79
107
  "error",
80
108
  {
81
- "multiline": true,
82
- "consistent": true
109
+ multiline: true,
110
+ consistent: true
83
111
  }
84
112
  ],
85
113
  "object-property-newline": [
86
114
  "error",
87
115
  {
88
- "allowAllPropertiesOnSameLine": true
116
+ allowAllPropertiesOnSameLine: true
89
117
  }
90
118
  ],
91
- "semi": [
119
+ semi: [
92
120
  "error",
93
121
  "always"
94
122
  ],
@@ -114,8 +142,8 @@ module.exports = {
114
142
  "space-unary-ops": [
115
143
  "error",
116
144
  {
117
- "words": true,
118
- "nonwords": false
145
+ words: true,
146
+ nonwords: false
119
147
  }
120
148
  ],
121
149
  "switch-colon-spacing": [
@@ -130,22 +158,24 @@ module.exports = {
130
158
  "unix"
131
159
  ],
132
160
  "no-useless-escape": "off",
133
- "quotes": "off",
161
+ quotes: ["error",
162
+ "double"
163
+ ],
134
164
  "valid-jsdoc": [
135
165
  "error",
136
166
  {
137
- "requireReturn": false
167
+ requireReturn: false
138
168
  }
139
169
  ],
140
170
  "require-jsdoc": [
141
171
  "error",
142
172
  {
143
- "require": {
144
- "FunctionDeclaration": true,
145
- "MethodDefinition": true,
146
- "ClassDeclaration": true,
147
- "ArrowFunctionExpression": true,
148
- "FunctionExpression": false
173
+ require: {
174
+ FunctionDeclaration: true,
175
+ MethodDefinition: true,
176
+ ClassDeclaration: true,
177
+ ArrowFunctionExpression: true,
178
+ FunctionExpression: false
149
179
  }
150
180
  }
151
181
  ],
@@ -155,7 +185,7 @@ module.exports = {
155
185
  "dot-notation": [
156
186
  "error"
157
187
  ],
158
- "eqeqeq": [
188
+ eqeqeq: [
159
189
  "error",
160
190
  "always"
161
191
  ],
@@ -181,19 +211,5 @@ module.exports = {
181
211
  "error"
182
212
  ]
183
213
  },
184
- "overrides": [
185
- {
186
- "files": [
187
- "test/**/*.js",
188
- "webpack.config.js"
189
- ],
190
- "env": {
191
- "es6": true,
192
- "node": true
193
- },
194
- rules: {
195
- "require-jsdoc": "off",
196
- }
197
- }
198
- ]
199
- };
214
+
215
+ };
@@ -5,9 +5,9 @@ name: Node.js CI
5
5
 
6
6
  on:
7
7
  push:
8
- branches: [ master, next ]
8
+ branches: [ master, staging ]
9
9
  pull_request:
10
- branches: [ master, next ]
10
+ branches: [ master, staging ]
11
11
 
12
12
  jobs:
13
13
  build:
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 21.11.1
2
+ - Fixed feedback widget bug related to the 'close events' origin check
3
+ - When consent is changed it will now send the full consent state instead of just the changed consents
4
+ - Rating widgets will now also be used through the feedback widgets API (in case the server supports it)
5
+ - When overriding 'getViewName' it is now possible to return 'null' to indicate that the page name should not be recorded
6
+ - Logs are now rearranged to include log levels
7
+
1
8
  ## 21.11.0
2
9
  - !! Major breaking change !! Rating and Feedback widgets now require 'star-rating' or 'feedback' consent exclusively, according to their type, instead of both:
3
10
  - `present_feedback_widget` needs 'feedback' consent only
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Countly Web SDK
2
- [![Build Status](https://api.travis-ci.org/Countly/countly-sdk-web.png?branch=master)](https://travis-ci.org/Countly/countly-sdk-web) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/031d2021b8334af3ac8d2462500bd1aa)](https://www.codacy.com/app/ar2rsawseen/countly-sdk-web?utm_source=github.com&utm_medium=referral&utm_content=Countly/countly-sdk-web&utm_campaign=Badge_Grade) [![npm version](https://badge.fury.io/js/countly-sdk-web.svg)](https://badge.fury.io/js/countly-sdk-web) [![Inline docs](https://inch-ci.org/github/Countly/countly-sdk-web.svg?branch=master)](https://inch-ci.org/github/Countly/countly-sdk-web) [![](https://data.jsdelivr.com/v1/package/npm/countly-sdk-web/badge)](https://www.jsdelivr.com/package/npm/countly-sdk-web)
2
+ [![Codacy Badge](https://api.codacy.com/project/badge/Grade/031d2021b8334af3ac8d2462500bd1aa)](https://www.codacy.com/app/ar2rsawseen/countly-sdk-web?utm_source=github.com&utm_medium=referral&utm_content=Countly/countly-sdk-web&utm_campaign=Badge_Grade) [![npm version](https://badge.fury.io/js/countly-sdk-web.svg)](https://badge.fury.io/js/countly-sdk-web) [![Inline docs](https://inch-ci.org/github/Countly/countly-sdk-web.svg?branch=master)](https://inch-ci.org/github/Countly/countly-sdk-web) [![](https://data.jsdelivr.com/v1/package/npm/countly-sdk-web/badge)](https://www.jsdelivr.com/package/npm/countly-sdk-web)
3
3
 
4
4
  ## What is Countly?
5
5
  [Countly](http://count.ly) is a product analytics solution and innovation enabler that helps teams track product performance and customer journey and behavior across [mobile](https://count.ly/mobile-analytics), [web](http://count.ly/web-analytics), and [desktop](https://count.ly/desktop-analytics) applications. [Ensuring privacy by design](https://count.ly/your-data-your-rules), Countly allows you to innovate and enhance your products to provide personalized and customized customer experiences, and meet key business and revenue goals.
@@ -30,7 +30,7 @@ or
30
30
 
31
31
  Countly web SDK is available on CDNJS. Use either
32
32
 
33
- [https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/21.11.0/countly.min.js](https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/21.11.0/countly.min.js)
33
+ [https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/21.11.1/countly.min.js](https://cdnjs.cloudflare.com/ajax/libs/countly-sdk-web/21.11.1/countly.min.js)
34
34
 
35
35
  or
36
36
 
@@ -0,0 +1,23 @@
1
+ module.exports = {
2
+ plugins: [
3
+ "cypress"
4
+ ],
5
+ parserOptions: {
6
+ ecmaVersion: 6
7
+ },
8
+ rules: {
9
+ "cypress/no-assigning-return-values": "error",
10
+ "cypress/no-unnecessary-waiting": "off",
11
+ "cypress/assertion-before-screenshot": "warn",
12
+ "cypress/no-force": "warn",
13
+ "cypress/no-async-tests": "error",
14
+ "cypress/no-pause": "error"
15
+ },
16
+ env: {
17
+ "cypress/globals": true
18
+ },
19
+ extends: [
20
+ "plugin:cypress/recommended",
21
+ "plugin:chai-friendly/recommended"
22
+ ],
23
+ };
@@ -0,0 +1 @@
1
+ {}
@@ -0,0 +1,166 @@
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(consent) {
7
+ Countly.init({
8
+ app_key: "YOUR_APP_KEY",
9
+ url: "https://try.count.ly",
10
+ require_consent: consent,
11
+ device_id: "György Ligeti",
12
+ tests: true,
13
+ max_events: -1,
14
+ debug: true
15
+ });
16
+ }
17
+ // gathered events. count and segmentation key/values must be consistent
18
+ const eventArray = [
19
+ // first event must be custom event
20
+ {
21
+ key: "a",
22
+ count: 1,
23
+ segmentation: {
24
+ 1: "1",
25
+ },
26
+ },
27
+ // rest can be internal events
28
+ {
29
+ key: "[CLY]_view",
30
+ count: 2,
31
+ segmentation: {
32
+ 2: "2",
33
+ },
34
+ },
35
+ {
36
+ key: "[CLY]_nps",
37
+ count: 3,
38
+ segmentation: {
39
+ 3: "3",
40
+ },
41
+ },
42
+ {
43
+ key: "[CLY]_survey",
44
+ count: 4,
45
+ segmentation: {
46
+ 4: "4",
47
+ },
48
+ },
49
+ {
50
+ key: "[CLY]_star_rating",
51
+ count: 5,
52
+ segmentation: {
53
+ 5: "5",
54
+ },
55
+ },
56
+ {
57
+ key: "[CLY]_orientation",
58
+ count: 6,
59
+ segmentation: {
60
+ 6: "6",
61
+ },
62
+ }
63
+ ];
64
+ // event adding loop
65
+ function events() {
66
+ for (var i = 0, len = eventArray.length; i < len; i++) {
67
+ Countly.add_event(eventArray[i]);
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Checks a queue object for valid/correct values/limits during consent tests
73
+ * @param {Array} eq - events queue
74
+ * @param {Array} eventArr - events array for the events to test
75
+ * @param {boolean} custom - custom event check
76
+ * @param {boolean} internalOnly - internal event check
77
+ */
78
+ function consent_check(eq, eventArr, custom, internalOnly) {
79
+ var i = 0;
80
+ var b = i;
81
+ var len = eventArr.length;
82
+ if (custom) {
83
+ len = 0;
84
+ }
85
+ if (internalOnly) {
86
+ b = i + 1;
87
+ len = eventArr.length - 1;
88
+ }
89
+ while (i < len) {
90
+ expect(eq[i].key).to.equal(eventArr[b].key);
91
+ expect(eq[i].count).to.equal(eventArr[b].count);
92
+ expect(eq[i].segmentation[eventArr[b].count]).to.equal(eventArr[b].segmentation[eventArr[b].count]);
93
+ i++;
94
+ b++;
95
+ }
96
+ }
97
+
98
+ // tests
99
+ describe("Consent tests", () => {
100
+ it("Only custom event should be sent to the queue", () => {
101
+ hp.haltAndClearStorage(() => {
102
+ initMain(true);
103
+ Countly.add_consent(["events"]);
104
+ events();
105
+ cy.fetch_local_event_queue().then((eq) => {
106
+ expect(eq.length).to.equal(1);
107
+ consent_check(eq, eventArray, true);
108
+ });
109
+ });
110
+ });
111
+ it("All but custom event should be sent to the queue", () => {
112
+ hp.haltAndClearStorage(() => {
113
+ initMain(true);
114
+ Countly.add_consent(["sessions", "views", "users", "star-rating", "apm", "feedback"]);
115
+ events();
116
+ cy.fetch_local_event_queue().then((eq) => {
117
+ expect(eq.length).to.equal(5);
118
+ consent_check(eq, eventArray, false, true);
119
+ });
120
+ });
121
+ });
122
+ it("All consents given and all events should be recorded", () => {
123
+ hp.haltAndClearStorage(() => {
124
+ initMain(true);
125
+ Countly.add_consent(["sessions", "views", "users", "star-rating", "apm", "feedback", "events"]);
126
+ events();
127
+ cy.fetch_local_event_queue().then((eq) => {
128
+ expect(eq.length).to.equal(6);
129
+ consent_check(eq, eventArray, false, false);
130
+ });
131
+ });
132
+ });
133
+ it("No consent required and all events should be recorded", () => {
134
+ hp.haltAndClearStorage(() => {
135
+ initMain(false);
136
+ events();
137
+ cy.fetch_local_event_queue().then((eq) => {
138
+ expect(eq.length).to.equal(6);
139
+ consent_check(eq, eventArray, false, false);
140
+ });
141
+ });
142
+ });
143
+ it("Non-merge ID change should reset all consents", () => {
144
+ hp.haltAndClearStorage(() => {
145
+ initMain(true);
146
+ Countly.add_consent(["sessions", "views", "users", "star-rating", "apm", "feedback"]);
147
+ Countly.change_id("Richard Wagner II", false);
148
+ events();
149
+ cy.fetch_local_event_queue().then((eq) => {
150
+ expect(eq.length).to.equal(0);
151
+ });
152
+ });
153
+ });
154
+ it("Merge ID change should not reset consents", () => {
155
+ hp.haltAndClearStorage(() => {
156
+ initMain(true);
157
+ Countly.add_consent(["sessions", "views", "users", "star-rating", "apm", "feedback"]);
158
+ Countly.change_id("Richard Wagner the second", true);
159
+ events();
160
+ cy.fetch_local_event_queue().then((eq) => {
161
+ expect(eq.length).to.equal(5);
162
+ consent_check(eq, eventArray, false, true);
163
+ });
164
+ });
165
+ });
166
+ });
@@ -0,0 +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
+ tests: 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,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
+ tests: 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
+ });