Skip to content

Commit 6d45c19

Browse files
authored
Merge branch 'master' into ar2rsawseen/master
2 parents 02d8199 + 6e95089 commit 6d45c19

File tree

24 files changed

+1326
-842
lines changed

24 files changed

+1326
-842
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,5 @@ log/
4444
log/supervisord/
4545
plugins/plugins.json.*
4646
.sdk
47-
dump
47+
dump
48+
dist/

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
Features:
44
- Add ability to allow multiple CORS per app for web apps
5+
- Add app id and name as view segment for self-tracking
6+
7+
Enterprise Features:
8+
- [license] Update locking conditions for expired license and over limit usage
9+
- [license] Enable force locking with remote config
10+
- [license] Update dashboard lock with redirection to home page for non admin user
511

612
Dependencies:
713
- Bump body-parser from 1.20.3 to 2.2.0

api/lib/countly.common.js

Lines changed: 31 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,15 @@
33
* @module "api/lib/countly.common"
44
*/
55

6+
/**
7+
* @typedef {import('moment-timezone').Moment} MomentTimezone
8+
*/
9+
610
/** @lends module:api/lib/countly.common */
711
var countlyCommon = {},
12+
/**
13+
* Reference to momentjs
14+
*/
815
moment = require('moment-timezone'),
916
underscore = require('underscore');
1017

@@ -16,57 +23,11 @@ var _period = "hour",
1623
// Private Methods
1724

