diff --git a/plugins/populator/frontend/public/javascripts/countly.models.js b/plugins/populator/frontend/public/javascripts/countly.models.js index 3e2b5ba4fc9..6a8e06636d2 100644 --- a/plugins/populator/frontend/public/javascripts/countly.models.js +++ b/plugins/populator/frontend/public/javascripts/countly.models.js @@ -1336,6 +1336,7 @@ var abExampleCount = 1; var abExampleName = "Pricing"; var _templateType = ''; + var _featuresToPopulate = []; var runCount = 0; var completedRequestCount = 0; var crashSymbolVersions = { @@ -1700,26 +1701,31 @@ * @param {function} callback - callback method */ function generateRatingWidgets(callback) { - createFeedbackWidget("What's your opinion about this page?", "Add comment", "Contact me by e-mail", "Send feedback", "Thanks for feedback!", "mleft", "#fff", "#ddd", "Feedback", {phone: true, tablet: false, desktop: true}, ["/"], "selected", true, false, function() { - createFeedbackWidget("Leave us a feedback", "Add comment", "Contact me by e-mail", "Send feedback", "Thanks!", "mleft", "#fff", "#ddd", "Feedback", {phone: true, tablet: false, desktop: false}, ["/"], "selected", true, false, function() { - createFeedbackWidget("Did you like this web page?", "Add comment", "Contact me by e-mail", "Send feedback", "Thanks!", "bright", "#fff", "#ddd", "Feedback", {phone: true, tablet: false, desktop: false}, ["/"], "selected", true, false, function() { - $.ajax({ - type: "GET", - url: countlyCommon.API_URL + "/o/feedback/widgets", - data: { - app_id: countlyCommon.ACTIVE_APP_ID - }, - success: function(json) { - ratingWidgetList = json; - callback(); - }, - error: function() { - callback(); - } + if (countlyGlobal.plugins.indexOf("star-rating") !== -1 && countlyAuth.validateCreate("star-rating") && _featuresToPopulate.includes("star-rating")) { + createFeedbackWidget("What's your opinion about this page?", "Add comment", "Contact me by e-mail", "Send feedback", "Thanks for feedback!", "mleft", "#fff", "#ddd", "Feedback", {phone: true, tablet: false, desktop: true}, ["/"], "selected", true, false, function() { + createFeedbackWidget("Leave us a feedback", "Add comment", "Contact me by e-mail", "Send feedback", "Thanks!", "mleft", "#fff", "#ddd", "Feedback", {phone: true, tablet: false, desktop: false}, ["/"], "selected", true, false, function() { + createFeedbackWidget("Did you like this web page?", "Add comment", "Contact me by e-mail", "Send feedback", "Thanks!", "bright", "#fff", "#ddd", "Feedback", {phone: true, tablet: false, desktop: false}, ["/"], "selected", true, false, function() { + $.ajax({ + type: "GET", + url: countlyCommon.API_URL + "/o/feedback/widgets", + data: { + app_id: countlyCommon.ACTIVE_APP_ID + }, + success: function(json) { + ratingWidgetList = json; + callback(); + }, + error: function() { + callback(); + } + }); }); }); }); - }); + } + else { + callback(); + } } /** @@ -1727,9 +1733,14 @@ * @param {function} callback - callback method */ function generateNPSWidgets(callback) { - createNPSWidget("Separate per response type", "score", "How likely are you to recommend our product to a friend or colleague?", "We're glad you like us. What do you like the most about our product?", "Thank you for your feedback. How can we improve your experience?", "We're sorry to hear it. What would you like us to improve on?", "", "Thank you for your feedback", "full", "uclose", "#ddd", function() { - createNPSWidget("One response for all", "one", "How likely are you to recommend our product to a friend or colleague?", "", "", "", "What can/should we do to WOW you?", "Thank you for your feedback", "full", "uclose", "#ddd", callback); - }); + if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys") && _featuresToPopulate.includes("surveys")) { + createNPSWidget("Separate per response type", "score", "How likely are you to recommend our product to a friend or colleague?", "We're glad you like us. What do you like the most about our product?", "Thank you for your feedback. How can we improve your experience?", "We're sorry to hear it. What would you like us to improve on?", "", "Thank you for your feedback", "full", "uclose", "#ddd", function() { + createNPSWidget("One response for all", "one", "How likely are you to recommend our product to a friend or colleague?", "", "", "", "What can/should we do to WOW you?", "Thank you for your feedback", "full", "uclose", "#ddd", callback); + }); + } + else { + callback(); + } } /** @@ -1863,27 +1874,32 @@ }); }); } - if (countlyGlobal.plugins.indexOf("star-rating") !== -1 && countlyAuth.validateCreate("star-rating")) { - generateRatingWidgets(function() { - if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys")) { - generateNPSWidgets(function() { - setTimeout(function() { - generateSurveyWidgets1(function() { - generateSurveyWidgets2(function() { - generateSurveyWidgets3(done); - }); - }); - }, 100); + + /** + * Create 3 survey widgets + * @param {function} callback - callback method + */ + function generateSurveryWidgets(callback) { + if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys") && _featuresToPopulate.includes("surveys")) { + generateSurveyWidgets1(function() { + generateSurveyWidgets2(function() { + generateSurveyWidgets3(callback); }); - } - else { - done(); - } - }); - } - else { - done(); + }); + } + else { + callback(); + } } + + generateRatingWidgets(function() { + generateNPSWidgets(function() { + setTimeout(function() { + generateSurveryWidgets(done); + }, 100); + }); + }); + } @@ -1958,7 +1974,7 @@ * @param {callback} callback - callback method **/ function generateCampaigns(callback) { - if (!CountlyHelpers.isPluginEnabled("attribution") || typeof countlyAttribution === "undefined") { + if (!CountlyHelpers.isPluginEnabled("attribution") || typeof countlyAttribution === "undefined" || !_featuresToPopulate.includes("attribution")) { callback(); return; } @@ -2262,7 +2278,7 @@ generateCampaigns(async function() { await createUsers(); - if (countlyGlobal.plugins.indexOf("ab-testing") !== -1 && countlyAuth.validateCreate("ab-testing")) { + if (countlyGlobal.plugins.indexOf("ab-testing") !== -1 && countlyAuth.validateCreate("ab-testing") && _featuresToPopulate.includes("ab-testing")) { abExampleName = "Pricing" + abExampleCount++; generateAbTests(function() { if (users.length) { @@ -2347,7 +2363,7 @@ var template = this.currentTemplate || {}; - if (CountlyHelpers.isPluginEnabled("cohorts") && typeof countlyCohorts !== "undefined" && countlyAuth.validateCreate('cohorts')) { + if (CountlyHelpers.isPluginEnabled("cohorts") && typeof countlyCohorts !== "undefined" && countlyAuth.validateCreate('cohorts') && _featuresToPopulate.includes("cohorts")) { if (template.events && template.events.length) { var firstEventKey = template.events[getRandomInt(0, template.events.length - 1)].key; @@ -2470,7 +2486,7 @@ }); } - if (CountlyHelpers.isPluginEnabled("funnels") && typeof countlyFunnel !== "undefined" && countlyAuth.validateCreate('funnels')) { + if (CountlyHelpers.isPluginEnabled("funnels") && typeof countlyFunnel !== "undefined" && countlyAuth.validateCreate('funnels') && _featuresToPopulate.includes("funnels")) { let pages = countlyGlobal.apps[countlyCommon.ACTIVE_APP_ID].type === "mobile" ? viewSegments.name : getPageTemplates(countlyPopulator.getSelectedTemplate().substr(7).toLowerCase()); let page1 = pages[getRandomInt(0, pages.length - 1)]; @@ -2502,7 +2518,7 @@ } } - if (countlyGlobal.plugins.indexOf('crash_symbolication') !== -1 && countlyAuth.validateCreate('crash_symbolication')) { + if (countlyGlobal.plugins.indexOf('crash_symbolication') !== -1 && countlyAuth.validateCreate('crash_symbolication') && _featuresToPopulate.includes("crash_symbolication")) { const crashPlatforms = Object.keys(crashSymbolVersions).filter(key => crashSymbolVersions[key].length); @@ -2556,7 +2572,7 @@ }); } - if (CountlyHelpers.isPluginEnabled("push")) { + if (CountlyHelpers.isPluginEnabled("push") && _featuresToPopulate.includes("push")) { createMessage(messages[0]); createMessage(messages[1]); createMessage(messages[2]); @@ -2575,6 +2591,10 @@ _templateType = value; }; + countlyPopulator.setSelectedFeatures = function(value) { + _featuresToPopulate = value; + }; + countlyPopulator.getTemplate = function(templateId, callback) { var foundDefault = defaultTemplates.find(function(template) { return template._id === templateId; diff --git a/plugins/populator/frontend/public/javascripts/countly.views.js b/plugins/populator/frontend/public/javascripts/countly.views.js index 8cea6458ca0..b98db31110c 100644 --- a/plugins/populator/frontend/public/javascripts/countly.views.js +++ b/plugins/populator/frontend/public/javascripts/countly.views.js @@ -9,6 +9,7 @@ currentTab: "data-populator", dialog: {type: '', showDialog: false, saveButtonLabel: '', cancelButtonLabel: '', title: '', text: '', params: {}}, selectedTemplate: '', + selectedFeatures: [], generateDataModal: {showDialog: false}, percentage: 0, templates: [], @@ -47,6 +48,21 @@ } ]; }, + availableFeatures: function() { + const plugins = [ + {value: "ab-testing", label: CV.i18n("ab-testing.title")}, + {value: "attribution", label: CV.i18n("attribution.title")}, + {value: "cohorts", label: CV.i18n("cohorts.cohorts")}, + {value: "crash_symbolication", label: CV.i18n("crash_symbolication.title")}, + {value: "funnels", label: CV.i18n("funnels.plugin-title")}, + {value: "push", label: CV.i18n("push-notification.title")}, + {value: "star-rating", label: CV.i18n("star-rating.plugin-title")}, + {value: "surveys", label: CV.i18n("surveys.plugin-title")}, + ]; + return plugins.filter(function(plugin) { + return CountlyHelpers.isPluginEnabled(plugin.value); + }); + } }, methods: { refreshTable: function(res) { @@ -304,6 +320,7 @@ } else { countlyPopulator.setSelectedTemplate(self.selectedTemplate); + countlyPopulator.setSelectedFeatures(this.selectedFeatures); this.selectedTemplateInformation.saveEnvironment = this.isOpen; this.selectedTemplateInformation.environmentName = this.environmentName; countlyPopulator.generateUsers(self.selectedRunCount, this.selectedTemplateInformation); diff --git a/plugins/populator/frontend/public/localization/populator.properties b/plugins/populator/frontend/public/localization/populator.properties index 749a890ab35..d081e33002c 100644 --- a/plugins/populator/frontend/public/localization/populator.properties +++ b/plugins/populator/frontend/public/localization/populator.properties @@ -211,3 +211,6 @@ populator.warning-generate-users = Populator can't fully support generating data populator.warning-generate-users-header = There is a high chance of spike populator-template.add-step-tooltip = Events or view properties are required to add steps to sequences. populator.error-salt = You should remove the salt for checksum value from application settings to continue using the populator +populator.include-features = Include Features +populator.select-features = Select features +populator.include-features-tooltip = The selected features will be populated with sample data diff --git a/plugins/populator/frontend/public/templates/populator.html b/plugins/populator/frontend/public/templates/populator.html index 6258f2e900e..0ec4dbfd018 100644 --- a/plugins/populator/frontend/public/templates/populator.html +++ b/plugins/populator/frontend/public/templates/populator.html @@ -47,6 +47,14 @@ + + + {{ i18n('populator.include-features') }} + + + + + {{ i18n('populator.start') }}