Skip to content

Commit

Permalink
Merge branch 'anna/next' of https://github.com/Countly/countly-server
Browse files Browse the repository at this point in the history
…into anna/next
  • Loading branch information
Cookiezaurs committed Oct 3, 2024
2 parents 4a5b653 + 29129ce commit ff5b409
Show file tree
Hide file tree
Showing 19 changed files with 291 additions and 97 deletions.
17 changes: 16 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
## Version 24.05.14
Fixes:
- [code] Added better handling for countly servers while deployed using subdirectory
- [data-manager] Added missing "Create" button for event groups
- [data-manager] Fixes for auto toggling data masking setting on redaction change
- [populator] Fixed issues in case of wrongly structured data
- [push] token shouldn't be revoked if it's already in db
- [server-stats] Fixed a data point calculation bug

Enterprise fixes:
- [push_approver] Fixed issue with the plugin not handling being "soft disabled"
- [surveys] fixed a bug with the Survey widget where the "submit" button could become non interactable
- [surveys] fixed issues with dashboard editor in relation to the "terms and conditions"
- [surveys] fixed issues with previewing, creating and editing nps widgets

## Version 24.05.13
Fixes:
- [alerts] Fixed bugs related to NPS alerts
Expand Down Expand Up @@ -32,7 +47,7 @@ Fixes:
- [logs] Show collected problems on logger

Enterprise fixes:
- [data-manager] Fixes n UI to allow events starting with "/"
- [data-manager] Fixes in UI to allow events starting with "/"
- [flows] Fixes for flows step generation
- [surveys] Other is not allowed as a valid answer for required questions

