Skip to content

Commit 7b52459

Browse files
authoredOct 2, 2024··
Merge branch 'master' into SER-1927
2 parents 7a8c9d4 + 942ad88 commit 7b52459

File tree

12 files changed

+182
-77
lines changed

12 files changed

+182
-77
lines changed
 

‎Gruntfile.js

+20-2
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ module.exports = function(grunt) {
241241
'frontend/express/public/javascripts/dom/drop/drop-theme-countly.min.css',
242242
'frontend/express/public/javascripts/utils/tooltipster/tooltipster.bundle.min.css',
243243
'frontend/express/public/stylesheets/bulma/bulma-custom.css',
244-
'frontend/express/public/stylesheets/styles/manifest.css',
244+
'frontend/express/public/stylesheets/styles/manifest2.css',
245245
'frontend/express/public/stylesheets/vue/element-tiptap.css',
246246
]
247247
}
@@ -324,7 +324,25 @@ module.exports = function(grunt) {
324324

325325
grunt.registerTask('default', ['mochaTest']);
326326

327-
grunt.registerTask('dist', ['sass', 'concat', 'uglify', 'cssmin']);
327+
grunt.registerTask('replace-paths', 'Replace image paths in prod CSS files', function() {
328+
var cssFiles = [
329+
{
330+
filepath: 'frontend/express/public/stylesheets/styles/manifest.css',
331+
lookup: '../../images',
332+
replacement: '../images',
333+
newPath: 'frontend/express/public/stylesheets/styles/manifest2.css'
334+
}
335+
];
336+
337+
cssFiles.forEach(function(file) {
338+
var content = grunt.file.read(file.filepath);
339+
var newContent = content.replace(/\.\.\/\.\.\/images/g, file.replacement);
340+
grunt.file.write(file.newPath, newContent);
341+
grunt.log.writeln('Processed file: ' + file.filepath);
342+
});
343+
});
344+
345+
grunt.registerTask('dist', ['sass', 'concat', 'uglify', 'replace-paths', 'cssmin']);
328346

329347
grunt.registerTask('plugins', 'Minify plugin JS / CSS files and copy images', function() {
330348
var js = [], css = [], img = [], fs = require('fs'), path = require('path');

‎api/parts/mgmt/mail.js

+6
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ mail.sendToNewMember = function(member, memberPassword) {
186186
mail.sendToNewMemberLink = function(member, prid) {
187187
member.lang = member.lang || "en";
188188
mail.lookup(function(err, host) {
189+
if (config.path) {
190+
host = host + config.path;
191+
}
189192
localize.getProperties(member.lang, function(err2, properties) {
190193
var message = localize.format(properties["mail.new-member-prid"], mail.escapedHTMLString(mail.getUserFirstName(member)), host, mail.escapedHTMLString(member.username), prid);
191194
mail.sendMessage(member.email, properties["mail.new-member-subject"], message);
@@ -217,6 +220,9 @@ mail.sendToUpdatedMember = function(member, memberPassword) {
217220
mail.sendPasswordResetInfo = function(member, prid) {
218221
member.lang = member.lang || "en";
219222
mail.lookup(function(err, host) {
223+
if (config.path) {
224+
host = host + config.path;
225+
}
220226
localize.getProperties(member.lang, function(err2, properties) {
221227
var message = localize.format(properties["mail.password-reset"], mail.escapedHTMLString(mail.getUserFirstName(member)), host, prid);
222228
mail.sendMessage(member.email, properties["mail.password-reset-subject"], message);

‎api/utils/common.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -181,13 +181,14 @@ function getJSON(val) {
181181
}
182182
return ret;
183183
}
184+
184185
/**
185-
* Logger object for creating module specific logging
186-
* @type {module:api/utils/log~Logger}
187-
* @example
188-
* var log = common.log('myplugin:api');
189-
* log.i('myPlugin got a request: %j', params.qstring);
190-
*/
186+
* Logger object for creating module-specific logging
187+
* @type {function(string): Logger}
188+
* @example
189+
* const log = common.log('myplugin:api');
190+
* log.i('myPlugin got a request: %j', params.qstring);
191+
*/
191192
common.log = logger;
192193

193194
/**

‎api/utils/log.js

+123-43
Original file line numberDiff line numberDiff line change
@@ -275,57 +275,124 @@ var ipcHandler = function(msg) {
275275
};
276276

277277
/**
278-
* Creates new logger object for provided module
279-
* @param {string} name - name of the module
280-
* @returns {module:api/utils/log~Logger} logger object
281-
**/
278+
* @typedef {Object} Logger
279+
* @property {function(): string} id - Get the logger id
280+
* @example
281+
* const loggerId = logger.id();
282+
* console.log(`Current logger ID: ${loggerId}`);
283+
*
284+
* @property {function(...*): void} d - Log debug level messages
285+
* @example
286+
* logger.d('Debug message: %s', 'Some debug info');
287+
*
288+
* @property {function(...*): void} i - Log information level messages
289+
* @example
290+
* logger.i('Info message: User %s logged in', username);
291+
*
292+
* @property {function(...*): void} w - Log warning level messages
293+
* @example
294+
* logger.w('Warning: %d attempts failed', attempts);
295+
*
296+
* @property {function(...*): void} e - Log error level messages
297+
* @example
298+
* logger.e('Error occurred: %o', errorObject);
299+
*
300+
* @property {function(string, function, string, ...*): boolean} f - Log variable level messages
301+
* @example
302+
* logger.f('d', (log) => {
303+
* const expensiveOperation = performExpensiveCalculation();
304+
* log('Debug: Expensive operation result: %j', expensiveOperation);
305+
* }, 'i', 'Skipped expensive debug logging');
306+
*
307+
* @property {function(function=): function} callback - Create a callback function for logging
308+
* @example
309+
* const logCallback = logger.callback((result) => {
310+
* console.log('Operation completed with result:', result);
311+
* });
312+
* someAsyncOperation(logCallback);
313+
*
314+
* @property {function(string, function=, function=): function} logdb - Create a callback function for logging database operations
315+
* @example
316+
* const dbCallback = logger.logdb('insert user',
317+
* (result) => { console.log('User inserted:', result); },
318+
* (error) => { console.error('Failed to insert user:', error); }
319+
* );
320+
* database.insertUser(userData, dbCallback);
321+
*
322+
* @property {function(string): Logger} sub - Create a sub-logger
323+
* @example
324+
* const subLogger = logger.sub('database');
325+
* subLogger.i('Connected to database');
326+
*/
327+
328+
/**
329+
* Creates a new logger object for the provided module
330+
* @module api/utils/log
331+
* @param {string} name - Name of the module
332+
* @returns {Logger} Logger object
333+
* @example
334+
* const logger = require('./log.js')('myModule');
335+
* logger.i('MyModule initialized');
336+
*/
282337
module.exports = function(name) {
283338
setLevel(name, logLevel(name));
284339
// console.log('Got level for ' + name + ': ' + levels[name] + ' ( prefs ', prefs);
285340
/**
286-
* @class Logger
287-
**/
341+
* @type Logger
342+
**/
288343
return {
289344
/**
290-
* Get logger id
291-
* @returns {string} id of this logger
292-
*/
345+
* Get logger id
346+
* @returns {string} id of this logger
347+
* @example
348+
* const loggerId = logger.id();
349+
* console.log(`Current logger ID: ${loggerId}`);
350+
*/
293351
id: () => name,
294352
/**
295-
* Log debug level messages
296-
* @memberof module:api/utils/log~Logger
297-
* @param {...*} var_args - string and values to format string with
298-
**/
353+
* Log debug level messages
354+
* @param {...*} var_args - string and values to format string with
355+
* @example
356+
* logger.d('Debug message: %s', 'Some debug info');
357+
*/
299358
d: log(NAMES.d, name, getEnabledWithLevel(ACCEPTABLE.d, name), this, console.log),
300359

301360
/**
302-
* Log information level messages
303-
* @memberof module:api/utils/log~Logger
304-
* @param {...*} var_args - string and values to format string with
305-
**/
361+
* Log information level messages
362+
* @param {...*} var_args - string and values to format string with
363+
* @example
364+
* logger.i('Info message: User %s logged in', username);
365+
*/
306366
i: log(NAMES.i, name, getEnabledWithLevel(ACCEPTABLE.i, name), this, console.info),
307367

308368
/**
309-
* Log warning level messages
310-
* @memberof module:api/utils/log~Logger
311-
* @param {...*} var_args - string and values to format string with
312-
**/
369+
* Log warning level messages
370+
* @param {...*} var_args - string and values to format string with
371+
* @example
372+
* logger.w('Warning: %d attempts failed', attempts);
373+
*/
313374
w: log(NAMES.w, name, getEnabledWithLevel(ACCEPTABLE.w, name), this, console.warn, styles.stylers.warn),
314375

315376
/**
316-
* Log error level messages
317-
* @memberof module:api/utils/log~Logger
318-
* @param {...*} var_args - string and values to format string with
319-
**/
377+
* Log error level messages
378+
* @param {...*} var_args - string and values to format string with
379+
* @example
380+
* logger.e('Error occurred: %o', errorObject);
381+
*/
320382
e: log(NAMES.e, name, getEnabledWithLevel(ACCEPTABLE.e, name), this, console.error, styles.stylers.error),
321383

322384
/**
323385
* Log variable level messages (for cases when logging parameters calculation are expensive enough and shouldn't be done unless the level is enabled)
324-
* @param {String} l log level (d, i, w, e)
325-
* @param {function} fn function to call with single argument - logging function
326-
* @param {String} fl fallback level if l is disabled
327-
* @param {any[]} fargs fallback level arguments
386+
* @param {string} l - log level (d, i, w, e)
387+
* @param {function} fn - function to call with single argument - logging function
388+
* @param {string} fl - fallback level if l is disabled
389+
* @param {...*} fargs - fallback level arguments
328390
* @returns {boolean} true if f() has been called
391+
* @example
392+
* logger.f('d', (log) => {
393+
* const expensiveOperation = performExpensiveCalculation();
394+
* log('Debug: Expensive operation result: %j', expensiveOperation);
395+
* }, 'i', 'Skipped expensive debug logging');
329396
*/
330397
f: function(l, fn, fl, ...fargs) {
331398
if (ACCEPTABLE[l].indexOf(levels[name] || deflt) !== -1) {
@@ -338,11 +405,15 @@ module.exports = function(name) {
338405
},
339406

340407
/**
341-
* Logging inside callbacks
342-
* @memberof module:api/utils/log~Logger
343-
* @param {function=} next - next function to call, after callback executed
344-
* @returns {function} function to pass as callback
345-
**/
408+
* Logging inside callbacks
409+
* @param {function=} next - next function to call, after callback executed
410+
* @returns {function} function to pass as callback
411+
* @example
412+
* const logCallback = logger.callback((result) => {
413+
* console.log('Operation completed with result:', result);
414+
* });
415+
* someAsyncOperation(logCallback);
416+
*/
346417
callback: function(next) {
347418
var self = this;
348419
return function(err) {
@@ -356,13 +427,18 @@ module.exports = function(name) {
356427
};
357428
},
358429
/**
359-
* Logging database callbacks
360-
* @memberof module:api/utils/log~Logger
361-
* @param {string} opname - name of the performed operation
362-
* @param {function=} next - next function to call, after callback executed
363-
* @param {function=} nextError - function to pass error to
364-
* @returns {function} function to pass as callback
365-
**/
430+
* Logging database callbacks
431+
* @param {string} opname - name of the performed operation
432+
* @param {function=} next - next function to call, after callback executed
433+
* @param {function=} nextError - function to pass error to
434+
* @returns {function} function to pass as callback
435+
* @example
436+
* const dbCallback = logger.logdb('insert user',
437+
* (result) => { console.log('User inserted:', result); },
438+
* (error) => { console.error('Failed to insert user:', error); }
439+
* );
440+
* database.insertUser(userData, dbCallback);
441+
*/
366442
logdb: function(opname, next, nextError) {
367443
var self = this;
368444
return function(err) {
@@ -382,9 +458,13 @@ module.exports = function(name) {
382458
},
383459
/**
384460
* Add one more level to the logging output while leaving loglevel the same
385-
* @param {string} subname sublogger name
386-
* @returns {object} new logger
461+
* @param {string} subname - sublogger name
462+
* @returns {Logger} new logger
463+
* @example
464+
* const subLogger = logger.sub('database');
465+
* subLogger.i('Connected to database');
387466
*/
467+
388468
sub: function(subname) {
389469
let full = name + ':' + subname,
390470
self = this;

‎api/utils/rights.js

+11-11
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function validate_token_if_exists(params) {
5555
* Additionally populates params with member information and app information.
5656
* @param {params} params - {@link params} object
5757
* @param {function} callback - function to call only if validation passes
58-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
58+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
5959
* @returns {Promise} promise
6060
*/
6161
exports.validateUserForRead = function(params, callback, callbackParam) {
@@ -151,7 +151,7 @@ exports.validateUserForRead = function(params, callback, callbackParam) {
151151
* Additionally populates params with member information and app information.
152152
* @param {params} params - {@link params} object
153153
* @param {function} callback - function to call only if validation passes
154-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
154+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
155155
* @returns {Promise} promise
156156
*/
157157
exports.validateUserForWrite = function(params, callback, callbackParam) {
@@ -240,7 +240,7 @@ exports.validateUserForWrite = function(params, callback, callbackParam) {
240240
* Additionally populates params with member information.
241241
* @param {params} params - {@link params} object
242242
* @param {function} callback - function to call only if validation passes
243-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
243+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
244244
* @returns {Promise} promise
245245
*/
246246
exports.validateGlobalAdmin = function(params, callback, callbackParam) {
@@ -311,7 +311,7 @@ exports.validateGlobalAdmin = function(params, callback, callbackParam) {
311311
* Additionally populates params with member information.
312312
* @param {params} params - {@link params} object
313313
* @param {function} callback - function to call only if validation passes
314-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
314+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
315315
* @returns {Promise} promise
316316
*/
317317
exports.validateAppAdmin = function(params, callback, callbackParam) {
@@ -389,7 +389,7 @@ exports.validateAppAdmin = function(params, callback, callbackParam) {
389389
* Additionally populates params with member information.
390390
* @param {params} params - {@link params} object
391391
* @param {function} callback - function to call only if validation passes
392-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
392+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
393393
* @returns {Promise} promise
394394
*/
395395
exports.validateUser = function(params, callback, callbackParam) {
@@ -458,7 +458,7 @@ exports.validateUser = function(params, callback, callbackParam) {
458458
* Wrap callback using promise
459459
* @param {params} params - {@link params} object
460460
* @param {function} callback - function to call only if validation passes
461-
* @param {any} callbackParam - parameter to pass to callback function
461+
* @param {any=} callbackParam - parameter to pass to callback function
462462
* @param {function} func - promise function
463463
* @returns {Promise} promise
464464
*/
@@ -794,7 +794,7 @@ exports.dbUserHasAccessToCollection = function(params, collection, app_id, callb
794794
* @param {params} params - {@link params} object
795795
* @param {string} feature - feature that trying to access
796796
* @param {function} callback - function to call only if validation passes
797-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
797+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
798798
* @returns {Promise} promise
799799
*/
800800
exports.validateRead = function(params, feature, callback, callbackParam) {
@@ -947,7 +947,7 @@ exports.validateRead = function(params, feature, callback, callbackParam) {
947947
* @param {string} feature - feature that trying to access
948948
* @param {string} accessType - required access type for related request (c: create, u: update and d: delete)
949949
* @param {function} callback - function to call only if validation passes
950-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
950+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
951951
* @returns {Promise} promise
952952
*/
953953
function validateWrite(params, feature, accessType, callback, callbackParam) {
@@ -1089,7 +1089,7 @@ function validateWrite(params, feature, accessType, callback, callbackParam) {
10891089
* @param {params} params - {@link params} object
10901090
* @param {string} feature - feature that trying to access
10911091
* @param {function} callback - function to call only if validation passes
1092-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
1092+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
10931093
*/
10941094
exports.validateCreate = function(params, feature, callback, callbackParam) {
10951095
validateWrite(params, feature, 'c', callback, callbackParam);
@@ -1100,7 +1100,7 @@ exports.validateCreate = function(params, feature, callback, callbackParam) {
11001100
* @param {params} params - {@link params} object
11011101
* @param {string} feature - feature that trying to access
11021102
* @param {function} callback - function to call only if validation passes
1103-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
1103+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
11041104
*/
11051105
exports.validateUpdate = function(params, feature, callback, callbackParam) {
11061106
validateWrite(params, feature, 'u', callback, callbackParam);
@@ -1111,7 +1111,7 @@ exports.validateUpdate = function(params, feature, callback, callbackParam) {
11111111
* @param {params} params - {@link params} object
11121112
* @param {string} feature - feature that trying to access
11131113
* @param {function} callback - function to call only if validation passes
1114-
* @param {any} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
1114+
* @param {any=} callbackParam - parameter to pass to callback function (params is automatically passed to callback function, no need to include that)
11151115
*/
11161116
exports.validateDelete = function(params, feature, callback, callbackParam) {
11171117
validateWrite(params, feature, 'd', callback, callbackParam);

‎frontend/express/public/core/events/stylesheets/_main.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
&--image {
9090
width: 242px;
9191
height: 242px;
92-
background-image: url('../../../images/dashboard/events-overview-noevents.svg');
92+
background-image: url('../../images/dashboard/events-overview-noevents.svg');
9393
}
9494
}
9595
&--text{

‎frontend/express/public/core/onboarding/stylesheets/_main.scss

+4-4
Original file line numberDiff line numberDiff line change
@@ -63,23 +63,23 @@
6363
}
6464

6565
.setup-radio-icon {
66-
background-image: url('../../../images/dashboard/onboarding/box.svg');
66+
background-image: url('../../images/dashboard/onboarding/box.svg');
6767
background-position: center;
6868
background-repeat: no-repeat;
6969
width: 100%;
7070
height: 100%;
7171
}
7272

7373
.setup-radio-icon--app-type-mobile {
74-
background-image: url('../../../images/dashboard/onboarding/app-type-mobile.svg');
74+
background-image: url('../../images/dashboard/onboarding/app-type-mobile.svg');
7575
}
7676

7777
.setup-radio-icon--app-type-web {
78-
background-image: url('../../../images/dashboard/onboarding/app-type-web.svg');
78+
background-image: url('../../images/dashboard/onboarding/app-type-web.svg');
7979
}
8080

8181
.setup-radio-icon--app-type-desktop {
82-
background-image: url('../../../images/dashboard/onboarding/app-type-desktop.svg');
82+
background-image: url('../../images/dashboard/onboarding/app-type-desktop.svg');
8383
}
8484

8585
.is-checked .setup-radio-icon {

‎frontend/express/public/javascripts/countly/vue/components/sidebar.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@
569569
versionInfo: countlyGlobal.countlyTypeName,
570570
countlySidebarVersionPath: '/dashboard#/' + countlyCommon.ACTIVE_APP_ID + '/versions',
571571
showMainMenu: true,
572-
redirectHomePage: '/dashboard#/' + countlyCommon.ACTIVE_APP_ID,
572+
redirectHomePage: 'dashboard#/' + countlyCommon.ACTIVE_APP_ID,
573573
onOptionsMenu: false,
574574
onMainMenu: false,
575575
enableGuides: CountlyHelpers.isPluginEnabled('guides'),

‎frontend/express/public/stylesheets/styles/blocks/_helpers.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
border: 1px solid #E2E4E8;
124124
background-color: #F8FAFD;
125125
border-radius:8px;
126-
background-image: url('/images/icons/empty-background.svg');
126+
background-image: url('../../images/icons/empty-background.svg');
127127
background-position: 100% 100%;
128128
background-repeat: no-repeat;
129129
}

‎frontend/express/public/stylesheets/vue/clyvue.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@
367367
display: inline-block;
368368
width: 60px;
369369
height: 60px;
370-
background-image: url("../images/dashboard/graph-no-data.svg");
370+
background-image: url("../../images/dashboard/graph-no-data.svg");
371371
background-size: contain;
372372
margin-right: 20px;
373373
background-repeat: no-repeat;

‎plugins/push/api/api-push.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ ipc.attach();
9191

9292
/**
9393
* Process token session request
94-
*
94+
*
9595
* @param {Object} msg IPC message
9696
*/
9797
async function processTokenSession(msg) {
@@ -146,10 +146,10 @@ async function processTokenSession(msg) {
146146
});
147147
}, 10000);
148148
}
149-
else {
150-
appusersCollection.updateOne({_id: app_user_id}, {$unset: {[appusersField]: 1}}, function() {});
151-
pushCollection.updateOne({_id: uid}, {$unset: {[pushField]: 1}}, function() {});
152-
}
149+
// else {
150+
// appusersCollection.updateOne({_id: app_user_id}, {$unset: {[appusersField]: 1}}, function() {});
151+
// pushCollection.updateOne({_id: uid}, {$unset: {[pushField]: 1}}, function() {});
152+
// }
153153
}
154154

155155
module.exports.onTokenSession = async(dbAppUser, params) => {

‎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)
Please sign in to comment.