Skip to content

Commit 67d5ba8

Browse files
committed
chore: dynamic survey urls
1 parent 9367368 commit 67d5ba8

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

src/extensionsIntegrated/Phoenix/guided-tour.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ define(function (require, exports, module) {
3535
NOTIFICATION_BACKOFF = 10000,
3636
GUIDED_TOUR_LOCAL_STORAGE_KEY = "guidedTourActions";
3737

38+
const surveyLinksURL = "https://updates.phcode.io/surveys.json";
39+
3840
// All popup notifications will show immediately on boot, we don't want to interrupt user amidst his work
3941
// by showing it at a later point in time.
4042
const BOOT_DIALOG_DELAY = 2000,
@@ -213,12 +215,12 @@ define(function (require, exports, module) {
213215
}
214216
}
215217

216-
function _showGeneralSurvey() {
218+
function _showGeneralSurvey(surveyURL) {
217219
setTimeout(()=>{
218220
let surveyVersion = 6; // increment this if you want to show this again
219221
var templateVars = {
220222
Strings: Strings,
221-
surveyURL: "https://s.surveyplanet.com/g837j5k9"
223+
surveyURL
222224
};
223225
if(userAlreadyDidAction.generalSurveyShownVersion !== surveyVersion){
224226
Metrics.countEvent(Metrics.EVENT_TYPE.USER, "survey", "generalShown", 1);
@@ -247,7 +249,7 @@ define(function (require, exports, module) {
247249
return totalUsageDays >= 3 || (totalUsageMinutes/60) >= 8;
248250
}
249251

250-
function _showPowerUserSurvey() {
252+
function _showPowerUserSurvey(surveyURL) {
251253
if(_isPowerUser()) {
252254
Metrics.countEvent(Metrics.EVENT_TYPE.USER, "power", "user", 1);
253255
let lastShownDate = userAlreadyDidAction.lastShownPowerSurveyDate;
@@ -261,7 +263,7 @@ define(function (require, exports, module) {
261263
Metrics.countEvent(Metrics.EVENT_TYPE.USER, "survey", "powerShown", 1);
262264
const templateVars = {
263265
Strings: Strings,
264-
surveyURL: "https://s.surveyplanet.com/2dgk0hbn"
266+
surveyURL
265267
};
266268
Dialogs.showModalDialogUsingTemplate(Mustache.render(SurveyTemplate, templateVars));
267269
userAlreadyDidAction.lastShownPowerSurveyDate = Date.now();
@@ -270,6 +272,21 @@ define(function (require, exports, module) {
270272
}
271273
}
272274

275+
async function _showSurveys() {
276+
try {
277+
if(!navigator.onLine){
278+
return;
279+
}
280+
let surveyJSON = await fetch(surveyLinksURL);
281+
surveyJSON = await surveyJSON.json();
282+
surveyJSON.newUser && _showGeneralSurvey(surveyJSON.newUser);
283+
surveyJSON.powerUser && _showPowerUserSurvey(surveyJSON.powerUser);
284+
} catch (e) {
285+
console.error("Error fetching survey link", surveyLinksURL);
286+
Metrics.countEvent(Metrics.EVENT_TYPE.USER, "survey", "fetchError", 1);
287+
}
288+
}
289+
273290
let tourStarted = false;
274291
exports.startTourIfNeeded = function () {
275292
if(tourStarted) {
@@ -279,7 +296,6 @@ define(function (require, exports, module) {
279296
_showNewProjectNotification();
280297
_showBeautifyNotification();
281298
_showRequestStarsPopup();
282-
_showGeneralSurvey();
283-
_showPowerUserSurvey();
299+
_showSurveys();
284300
};
285301
});

src/nls/root/strings.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,7 @@ define({
11301130
"BEAUTIFY_CODE_NOTIFICATION": "Click here or press <b>`{0}`</b> to Beautify code. </br> <img src=\"styles/images/beautify.gif\"> <br/> <a href='#' style='float:right;'>ok</a>",
11311131
"DEFAULT_PROJECT_NOTIFICATION": "Click here to open the <br/><b>default project</b> in phoenix. </br> <a href='#' style='float:right;'>ok</a>",
11321132
"DIRECTORY_REPLACE_MESSAGE": "The selected folder <span class='dialog-filename'>{0}</span> is not empty. Are you sure you want to replace the folder contents with the project?",
1133-
"DEFAULT_PROJECT_HTML_CLICK_HERE": "Click here to open this HTML file in the editor. The cursor will be pointed to code corresponding to this &ltspan&gt",
1133+
"DEFAULT_PROJECT_HTML_CLICK_HERE": "Click here locate this this &ltspan&gt in the HTML file",
11341134
"BUILD_WEBSITE_SECTION": "Build Website",
11351135
"LEARN_SECTION": "Learn With Examples",
11361136
"CREATE_EXTENSION_SECTION": "Create {APP_NAME} Extensions and Themes",

0 commit comments

Comments
 (0)