Skip to content

Commit 24cc79b

Browse files
authored
Merge pull request #5981 from Countly/myc-1131
[MYC-1131] Add UTM tag to Flex link from Countly Lite banner
2 parents 3b6b43d + 77b5210 commit 24cc79b

File tree

1 file changed

+49
-2
lines changed
  • frontend/express/public/javascripts/countly/vue/components

1 file changed

+49
-2
lines changed

frontend/express/public/javascripts/countly/vue/components/sidebar.js

+49-2
Original file line numberDiff line numberDiff line change
@@ -898,9 +898,56 @@
898898
return menu;
899899
});
900900
},
901-
handleButtonClick: function() {
901+
getFlexBannerUrl: function() {
902+
let defaultFlexUrl = 'https://flex.countly.com?utm_source=countly_lite_banner'; //fallback
903+
904+
return new Promise((resolve) => {
905+
try {
906+
if (!window.Countly) {
907+
CountlyHelpers.notify({
908+
title: "Error",
909+
message: "Countly SDK is not available",
910+
type: "error"
911+
});
912+
return resolve(defaultFlexUrl);
913+
}
914+
915+
let CountlySDK;
916+
if (window.Countly.present_feedback_widget) {
917+
CountlySDK = window.Countly;
918+
}
919+
else {
920+
CountlySDK = window.Countly.init({
921+
app_key: countlyGlobal.frontend_app,
922+
url: countlyGlobal.frontend_server,
923+
device_id: window.Countly.device_id || window.location.hostname,
924+
remote_config: true
925+
});
926+
}
927+
928+
if (CountlySDK.fetch_remote_config) {
929+
CountlySDK.fetch_remote_config(function(err, conf) {
930+
if (err) {
931+
resolve(defaultFlexUrl);
932+
}
933+
else {
934+
resolve(conf.flex_banner_url || defaultFlexUrl);
935+
}
936+
});
937+
}
938+
else {
939+
resolve(defaultFlexUrl);
940+
}
941+
}
942+
catch {
943+
resolve(defaultFlexUrl);
944+
}
945+
});
946+
},
947+
handleButtonClick: async function() {
948+
const flexRedirectUrl = await this.getFlexBannerUrl();
902949
CountlyHelpers.goTo({
903-
url: "https://flex.countly.com",
950+
url: flexRedirectUrl,
904951
isExternalLink: true
905952
});
906953
}

0 commit comments

Comments
 (0)