Skip to content

Commit db60f48

Browse files
committed
fix: Remove revenue plugin and its all dependencies
1 parent 17e44ee commit db60f48

File tree

11 files changed

+76
-331
lines changed

11 files changed

+76
-331
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/**
2+
* Description:
3+
* This script clean up deprecated references to the removed "revenue" plugin in Countly.
4+
* The "revenue" plugin has been deprecated and removed from the Countly and will no longer be supported
5+
*
6+
* This script will:
7+
* - Identify and remove all leftover "revenue"-related widgets, metrics, conditions, or configurations
8+
* from custom dashboards, alerts, and email reports.
9+
* - Disable revenue and performance-monitoring plugins in the plugins configuration.
10+
*
11+
* Server: countly
12+
* Path: $(countly dir)/bin/scripts/revenue_plugin_cleanup.js
13+
* Command: node revenue_plugin_cleanup.js
14+
*/
15+
16+
var pluginManager = require('./../../../plugins/pluginManager.js');
17+
var Promise = require("bluebird");
18+
19+
Promise.all([pluginManager.dbConnection("countly")]).then(async function([countlyDb]) {
20+
console.log("Starting revenue data cleanup...");
21+
22+
try {
23+
// 1. Clean revenue widgets
24+
console.log("Cleaning widgets collection...");
25+
const widgetsQuery = { "feature": "revenue" };
26+
const widgetsResult = await countlyDb.collection("widgets").deleteMany(widgetsQuery);
27+
console.log(`Removed ${widgetsResult.deletedCount} revenue widgets from widgets collection`);
28+
29+
// 2. Clean revenue e-mail reports
30+
console.log("Cleaning reports collection...");
31+
const reportsQuery = { "metrics.revenue": true };
32+
const reportsResult = await countlyDb.collection("reports").deleteMany(reportsQuery);
33+
console.log(`Removed ${reportsResult.deletedCount} revenue reports from reports collection`);
34+
35+
// 3. Clean revenue alerts
36+
console.log("Cleaning alerts collection...");
37+
const alertsQuery = { "alertDataType": "revenue" };
38+
const alertsResult = await countlyDb.collection("alerts").deleteMany(alertsQuery);
39+
console.log(`Successfully removed ${alertsResult.deletedCount} revenue alerts from alerts collection`);
40+
41+
// 4. Disable revenue and performance-monitoring plugins
42+
console.log("Disabling revenue and performance-monitoring plugins...");
43+
const updateFields = {
44+
"plugins.revenue": false,
45+
"plugins.performance-monitoring": false
46+
};
47+
48+
const pluginsResult = await countlyDb.collection("plugins").updateOne(
49+
{ _id: "plugins" },
50+
{ $set: updateFields }
51+
);
52+
53+
if (pluginsResult.matchedCount > 0) {
54+
console.log("Successfully disabled revenue and performance-monitoring plugins");
55+
}
56+
else {
57+
console.log("No plugins document found to update");
58+
}
59+
60+
console.log("\n\nRevenue data cleanup completed successfully!");
61+
62+
}
63+
catch (error) {
64+
console.log("Error during revenue data cleanup:", error);
65+
}
66+
finally {
67+
countlyDb.close();
68+
}
69+
}).catch(function(error) {
70+
console.log("Database connection error:", error);
71+
});

plugins/alerts/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ alerts/
1414
│ ├── events.js # events alert checker
1515
│ ├── nps.js # NPS alert checker
1616
│ ├── rating.js # rating alert checker
17-
│ ├── revenue.js # revenue alert checker
1817
│ ├── sessions.js # sessions alert checker
1918
│ ├── survey.js # survey alert checker
2019
│ ├── users.js # users alert checker

plugins/alerts/api/alertModules/revenue.js

Lines changed: 0 additions & 167 deletions
This file was deleted.

plugins/alerts/api/jobs/monitor.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const ALERT_MODULES = {
1212
"sessions": require("../alertModules/sessions.js"),
1313
"survey": require("../alertModules/survey.js"),
1414
"nps": require("../alertModules/nps.js"),
15-
"revenue": require("../alertModules/revenue.js"),
1615
"events": require("../alertModules/events.js"),
1716
"rating": require("../alertModules/rating.js"),
1817
"cohorts": require("../alertModules/cohorts.js"),

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

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -179,24 +179,7 @@
179179
label: "# of users in the profile group",
180180
},
181181
],
182-
},
183-
revenue: {
184-
target: [
185-
{ value: "total revenue", label: "total revenue" },
186-
{
187-
value: "average revenue per user",
188-
label: "average revenue per user",
189-
},
190-
{
191-
value: "average revenue per paying user",
192-
label: "average revenue per paying user",
193-
},
194-
{
195-
value: "# of paying users",
196-
label: "# of paying users",
197-
},
198-
],
199-
},
182+
}
200183
},
201184
emailOptions: [
202185
{
@@ -330,10 +313,6 @@
330313
value: "profile_groups",
331314
},
332315
{ label: jQuery.i18n.map["alert.Rating"], value: "rating" },
333-
{
334-
label: jQuery.i18n.map["alert.Revenue"],
335-
value: "revenue",
336-
},
337316
{
338317
label: jQuery.i18n.map["alert.Session"],
339318
value: "sessions",
@@ -349,9 +328,6 @@
349328
if (!countlyGlobal.plugins.includes("surveys")) {
350329
alertDataTypeOptions = alertDataTypeOptions.filter(({ value }) => value !== "survey" && value !== "nps");
351330
}
352-
if (!countlyGlobal.plugins.includes("revenue")) {
353-
alertDataTypeOptions = alertDataTypeOptions.filter(({ value }) => value !== "revenue");
354-
}
355331
if (!countlyGlobal.plugins.includes("cohorts")) {
356332
alertDataTypeOptions = alertDataTypeOptions.filter(({ value }) => value !== "cohorts" && value !== "profile_groups");
357333
}
@@ -707,8 +683,6 @@
707683
return "cly-io-16 cly-is cly-is-user-group";
708684
case "rating":
709685
return "cly-io-16 cly-is cly-is-star";
710-
case "revenue":
711-
return "cly-io-16 cly-is cly-is-currency-dollar";
712686
case "sessions":
713687
return "cly-io-16 cly-is cly-is-clock";
714688
case "survey":

plugins/alerts/frontend/public/localization/alerts.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ alert.Data-points=Data Points
1818
alert.Online-users=Online Users
1919
alert.Cohorts=Cohorts
2020
alert.Profile-groups = Profile Groups
21-
alert.Revenue=Revenue
2221
alert.Data_type=Data Type
2322
alert.For_Application=For Application
2423
alert.all-applications=All Applications

plugins/reports/api/generate_reports.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ plugins.dbConnection().then((countlyDb) => {
5555
for (var i = 0; i < res.length; i++) {
5656
if (!res[i].global_admin) {
5757
var adminApps = getAdminApps(res[i]);
58-
arr.push({emails: [res[i].email], apps: adminApps || [], metrics: {"analytics": true, "revenue": true, "push": true, "crash": true }, frequency: "daily", hour: 17, minute: 0, day: 1, timezone: "Etc/GMT", user: res[i]._id});
58+
arr.push({emails: [res[i].email], apps: adminApps || [], metrics: {"analytics": true, "push": true, "crash": true }, frequency: "daily", hour: 17, minute: 0, day: 1, timezone: "Etc/GMT", user: res[i]._id});
5959
}
6060
}
6161
async.map(arr, function(report, done) {

0 commit comments

Comments
 (0)