From abfb1f0165688c9f46a1e66963652917a668eaa7 Mon Sep 17 00:00:00 2001 From: tyleroooo Date: Thu, 12 Dec 2024 18:35:08 -0500 Subject: [PATCH] fix: track parse errors (#1366) --- src/constants/analytics.ts | 1 + src/lib/abacus/stateNotification.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/constants/analytics.ts b/src/constants/analytics.ts index d3c4c6cd9..8428e9e99 100644 --- a/src/constants/analytics.ts +++ b/src/constants/analytics.ts @@ -336,6 +336,7 @@ export const AnalyticsEvents = unionize( assetSymbol?: string; assetName?: string; }>(), + WebsocketParseError: ofType<{ message: string }>(), // vaults ClickViewVaultFromPositionCard: ofType<{}>(), diff --git a/src/lib/abacus/stateNotification.ts b/src/lib/abacus/stateNotification.ts index 56612c335..d35ed69f0 100644 --- a/src/lib/abacus/stateNotification.ts +++ b/src/lib/abacus/stateNotification.ts @@ -16,6 +16,7 @@ import type { } from '@/constants/abacus'; import { Changes } from '@/constants/abacus'; import { NUM_PARENT_SUBACCOUNTS } from '@/constants/account'; +import { AnalyticsEvents } from '@/constants/analytics'; import { timeUnits } from '@/constants/time'; import { type RootStore } from '@/state/_store'; @@ -44,6 +45,7 @@ import { setLatestOrder, updateFilledOrders, updateOrders } from '@/state/localO import { updateNotifications } from '@/state/notifications'; import { setHistoricalFundings, setLiveTrades, setMarkets, setOrderbook } from '@/state/perpetuals'; +import { track } from '../analytics/analytics'; import { isTruthy } from '../isTruthy'; class AbacusStateNotifier implements AbacusStateNotificationProtocol { @@ -267,8 +269,11 @@ class AbacusStateNotifier implements AbacusStateNotificationProtocol { } errorsEmitted(errors: ParsingErrors) { + const arr = errors.toArray(); + + track(AnalyticsEvents.WebsocketParseError({ message: arr.map((a) => a.message).join(', ') })); // eslint-disable-next-line no-console - console.error('parse errors', errors.toArray()); + console.error('parse errors', arr); } apiStateChanged(apiState: AbacusApiState) {