Skip to content

Commit 422054d

Browse files
Merge pull request #1091 from wanderwallet/refactor/remove-balance-event
refactor: remove balance alarm and related analytics functionality
2 parents 55aad58 + 8f5b0a1 commit 422054d

File tree

4 files changed

+0
-73
lines changed

4 files changed

+0
-73
lines changed

src/api/background/background-setup.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import { handleActiveAddressChange } from "~api/background/handlers/storage/acti
99
import { handleWalletsChange } from "~api/background/handlers/storage/wallet-change/wallet-change.handler";
1010
import { handleAppsChange } from "~api/background/handlers/storage/apps-change/app-change.handler";
1111
import { handleAppConfigChange } from "~api/background/handlers/storage/app-config-change/app-config-change.handler";
12-
import { handleTrackBalanceAlarm } from "~api/background/handlers/alarms/track-balance/track-balance-alarm.handler";
1312
import { handleGetPrinters } from "~api/background/handlers/browser/printer/get-printers/get-printers.handler";
1413
import { handleGetCapabilities } from "~api/background/handlers/browser/printer/get-capabilities/get-capabilities.handler";
1514
import { handlePrint } from "~api/background/handlers/browser/printer/print/print.handler";
@@ -99,7 +98,6 @@ export function setupBackgroundService() {
9998
// ALARMS:
10099
browser.alarms.onAlarm.addListener(handleNotificationsAlarm);
101100
browser.alarms.onAlarm.addListener(handleSubscriptionsAlarm);
102-
browser.alarms.onAlarm.addListener(handleTrackBalanceAlarm);
103101
browser.alarms.onAlarm.addListener(handleGatewayUpdateAlarm);
104102
browser.alarms.onAlarm.addListener(handleSyncLabelsAlarm);
105103
browser.alarms.onAlarm.addListener(handleKeyRemovalAlarm);

src/api/background/handlers/alarms/track-balance/track-balance-alarm.handler.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

src/api/background/handlers/browser/install/install.handler.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { scheduleGatewayUpdate } from "~gateways/cache";
22
import browser, { type Runtime } from "webextension-polyfill";
33
import { loadTokens } from "~tokens/token";
4-
import { initializeARBalanceMonitor } from "~utils/analytics";
54
import { handleGatewayUpdateAlarm } from "~api/background/handlers/alarms/gateway-update/gateway-update-alarm.handler";
65
import { openOrSelectWelcomePage } from "~wallets";
76
import { ExtensionStorage } from "~utils/storage";
@@ -42,9 +41,6 @@ export async function handleInstall(details: Runtime.OnInstalledDetailsType) {
4241
schedulePendingTransactionsCleanupAlarm();
4342
}
4443

45-
// init monthly AR
46-
await initializeARBalanceMonitor();
47-
4844
// initialize alarm to fetch notifications
4945
browser.alarms.create("notifications", { periodInMinutes: 10 });
5046

src/utils/analytics.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export enum EventType {
2222
CONNECTED_APP = "CONNECTED_APP",
2323
LOGIN = "LOGIN",
2424
ONBOARDED = "ONBOARDED",
25-
BALANCE = "BALANCE",
2625
SIGNED = "SIGNED",
2726
TRANSACTION_INCOMPLETE = "TRANSACTION_INCOMPLETE",
2827
FALLBACK = "FALLBACK",
@@ -228,32 +227,6 @@ export const trackEvent = async (eventName: EventType, properties: any) => {
228227
}
229228
};
230229

231-
/**
232-
* Initializes the AR balance event tracker.
233-
* This function sets up a monthly alarm to track the total balance.
234-
* It schedules the first alarm to the start of the next month and
235-
* stores this schedule time in the extension storage.
236-
*/
237-
238-
export const initializeARBalanceMonitor = async () => {
239-
const timer = setToStartOfNextMonth(new Date());
240-
browser.alarms.create("track-balance", {
241-
when: timer.getTime(),
242-
});
243-
};
244-
245-
/**
246-
* Sets the given date to the start of the next month in UTC
247-
* The time is set to beginning of the month (00:00:00.000).
248-
* @param {Date} currentDate
249-
* @returns {Date} Date to trigger alarm
250-
*/
251-
252-
export const setToStartOfNextMonth = (currentDate: Date): Date => {
253-
const newDate = new Date(Date.UTC(currentDate.getUTCFullYear(), currentDate.getUTCMonth() + 1, 1, 0, 0, 0, 0));
254-
return newDate;
255-
};
256-
257230
export interface WalletBitsCheck {
258231
checked: boolean;
259232
mismatch: boolean;

0 commit comments

Comments
 (0)