Skip to content

Commit

Permalink
fix: track parse errors (#1366)
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleroooo authored Dec 12, 2024
1 parent ad70e35 commit abfb1f0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/constants/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ export const AnalyticsEvents = unionize(
assetSymbol?: string;
assetName?: string;
}>(),
WebsocketParseError: ofType<{ message: string }>(),

// vaults
ClickViewVaultFromPositionCard: ofType<{}>(),
Expand Down
7 changes: 6 additions & 1 deletion src/lib/abacus/stateNotification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit abfb1f0

Please sign in to comment.