Skip to content

Commit 15f4aa7

Browse files
committed
Merge branch 'SER-683' of https://github.com/Countly/countly-server into SER-683
2 parents a46cd0e + d93b3a5 commit 15f4aa7

File tree

193 files changed

+10082
-12168
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+10082
-12168
lines changed

.eslintrc.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,6 @@
237237
"for-direction": [
238238
"off"
239239
],
240-
"no-console": [
241-
"off"
242-
],
243240
"no-control-regex": [
244241
"off"
245242
],
@@ -343,4 +340,4 @@
343340
}
344341
}
345342
]
346-
}
343+
}

.github/dependabot.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,9 @@ updates:
202202
interval: daily
203203
open-pull-requests-limit: 10
204204
reviewers:
205-
- iartem
205+
- cihadtekin
206206
assignees:
207-
- iartem
207+
- cihadtekin
208208
labels:
209209
- dependencies
210210
versioning-strategy: increase-if-necessary

.github/workflows/main.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,11 @@ jobs:
155155
shell: bash
156156
run: "sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js"
157157

158+
- name: NPM install
159+
shell: bash
160+
working-directory: /opt/countly
161+
run: npm install
162+
158163
- name: Run tests
159164
shell: bash
160165
working-directory: /opt/countly
@@ -202,6 +207,11 @@ jobs:
202207
shell: bash
203208
run: "sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js"
204209

210+
- name: NPM install
211+
shell: bash
212+
working-directory: /opt/countly
213+
run: npm install
214+
205215
- name: Install plugins
206216
shell: bash
207217
run: |
@@ -255,6 +265,11 @@ jobs:
255265
shell: bash
256266
run: "sed -i 's/mongosh --quiet/mongosh --host mongodb --quiet/' /opt/countly/bin/backup/import_events.sh && sed -i 's/mongoimport --db/mongoimport --host mongodb --db/' /opt/countly/bin/backup/import_events.sh"
257267

268+
- name: NPM install
269+
shell: bash
270+
working-directory: /opt/countly
271+
run: npm install
272+
258273
- name: Prepare environment
259274
shell: bash
260275
working-directory: /opt/countly
@@ -332,6 +347,11 @@ jobs:
332347
shell: bash
333348
run: "sed -i 's/mongosh --quiet/mongosh --host mongodb --quiet/' /opt/countly/bin/backup/import_events.sh && sed -i 's/mongoimport --db/mongoimport --host mongodb --db/' /opt/countly/bin/backup/import_events.sh"
334349

350+
- name: NPM install
351+
shell: bash
352+
working-directory: /opt/countly
353+
run: npm install
354+
335355
- name: Prepare environment
336356
shell: bash
337357
working-directory: /opt/countly

