Skip to content

Commit 97ac5a3

Browse files
authored
Merge branch 'master' into rating-consent
2 parents 1320a66 + 289e1ef commit 97ac5a3

11 files changed

Lines changed: 733 additions & 1374 deletions

File tree

.github/workflows/main.yml

Lines changed: 17 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -242,91 +242,13 @@ jobs:
242242
/sbin/my_init &
243243
node bin/scripts/test.connection.js
244244
npx grunt mochaTest
245-
ui-test-dashboard:
246-
runs-on: ubuntu-latest
247-
248-
services:
249-
mongodb:
250-
image: mongo:8.0
251-
options: >-
252-
--health-cmd mongosh
253-
--health-interval 10s
254-
--health-timeout 5s
255-
--health-retries 5
256-
ports:
257-
- 27017:27017
258-
259-
container:
260-
image: countly/countly-core:pipelines-${{ inputs.custom_tag || github.base_ref || github.ref_name }}
261-
env:
262-
COUNTLY_CONFIG__MONGODB_HOST: mongodb
263-
COUNTLY_CONFIG_API_PREVENT_JOBS: true
264-
265-
steps:
266-
- uses: actions/checkout@v4
267-
268-
- name: Install Chrome
269-
shell: bash
270-
run: |
271-
apt update
272-
apt install -y libgtk2.0-0 libgtk-3-0 libgbm-dev libnotify-dev libgconf-2-4 libnss3 libxss1 libasound2 libxtst6 xauth xvfb wget
273-
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb -O /tmp/chrome.deb
274-
apt install -y /tmp/chrome.deb
275-
276-
- name: Copy code
277-
shell: bash
278-
run: cp -rf ./* /opt/countly
279-
280-
- name: Prepare files to use correct MongoDB host
281-
shell: bash
282-
run: "sed -i 's/mongosh --quiet/mongosh --host mongodb --quiet/' /opt/countly/bin/backup/import_events.sh && sed -i 's/mongoimport --db/mongoimport --host mongodb --db/' /opt/countly/bin/backup/import_events.sh"
283-
284-
- name: NPM install
285-
shell: bash
286-
working-directory: /opt/countly
287-
run: npm install
288-
289-
- name: Prepare environment
290-
shell: bash
291-
working-directory: /opt/countly
292-
run: |
293-
sed -i 's/port: 3001,/port: 3001, workers: 1,/' /opt/countly/api/config.js
294-
cp "./plugins/plugins.default.json" "/opt/countly/plugins/plugins.json"
295-
npm install
296-
sudo countly task dist-all
297-
bash bin/backup/import_events.sh
298-
bash bin/scripts/countly.prepare.ce.tests.sh
299-
countly add_user '${{ secrets.CYPRESS_USER_EMAIL }}' '${{ secrets.CYPRESS_USER_PASSWORD }}'
300-
mongosh --host mongodb --eval 'db.getSiblingDB("countly").members.updateOne({username: "${{ secrets.CYPRESS_USER_EMAIL }}"}, {$set: {username: "${{ secrets.CYPRESS_USER_USERNAME }}", subscribe_newsletter: true}});'
301-
mongosh --host mongodb --eval 'db.getSiblingDB("countly").plugins.updateOne({_id: "plugins"}, {$set: {"frontend.countly_tracking": true}});'
302-
cd ui-tests
303-
echo '{"username": "${{ secrets.CYPRESS_USER_USERNAME }}","email": "${{ secrets.CYPRESS_USER_EMAIL }}","password": "${{ secrets.CYPRESS_USER_PASSWORD }}"}' > cypress/fixtures/user.json
304-
sed -i 's/00000000-0000-0000-0000-000000000000/${{ secrets.CYPRESS_KEY }}/g' package.json
305-
cp cypress.config.sample.js cypress.config.js
306-
sed -i 's/000000/${{ secrets.CYPRESS_PROJECT_ID }}/g' cypress.config.js
307245
308-
- name: Run UI tests
309-
shell: bash
310-
working-directory: /opt/countly
311-
run: |
312-
/sbin/my_init &
313-
cd ui-tests
314-
npm install
315-
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \
316-
npm run cy:run:dashboard
246+
ui-tests:
247+
runs-on: ubuntu-22.04-4core
317248

318-
- name: Upload UI tests artifacts
319-
if: ${{ failure() }}
320-
shell: bash
321-
working-directory: /opt/countly/ui-tests/cypress
322-
run: |
323-
ARTIFACT_ARCHIVE_NAME="$(date '+%Y%m%d-%H.%M')_${GITHUB_REPOSITORY#*/}_CI#${{ github.run_number }}.tar.gz"
324-
mkdir -p screenshots videos
325-
tar zcvf "$ARTIFACT_ARCHIVE_NAME" screenshots videos
326-
curl -o /tmp/uploader.log -u "${{ secrets.BOX_UPLOAD_AUTH }}" ${{ secrets.BOX_UPLOAD_PATH }} -T "$ARTIFACT_ARCHIVE_NAME"
327-
328-
ui-test-onboarding:
329-
runs-on: ubuntu-latest
249+
strategy:
250+
matrix:
251+
test_type: [dashboard, onboarding]
330252

