Skip to content
Merged
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
110 changes: 65 additions & 45 deletions plugins/populator/frontend/public/javascripts/countly.models.js
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,7 @@
var abExampleCount = 1;
var abExampleName = "Pricing";
var _templateType = '';
var _featuresToPopulate = [];
var runCount = 0;
var completedRequestCount = 0;
var crashSymbolVersions = {
Expand Down Expand Up @@ -1700,36 +1701,46 @@
* @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();
}
}

/**
* Create NPS widgets
* @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();
}
}

/**
Expand Down Expand Up @@ -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);
});
});

}


Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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)];
Expand Down Expand Up @@ -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);


Expand Down Expand Up @@ -2556,7 +2572,7 @@
});
}

if (CountlyHelpers.isPluginEnabled("push")) {
if (CountlyHelpers.isPluginEnabled("push") && _featuresToPopulate.includes("push")) {
createMessage(messages[0]);
createMessage(messages[1]);
createMessage(messages[2]);
Expand All @@ -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;
Expand Down
17 changes: 17 additions & 0 deletions plugins/populator/frontend/public/javascripts/countly.views.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
currentTab: "data-populator",
dialog: {type: '', showDialog: false, saveButtonLabel: '', cancelButtonLabel: '', title: '', text: '', params: {}},
selectedTemplate: '',
selectedFeatures: [],
generateDataModal: {showDialog: false},
percentage: 0,
templates: [],
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 8 additions & 0 deletions plugins/populator/frontend/public/templates/populator.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@
<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>
</div>
</cly-sub-section>
<cly-sub-section class="bu-columns bu-is-vcentered">
<div class="bu-column bu-is-2 populator-input-area">
<span class="text-medium font-weight-bold text-uppercase" data-test-id="populate-with-template-include-features-label">{{ i18n('populator.include-features') }}</span>
<cly-tooltip-icon :tooltip="i18n('populator.include-features-tooltip')" data-test-id="populate-with-template-include-features-tooltip"></cly-tooltip-icon>
</div>
<div class="bu-column main-page-container">
<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>
</cly-sub-section>
<cly-sub-section class="bu-level-right">
<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>
</cly-sub-section>
Expand Down
Loading