Expand Down
22 changes: 20 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ module.exports = function(grunt) {
'frontend/express/public/javascripts/dom/drop/drop-theme-countly.min.css',
'frontend/express/public/javascripts/utils/tooltipster/tooltipster.bundle.min.css',
'frontend/express/public/stylesheets/bulma/bulma-custom.css',
'frontend/express/public/stylesheets/styles/manifest.css',
'frontend/express/public/stylesheets/styles/manifest2.css',
'frontend/express/public/stylesheets/vue/element-tiptap.css',
]
}
Expand Down Expand Up @@ -324,7 +324,25 @@ module.exports = function(grunt) {

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

grunt.registerTask('dist', ['sass', 'concat', 'uglify', 'cssmin']);
grunt.registerTask('replace-paths', 'Replace image paths in prod CSS files', function() {
var cssFiles = [
{
filepath: 'frontend/express/public/stylesheets/styles/manifest.css',
lookup: '../../images',
replacement: '../images',
newPath: 'frontend/express/public/stylesheets/styles/manifest2.css'
}
];

cssFiles.forEach(function(file) {
var content = grunt.file.read(file.filepath);
var newContent = content.replace(/\.\.\/\.\.\/images/g, file.replacement);
grunt.file.write(file.newPath, newContent);
grunt.log.writeln('Processed file: ' + file.filepath);
});
});

grunt.registerTask('dist', ['sass', 'concat', 'uglify', 'replace-paths', 'cssmin']);

grunt.registerTask('plugins', 'Minify plugin JS / CSS files and copy images', function() {
var js = [], css = [], img = [], fs = require('fs'), path = require('path');
Expand Down
6 changes: 6 additions & 0 deletions api/parts/mgmt/mail.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,9 @@ mail.sendToNewMember = function(member, memberPassword) {
mail.sendToNewMemberLink = function(member, prid) {
member.lang = member.lang || "en";
mail.lookup(function(err, host) {
if (config.path) {
host = host + config.path;
}
localize.getProperties(member.lang, function(err2, properties) {
var message = localize.format(properties["mail.new-member-prid"], mail.escapedHTMLString(mail.getUserFirstName(member)), host, mail.escapedHTMLString(member.username), prid);
mail.sendMessage(member.email, properties["mail.new-member-subject"], message);
Expand Down Expand Up @@ -217,6 +220,9 @@ mail.sendToUpdatedMember = function(member, memberPassword) {
mail.sendPasswordResetInfo = function(member, prid) {
member.lang = member.lang || "en";
mail.lookup(function(err, host) {
if (config.path) {
host = host + config.path;
}
localize.getProperties(member.lang, function(err2, properties) {
var message = localize.format(properties["mail.password-reset"], mail.escapedHTMLString(mail.getUserFirstName(member)), host, prid);
mail.sendMessage(member.email, properties["mail.password-reset-subject"], message);
Expand Down
13 changes: 7 additions & 6 deletions api/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,14 @@ function getJSON(val) {
}
return ret;
}

/**
* Logger object for creating module specific logging
* @type {module:api/utils/log~Logger}
* @example
* var log = common.log('myplugin:api');
* log.i('myPlugin got a request: %j', params.qstring);
*/
* Logger object for creating module-specific logging
* @type {function(string): Logger}
* @example
* const log = common.log('myplugin:api');
* log.i('myPlugin got a request: %j', params.qstring);
*/
common.log = logger;

/**
Expand Down
166 changes: 123 additions & 43 deletions api/utils/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,57 +275,124 @@ var ipcHandler = function(msg) {
};

/**
* Creates new logger object for provided module
* @param {string} name - name of the module
* @returns {module:api/utils/log~Logger} logger object
**/
* @typedef {Object} Logger
* @property {function(): string} id - Get the logger id
* @example
* const loggerId = logger.id();
* console.log(`Current logger ID: ${loggerId}`);
*
* @property {function(...*): void} d - Log debug level messages
* @example
* logger.d('Debug message: %s', 'Some debug info');
*
* @property {function(...*): void} i - Log information level messages
* @example
* logger.i('Info message: User %s logged in', username);
*
* @property {function(...*): void} w - Log warning level messages
* @example
* logger.w('Warning: %d attempts failed', attempts);
*
* @property {function(...*): void} e - Log error level messages
* @example
* logger.e('Error occurred: %o', errorObject);
*
* @property {function(string, function, string, ...*): boolean} f - Log variable level messages
* @example
* logger.f('d', (log) => {
* const expensiveOperation = performExpensiveCalculation();
* log('Debug: Expensive operation result: %j', expensiveOperation);
* }, 'i', 'Skipped expensive debug logging');
*
* @property {function(function=): function} callback - Create a callback function for logging
* @example
* const logCallback = logger.callback((result) => {
* console.log('Operation completed with result:', result);
* });
* someAsyncOperation(logCallback);
*
* @property {function(string, function=, function=): function} logdb - Create a callback function for logging database operations
* @example
* const dbCallback = logger.logdb('insert user',
* (result) => { console.log('User inserted:', result); },
* (error) => { console.error('Failed to insert user:', error); }
* );
* database.insertUser(userData, dbCallback);
*
* @property {function(string): Logger} sub - Create a sub-logger
* @example
* const subLogger = logger.sub('database');
* subLogger.i('Connected to database');
*/

/**
* Creates a new logger object for the provided module
* @module api/utils/log
* @param {string} name - Name of the module
* @returns {Logger} Logger object
* @example
* const logger = require('./log.js')('myModule');
* logger.i('MyModule initialized');
*/
module.exports = function(name) {
setLevel(name, logLevel(name));
// console.log('Got level for ' + name + ': ' + levels[name] + ' ( prefs ', prefs);
/**
* @class Logger
**/
* @type Logger
**/
return {
/**
* Get logger id
* @returns {string} id of this logger
*/
* Get logger id
* @returns {string} id of this logger
* @example
* const loggerId = logger.id();
* console.log(`Current logger ID: ${loggerId}`);
*/
id: () => name,
/**
* Log debug level messages
* @memberof module:api/utils/log~Logger
* @param {...*} var_args - string and values to format string with
**/
* Log debug level messages
* @param {...*} var_args - string and values to format string with
* @example
* logger.d('Debug message: %s', 'Some debug info');
*/
d: log(NAMES.d, name, getEnabledWithLevel(ACCEPTABLE.d, name), this, console.log),

/**
* Log information level messages
* @memberof module:api/utils/log~Logger
* @param {...*} var_args - string and values to format string with
**/
* Log information level messages
* @param {...*} var_args - string and values to format string with
* @example
* logger.i('Info message: User %s logged in', username);
*/
i: log(NAMES.i, name, getEnabledWithLevel(ACCEPTABLE.i, name), this, console.info),

/**
* Log warning level messages
* @memberof module:api/utils/log~Logger
* @param {...*} var_args - string and values to format string with
**/
* Log warning level messages
* @param {...*} var_args - string and values to format string with
* @example
* logger.w('Warning: %d attempts failed', attempts);
*/
w: log(NAMES.w, name, getEnabledWithLevel(ACCEPTABLE.w, name), this, console.warn, styles.stylers.warn),

/**
* Log error level messages
* @memberof module:api/utils/log~Logger
* @param {...*} var_args - string and values to format string with
**/
* Log error level messages
* @param {...*} var_args - string and values to format string with
* @example
* logger.e('Error occurred: %o', errorObject);
*/
e: log(NAMES.e, name, getEnabledWithLevel(ACCEPTABLE.e, name), this, console.error, styles.stylers.error),

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

/**
* Logging inside callbacks
* @memberof module:api/utils/log~Logger
* @param {function=} next - next function to call, after callback executed
* @returns {function} function to pass as callback
**/
* Logging inside callbacks
* @param {function=} next - next function to call, after callback executed
* @returns {function} function to pass as callback
* @example
* const logCallback = logger.callback((result) => {
* console.log('Operation completed with result:', result);
* });
* someAsyncOperation(logCallback);
*/
callback: function(next) {
var self = this;
return function(err) {
Expand All @@ -356,13 +427,18 @@ module.exports = function(name) {
};
},
/**
* Logging database callbacks
* @memberof module:api/utils/log~Logger
* @param {string} opname - name of the performed operation
* @param {function=} next - next function to call, after callback executed
* @param {function=} nextError - function to pass error to
* @returns {function} function to pass as callback
**/
* Logging database callbacks
* @param {string} opname - name of the performed operation
* @param {function=} next - next function to call, after callback executed
* @param {function=} nextError - function to pass error to
* @returns {function} function to pass as callback
* @example
* const dbCallback = logger.logdb('insert user',
* (result) => { console.log('User inserted:', result); },
* (error) => { console.error('Failed to insert user:', error); }
* );
* database.insertUser(userData, dbCallback);
*/
logdb: function(opname, next, nextError) {
var self = this;
return function(err) {
Expand All @@ -382,9 +458,13 @@ module.exports = function(name) {
},
/**
* Add one more level to the logging output while leaving loglevel the same
* @param {string} subname sublogger name
* @returns {object} new logger
* @param {string} subname - sublogger name
* @returns {Logger} new logger
* @example
* const subLogger = logger.sub('database');
* subLogger.i('Connected to database');
*/

sub: function(subname) {
let full = name + ':' + subname,
self = this;
Expand Down
Loading

0 comments on commit ff5b409

Please sign in to comment.