Skip to content

Commit aca8ec2

Browse files
committed
add option to select features to populate
1 parent 49dcf72 commit aca8ec2

File tree

4 files changed

+89
-45
lines changed

4 files changed

+89
-45
lines changed

plugins/populator/frontend/public/javascripts/countly.models.js

Lines changed: 61 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,7 @@
13361336
var abExampleCount = 1;
13371337
var abExampleName = "Pricing";
13381338
var _templateType = '';
1339+
var _featuresToPopulate = [];
13391340
var runCount = 0;
13401341
var completedRequestCount = 0;
13411342
var crashSymbolVersions = {
@@ -1700,36 +1701,46 @@
17001701
* @param {function} callback - callback method
17011702
*/
17021703
function generateRatingWidgets(callback) {
1703-
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() {
1704-
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() {
1705-
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() {
1706-
$.ajax({
1707-
type: "GET",
1708-
url: countlyCommon.API_URL + "/o/feedback/widgets",
1709-
data: {
1710-
app_id: countlyCommon.ACTIVE_APP_ID
1711-
},
1712-
success: function(json) {
1713-
ratingWidgetList = json;
1714-
callback();
1715-
},
1716-
error: function() {
1717-
callback();
1718-
}
1704+
if (countlyGlobal.plugins.indexOf("star-rating") !== -1 && countlyAuth.validateCreate("star-rating") && _featuresToPopulate.includes("star-rating")) {
1705+
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() {
1706+
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() {
1707+
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() {
1708+
$.ajax({
1709+
type: "GET",
1710+
url: countlyCommon.API_URL + "/o/feedback/widgets",
1711+
data: {
1712+
app_id: countlyCommon.ACTIVE_APP_ID
1713+
},
1714+
success: function(json) {
1715+
ratingWidgetList = json;
1716+
callback();
1717+
},
1718+
error: function() {
1719+
callback();
1720+
}
1721+
});
17191722
});
17201723
});
17211724
});
1722-
});
1725+
}
1726+
else {
1727+
callback();
1728+
}
17231729
}
17241730

17251731
/**
17261732
* Create NPS widgets
17271733
* @param {function} callback - callback method
17281734
*/
17291735
function generateNPSWidgets(callback) {
1730-
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() {
1731-
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);
1732-
});
1736+
if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys") && _featuresToPopulate.includes("surveys")) {
1737+
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() {
1738+
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);
1739+
});
1740+
}
1741+
else {
1742+
callback();
1743+
}
17331744
}
17341745

