Skip to content

Commit cadf1b8

Browse files
authored
Merge pull request #5736 from Countly/SER-1897
[SER-1897] [populator] add option to select features to populate
2 parents 3d9acb9 + bb5a6a5 commit cadf1b8

File tree

4 files changed

+93
-45
lines changed

4 files changed

+93
-45
lines changed

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

Lines changed: 65 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,32 @@
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+
/**
1879+
* Create 3 survey widgets
1880+
* @param {function} callback - callback method
1881+
*/
1882+
function generateSurveryWidgets(callback) {
1883+
if (countlyGlobal.plugins.indexOf("surveys") !== -1 && countlyAuth.validateCreate("surveys") && _featuresToPopulate.includes("surveys")) {
1884+
generateSurveyWidgets1(function() {
1885+
generateSurveyWidgets2(function() {
1886+
generateSurveyWidgets3(callback);
18771887
});
1878-
}
1879-
else {
1880-
done();
1881-
}
1882-
});
1883-
}
1884-
else {
1885-
done();
1888+
});
1889+
}
1890+
else {
1891+
callback();
1892+
}
18861893
}
1894+
1895+
generateRatingWidgets(function() {
1896+
generateNPSWidgets(function() {
1897+
setTimeout(function() {
1898+
generateSurveryWidgets(done);
1899+
}, 100);
1900+
});
1901+
});
1902+
18871903
}
18881904

18891905

@@ -1958,7 +1974,7 @@
19581974
* @param {callback} callback - callback method
19591975
**/
19601976
function generateCampaigns(callback) {
1961-
if (!CountlyHelpers.isPluginEnabled("attribution") || typeof countlyAttribution === "undefined") {
1977+
if (!CountlyHelpers.isPluginEnabled("attribution") || typeof countlyAttribution === "undefined" || !_featuresToPopulate.includes("attribution")) {
19621978
callback();
19631979
return;
19641980
}
@@ -2262,7 +2278,7 @@
22622278
generateCampaigns(async function() {
22632279
await createUsers();
22642280

2265-
if (countlyGlobal.plugins.indexOf("ab-testing") !== -1 && countlyAuth.validateCreate("ab-testing")) {
2281+
if (countlyGlobal.plugins.indexOf("ab-testing") !== -1 && countlyAuth.validateCreate("ab-testing") && _featuresToPopulate.includes("ab-testing")) {
22662282
abExampleName = "Pricing" + abExampleCount++;
22672283
generateAbTests(function() {
22682284
if (users.length) {
@@ -2347,7 +2363,7 @@
23472363

23482364
var template = this.currentTemplate || {};
23492365

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

@@ -2470,7 +2486,7 @@
24702486
});
24712487
}
24722488

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

24752491
let pages = countlyGlobal.apps[countlyCommon.ACTIVE_APP_ID].type === "mobile" ? viewSegments.name : getPageTemplates(countlyPopulator.getSelectedTemplate().substr(7).toLowerCase());
24762492
let page1 = pages[getRandomInt(0, pages.length - 1)];
@@ -2502,7 +2518,7 @@
25022518
}
25032519
}
25042520

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

25082524

@@ -2556,7 +2572,7 @@
25562572
});
25572573
}
25582574

2559-
if (CountlyHelpers.isPluginEnabled("push")) {
2575+
if (CountlyHelpers.isPluginEnabled("push") && _featuresToPopulate.includes("push")) {
25602576
createMessage(messages[0]);
25612577
createMessage(messages[1]);
25622578
createMessage(messages[2]);
@@ -2575,6 +2591,10 @@
25752591
_templateType = value;
25762592
};
25772593

2594+
countlyPopulator.setSelectedFeatures = function(value) {
2595+
_featuresToPopulate = value;
2596+
};
2597+
25782598
countlyPopulator.getTemplate = function(templateId, callback) {
25792599
var foundDefault = defaultTemplates.find(function(template) {
25802600
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)