1825
/**
19-
* Returns array with unique ticks for period
20-
* @param {moment} startTimestamp - start of period
21-
* @param {moment} endTimestamp - end of period
22-
* @returns {array} unique array ticks for period
23-
**/
24-
/*function getTicksBetween(startTimestamp, endTimestamp) {
25-
var dayIt = startTimestamp.clone(),
26-
ticks = [];
27-
28-
while (dayIt < endTimestamp) {
29-
let daysLeft = Math.round(moment.duration(endTimestamp - dayIt).asDays());
30-
if (daysLeft >= dayIt.daysInMonth() && dayIt.date() === 1) {
31-
ticks.push(dayIt.format("YYYY.M"));
32-
dayIt.add(1 + dayIt.daysInMonth() - dayIt.date(), "days");
33-
}
34-
else if (daysLeft >= (7 - dayIt.day()) && dayIt.day() === 1) {
35-
ticks.push(dayIt.format("YYYY.[w]W"));
36-
dayIt.add(8 - dayIt.day(), "days");
37-
}
38-
else {
39-
ticks.push(dayIt.format("YYYY.M.D"));
40-
dayIt.add(1, "day");
41-
}
42-
}
43-
44-
return ticks;
45-
}*/
46-
47-
/**
48-
* Returns array with more generalized unique ticks for period
49-
* @param {moment} startTimestamp - start of period
50-
* @param {moment} endTimestamp - end of period
51-
* @returns {array} unique array ticks for period
52-
**/
53-
/*function getTicksCheckBetween(startTimestamp, endTimestamp) {
54-
var dayIt = startTimestamp.clone(),
55-
ticks = [];
56-
while (dayIt < endTimestamp) {
57-
let daysLeft = Math.round(moment.duration(endTimestamp - dayIt).asDays());
58-
if (daysLeft >= (dayIt.daysInMonth() * 0.5 - dayIt.date())) {
59-
ticks.push(dayIt.format("YYYY.M"));
60-
dayIt.add(1 + dayIt.daysInMonth() - dayIt.date(), "days");
61-
}
62-
else {
63-
ticks.push(dayIt.format("YYYY.[w]W"));
64-
dayIt.add(8 - dayIt.day(), "days");
65-
}
66-
}
67-
return ticks;
68-
}*/
69-
26+
* Calculates unique values from a hierarchical map structure
27+
* @param {Object} dbObj - Database object containing hierarchical data (years, months, weeks, days)
28+
* @param {Object} uniqueMap - Map with hierarchical structure (years, months, weeks, days) used to calculate unique values
29+
* @returns {number} - Count of unique items
30+
*/
7031
countlyCommon.calculateUniqueFromMap = function(dbObj, uniqueMap) {
7132
var u = 0;
7233
for (var year in uniqueMap) {
@@ -105,13 +66,13 @@ countlyCommon.calculateUniqueFromMap = function(dbObj, uniqueMap) {
10566
};
10667

10768
/** returns unique period check array
108-
* @param {array} weeksArray_pd - weeks array
109-
* @param {array} weekCounts_pd - week counts
110-
* @param {array} monthsArray_pd - months array
111-
* @param {array} monthCounts_pd - months counts
112-
* @param {array} periodArr_pd - period array
113-
* @returns {array} periods
114-
*/
69+
* @param {Array<string>} weeksArray_pd - weeks array
70+
* @param {Array<string>} weekCounts_pd - week counts
71+
* @param {Array<string>} monthsArray_pd - months array
72+
* @param {Array<string>} monthCounts_pd - months counts
73+
* @param {Array<string>} periodArr_pd - period array
74+
* @returns {Array<string>} periods
75+
*/
11576
function getUniqArray(weeksArray_pd, weekCounts_pd, monthsArray_pd, monthCounts_pd, periodArr_pd) {
11677

11778
if (_period === "month" || _period === "day" || _period === "yesterday" || _period === "hour") {
@@ -230,12 +191,12 @@ function getUniqArray(weeksArray_pd, weekCounts_pd, monthsArray_pd, monthCounts_
230191
return uniquePeriods;
231192
}
232193
/** returns unique period check array
233-
* @param {array} weeksArray_pd - weeks array
234-
* @param {array} weekCounts_pd - week counts
235-
* @param {array} monthsArray_pd - months array
236-
* @param {array} monthCounts_pd - months counts
237-
* @returns {array} periods
238-
*/
194+
* @param {Array<string>} weeksArray_pd - weeks array
195+
* @param {Array<string>} weekCounts_pd - week counts
196+
* @param {Array<string>} monthsArray_pd - months array
197+
* @param {Array<string>} monthCounts_pd - months counts
198+
* @returns {Array<string>} periods
199+
*/
239200
function getUniqCheckArray(weeksArray_pd, weekCounts_pd, monthsArray_pd, monthCounts_pd) {
240201

241202
if (_period === "month" || _period === "day" || _period === "yesterday" || _period === "hour") {
@@ -306,9 +267,9 @@ function getUniqCheckArray(weeksArray_pd, weekCounts_pd, monthsArray_pd, monthCo
306267
}
307268

308269
/** Function to clone object
309-
* @param {object} obj - object to clone
310-
* @returns {object} cloned object
311-
*/
270+
* @param {object} obj - object to clone
271+
* @returns {object|undefined|string|Array<string>|Date} cloned object
272+
*/
312273
function clone(obj) {
313274
if (null === obj || "object" !== typeof obj) {
314275
return obj;
@@ -342,8 +303,8 @@ function clone(obj) {
342303

343304
/**
344305
* Returns number for timestamp making sure it is 13 digits
345-
* @param {integer}ts - number we need to se as timestamp
346-
* @returns {integer} timestamp in ms
306+
* @param {number} ts - number we need to se as timestamp
307+
* @returns {number} timestamp in ms
347308
**/
348309
function fixTimestampToMilliseconds(ts) {
349310
if ((ts + "").length > 13) {
@@ -355,7 +316,7 @@ function fixTimestampToMilliseconds(ts) {
355316

356317
/**
357318
* Returns a period object used by all time related data calculation functions
358-
* @param {moment} prmPeriod period to be calculated (optional)
319+
* @param {string|any} prmPeriod period to be calculated (optional) todo:figure this type out
359320
* @param {string} bucket - daily or monthly. If bucket is set, period will be modified to fit full months or days
360321
* @returns {timeObject} time object
361322
**/

api/parts/data/batcher.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class ReadBatcher {
422422
* @param {string} id - id of cache
423423
* @param {string} query - query for the document
424424
* @param {string} projection - which fields to return
425-
* @param {bool} multi - true if multiple documents
425+
* @param {boolean} multi - true if multiple documents
426426
* @returns {Promise} promise
427427
*/
428428
getData(collection, id, query, projection, multi) {
@@ -517,7 +517,7 @@ class ReadBatcher {
517517
* @param {string} collection - name of the collection where to update data
518518
* @param {object} query - query for the document
519519
* @param {object} projection - which fields to return
520-
* @param {bool} multi - true if multiple documents
520+
* @param {boolean} multi - true if multiple documents
521521
*/
522522
invalidate(collection, query, projection, multi) {
523523
if (!this.onMaster || cluster.isMaster) {
@@ -539,7 +539,7 @@ class ReadBatcher {
539539
* @param {string} collection - name of the collection where to update data
540540
* @param {object} query - query for the document
541541
* @param {object} projection - which fields to return
542-
* @param {bool} multi - true if multiple documents
542+
* @param {boolean} multi - true if multiple documents
543543
* @returns {Promise} promise
544544
*/
545545
get(collection, query, projection, multi) {
@@ -651,7 +651,7 @@ class ReadBatcher {
651651
* @param {string} query - query for the document
652652
* @param {string} projection - which fields to return
653653
* @param {object} data - data from database
654-
* @param {bool} multi - true if multiple documents
654+
* @param {boolean} multi - true if multiple documents
655655
*/
656656
cache(collection, id, query, projection, data, multi) {
657657
if (this.process) {

api/utils/authorizer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ const log = require('./log.js')('core:authorizer');
1515
* @param {object} options - options for the task
1616
* @param {object} options.db - database connection
1717
* @param {number} options.ttl - amount of seconds for token to work, 0 works indefinately
18-
* @param {bool} [options.multi=false] - if true, can be used many times until expired
18+
* @param {boolean} [options.multi=false] - if true, can be used many times until expired
1919
* @param {string} options.token - token to store, if not provided, will be generated
2020
* @param {string} options.owner - id of the user who created this token
2121
* @param {string} options.app - list of the apps for which token was created
2222
* @param {string} options.endpoint - regexp of endpoint(any string - is used as substring,to mach exact ^{yourpath}$)
2323
* @param {string} options.tryReuse - if true - tries to find not expired token with same parameters. If not founds cretes new token. If found - updates token expiration time to new one and returns token.
24-
* @param {bool} [options.temporary=false] - If logged in with temporary token. Doesn't kill other sessions on logout.
24+
* @param {boolean} [options.temporary=false] - If logged in with temporary token. Doesn't kill other sessions on logout.
2525
* @param {function} options.callback - function called when saving was completed or errored, providing error object as first param and token string as second
2626
*/
2727
authorizer.save = function(options) {

0 commit comments

Comments
 (0)