17351746
/**
@@ -1863,27 +1874,28 @@
18631874
});
18641875
});
18651876
}
1866-
if (countlyGlobal.plugins.indexOf("star-rating") !== -1 && countlyAuth.validateCreate("star-rating")) {
1867-
generateRatingWidgets(function() {
1868-
if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys")) {
1869-
generateNPSWidgets(function() {
1870-
setTimeout(function() {
1871-
generateSurveyWidgets1(function() {
1872-
generateSurveyWidgets2(function() {
1873-
generateSurveyWidgets3(done);
1874-
});
1875-
});
1876-
}, 100);
1877+
1878+
function generateSurveryWidgets(callback) {
1879+
if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys") && _featuresToPopulate.includes("surveys")) {
1880+
generateSurveyWidgets1(function() {
1881+
generateSurveyWidgets2(function() {
1882+
generateSurveyWidgets3(callback);
18771883
});
1878-
}
1879-
else {
1880-
done();
1881-
}
1882-
});
1883-
}
1884-
else {
1885-
done();
1884+
});
1885+
}
1886+
else {
1887+
callback();
1888+
}
18861889
}
1890+
1891+
generateRatingWidgets(function() {
1892+
generateNPSWidgets(function() {
1893+
setTimeout(function() {
1894+
generateSurveryWidgets(done);
1895+
}, 100);
1896+
});
1897+
});
1898+
18871899
}
18881900

18891901

@@ -1958,7 +1970,7 @@
19581970
* @param {callback} callback - callback method
19591971
**/
19601972
function generateCampaigns(callback) {
1961-
if (!CountlyHelpers.isPluginEnabled("attribution") || typeof countlyAttribution === "undefined") {
1973+
if (!CountlyHelpers.isPluginEnabled("attribution") || typeof countlyAttribution === "undefined" || !_featuresToPopulate.includes("attribution")) {
19621974
callback();
19631975
return;
19641976
}
@@ -2262,7 +2274,7 @@
22622274
generateCampaigns(async function() {
22632275
await createUsers();
22642276

2265-
if (countlyGlobal.plugins.indexOf("ab-testing") !== -1 && countlyAuth.validateCreate("ab-testing")) {
2277+
if (countlyGlobal.plugins.indexOf("ab-testing") !== -1 && countlyAuth.validateCreate("ab-testing") && _featuresToPopulate.includes("ab-testing")) {
22662278
abExampleName = "Pricing" + abExampleCount++;
22672279
generateAbTests(function() {
22682280
if (users.length) {
@@ -2347,7 +2359,7 @@
23472359

23482360
var template = this.currentTemplate || {};
23492361

2350-
if (CountlyHelpers.isPluginEnabled("cohorts") && typeof countlyCohorts !== "undefined" && countlyAuth.validateCreate('cohorts')) {
2362+
if (CountlyHelpers.isPluginEnabled("cohorts") && typeof countlyCohorts !== "undefined" && countlyAuth.validateCreate('cohorts') && _featuresToPopulate.includes("cohorts")) {
23512363
if (template.events && template.events.length) {
23522364
var firstEventKey = template.events[getRandomInt(0, template.events.length - 1)].key;
23532365

@@ -2470,7 +2482,7 @@
24702482
});
24712483
}
24722484

2473-
if (CountlyHelpers.isPluginEnabled("funnels") && typeof countlyFunnel !== "undefined" && countlyAuth.validateCreate('funnels')) {
2485+
if (CountlyHelpers.isPluginEnabled("funnels") && typeof countlyFunnel !== "undefined" && countlyAuth.validateCreate('funnels') && _featuresToPopulate.includes("funnels")) {
24742486

24752487
let pages = countlyGlobal.apps[countlyCommon.ACTIVE_APP_ID].type === "mobile" ? viewSegments.name : getPageTemplates(countlyPopulator.getSelectedTemplate().substr(7).toLowerCase());
24762488
let page1 = pages[getRandomInt(0, pages.length - 1)];
@@ -2502,7 +2514,7 @@
25022514
}
25032515
}
25042516

2505-
if (countlyGlobal.plugins.indexOf('crash_symbolication') !== -1 && countlyAuth.validateCreate('crash_symbolication')) {
2517+
if (countlyGlobal.plugins.indexOf('crash_symbolication') !== -1 && countlyAuth.validateCreate('crash_symbolication') && _featuresToPopulate.includes("crash_symbolication")) {
25062518
const crashPlatforms = Object.keys(crashSymbolVersions).filter(key => crashSymbolVersions[key].length);
25072519

25082520

@@ -2556,7 +2568,7 @@
25562568
});
25572569
}
25582570

2559-
if (CountlyHelpers.isPluginEnabled("push")) {
2571+
if (CountlyHelpers.isPluginEnabled("push") && _featuresToPopulate.includes("push")) {
25602572
createMessage(messages[0]);
25612573
createMessage(messages[1]);
25622574
createMessage(messages[2]);
@@ -2575,6 +2587,10 @@
25752587
_templateType = value;
25762588
};
25772589

2590+
countlyPopulator.setSelectedFeatures = function(value) {
2591+
_featuresToPopulate = value;
2592+
};
2593+
25782594
countlyPopulator.getTemplate = function(templateId, callback) {
25792595
var foundDefault = defaultTemplates.find(function(template) {
25802596
return template._id === templateId;

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
currentTab: "data-populator",
1010
dialog: {type: '', showDialog: false, saveButtonLabel: '', cancelButtonLabel: '', title: '', text: '', params: {}},
1111
selectedTemplate: '',
12+
selectedFeatures: [],
1213
generateDataModal: {showDialog: false},
1314
percentage: 0,
1415
templates: [],
@@ -47,6 +48,21 @@
4748
}
4849
];
4950
},
51+
availableFeatures: function() {
52+
const plugins = [
53+
{value: "ab-testing", label: CV.i18n("ab-testing.title")},
54+
{value: "attribution", label: CV.i18n("attribution.title")},
55+
{value: "cohorts", label: CV.i18n("cohorts.cohorts")},
56+
{value: "crash_symbolication", label: CV.i18n("crash_symbolication.title")},
57+
{value: "funnels", label: CV.i18n("funnels.plugin-title")},
58+
{value: "push", label: CV.i18n("push-notification.title")},
59+
{value: "star-rating", label: CV.i18n("star-rating.plugin-title")},
60+
{value: "surveys", label: CV.i18n("surveys.plugin-title")},
61+
]
62+
return plugins.filter(function(plugin) {
63+
return CountlyHelpers.isPluginEnabled(plugin.value);
64+
});
65+
}
5066
},
5167
methods: {
5268
refreshTable: function(res) {
@@ -304,6 +320,7 @@
304320
}
305321
else {
306322
countlyPopulator.setSelectedTemplate(self.selectedTemplate);
323+
countlyPopulator.setSelectedFeatures(this.selectedFeatures);
307324
this.selectedTemplateInformation.saveEnvironment = this.isOpen;
308325
this.selectedTemplateInformation.environmentName = this.environmentName;
309326
countlyPopulator.generateUsers(self.selectedRunCount, this.selectedTemplateInformation);

plugins/populator/frontend/public/localization/populator.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,6 @@ populator.warning-generate-users = Populator can't fully support generating data
211211
populator.warning-generate-users-header = There is a high chance of spike
212212
populator-template.add-step-tooltip = Events or view properties are required to add steps to sequences.
213213
populator.error-salt = You should remove the salt for checksum value from application settings to continue using the populator
214+
populator.include-features = Include Features
215+
populator.select-features = Select features
216+
populator.include-features-tooltip = The selected features will be populated with sample data

plugins/populator/frontend/public/templates/populator.html

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@
4747
<el-input class="populator-wrapper__save-field" v-model="environmentName" :placeholder="i18n('populator.save-as-environment')" test-id="populate-with-template-save-environment-input"></el-input>
4848
</div>
4949
</cly-sub-section>
50+
<cly-sub-section class="bu-columns bu-is-vcentered">
51+
<div class="bu-column bu-is-2 populator-input-area">
52+
<span class="text-medium font-weight-bold text-uppercase" data-test-id="populate-with-template-include-features-label">{{ i18n('populator.include-features') }}</span>
53+
<cly-tooltip-icon :tooltip="i18n('populator.include-features-tooltip')" data-test-id="populate-with-template-include-features-tooltip"></cly-tooltip-icon>
54+
</div>
55+
<div class="bu-column main-page-container">
56+
<cly-select-x class="main-page-inputs" v-model="selectedFeatures" :options="availableFeatures" :placeholder="i18n('populator.select-features')" mode="multi-check" test-id="populate-with-template-features-select"></cly-select-x> </div>
57+
</cly-sub-section>
5058
<cly-sub-section class="bu-level-right">
5159
<el-button type="success" :disabled="!selectedTemplate.length || (isOpen && !environmentName.length)" @click="openDialog()" data-test-id="populate-with-template-generate-demo-data-button">{{ i18n('populator.start') }}</el-button>
5260
</cly-sub-section>

0 commit comments

Comments
 (0)