331253
services:
332254
mongodb:
@@ -377,7 +299,13 @@ jobs:
377299
cp "./plugins/plugins.default.json" "/opt/countly/plugins/plugins.json"
378300
npm install
379301
sudo countly task dist-all
302+
bash bin/backup/import_events.sh
380303
bash bin/scripts/countly.prepare.ce.tests.sh
304+
if [ "${{ matrix.test_type }}" = "dashboard" ]; then
305+
countly add_user '${{ secrets.CYPRESS_USER_EMAIL }}' '${{ secrets.CYPRESS_USER_PASSWORD }}'
306+
mongosh --host mongodb --eval 'db.getSiblingDB("countly").members.updateOne({username: "${{ secrets.CYPRESS_USER_EMAIL }}"}, {$set: {username: "${{ secrets.CYPRESS_USER_USERNAME }}", subscribe_newsletter: true}});'
307+
mongosh --host mongodb --eval 'db.getSiblingDB("countly").plugins.updateOne({_id: "plugins"}, {$set: {"frontend.countly_tracking": true}});'
308+
fi
381309
cd ui-tests
382310
echo '{"username": "${{ secrets.CYPRESS_USER_USERNAME }}","email": "${{ secrets.CYPRESS_USER_EMAIL }}","password": "${{ secrets.CYPRESS_USER_PASSWORD }}"}' > cypress/fixtures/user.json
383311
sed -i 's/00000000-0000-0000-0000-000000000000/${{ secrets.CYPRESS_KEY }}/g' package.json
@@ -391,15 +319,18 @@ jobs:
391319
/sbin/my_init &
392320
cd ui-tests
393321
npm install
394-
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" \
395-
npm run cy:run:onboarding
322+
if [ "${{ matrix.test_type }}" = "dashboard" ]; then
323+
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" npm run cy:run:dashboard
324+
else
325+
xvfb-run --auto-servernum --server-args="-screen 0 1280x1024x24" npm run cy:run:onboarding
326+
fi
396327
397328
- name: Upload UI tests artifacts
398329
if: ${{ failure() }}
399330
shell: bash
400331
working-directory: /opt/countly/ui-tests/cypress
401332
run: |
402-
ARTIFACT_ARCHIVE_NAME="$(date '+%Y%m%d-%H.%M')_${GITHUB_REPOSITORY#*/}_CI#${{ github.run_number }}.tar.gz"
333+
ARTIFACT_ARCHIVE_NAME="$(date '+%Y%m%d-%H.%M')_${GITHUB_REPOSITORY#*/}_CI#${{ github.run_number }}_${{ matrix.test_type }}.tar.gz"
403334
mkdir -p screenshots videos
404335
tar zcvf "$ARTIFACT_ARCHIVE_NAME" screenshots videos
405336
curl -o /tmp/uploader.log -u "${{ secrets.BOX_UPLOAD_AUTH }}" ${{ secrets.BOX_UPLOAD_PATH }} -T "$ARTIFACT_ARCHIVE_NAME"

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22
Fixes:
33
- [star-rating] Fix consent text limit counter
44

5+
Enterprise Fixes:
6+
- [active-users] Fixed bug related to selecting calculation ranges. As a result, some dates were previously calculated on incomplete data set.
7+
8+
59
## Version 25.03.6
610
Enterprise Features:
711
- [journey_engine] Publish toggle is converted into button and rearranged
@@ -4736,4 +4740,4 @@ This version provides several features and bugfixes to both server and SDKs. The
47364740
admin or user. An admin of an application can edit application settings.
47374741
A user of an application can only view analytics for that application
47384742
and cannot edit its settings.
4739-
* Added csfr protection to all methods provided through app.js.
4743+
* Added csfr protection to all methods provided through app.js.

