Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions bin/scripts/fix-data/revenue_plugin_cleanup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* Description:
* This script clean up deprecated references to the removed "revenue" plugin in Countly.
* The "revenue" plugin has been deprecated and removed from the Countly and will no longer be supported
*
* This script will:
* - Identify and remove all leftover "revenue"-related widgets, metrics, conditions, or configurations
* from custom dashboards, alerts, and email reports.
* - Disable revenue and performance-monitoring plugins in the plugins configuration.
*
* Server: countly
* Path: $(countly dir)/bin/scripts/revenue_plugin_cleanup.js
* Command: node revenue_plugin_cleanup.js
*/

var pluginManager = require('./../../../plugins/pluginManager.js');
var Promise = require("bluebird");

Promise.all([pluginManager.dbConnection("countly")]).then(async function([countlyDb]) {
console.log("Starting revenue data cleanup...");

try {
// 1. Clean revenue widgets
console.log("Cleaning widgets collection...");
const widgetsQuery = { "feature": "revenue" };
const widgetsResult = await countlyDb.collection("widgets").deleteMany(widgetsQuery);
console.log(`Removed ${widgetsResult.deletedCount} revenue widgets from widgets collection`);

// 2. Clean revenue e-mail reports
console.log("Cleaning reports collection...");
const reportsQuery = { "metrics.revenue": true };
const reportsResult = await countlyDb.collection("reports").deleteMany(reportsQuery);
console.log(`Removed ${reportsResult.deletedCount} revenue reports from reports collection`);

// 3. Clean revenue alerts
console.log("Cleaning alerts collection...");
const alertsQuery = { "alertDataType": "revenue" };
const alertsResult = await countlyDb.collection("alerts").deleteMany(alertsQuery);
console.log(`Successfully removed ${alertsResult.deletedCount} revenue alerts from alerts collection`);

// 4. Disable revenue and performance-monitoring plugins
console.log("Disabling revenue and performance-monitoring plugins...");
const updateFields = {
"plugins.revenue": false,
"plugins.performance-monitoring": false
};

const pluginsResult = await countlyDb.collection("plugins").updateOne(
{ _id: "plugins" },
{ $set: updateFields }
);

if (pluginsResult.matchedCount > 0) {
console.log("Successfully disabled revenue and performance-monitoring plugins");
}
else {
console.log("No plugins document found to update");
}

console.log("\n\nRevenue data cleanup completed successfully!");

}
catch (error) {
console.log("Error during revenue data cleanup:", error);
}
finally {
countlyDb.close();
}
}).catch(function(error) {
console.log("Database connection error:", error);
});
1 change: 0 additions & 1 deletion plugins/alerts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ alerts/
│ ├── events.js # events alert checker
│ ├── nps.js # NPS alert checker
│ ├── rating.js # rating alert checker
│ ├── revenue.js # revenue alert checker
│ ├── sessions.js # sessions alert checker
│ ├── survey.js # survey alert checker
│ ├── users.js # users alert checker
Expand Down
167 changes: 0 additions & 167 deletions plugins/alerts/api/alertModules/revenue.js

This file was deleted.

1 change: 0 additions & 1 deletion plugins/alerts/api/jobs/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const ALERT_MODULES = {
"sessions": require("../alertModules/sessions.js"),
"survey": require("../alertModules/survey.js"),
"nps": require("../alertModules/nps.js"),
"revenue": require("../alertModules/revenue.js"),
"events": require("../alertModules/events.js"),
"rating": require("../alertModules/rating.js"),
"cohorts": require("../alertModules/cohorts.js"),
Expand Down
28 changes: 1 addition & 27 deletions plugins/alerts/frontend/public/javascripts/countly.views.js
Original file line number Diff line number Diff line change
Expand Up @@ -179,24 +179,7 @@
label: "# of users in the profile group",
},
],
},
revenue: {
target: [
{ value: "total revenue", label: "total revenue" },
{
value: "average revenue per user",
label: "average revenue per user",
},
{
value: "average revenue per paying user",
label: "average revenue per paying user",
},
{
value: "# of paying users",
label: "# of paying users",
},
],
},
}
},
emailOptions: [
{
Expand Down Expand Up @@ -330,10 +313,6 @@
value: "profile_groups",
},
{ label: jQuery.i18n.map["alert.Rating"], value: "rating" },
{
label: jQuery.i18n.map["alert.Revenue"],
value: "revenue",
},
{
label: jQuery.i18n.map["alert.Session"],
value: "sessions",
Expand All @@ -349,9 +328,6 @@
if (!countlyGlobal.plugins.includes("surveys")) {
alertDataTypeOptions = alertDataTypeOptions.filter(({ value }) => value !== "survey" && value !== "nps");
}
if (!countlyGlobal.plugins.includes("revenue")) {
alertDataTypeOptions = alertDataTypeOptions.filter(({ value }) => value !== "revenue");
}
if (!countlyGlobal.plugins.includes("cohorts")) {
alertDataTypeOptions = alertDataTypeOptions.filter(({ value }) => value !== "cohorts" && value !== "profile_groups");
}
Expand Down Expand Up @@ -707,8 +683,6 @@
return "cly-io-16 cly-is cly-is-user-group";
case "rating":
return "cly-io-16 cly-is cly-is-star";
case "revenue":
return "cly-io-16 cly-is cly-is-currency-dollar";
case "sessions":
return "cly-io-16 cly-is cly-is-clock";
case "survey":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ alert.Data-points=Data Points
alert.Online-users=Online Users
alert.Cohorts=Cohorts
alert.Profile-groups = Profile Groups
alert.Revenue=Revenue
alert.Data_type=Data Type
alert.For_Application=For Application
alert.all-applications=All Applications
Expand Down
2 changes: 1 addition & 1 deletion plugins/reports/api/generate_reports.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ plugins.dbConnection().then((countlyDb) => {
for (var i = 0; i < res.length; i++) {
if (!res[i].global_admin) {
var adminApps = getAdminApps(res[i]);
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});
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});
}
}
async.map(arr, function(report, done) {
Expand Down
Loading
Loading