Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(web): replace live-update disconnect toast with telemetry (#8522)

Wolf Mermelstein55c15e146931
diff --git a/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.test.ts b/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.test.ts
index 70c618a061..3ee56c36bb 100644
--- a/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.test.ts
+++ b/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.test.ts
@@ -1,9 +1,9 @@
import { err, ok } from 'neverthrow';
import { afterEach, describe, expect, it, vi } from 'vitest';
-const toastFailure = vi.hoisted(() => vi.fn());
-vi.mock('@core/component/Toast/Toast', () => ({
- toast: { failure: toastFailure },
+const telemetryError = vi.hoisted(() => vi.fn());
+vi.mock('@macro-inc/observability', () => ({
+ Telemetry: { error: telemetryError },
}));
const nativeStatus = vi.hoisted(() => ({
@@ -287,7 +287,7 @@ describe('GraphQL Soup subscription lifecycle', () => {
});
it('signals a terminal subscription failure once across both subscriptions', () => {
- toastFailure.mockClear();
+ telemetryError.mockClear();
const receive: Array<(result: { error?: unknown }) => void> = [];
const client = {
subscription: vi.fn(() => ({
@@ -306,18 +306,19 @@ describe('GraphQL Soup subscription lifecycle', () => {
} as never
);
- receive[0]?.({ error: new Error('retry budget exhausted') });
+ const firstError = new Error('retry budget exhausted');
+ receive[0]?.({ error: firstError });
receive[1]?.({ error: new Error('duplicate terminal result') });
- expect(toastFailure).toHaveBeenCalledOnce();
- expect(toastFailure).toHaveBeenCalledWith('Live updates disconnected', {
- subtext: 'Refresh to reconnect.',
+ expect(telemetryError).toHaveBeenCalledOnce();
+ expect(telemetryError).toHaveBeenCalledWith(firstError, {
+ 'error.source': 'graphql-soup-websocket',
});
lifecycle.dispose();
});
it('reattaches an ended subscription set on the next foreground or online signal', () => {
- toastFailure.mockClear();
+ telemetryError.mockClear();
const receive: Array<
(result: { error?: unknown; hasNext?: boolean }) => void
> = [];
@@ -358,7 +359,7 @@ describe('GraphQL Soup subscription lifecycle', () => {
setVisibility('visible');
dispatchEvent(new Event('online'));
expect(client.subscription).toHaveBeenCalledTimes(4);
- expect(toastFailure).toHaveBeenCalledOnce();
+ expect(telemetryError).toHaveBeenCalledOnce();
receive[2]?.({ error: new Error('again'), hasNext: false });
lifecycle.dispose();
@@ -367,7 +368,7 @@ describe('GraphQL Soup subscription lifecycle', () => {
});
it('signals a new outage after a successful reconnection', () => {
- toastFailure.mockClear();
+ telemetryError.mockClear();
const receive: Array<(result: { error?: unknown }) => void> = [];
const client = {
subscription: vi.fn(() => ({
@@ -384,7 +385,7 @@ describe('GraphQL Soup subscription lifecycle', () => {
lifecycle.connected();
receive[0]?.({ error: new Error('second outage') });
- expect(toastFailure).toHaveBeenCalledTimes(2);
+ expect(telemetryError).toHaveBeenCalledTimes(2);
lifecycle.dispose();
});
});
diff --git a/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.ts b/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.ts
index bd8b2334b5..fcd0dfd828 100644
--- a/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.ts
+++ b/apps/web/src/lib/service-clients/service-storage/graphql-soup-websocket.ts
@@ -1,8 +1,8 @@
-import { toast } from '@core/component/Toast/Toast';
import { subscribeNativeNetworkStatus } from '@core/mobile/native-network-status';
import { fireAndForget } from '@core/util/fireAndForget';
import { normalizedCacheResultMetadata } from '@graphql-cache/exchange/normalized-cache-exchange';
import type { CacheHost } from '@graphql-cache/host/types';
+import { Telemetry } from '@macro-inc/observability';
import type { Client, OperationResult } from '@urql/core';
import type { Result } from 'neverthrow';
import {
@@ -309,8 +309,8 @@ export function createGraphqlSoupSubscriptionsLifecycle(
console.warn(errorMessage, result.error);
if (!signaledFailure) {
signaledFailure = true;
- toast.failure('Live updates disconnected', {
- subtext: 'Refresh to reconnect.',
+ Telemetry.error(result.error, {
+ 'error.source': 'graphql-soup-websocket',
});
}
}