api/utils/countly-request/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bin/scripts/add_indexes.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@ pluginManager.dbConnection().then((countlyDb) => {
2929
() => countlyDb.collection('app_users' + app._id).ensureIndex({"tsd": 1}, { background: true }, cb),
3030
() => countlyDb.collection('app_users' + app._id).ensureIndex({"did": 1}, { background: true }, cb),
3131
() => countlyDb.collection('app_users' + app._id).dropIndex("lac_1_ls_1", cb),
32-
() => countlyDb.collection('app_user_merges' + app._id).ensureIndex({cd: 1}, {expireAfterSeconds: 60 * 60 * 3, background: true}, cb),
33-
() => countlyDb.collection('metric_changes' + app._id).ensureIndex({ts: -1}, { background: true }, cb),
3432
() => countlyDb.collection('metric_changes' + app._id).ensureIndex({ts: 1, "cc.o": 1}, { background: true }, cb),
3533
() => countlyDb.collection('metric_changes' + app._id).ensureIndex({uid: 1}, { background: true }, cb)
3634
];
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/**
2+
* MongoDB script to delete all collections from a database
3+
* that start with "drill_events" string, but excluding the exact "drill_events" collection
4+
*
5+
*
6+
* Server: MongoDB
7+
* Path: any
8+
* Command: mongosh -u uname -p 'password' --authenticationDatabase admin delete_old_drill_events.js
9+
*/
10+
11+
/* global db, print, quit */
12+
13+
// Set the database name
14+
const dbName = "countly_drill";
15+
16+
// Set to true for dry run, false to actually delete collections
17+
const dryRun = true;
18+
19+
print(`Using database: ${dbName}`);
20+
var cly = db;
21+
// If we need to switch to a different database
22+
if (db.getName() !== dbName) {
23+
cly = db.getSiblingDB(dbName);
24+
}
25+
26+
console.log(`Operating on database: ${dbName}`);
27+
28+
// Get all collection names that start with "drill_events" but are not exactly "drill_events"
29+
const collections = cly.getCollectionInfos().map(info => info.name).filter(collName =>
30+
collName.startsWith("drill_events") && collName !== "drill_events"
31+
);
32+
33+
// Print the collections that will be deleted
34+
print("Collections to be deleted:");
35+
collections.forEach(collName => print(`- ${collName}`));
36+
37+
// Ask for confirmation
38+
if (collections.length === 0) {
39+
print("No matching collections found to delete.");
40+
quit();
41+
}
42+
43+
print(`\nFound ${collections.length} collections to delete.`);
44+
45+
46+
if (dryRun) {
47+
print("Dry run mode is enabled. No collections will be deleted.");
48+
print("To proceed with deletion, set 'dryRun' to false in the script.");
49+
quit();
50+
}
51+
52+
// Delete each collection
53+
let deletedCount = 0;
54+
collections.forEach(collName => {
55+
try {
56+
cly[collName].drop();
57+
print(`Dropped collection: ${collName}`);
58+
deletedCount++;
59+
}
60+
catch (error) {
61+
print(`Error dropping collection ${collName}: ${error}`);
62+
}
63+
});
64+
65+
// Print summary
66+
print(`\nOperation completed. Deleted ${deletedCount} out of ${collections.length} collections.`);

bin/scripts/sharding/sharding.js

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,17 @@
22
* Sharding Countly collections when DB requires authentication, provide it to authDB.auth command in the code
33
* Server: mongodb
44
* Path: any
5-
* Command: mongosh < sharding.js
5+
* Command: mongosh -u uname -p 'password' --authenticationDatabase admin sharding.js
66
*/
77

8-
/* global Mongo, print, printjson */
9-
var COUNTLY_DRILL = 'countly_drill',
10-
COUNTLY = 'countly',
11-
COUNT_TO_SHARD = 100000;
8+
/* global db, print, printjson */
9+
10+
// Set countly_drill database name
11+
const COUNTLY_DRILL = 'countly_drill';
12+
// Set countly database name
13+
const COUNTLY = 'countly';
14+
// Set the threshold for sharding collections
15+
const COUNT_TO_SHARD = 100000;
1216

1317
var EXCEPTIONS = [
1418
/^system\./,
@@ -27,14 +31,8 @@ var COUNTLY_TO_SHARD = [
2731
"feedback",
2832
];
2933

30-
var conn = new Mongo(),
31-
authDB = conn.getDB('admin');
32-
33-
// need to update this info
34-
authDB.auth('<username>', '<password>');
35-
36-
var cly = conn.getDB(COUNTLY),
37-
drill = conn.getDB(COUNTLY_DRILL);
34+
var cly = db.getSiblingDB(COUNTLY),
35+
drill = db.getSiblingDB(COUNTLY_DRILL);
3836

3937
var clyCollections = cly.getCollectionNames(), collections = clyCollections.concat(drill.getCollectionNames()), check = [];
4038

@@ -61,8 +59,7 @@ check.forEach(function(c) {
6159
var db = clyCollections.indexOf(c) === -1 ? drill : cly,
6260
dbName = clyCollections.indexOf(c) === -1 ? COUNTLY_DRILL : COUNTLY,
6361
count = db[c].count(),
64-
capped = db[c].stats()['capped'],
65-
status = db[c].getShardVersion().ok;
62+
capped = db[c].stats()['capped'];
6663

6764
COUNTLY_TO_SHARD.some((e) => {
6865
if (c.indexOf(e) == 0) {
@@ -71,7 +68,7 @@ check.forEach(function(c) {
7168
}
7269
});
7370

74-
if (!capped && count > COUNT_TO_SHARD && !status && !exceptional) {
71+
if (!capped && count > COUNT_TO_SHARD && !exceptional) {
7572
print('Creating hashed index & enabling sharding for collection "' + c + '"... ');
7673

7774
db.getCollection(c).createIndex({ _id: 'hashed' });

0 commit comments

Comments
 (0)