|
1336 | 1336 | var abExampleCount = 1; |
1337 | 1337 | var abExampleName = "Pricing"; |
1338 | 1338 | var _templateType = ''; |
| 1339 | + var _featuresToPopulate = []; |
1339 | 1340 | var runCount = 0; |
1340 | 1341 | var completedRequestCount = 0; |
1341 | 1342 | var crashSymbolVersions = { |
|
1700 | 1701 | * @param {function} callback - callback method |
1701 | 1702 | */ |
1702 | 1703 | 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 | + }); |
1719 | 1722 | }); |
1720 | 1723 | }); |
1721 | 1724 | }); |
1722 | | - }); |
| 1725 | + } |
| 1726 | + else { |
| 1727 | + callback(); |
| 1728 | + } |
1723 | 1729 | } |
1724 | 1730 |
|
1725 | 1731 | /** |
1726 | 1732 | * Create NPS widgets |
1727 | 1733 | * @param {function} callback - callback method |
1728 | 1734 | */ |
1729 | 1735 | 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 | + } |
1733 | 1744 | } |
1734 | 1745 |
|
1735 | 1746 | /** |
|
1863 | 1874 | }); |
1864 | 1875 | }); |
1865 | 1876 | } |
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); |
1877 | 1883 | }); |
1878 | | - } |
1879 | | - else { |
1880 | | - done(); |
1881 | | - } |
1882 | | - }); |
1883 | | - } |
1884 | | - else { |
1885 | | - done(); |
| 1884 | + }); |
| 1885 | + } |
| 1886 | + else { |
| 1887 | + callback(); |
| 1888 | + } |
1886 | 1889 | } |
| 1890 | + |
| 1891 | + generateRatingWidgets(function() { |
| 1892 | + generateNPSWidgets(function() { |
| 1893 | + setTimeout(function() { |
| 1894 | + generateSurveryWidgets(done); |
| 1895 | + }, 100); |
| 1896 | + }); |
| 1897 | + }); |
| 1898 | + |
1887 | 1899 | } |
1888 | 1900 |
|
1889 | 1901 |
|
|
1958 | 1970 | * @param {callback} callback - callback method |
1959 | 1971 | **/ |
1960 | 1972 | function generateCampaigns(callback) { |
1961 | | - if (!CountlyHelpers.isPluginEnabled("attribution") || typeof countlyAttribution === "undefined") { |
| 1973 | + if (!CountlyHelpers.isPluginEnabled("attribution") || typeof countlyAttribution === "undefined" || !_featuresToPopulate.includes("attribution")) { |
1962 | 1974 | callback(); |
1963 | 1975 | return; |
1964 | 1976 | } |
|
2262 | 2274 | generateCampaigns(async function() { |
2263 | 2275 | await createUsers(); |
2264 | 2276 |
|
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")) { |
2266 | 2278 | abExampleName = "Pricing" + abExampleCount++; |
2267 | 2279 | generateAbTests(function() { |
2268 | 2280 | if (users.length) { |
|
2347 | 2359 |
|
2348 | 2360 | var template = this.currentTemplate || {}; |
2349 | 2361 |
|
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")) { |
2351 | 2363 | if (template.events && template.events.length) { |
2352 | 2364 | var firstEventKey = template.events[getRandomInt(0, template.events.length - 1)].key; |
2353 | 2365 |
|
|
2470 | 2482 | }); |
2471 | 2483 | } |
2472 | 2484 |
|
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")) { |
2474 | 2486 |
|
2475 | 2487 | let pages = countlyGlobal.apps[countlyCommon.ACTIVE_APP_ID].type === "mobile" ? viewSegments.name : getPageTemplates(countlyPopulator.getSelectedTemplate().substr(7).toLowerCase()); |
2476 | 2488 | let page1 = pages[getRandomInt(0, pages.length - 1)]; |
|
2502 | 2514 | } |
2503 | 2515 | } |
2504 | 2516 |
|
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")) { |
2506 | 2518 | const crashPlatforms = Object.keys(crashSymbolVersions).filter(key => crashSymbolVersions[key].length); |
2507 | 2519 |
|
2508 | 2520 |
|
|
2556 | 2568 | }); |
2557 | 2569 | } |
2558 | 2570 |
|
2559 | | - if (CountlyHelpers.isPluginEnabled("push")) { |
| 2571 | + if (CountlyHelpers.isPluginEnabled("push") && _featuresToPopulate.includes("push")) { |
2560 | 2572 | createMessage(messages[0]); |
2561 | 2573 | createMessage(messages[1]); |
2562 | 2574 | createMessage(messages[2]); |
|
2575 | 2587 | _templateType = value; |
2576 | 2588 | }; |
2577 | 2589 |
|
| 2590 | + countlyPopulator.setSelectedFeatures = function(value) { |
| 2591 | + _featuresToPopulate = value; |
| 2592 | + }; |
| 2593 | + |
2578 | 2594 | countlyPopulator.getTemplate = function(templateId, callback) { |
2579 | 2595 | var foundDefault = defaultTemplates.find(function(template) { |
2580 | 2596 | return template._id === templateId; |
|
0 commit comments