Skip to content

Commit 23cb989

Browse files
authored
Merge branch 'master' into SER-1993-push-token-gets-revoked-on-device-request-if-its-already-in-db
2 parents 1f2a0dc + 32ce8ba commit 23cb989

File tree

11 files changed

+154
-36
lines changed

11 files changed

+154
-36
lines changed

CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1+
## Version 24.05.13
2+
Fixes:
3+
- [alerts] Fixed bugs related to NPS alerts
4+
- [crash] Reworked symbol files upload to support larger symbol files
5+
- [push] Fixed bug that would surface when sending Array or Object related payload
6+
7+
Enterprise fixes:
8+
- [ab-testing] Slight improvements to the UI and UX
9+
- [remote-config] Slight improvements to the UI and UX
10+
11+
Enterprise Features:
12+
- [ab-testing] Improved UI for selecting AB test expiration
13+
114
## Version 24.05.12
215
Fixes:
316
- [dashboards] Fixes for dashboards grid

api/api.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,18 @@ plugins.connectToAllDatabases().then(function() {
370370
}
371371

372372
const form = new formidable.IncomingForm(formidableOptions);
373-
req.body = '';
374-
req.on('data', (data) => {
375-
req.body += data;
376-
});
373+
if (/crash_symbols\/(add_symbol|upload_symbol)/.test(req.url)) {
374+
req.body = [];
375+
req.on('data', (data) => {
376+
req.body.push(data);
377+
});
378+
}
379+
else {
380+
req.body = '';
381+
req.on('data', (data) => {
382+
req.body += data;
383+
});
384+
}
377385

378386
let multiFormData = false;
379387
// Check if we have 'multipart/form-data'
@@ -432,4 +440,4 @@ plugins.connectToAllDatabases().then(function() {
432440

433441
plugins.loadConfigs(common.db);
434442
}
435-
});
443+
});

api/parts/data/cache.js

+1-1
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, noCursorTimeout: true, numberOfRetries: -1}).stream();
974+
this.stream = col.find({_id: {$gt: last}}, {tailable: true, awaitData: true, numberOfRetries: -1}).stream();
975975

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

api/parts/mgmt/cms.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,21 @@ function syncCMSDataToDB(params) {
157157
}
158158

