Skip to content

Commit cc5294b

Browse files
committed
Record consent and push sent in drill
1 parent ca9f7ed commit cc5294b

File tree

16 files changed

+64
-13
lines changed

16 files changed

+64
-13
lines changed

api/jobs/appExpire.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class AppExpireJob extends job.Job {
3030
const INDEX_NAME = "cd_1";
3131

3232
let collections = [];
33-
let events = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey"];
33+
let events = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_consent"];
3434
let fromPlugins = plugins.getExpireList();
3535

3636
// predefined drill events

bin/scripts/drill_index.js

+2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ Promise.all([plugins.dbConnection("countly"), plugins.dbConnection("countly_dril
1717
hashes["drill_events" + crypto.createHash('sha1').update("[CLY]_session" + apps[i]._id).digest('hex')] = "[CLY]_session";
1818
hashes["drill_events" + crypto.createHash('sha1').update("[CLY]_crash" + apps[i]._id).digest('hex')] = "[CLY]_crash";
1919
hashes["drill_events" + crypto.createHash('sha1').update("[CLY]_push_action" + apps[i]._id).digest('hex')] = "[CLY]_push_action";
20+
hashes["drill_events" + crypto.createHash('sha1').update("[CLY]_push_sent" + apps[i]._id).digest('hex')] = "[CLY]_push_sent";
21+
hashes["drill_events" + crypto.createHash('sha1').update("[CLY]_consent" + apps[i]._id).digest('hex')] = "[CLY]_consent";
2022
hashes["drill_events" + crypto.createHash('sha1').update("[CLY]_star_rating" + apps[i]._id).digest('hex')] = "[CLY]_star_rating";
2123
hashes["drill_events" + crypto.createHash('sha1').update("[CLY]_nps" + apps[i]._id).digest('hex')] = "[CLY]_nps";
2224
hashes["drill_events" + crypto.createHash('sha1').update("[CLY]_survery" + apps[i]._id).digest('hex')] = "[CLY]_survey";

bin/scripts/expire-data/countly_single_app_expireData.js

+6
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,13 @@ Promise.all([plugins.dbConnection("countly"), plugins.dbConnection("countly_dril
2424
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_view" + APP_ID).digest('hex'));
2525
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_action" + APP_ID).digest('hex'));
2626
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_push_action" + APP_ID).digest('hex'));
27+
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_push_sent" + APP_ID).digest('hex'));
2728
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_star_rating" + APP_ID).digest('hex'));
29+
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_consent" + APP_ID).digest('hex'));
30+
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_nps" + APP_ID).digest('hex'));
31+
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_survey" + APP_ID).digest('hex'));
32+
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_apm_device" + APP_ID).digest('hex'));
33+
collections.push("drill_events" + crypto.createHash('sha1').update("[CLY]_apm_network" + APP_ID).digest('hex'));
2834
db.collection("events").findOne({'_id': db.ObjectID(APP_ID)}, {list: 1}, function(err, eventData) {
2935
if (eventData && eventData.list) {
3036
for (var i = 0; i < eventData.list.length; i++) {

bin/scripts/expire-data/countly_single_app_expireDataBatches.js

+2
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ function processDrillCollections(db, drill_db, callback) {
184184
collections.push({'db': drill_db, 'collection': "drill_events" + crypto.createHash('sha1').update("[CLY]_survey" + APP_ID).digest('hex')});
185185
collections.push({'db': drill_db, 'collection': "drill_events" + crypto.createHash('sha1').update("[CLY]_push_action" + APP_ID).digest('hex')});
186186
collections.push({'db': drill_db, 'collection': "drill_events" + crypto.createHash('sha1').update("[CLY]_star_rating" + APP_ID).digest('hex')});
187+
collections.push({'db': drill_db, 'collection': "drill_events" + crypto.createHash('sha1').update("[CLY]_push_sent" + APP_ID).digest('hex')});
188+
collections.push({'db': drill_db, 'collection': "drill_events" + crypto.createHash('sha1').update("[CLY]_consent" + APP_ID).digest('hex')});
187189
db.collection("events").findOne({'_id': db.ObjectID(APP_ID)}, {list: 1}, function(err, eventData) {
188190
if (eventData && eventData.list) {
189191
for (var i = 0; i < eventData.list.length; i++) {

bin/scripts/export-data/drill_collections_anonymized.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
7474
var collections = [];
7575
try {
7676
var events = await countlyDb.collection("events").findOne({_id: common.db.ObjectID(appId)});
77-
var list = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device"];
77+
var list = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
7878

7979
if (events && events.list) {
8080
for (var p = 0; p < events.list.length; p++) {

bin/scripts/export-data/getAllEventsForApp.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var APP_ID = "5ab0c3ef92938d0e61cf77f4";
1010

1111
var plugins = require("../../../plugins/pluginManager.js");
1212
var crypto = require("crypto");
13-
var internalDrillEvents = ["[CLY]_session", "[CLY]_view", "[CLY]_nps", "[CLY]_crash", "[CLY]_action", "[CLY]_session", "[CLY]_survey", "[CLY]_star_rating", "[CLY]_apm_device", "[CLY]_apm_network", "[CLY]_push_action"];
13+
var internalDrillEvents = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
1414
var result = [];
1515
plugins.dbConnection("countly").then(function(db) {
1616
db.collection("events").findOne({_id: db.ObjectID(APP_ID)}, {"list": true}, function(err, event) {

bin/scripts/fix-data/recheck_merges.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
7272
var collections = [];
7373
try {
7474
var events = await countlyDb.collection("events").findOne({_id: common.db.ObjectID(app_id)});
75-
var list = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device"];
75+
var list = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
7676

7777
if (events && events.list) {
7878
for (var p = 0; p < events.list.length; p++) {

bin/scripts/fix-data/recheck_merges_new.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Promise.all([pluginManager.dbConnection("countly"), pluginManager.dbConnection("
5050
var collections = [];
5151
try {
5252
var events = await countlyDb.collection("events").findOne({_id: common.db.ObjectID(app_id)});
53-
var list = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device"];
53+
var list = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
5454

5555
if (events && events.list) {
5656
for (var p = 0; p < events.list.length; p++) {

bin/scripts/modify-data/delete/delete_user_properties.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var plugins = require("./../../../../plugins/pluginManager.js");
1717
var asyncjs = require("async");
1818
var crypto = require("crypto");
1919

20-
var internal_events = ["[CLY]_view", "[CLY]_session", "[CLY]_crash", "[CLY]_push_action", "[CLY]_star_rating", "[CLY]_action", "[CLY]_apm_device", "[CLY]_apm_network", "[CLY]_action"];
20+
var internal_events = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
2121
var unset = {};
2222
unset[PROPERTY] = "";
2323

bin/scripts/modify-data/list_unused_collections.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ function checkEvents(countlyDb, collections, apps, callback) {
2929
}
3030
}
3131

32-
var internalDrillEvents = ["[CLY]_session", "[CLY]_view", "[CLY]_nps", "[CLY]_crash", "[CLY]_action", "[CLY]_session", "[CLY]_survey", "[CLY]_star_rating", "[CLY]_apm_device", "[CLY]_apm_network", "[CLY]_push_action"];
33-
var internalEvents = ["[CLY]_session", "[CLY]_view", "[CLY]_nps", "[CLY]_crash", "[CLY]_action", "[CLY]_session", "[CLY]_survey", "[CLY]_star_rating", "[CLY]_apm_device", "[CLY]_apm_network", "[CLY]_push_action"];
32+
var internalDrillEvents = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
33+
var internalEvents = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
3434

3535
if (internalDrillEvents) {
3636
for (let i = 0; i < internalDrillEvents.length; i++) {

frontend/express/public/javascripts/countly/vue/components/helpers.js

+16-1
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,14 @@
597597
}
598598

599599

600+
if (countlyGlobal.plugins.indexOf('compliance-hub') !== -1) {
601+
availableEvents.push({
602+
"label": this.i18n('internal-events.[CLY]_consent'),
603+
"name": "[CLY]_consent",
604+
"options": [ { label: this.i18n('internal-events.[CLY]_consent'), value: '[CLY]_consent' } ]
605+
});
606+
}
607+
600608
if (countlyGlobal.plugins.indexOf('crashes') !== -1) {
601609
availableEvents.push({
602610
"label": this.i18n('internal-events.[CLY]_crash'),
@@ -607,7 +615,14 @@
607615

608616
if (countlyGlobal.plugins.indexOf('push') !== -1) {
609617
availableEvents.push({
610-
"label": 'Push',
618+
"label": 'Push Sent',
619+
"name": "[CLY]_push_sent",
620+
"options": [
621+
{ label: this.i18n('internal-events.[CLY]_push_sent'), value: '[CLY]_push_sent' }
622+
]
623+
});
624+
availableEvents.push({
625+
"label": 'Push Actioned',
611626
"name": "[CLY]_push_action",
612627
"options": [
613628
{ label: this.i18n('internal-events.[CLY]_push_action'), value: '[CLY]_push_action' }

plugins/compliance-hub/api/api.js

+22
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ const FEATURE_NAME = 'compliance_hub';
1212
plugins.register("/permissions/features", function(ob) {
1313
ob.features.push(FEATURE_NAME);
1414
});
15+
16+
plugins.internalDrillEvents.push("[CLY]_consent");
17+
1518
//write api call
1619
plugins.register("/sdk/user_properties", function(ob) {
1720
var params = ob.params;
@@ -93,6 +96,13 @@ const FEATURE_NAME = 'compliance_hub';
9396
sc: params.app_user.sc || 0
9497
});
9598

99+
var events = [{
100+
key: "[CLY]_consent",
101+
count: 1,
102+
segmentation: params.qstring.consent
103+
}];
104+
plugins.dispatch("/plugins/drill", {params: params, dbAppUser: params.app_user, events: events});
105+
96106
plugins.dispatch("/consent/change", {params: params, changes: changes});
97107
}
98108
}
@@ -361,23 +371,35 @@ const FEATURE_NAME = 'compliance_hub';
361371
var appId = ob.appId;
362372
common.db.collection('consents').remove({'_id': {$regex: appId + ".*"}}, function() {});
363373
common.db.collection('consent_history' + appId).drop(function() {});
374+
if (common.drillDb) {
375+
common.drillDb.collection("drill_events" + crypto.createHash('sha1').update("[CLY]_consent" + appId).digest('hex')).drop(function() {});
376+
}
364377
});
365378

366379
plugins.register("/i/apps/reset", function(ob) {
367380
var appId = ob.appId;
368381
common.db.collection('consents').remove({'_id': {$regex: appId + ".*"}}, function() {});
369382
common.db.collection('consent_history' + appId).drop(function() {});
383+
if (common.drillDb) {
384+
common.drillDb.collection("drill_events" + crypto.createHash('sha1').update("[CLY]_consent" + appId).digest('hex')).drop(function() {});
385+
}
370386
});
371387

372388
plugins.register("/i/apps/clear_all", function(ob) {
373389
var appId = ob.appId;
374390
common.db.collection('consents').remove({'_id': {$regex: appId + ".*"}}, function() {});
391+
if (common.drillDb) {
392+
common.drillDb.collection("drill_events" + crypto.createHash('sha1').update("[CLY]_consent" + appId).digest('hex')).drop(function() {});
393+
}
375394
});
376395

377396
plugins.register("/i/apps/clear", function(ob) {
378397
var appId = ob.appId;
379398
var ids = ob.ids;
380399
common.db.collection('consents').remove({$and: [{'_id': {$regex: appId + ".*"}}, {'_id': {$nin: ids}}]}, function() {});
400+
if (common.drillDb) {
401+
common.drillDb.collection("drill_events" + crypto.createHash('sha1').update("[CLY]_consent" + appId).digest('hex')).remove({ts: {$lt: ob.moment.valueOf()}}, function() {});
402+
}
381403
});
382404
}(plugin));
383405

plugins/compliance-hub/frontend/public/localization/compliance-hub.properties

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ consent.metrics-desc = View consent requests (opt-ins or opt-outs) in a time ser
3737
consent.users-desc = View list of users and their consent states
3838
consent.history-desc = View a history of consent changes
3939
consent.exports-desc = View all export and purge actions previously executed
40-
userdata.consents = User's consent history
40+
userdata.consents = User's consent history
41+
internal-events.[CLY]_consent = Consent

plugins/pluginManager.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1856,8 +1856,8 @@ var pluginManager = function pluginManager() {
18561856
hashMap[crypto.createHash('sha1').update(eventsDb[z].list[i] + eventsDb[z]._id + "").digest('hex')] = {"a": eventsDb[z]._id, "e": eventsDb[z].list[i]};
18571857
}
18581858

1859-
var internalDrillEvents = ["[CLY]_session", "[CLY]_view", "[CLY]_nps", "[CLY]_crash", "[CLY]_action", "[CLY]_session", "[CLY]_survey", "[CLY]_star_rating", "[CLY]_apm_device", "[CLY]_apm_network", "[CLY]_push_action"];
1860-
var internalEvents = ["[CLY]_session", "[CLY]_view", "[CLY]_nps", "[CLY]_crash", "[CLY]_action", "[CLY]_session", "[CLY]_survey", "[CLY]_star_rating", "[CLY]_apm_device", "[CLY]_apm_network", "[CLY]_push_action"];
1859+
var internalDrillEvents = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
1860+
var internalEvents = ["[CLY]_session", "[CLY]_crash", "[CLY]_view", "[CLY]_action", "[CLY]_push_action", "[CLY]_push_sent", "[CLY]_star_rating", "[CLY]_nps", "[CLY]_survey", "[CLY]_apm_network", "[CLY]_apm_device", "[CLY]_consent"];
18611861

18621862
if (internalDrillEvents) {
18631863
for (let i = 0; i < internalDrillEvents.length; i++) {

plugins/push/api/api.js

+1
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ plugins.setConfigs(FEATURE_NAME, {
7272
plugins.internalEvents.push('[CLY]_push_sent');
7373
plugins.internalEvents.push('[CLY]_push_action');
7474
plugins.internalDrillEvents.push('[CLY]_push_action');
75+
plugins.internalDrillEvents.push('[CLY]_push_sent');
7576

7677

7778
plugins.register('/worker', function() {

plugins/server-stats/api/parts/stats.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ const internalEventsEnum =
1111
"[CLY]_star_rating": "str",
1212
"[CLY]_apm_device": "apm",
1313
"[CLY]_apm_network": "apm",
14-
"[CLY]_push_action": "p"
14+
"[CLY]_push_action": "p",
15+
"[CLY]_push_sent": "ps",
16+
"[CLY]_consent": "cs",
1517
};
1618

1719
/**

0 commit comments

Comments
 (0)