CHANGELOG.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,121 @@
1+
## Version 24.05.11
2+
Fixes:
3+
- [cache] Use a cursor without timeout
4+
5+
## Version 24.05.10
6+
Fixes:
7+
- [alerts] Alerts improvements
8+
- [core] Various fixes for frontend to support running countly from subdirectory
9+
- [logs] Show collected problems on logger
10+
11+
Enterprise fixes:
12+
- [data-manager] Fixes n UI to allow events starting with "/"
13+
- [flows] Fixes for flows step generation
14+
- [surveys] Other is not allowed as a valid answer for required questions
15+
16+
## Version 24.05.9
17+
Fixes:
18+
- [crashes] Fix crashes template paths and add data check
19+
20+
Enterprise fixes:
21+
- [license] Fix for License warning appears is Flex server
22+
- [drill] Fix typo in view regeneration api response
23+
24+
## Version 24.05.8
25+
Fixes:
26+
- [scripts] script to check settings limits
27+
- [crashes] Update custom field cleanup script with streaming
28+
- [core] Skip data masking on internal appUsers data refetching query
29+
- [core][bugfix] Correct validation on "is any plugin masked"
30+
- [scripts] Delete custom events scripts
31+
- [dashboards] Show edit option also for invalid widgets
32+
- [core] batcher stats added
33+
- [dependencies] Bump xlsx-write-stream from 1.0.2 to 1.0.3
34+
35+
Enterprise fixes:
36+
- [data-manager] changes to allow skipping query rewriting using passed property
37+
- [os] fix for changing default repository of CentOS 8 to vault because OS reached EOL
38+
39+
## Version 24.05.7
40+
Fixes:
41+
- [countly-request]Fix countly-request get and post methods
42+
- [core] Improvements to prevent XSS
43+
- [push] objects are not allowed for the properties inside "data" key of the payload in new FCM API
44+
- [populator] Fixes for handling bulk requests
45+
46+
Enterprise fixes:
47+
- [adjust] Added adjust plugin
48+
- [surveys] UI changes for table
49+
50+
## Version 24.05.6
51+
Fixes:
52+
- [data-manager] Fix for event deletion timeout
53+
- [alerts] Fix for special character problem in value part for all data types
54+
- [scripts] Fix for old views script
55+
- [server-stats] Add monthly data points endpoint
56+
57+
Enterprise fixes:
58+
- [config-transfer] Correct check when adding config transfer menu item
59+
- [users] Changes to show sample document download for all users
60+
- [funnels] Prevent autofill from Chrome on inputs
61+
- [drill] Fix for case when it is not possible to download table in drill
62+
- [surveys] Update popup height attribute in survey widgets
63+
- [license] Get correct license metric values
64+
- [okta] Add config extender code for OKTA
65+
66+
## Version 24.05.5
67+
Fixes:
68+
- [push] p12 file parsing bug fixed
69+
- [views] script to delete old views
70+
71+
Enterprise fixes:
72+
- [active_users] Fixes for Active users recalculation
73+
74+
## Version 24.05.4
75+
Fixes:
76+
- [core] Make sure Unicode characters are escaped for events segment values on incoming data
77+
- [dashboard] Small UI fixes for dealing with unexpected appid values
78+
79+
Features:
80+
- [core] Script for getting document counts of drill collections
81+
82+
Enterprise fixes:
83+
- [drill] Make sure Unicode characters are escaped for events segment values on incoming data
84+
85+
## Version 24.05.3
86+
Fixes:
87+
- [core] Bugfix for newsletter check
88+
- [core] Presets UI fixes
89+
- [core] Security Vulnerabilities and bugs
90+
- [events] Fix event chart selection
91+
- [push] Hotfix: removed the projection from push token query
92+
- [star-rating] Text and link sanitization
93+
94+
Features:
95+
- [core] Run once option for crash removal script
96+
- [populator] Add warning in case salt is set to application
97+
98+
Enterprise fixes:
99+
- [block] Add user prop support for crash blocking and isset operator overall
100+
- [drill] Fixes for query builder when dealing with values starting with an empty string
101+
102+
103+
## Version 24.05.2
104+
Fixes:
105+
- [dashboards] Disable intercom for custom dashboards
106+
- [data-manager] Fix duplicate Create Event Group button
107+
- [push] Push config is not being loaded properly
108+
- [push] Push FCM SDK is not using proxy while sending messages
109+
- [core] Fix height inconsistency in datepicker popup
110+
- [core] Fixes to prevent scheduling duplicated jobs
111+
- [core] Making sure "Exclude current day" works everywhere
112+
- [dashboards] Fix issues in note widget
113+
- [flows] Nullcheck in default flows creation function.
114+
115+
Enterprise fixes:
116+
- [flows] Nullcheck in default flows creation function
117+
- [drill] Nullcheck when fetching snapshots data
118+
1119
## Version 24.05.1
2120
Fixes:
3121
- [populator] Bugfix for - Can't edit populator template

