Skip to content

Commit 4783d0f

Browse files
authored
Merge pull request #7000 from Countly/ar2rsawseen/master2
Tracking improvements
2 parents d287168 + e0cd863 commit 4783d0f

File tree

13 files changed

+111
-51
lines changed

13 files changed

+111
-51
lines changed

api/configextender.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,12 @@ const OVERRIDES = {
5353
CA: 'ca',
5454
},
5555
},
56-
56+
COOKIE: {
57+
SAMESITE: 'sameSite',
58+
HTTPONLY: 'httpOnly',
59+
MAXAGE: 'maxAge',
60+
MAXAGELOGIN: 'maxAgeLogin',
61+
},
5762
MAIL: {
5863
CONFIG: {
5964
IGNORETLS: "ignoreTLS"

api/jobs/ping.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class PingJob extends job.Job {
5151

5252
if (days > 0) {
5353
//calculate seconds timestamp of days before today
54-
var startTs = Math.round((new Date().getTime() - (30 * 24 * 60 * 60 * 1000)) / 1000);
54+
var startTs = Math.round((new Date().getTime() - (days * 24 * 60 * 60 * 1000)) / 1000);
5555

5656
//sync server events - use aggregation pipeline to group by day and action on MongoDB side
5757
var aggregationPipeline = [

api/parts/mgmt/tracker.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,13 @@ tracker.collectServerData = async function() {
249249
edition = "Enterprise";
250250
}
251251
props.edition = edition;
252+
props.hosting = "self-hosted";
253+
if (props.edition === "Flex") {
254+
props.hosting = "flex";
255+
}
256+
else if (props.plugins.includes("tracker")) {
257+
props.hosting = "countly-hosted";
258+
}
252259
if (common.db.build && common.db.build.version) {
253260
props.mongodb = common.db.build.version;
254261
}

api/parts/mgmt/users.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,9 @@ usersApi.checkNoteEditPermission = async function(params) {
861861
if (error) {
862862
return reject(false);
863863
}
864+
if (!note) {
865+
return resolve(false);
866+
}
864867
const globalAdmin = params.member.global_admin;
865868
const isAppAdmin = hasAdminAccess(params.member, params.qstring.app_id);
866869
const noteOwner = (note.owner + '' === params.member._id + '');

api/utils/common.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,7 +1071,7 @@ common.validateArgs = function(args, argProperties, returnErrors) {
10711071
}
10721072

10731073
if (argProperties[arg]['max-length']) {
1074-
if (args[arg].length > argProperties[arg]['max-length']) {
1074+
if (args[arg] && args[arg].length > argProperties[arg]['max-length']) {
10751075
if (returnErrors) {
10761076
returnObj.errors.push("Length of " + arg + " is greater than max length value");
10771077
returnObj.result = false;
@@ -1084,7 +1084,7 @@ common.validateArgs = function(args, argProperties, returnErrors) {
10841084
}
10851085

10861086
if (argProperties[arg]['min-length']) {
1087-
if (args[arg].length < argProperties[arg]['min-length']) {
1087+
if (args[arg] && args[arg].length < argProperties[arg]['min-length']) {
10881088
if (returnErrors) {
10891089
returnObj.errors.push("Length of " + arg + " is lower than min length value");
10901090
returnObj.result = false;

countly-community

Lines changed: 0 additions & 1 deletion
This file was deleted.

plugins/alerts/api/api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,10 @@ const PERIOD_TO_TEXT_EXPRESSION_MAPPER = {
193193

194194
validateCreate(params, FEATURE_NAME, function() {
195195
let alertConfig = params.qstring.alert_config;
196+
if (!alertConfig) {
197+
common.returnMessage(params, 400, 'Missing alert_config');
198+
return;
199+
}
196200
try {
197201
alertConfig = JSON.parse(alertConfig);
198202
var checkProps = {

plugins/compliance-hub/api/api.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ const FEATURE_NAME = 'compliance_hub';
136136
case 'current': {
137137
if (!params.qstring.app_id) {
138138
common.returnMessage(params, 400, 'Missing parameter "app_id"');
139-
return false;
139+
return true;
140140
}
141141
validateRead(params, FEATURE_NAME, function() {
142142
var query = params.qstring.query || {};
@@ -157,7 +157,7 @@ const FEATURE_NAME = 'compliance_hub';
157157
case 'search': {
158158
if (!params.qstring.app_id) {
159159
common.returnMessage(params, 400, 'Missing parameter "app_id"');
160-
return false;
160+
return true;
161161
}
162162
validateRead(params, FEATURE_NAME, function() {
163163
var query = params.qstring.query || {};
@@ -279,7 +279,7 @@ const FEATURE_NAME = 'compliance_hub';
279279
case 'consents': {
280280
if (!params.qstring.app_id) {
281281
common.returnMessage(params, 400, 'Missing parameter "app_id"');
282-
return false;
282+
return true;
283283
}
284284
validateRead(params, FEATURE_NAME, function() {
285285
appUsers.count(params.qstring.app_id, {}, function(err, total) {

plugins/dashboards/frontend/public/javascripts/countly.models.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@
7373
}, {disableAutoCatch: true});
7474
},
7575
get: function(dashboardId, isRefresh) {
76+
if (!dashboardId) {
77+
return Promise.resolve(null);
78+
}
7679
return CV.$.ajax({
7780
type: "GET",
7881
url: countlyCommon.API_PARTS.data.r + "/dashboards",

plugins/dbviewer/api/api.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,12 @@ var spawn = require('child_process').spawn,
152152
**/
153153
function getIndexes() {
154154
dbs[dbNameOnParam].collection(params.qstring.collection).indexes(function(err, indexes) {
155-
if (err) {
156-
common.returnOutput(params, 'Somethings went wrong');
155+
if (err || !indexes) {
156+
common.returnOutput(params, 'Failed to retrieve indexes for the collection');
157+
}
158+
else {
159+
common.returnOutput(params, { limit: indexes.length, start: 1, end: indexes.length, total: indexes.length, pages: 1, curPage: 1, collections: indexes });
157160
}
158-
common.returnOutput(params, { limit: indexes.length, start: 1, end: indexes.length, total: indexes.length, pages: 1, curPage: 1, collections: indexes });
159161
});
160162
}
161163

0 commit comments

Comments
 (0)