Skip to content

Commit 0e8ffdd

Browse files
Merge branch 'next' into SER-1635-alert-testing-edit-columns-icon-is-missing-on-alert-home-page
2 parents ccc6204 + 8129806 commit 0e8ffdd

File tree

4 files changed

+57
-8
lines changed

4 files changed

+57
-8
lines changed

frontend/express/public/core/events/javascripts/countly.details.views.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,8 @@
178178
byVal: [],
179179
executed: false
180180
};
181-
if (doc.selectedSegment !== "segment") {
182-
URLparams.dbFilter[`sg.${doc.selectedSegment}`] = { "$in": [] };
183-
if (doc.selectedSegmentValues.length > 0) {
184-
URLparams.dbFilter[`sg.${doc.selectedSegment}`].$in = doc.selectedSegmentValues;
185-
}
181+
if (doc.selectedSegment !== "segment" && doc.selectedSegmentValues.length > 0) {
182+
URLparams.dbFilter[`sg.${doc.selectedSegment}`] = { "$in": doc.selectedSegmentValues };
186183
}
187184
//Go to drill page
188185
app.navigate("#/drill/" + JSON.stringify(URLparams), true);

plugins/hooks/api/api.js

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ const Triggers = require('./parts/triggers/index.js');
22
const Effects = require('./parts/effects/index.js');
33
const asyncLib = require('async');
44
const EventEmitter = require('events');
5-
65
const common = require('../../../api/utils/common.js');
76
const { validateRead, validateCreate, validateDelete, validateUpdate } = require('../../../api/utils/rights.js');
87
const plugins = require('../../pluginManager.js');
@@ -304,6 +303,21 @@ plugins.register("/i/hook/save", function(ob) {
304303
{new: true},
305304
function(err, result) {
306305
if (!err) {
306+
// Audit log: Hook updated
307+
if (result && result.value) {
308+
plugins.dispatch("/systemlogs", {
309+
params: params,
310+
action: "hook_updated",
311+
data: {
312+
updatedHookID: result.value._id,
313+
updatedBy: params.member._id,
314+
updatedHookName: result.value.name
315+
}
316+
});
317+
}
318+
else {
319+
common.returnMessage(params, 500, "No result found");
320+
}
307321
common.returnOutput(params, result && result.value);
308322
}
309323
else {
@@ -318,6 +332,16 @@ plugins.register("/i/hook/save", function(ob) {
318332
function(err, result) {
319333
log.d("insert new hook:", err, result);
320334
if (!err && result && result.insertedIds && result.insertedIds[0]) {
335+
// Audit log: Hook created
336+
plugins.dispatch("/systemlogs", {
337+
params: params,
338+
action: "hook_created",
339+
data: {
340+
createdHookID: hookConfig._id,
341+
createdBy: params.member._id,
342+
createdHookName: hookConfig.name
343+
}
344+
});
321345
common.returnOutput(params, result.insertedIds[0]);
322346
}
323347
else {
@@ -514,6 +538,12 @@ plugins.register("/i/hook/status", function(ob) {
514538
}
515539
Promise.all(batch).then(function() {
516540
log.d("hooks all updated.");
541+
// Audit log: Hook status updated
542+
plugins.dispatch("/systemlogs", {
543+
params: params,
544+
action: "hook_status_updated",
545+
data: { updatedHooksCount: Object.keys(statusList).length, requestedBy: params.member._id }
546+
});
517547
common.returnOutput(params, true);
518548
});
519549
}, paramsInstance);
@@ -548,6 +578,15 @@ plugins.register("/i/hook/delete", function(ob) {
548578
function(err, result) {
549579
log.d(err, result, "delete an hook");
550580
if (!err) {
581+
// Audit log: Hook deleted
582+
plugins.dispatch("/systemlogs", {
583+
params: params,
584+
action: "hook_deleted",
585+
data: {
586+
deletedHookID: hookID,
587+
requestedBy: params.member._id
588+
}
589+
});
551590
common.returnMessage(params, 200, "Deleted an hook");
552591
}
553592
}

plugins/hooks/frontend/public/localization/hooks.properties

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,4 +143,9 @@ hooks.actions-tips = Select the actions the hook will do upon being triggered. Y
143143
hooks.application-tips = The app(s) for which you want to create a hook.
144144
hooks.trigger-count-tips = Number of times the hook has been triggered.
145145
hooks.trigger-action-tips = Identifies the trigger for the hook, and the actions that show the method through which data will be sent.
146-
hooks.trigger-save-failed = Hook could not be saved.
146+
hooks.trigger-save-failed = Hook could not be saved.
147+
148+
systemlogs.action.hook_created = Hook Created
149+
systemlogs.action.hook_updated = Hook Updated
150+
systemlogs.action.hook_status_updated = Hook Status Updated
151+
systemlogs.action.hook_deleted = Hook Deleted

plugins/views/frontend/public/javascripts/countly.views.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,15 @@
185185
URLparams.dbFilter[`sg.name`] = { "$in": doc.selectedViews };
186186
}
187187
if (doc.selectedSegment !== "all" && doc.selectedSegmentValues.length > 0) {
188-
URLparams.dbFilter[`sg.${doc.selectedSegment}`] = { "$in": doc.selectedSegmentValues };
188+
if (doc.selectedSegment === "segment" || doc.selectedSegment === "platform") {
189+
URLparams.dbFilter.$or = [
190+
{ "sg.platform": { "$in": doc.selectedSegmentValues } },
191+
{ "sg.segment": { "$in": doc.selectedSegmentValues } }
192+
];
193+
}
194+
else {
195+
URLparams.dbFilter[`sg.${doc.selectedSegment}`] = { "$in": doc.selectedSegmentValues };
196+
}
189197
}
190198
//Go to drill page
191199
app.navigate("#/drill/" + JSON.stringify(URLparams), true);

0 commit comments

Comments
 (0)