api/config.sample.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ var countlyConfig = {
106106
* Specifies where to store files. Value "fs" means file system or basically storing files on hard drive. Another currently supported option is "gridfs" storing files in MongoDB database using GridFS. By default fallback to "fs";
107107
* @type {string} [default=fs]
108108
*/
109-
fileStorage: "fs",
109+
fileStorage: "gridfs",
110110
/**
111111
* Specifies after how long time configurations are reloded from data base. Default value is 10000 (10 seconds)
112112
* @type {integer} [default=10000]
@@ -120,7 +120,7 @@ var countlyConfig = {
120120
/**
121121
* Share same database connection pool between databases
122122
*/
123-
shared_connection: false,
123+
shared_connection: true,
124124
/**
125125
* Simple SMTP mail sender configuration.
126126
* Can only be used when you don't have custom mailer extend ({@code countly/extend/mail.js}).

api/lib/countly.common.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,17 @@ function getPeriodObject(prmPeriod, bucket) {
384384

385385
var period = prmPeriod || _period;
386386

387-
var excludeCurrentDay = period.excludeCurrentDay || false;
387+
if (typeof period === 'string' && period.indexOf(",") !== -1) {
388+
try {
389+
period = JSON.parse(period);
390+
}
391+
catch (SyntaxError) {
392+
console.log("period JSON parse failed");
393+
period = "30days";
394+
}
395+
}
396+
397+
var excludeCurrentDay = period.exclude_current_day || false;
388398

389399
if (period.period) {
390400
period = period.period;
@@ -396,16 +406,6 @@ function getPeriodObject(prmPeriod, bucket) {
396406
period = [period.since, endTimestamp.clone().valueOf()];
397407
}
398408

399-
if (period && typeof period === 'string' && period.indexOf(",") !== -1) {
400-
try {
401-
period = JSON.parse(period);
402-
}
403-
catch (SyntaxError) {
404-
console.log("period JSON parse failed");
405-
period = "30days";
406-
}
407-
}
408-
409409
if (Array.isArray(period)) {
410410
if ((period[0] + "").length === 10) {
411411
period[0] *= 1000;

api/parts/data/batcher.js

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@ const plugins = require('../../../plugins/pluginManager.js');
44
const log = require('../../utils/log.js')("batcher");
55
const common = require('../../utils/common.js');
66

7-
7+
var batcherStats = {
8+
key: 'BATCHER_STATS',
9+
pid: process.pid,
10+
insert_queued: 0,
11+
insert_processing: 0,
12+
insert_errored_fallback: 0,
13+
insert_errored_no_fallback: 0,
14+
insert_errored_no_fallback_last_error: "",
15+
update_queued: 0,
16+
update_processing: 0,
17+
update_errored_fallback: 0,
18+
update_errored_no_fallback: 0,
19+
update_errored_no_fallback_last_error: "",
20+
};
21+
22+
setInterval(function() {
23+
log.i('%j', batcherStats);
24+
}, 10000);
825
/**
926
* Class for batching database insert operations
1027
* @example
@@ -56,13 +73,16 @@ class InsertBatcher {
5673
if (this.data[db][collection].length) {
5774
var docs = this.data[db][collection];
5875
this.data[db][collection] = [];
76+
batcherStats.insert_queued -= docs.length;
77+
batcherStats.insert_processing += docs.length;
5978
try {
6079
await new Promise((resolve, reject) => {
6180
this.dbs[db].collection(collection).insertMany(docs, {ordered: false, ignore_errors: [11000]}, function(err, res) {
6281
if (err) {
6382
reject(err);
6483
return;
6584
}
85+
batcherStats.insert_processing -= docs.length;
6686
resolve(res);
6787
});
6888
});
@@ -75,7 +95,10 @@ class InsertBatcher {
7595
//trying to rollback operations to try again on next iteration
7696
if (ex.writeErrors && ex.writeErrors.length) {
7797
for (let i = 0; i < ex.writeErrors.length; i++) {
98+
batcherStats.insert_processing--;
7899
if (no_fallback_errors.indexOf(ex.writeErrors[i].code) !== -1) {
100+
batcherStats.insert_errored_no_fallback++;
101+
batcherStats.insert_errored_no_fallback_last_error = ex.writeErrors[i].errmsg;
79102
//dispatch failure
80103
if (notify_fallback_errors.indexOf(ex.writeErrors[i].code) !== -1) {
81104
var index0 = ex.writeErrors[i].index;
@@ -85,6 +108,7 @@ class InsertBatcher {
85108
//we could record in diagnostic data
86109
continue;
87110
}
111+
batcherStats.insert_errored_fallback++;
88112
let index = ex.writeErrors[i].index;
89113
if (docs[index]) {
90114
this.data[db][collection].push(docs[index]);
@@ -136,8 +160,10 @@ class InsertBatcher {
136160
for (let i = 0; i < doc.length; i++) {
137161
this.data[db][collection].push(doc[i]);
138162
}
163+
batcherStats.insert_queued += doc.length;
139164
}
140165
else {
166+
batcherStats.insert_queued++;
141167
this.data[db][collection].push(doc);
142168
}
143169
if (!this.process) {
@@ -212,13 +238,16 @@ class WriteBatcher {
212238
}
213239
}
214240
this.data[db][collection] = {};
241+
batcherStats.update_queued -= queries.length;
242+
batcherStats.update_processing += queries.length;
215243
try {
216244
await new Promise((resolve, reject) => {
217245
this.dbs[db].collection(collection).bulkWrite(queries, {ordered: false, ignore_errors: [11000]}, function(err, res) {
218246
if (err) {
219247
reject(err);
220248
return;
221249
}
250+
batcherStats.update_processing -= queries.length;
222251
resolve(res);
223252
});
224253
});
@@ -231,8 +260,10 @@ class WriteBatcher {
231260
//trying to rollback operations to try again on next iteration
232261
if (ex.writeErrors && ex.writeErrors.length) {
233262
for (let i = 0; i < ex.writeErrors.length; i++) {
234-
263+
batcherStats.update_processing--;
235264
if (no_fallback_errors.indexOf(ex.writeErrors[i].code) !== -1) {
265+
batcherStats.update_errored_no_fallback++;
266+
batcherStats.update_errored_no_fallback_last_error = ex.writeErrors[i].errmsg;
236267
//dispatch failure
237268
if (notify_errors.indexOf(ex.writeErrors[i].code) !== -1) {
238269
var index0 = ex.writeErrors[i].index;
@@ -242,6 +273,7 @@ class WriteBatcher {
242273
//we could record in diagnostic data
243274
continue;
244275
}
276+
batcherStats.update_errored_fallback++;
245277
let index = ex.writeErrors[i].index;
246278
if (queries[index]) {
247279
//if we don't have anything for this document yet just use query
@@ -316,6 +348,7 @@ class WriteBatcher {
316348
}
317349
if (!this.data[db][collection][id]) {
318350
this.data[db][collection][id] = {id: id, value: operation};
351+
batcherStats.update_queued++;
319352
}
320353
else {
321354
this.data[db][collection][id].value = common.mergeQuery(this.data[db][collection][id].value, operation);
@@ -653,4 +686,4 @@ function getId() {
653686
return crypto.randomBytes(16).toString("hex");
654687
}
655688

656-
module.exports = {WriteBatcher, ReadBatcher, InsertBatcher};
689+
module.exports = {WriteBatcher, ReadBatcher, InsertBatcher};

api/parts/data/cache.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ class StreamedCollection {
971971
let [col, last] = await createCollection(this.db, this.name, 1e7);
972972

973973
this.col = col;
974-
this.stream = col.find({_id: {$gt: last}}, {tailable: true, awaitData: true, numberOfRetries: -1}).stream();
974+
this.stream = col.find({_id: {$gt: last}}, {tailable: true, awaitData: true, noCursorTimeout: true, numberOfRetries: -1}).stream();
975975

976976
this.stream.on('data', doc => {
977977
if (this.inserts.indexOf(doc._id.toString()) !== -1) {

0 commit comments

Comments
 (0)