From 77b5210e57d44129faeae2e507003f770839a8ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C4=B1nar=20Gen=C3=A7?= Date: Fri, 7 Feb 2025 13:14:20 +0300 Subject: [PATCH] [MYC-1131] Add UTM tag to Flex link from Countly Lite banner --- .../countly/vue/components/sidebar.js | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/frontend/express/public/javascripts/countly/vue/components/sidebar.js b/frontend/express/public/javascripts/countly/vue/components/sidebar.js index efd541993b3..01f51276600 100644 --- a/frontend/express/public/javascripts/countly/vue/components/sidebar.js +++ b/frontend/express/public/javascripts/countly/vue/components/sidebar.js @@ -898,9 +898,56 @@ return menu; }); }, - handleButtonClick: function() { + getFlexBannerUrl: function() { + let defaultFlexUrl = 'https://flex.countly.com?utm_source=countly_lite_banner'; //fallback + + return new Promise((resolve) => { + try { + if (!window.Countly) { + CountlyHelpers.notify({ + title: "Error", + message: "Countly SDK is not available", + type: "error" + }); + return resolve(defaultFlexUrl); + } + + let CountlySDK; + if (window.Countly.present_feedback_widget) { + CountlySDK = window.Countly; + } + else { + CountlySDK = window.Countly.init({ + app_key: countlyGlobal.frontend_app, + url: countlyGlobal.frontend_server, + device_id: window.Countly.device_id || window.location.hostname, + remote_config: true + }); + } + + if (CountlySDK.fetch_remote_config) { + CountlySDK.fetch_remote_config(function(err, conf) { + if (err) { + resolve(defaultFlexUrl); + } + else { + resolve(conf.flex_banner_url || defaultFlexUrl); + } + }); + } + else { + resolve(defaultFlexUrl); + } + } + catch { + resolve(defaultFlexUrl); + } + }); + }, + handleButtonClick: async function() { + const flexRedirectUrl = await this.getFlexBannerUrl(); CountlyHelpers.goTo({ - url: "https://flex.countly.com", + url: flexRedirectUrl, isExternalLink: true }); }