From a7b5f45e02f54129e487ea57308d27930baaff7f Mon Sep 17 00:00:00 2001 From: Praba Ponnambalam Date: Fri, 13 Sep 2024 09:56:41 +0530 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9C=A8=20add=20status=20label?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit status: Normal | Throtted | Any other status of API --- package.json | 2 +- src/popup/popup.css | 35 ++++++++++++++++++++++++++++++++--- src/popup/popup.html | 5 ++++- src/popup/popup.js | 35 +++++++++++++++++++++++++++++++++-- 4 files changed, 70 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 240da44..18fd319 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "slt-bb-usage-checker", "private": true, - "version": "1.1.4", + "version": "1.2.0", "type": "module", "scripts": { "dev": "vite", diff --git a/src/popup/popup.css b/src/popup/popup.css index bc10552..ccf66da 100644 --- a/src/popup/popup.css +++ b/src/popup/popup.css @@ -55,11 +55,40 @@ h1 sup { display: none; } +#account-info { + display: flex; + justify-content: center; + align-items: center; + gap: 5px; + margin: 15px 0; +} + #account-id { font-size: 15px; - color: rgba(128, 128, 128, 0.626); - text-align: center; - margin: 15px 0; + color: gray; +} + +.status-pill { + padding: 1px 10px; + border-radius: 10px; + font-size: 10px; + font-weight: 500; + text-transform: uppercase; +} + +.status-normal { + background-color: #e8f5e9; + color: #1b5e20; +} + +.status-throttled { + background-color: #fff3e0; + color: #e65100; +} + +.status-other { + background-color: #e0e0e0; + color: #424242; } main { diff --git a/src/popup/popup.html b/src/popup/popup.html index ece3acb..31bf169 100644 --- a/src/popup/popup.html +++ b/src/popup/popup.html @@ -15,7 +15,10 @@

-
+
+ + +
diff --git a/src/popup/popup.js b/src/popup/popup.js index a4ef4a4..86b74e2 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -325,7 +325,7 @@ const displayUsageData = (data, subscriberId) => { return; } - updateAccountInfo(subscriberId); + updateAccountInfo(subscriberId, data.speed_status); createUsageDataGroups(data.usage_data); updateLastUpdatedTime(data.reported_time); @@ -344,13 +344,44 @@ const formatAccountId = (accountId) => { return accountId; }; -const updateAccountInfo = (accountId) => { +const updateAccountInfo = (accountId, speedStatus) => { const accountIdElement = document.getElementById('account-id'); + const speedStatusElement = document.getElementById('speed-status'); + if (accountIdElement) { const formattedId = formatAccountId(accountId); accountIdElement.textContent = `Account: ${formattedId}`; console.log('Formatted Account ID:', formattedId); } + + if (speedStatusElement && speedStatus) { + const formattedStatus = formatSpeedStatus(speedStatus); + speedStatusElement.textContent = formattedStatus; + speedStatusElement.className = `status-pill ${getStatusClass(speedStatus)}`; + console.log('Speed Status:', formattedStatus); + } +}; + +const formatSpeedStatus = (status) => { + status = status.toLowerCase(); + if (status === 'normal') { + return 'Speed is Normal'; + } else if (status === 'throttle' || status === 'throttled') { + return 'Speed is Throttled'; + } else { + return status.charAt(0).toUpperCase() + status.slice(1); + } +}; + +const getStatusClass = (status) => { + status = status.toLowerCase(); + if (status === 'normal') { + return 'status-normal'; + } else if (status === 'throttle' || status === 'throttled') { + return 'status-throttled'; + } else { + return 'status-other'; + } }; const createUsageDataGroups = (usageData) => { From 627e0251185237655f3b538d53c465008678796b Mon Sep 17 00:00:00 2001 From: Praba Ponnambalam Date: Fri, 13 Sep 2024 10:04:56 +0530 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=93=88=20add=20event=20speed=5Fstatus?= =?UTF-8?q?=5Fchecked?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit params: speed_status & app_version --- src/popup/popup.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/popup/popup.js b/src/popup/popup.js index 86b74e2..c88c8e4 100644 --- a/src/popup/popup.js +++ b/src/popup/popup.js @@ -359,6 +359,15 @@ const updateAccountInfo = (accountId, speedStatus) => { speedStatusElement.textContent = formattedStatus; speedStatusElement.className = `status-pill ${getStatusClass(speedStatus)}`; console.log('Speed Status:', formattedStatus); + + // Send GA4 event for speed status + sendEvent( + 'speed_status_checked', + { + speed_status: speedStatus.toLowerCase(), + }, + __APP_VERSION__ + ); } };