159159
cmsApi.saveEntries = function(params) {
160+
161+
var entries = [];
162+
try {
163+
entries = JSON.parse(params.qstring.entries);
164+
}
165+
catch (ex) {
166+
log.e(params.qstring.entries);
167+
common.returnMessage(params, 400, 'Invalid entries parameter');
168+
return;
169+
}
170+
160171
transformAndStoreData(
161172
Object.assign({dataTransformed: true}, params),
162173
null,
163-
JSON.parse(params.qstring.entries),
174+
entries,
164175
function(err1) {
165176
if (err1) {
166177
log.e('An error occured while storing entries in DB: ' + err1);

api/utils/requestProcessor.js

+9
Original file line numberDiff line numberDiff line change
@@ -1824,6 +1824,9 @@ const processRequest = (params) => {
18241824
switch (paths[3]) {
18251825
case 'all':
18261826
validateRead(params, 'core', () => {
1827+
if (!params.qstring.query) {
1828+
params.qstring.query = {};
1829+
}
18271830
if (typeof params.qstring.query === "string") {
18281831
try {
18291832
params.qstring.query = JSON.parse(params.qstring.query);
@@ -1864,6 +1867,9 @@ const processRequest = (params) => {
18641867
break;
18651868
case 'count':
18661869
validateRead(params, 'core', () => {
1870+
if (!params.qstring.query) {
1871+
params.qstring.query = {};
1872+
}
18671873
if (typeof params.qstring.query === "string") {
18681874
try {
18691875
params.qstring.query = JSON.parse(params.qstring.query);
@@ -1896,6 +1902,9 @@ const processRequest = (params) => {
18961902
break;
18971903
case 'list':
18981904
validateRead(params, 'core', () => {
1905+
if (!params.qstring.query) {
1906+
params.qstring.query = {};
1907+
}
18991908
if (typeof params.qstring.query === "string") {
19001909
try {
19011910
params.qstring.query = JSON.parse(params.qstring.query);

frontend/express/public/localization/dashboard/dashboard.properties

+2
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ common.in-last-weeks-plural = in the last {0} weeks
290290
common.in-last-weeks = in the last week
291291
common.in-last-months-plural = in the last {0} months
292292
common.in-last-months = in the last month
293+
common.in-last-years-plural = in the last {0} years
294+
common.in-last-years = in the last year
293295
common.time-period-select.custom-range = Custom range
294296
common.time-period-select.presets = Presets
295297
common.time-period-select.last-n = In the last

frontend/express/views/dashboard.html

+16
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,22 @@
2929
ignoreURLs: ["action=refresh", "method=live", "stats.count.ly", "method=get_events", "display_loader=false"]
3030
}
3131
};
32+
window.loadPlugin = function(plugin, callback, args){
33+
if (typeof plugin !== "string") {
34+
console.log("when loading plugin, provided plugin was not a string, but a", plugin);
35+
}
36+
if (typeof callback !== "function") {
37+
console.log("when loading plugin", plugin, "provided callback was not a function, but a", callback);
38+
}
39+
if (countlyGlobal.plugins.indexOf(plugin) !== -1) {
40+
if (Array.isArray(args)){
41+
callback.apply(window, args);
42+
}
43+
else {
44+
callback(args);
45+
}
46+
}
47+
};
3248
</script>
3349
<link rel="stylesheet" href="<%- cdn %>stylesheets/font-awesome/css/font-awesome.min.css?<%= countlyVersion %>" />
3450
<link rel="stylesheet" href="<%- cdn %>stylesheets/countly-icons/style.css?<%= countlyVersion %>" />

plugins/pluginManager.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -2087,21 +2087,27 @@ var pluginManager = function pluginManager() {
20872087
return value;
20882088
}
20892089
else {
2090-
return !!myOb;
2090+
if (myOb === true) {
2091+
return true;
2092+
}
2093+
else {
2094+
return false;
2095+
}
20912096
}
20922097
}
20932098
this.isAnyMasked = function() {
2099+
var result = false;
20942100
if (masking && masking.apps) {
20952101
for (var app in masking.apps) {
20962102
if (masking.apps[app]) {
2097-
return hasAnyValueTrue(masking.apps[app].masking);
2103+
result = result || hasAnyValueTrue(masking.apps[app]);
2104+
if (result) {
2105+
return true;
2106+
}
20982107
}
20992108
}
2100-
return false;
2101-
}
2102-
else {
2103-
return false;
21042109
}
2110+
return result;
21052111
};
21062112

21072113
this.getMaskingSettings = function(appID) {

plugins/populator/api/api.js

+29-21
Original file line numberDiff line numberDiff line change
@@ -210,28 +210,36 @@ const FEATURE_NAME = 'populator';
210210

211211
const saveEnvironment = function(ob) {
212212
const obParams = ob.params;
213-
const users = JSON.parse(ob.params.qstring.users);
214-
const setEnviromentInformationOnce = ob.params.qstring.setEnviromentInformationOnce;
215-
if (!users || !users.length) {
216-
common.returnMessage(obParams, 400, "Missing params: " + users);
217-
return false;
218-
}
219-
220-
const environmentId = common.crypto.createHash('sha1').update(users[0].appId + users[0].environmentName).digest('hex');
221-
const insertedInformations = [];
222-
const createdAt = new Date().getTime();
223-
for (let i = 0; i < users.length; i++) {
224-
insertedInformations.push({
225-
_id: users[i].appId + "_" + users[i].templateId + "_" + environmentId + "_" + users[i].deviceId,
226-
userName: users[i].userName,
227-
platform: users[i].platform,
228-
device: users[i].device,
229-
appVersion: users[i].appVersion,
230-
custom: users[i].custom,
231-
createdAt: createdAt
232-
});
233-
}
234213
validateCreate(obParams, FEATURE_NAME, function(params) {
214+
var users = [];
215+
try {
216+
users = JSON.parse(ob.params?.qstring?.users);
217+
}
218+
catch (e) {
219+
log.e(e);
220+
users = [];
221+
}
222+
const setEnviromentInformationOnce = ob.params?.qstring?.setEnviromentInformationOnce ;
223+
if (!users || !users.length) {
224+
common.returnMessage(obParams, 400, "Missing params: users");
225+
return false;
226+
}
227+
228+
const environmentId = common.crypto.createHash('sha1').update(users[0].appId + users[0].environmentName).digest('hex');
229+
const insertedInformations = [];
230+
const createdAt = new Date().getTime();
231+
for (let i = 0; i < users.length; i++) {
232+
insertedInformations.push({
233+
_id: users[i].appId + "_" + users[i].templateId + "_" + environmentId + "_" + users[i].deviceId,
234+
userName: users[i].userName,
235+
platform: users[i].platform,
236+
device: users[i].device,
237+
appVersion: users[i].appVersion,
238+
custom: users[i].custom,
239+
createdAt: createdAt
240+
});
241+
}
242+
235243
if (setEnviromentInformationOnce) {
236244
common.db.collection('populator_environments').insertOne({
237245
_id: environmentId,

plugins/populator/tests.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
var request = require('supertest');
2+
var should = require('should');
3+
var testUtils = require("../../test/testUtils");
4+
request = request(testUtils.url);
5+
6+
var APP_KEY = "";
7+
var API_KEY_ADMIN = "";
8+
var APP_ID = "";
9+
var DEVICE_ID = "1234567890";
10+
11+
describe('Testing Populator plugin', function() {
12+
describe('Testing enviroment endpoint ', function() {
13+
it('Set params', function(done) {
14+
API_KEY_ADMIN = testUtils.get("API_KEY_ADMIN");
15+
APP_ID = testUtils.get("APP_ID");
16+
APP_KEY = testUtils.get("APP_KEY");
17+
done();
18+
});
19+
20+
it('Try without any params', function(done) {
21+
request
22+
.get('/i/populator/environment/save')
23+
.expect(400)
24+
.end(function(err, res) {
25+
var ob = JSON.parse(res.text);
26+
ob.result.should.eql("Missing parameter \"api_key\" or \"auth_token\"");
27+
done();
28+
});
29+
30+
});
31+
32+
it('Try without "users"', function(done) {
33+
request
34+
.get('/i/populator/environment/save?api_key=' + API_KEY_ADMIN)
35+
.expect(400)
36+
.end(function(err, res) {
37+
var ob = JSON.parse(res.text);
38+
ob.result.should.eql("Missing params: users");
39+
done();
40+
});
41+
});
42+
});
43+
44+
45+
});

plugins/server-stats/api/parts/stats.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ function fetchDatapoints(db, filter, options, callback) {
246246
if (options.monthlyBreakdown) {
247247
const dataPoints = result
248248
.reduce((acc, current) => {
249-
let dp = current.e + current.s;
249+
let dp = (current.e || 0) + (current.s || 0);
250250

251251
if (/^\[CLY\]_consolidated/.test(current._id)) {
252252
// do not count consolidated dp for countly hosted clients
@@ -415,4 +415,4 @@ function getAppName(appId, appNames) {
415415
}
416416

417417

418-
module.exports = {updateDataPoints, isConsolidated, increaseDataPoints, punchCard, fetchDatapoints, getTop, getAppName, internalEventsEnum};
418+
module.exports = {updateDataPoints, isConsolidated, increaseDataPoints, punchCard, fetchDatapoints, getTop, getAppName, internalEventsEnum};

0 commit comments

Comments
 (0)