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): handle floating promises in lib/core (#8257)

teo60bde3b1ccac
diff --git a/apps/web/src/lib/core/comments/discussion/DiscussionInput.tsx b/apps/web/src/lib/core/comments/discussion/DiscussionInput.tsx
index 13e79a0770..e1827259f7 100644
--- a/apps/web/src/lib/core/comments/discussion/DiscussionInput.tsx
+++ b/apps/web/src/lib/core/comments/discussion/DiscussionInput.tsx
@@ -25,6 +25,7 @@ import { toast } from '@core/component/Toast/Toast';
import { isMobile } from '@core/mobile/isMobile';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import type { IUser } from '@core/user/types';
+import { Telemetry } from '@macro-inc/observability';
import PaperclipIcon from '@phosphor/paperclip.svg';
import { isIOS } from '@solid-primitives/platform';
import { CollapsedInput, ComposerSurface } from '@ui';
@@ -115,6 +116,9 @@ export function DiscussionInput(props: DiscussionInputProps) {
const [isSending, setIsSending] = createSignal(false);
let isInternalRefocus = false;
+ const reportCallbackError = (error: unknown) =>
+ Telemetry.error(error, { surface: 'discussion-input' });
+
const inputView = () => ({
...props.input,
value: value(),
@@ -149,7 +153,9 @@ export function DiscussionInput(props: DiscussionInputProps) {
},
onChange: (markdown) => {
setValue(markdown);
- props.onChange?.(createSnapshot());
+ Promise.resolve(props.onChange?.(createSnapshot())).catch(
+ reportCallbackError
+ );
},
onEnter: () => {
if (isMobile()) return false;
@@ -193,11 +199,15 @@ export function DiscussionInput(props: DiscussionInputProps) {
}
},
close: () => {
- props.onClose?.(createSnapshot());
+ Promise.resolve(props.onClose?.(createSnapshot())).catch(
+ reportCallbackError
+ );
},
toggleFormatRibbon: () => {
setShowFormatRibbon(!showFormatRibbon());
- props.onToggleFormatRibbon?.(!showFormatRibbon());
+ Promise.resolve(props.onToggleFormatRibbon?.(!showFormatRibbon())).catch(
+ reportCallbackError
+ );
},
attachFiles: async (files: File[]) => {
// Insert images into the editor
diff --git a/apps/web/src/lib/core/component/AI/component/debug/Attachment.tsx b/apps/web/src/lib/core/component/AI/component/debug/Attachment.tsx
index d9d0de4f6e..5db4c2ecd1 100644
--- a/apps/web/src/lib/core/component/AI/component/debug/Attachment.tsx
+++ b/apps/web/src/lib/core/component/AI/component/debug/Attachment.tsx
@@ -201,7 +201,7 @@ function RequestDebugger(props: {
};
createEffect(() => {
- if (props.go() > 0) makeRequest();
+ if (props.go() > 0) void makeRequest();
});
return (
@@ -209,7 +209,7 @@ function RequestDebugger(props: {
<Button
variant="accent"
onClick={() => {
- makeRequest();
+ void makeRequest();
}}
>
Send
diff --git a/apps/web/src/lib/core/component/AI/component/debug/HttpStream.tsx b/apps/web/src/lib/core/component/AI/component/debug/HttpStream.tsx
index 308c4defa5..2c2b1482c2 100644
--- a/apps/web/src/lib/core/component/AI/component/debug/HttpStream.tsx
+++ b/apps/web/src/lib/core/component/AI/component/debug/HttpStream.tsx
@@ -32,7 +32,7 @@ export default function HttpStreamDebug() {
const id = chatId();
const connected = connectionState() === WebsocketConnectionState.Open;
if (id && connected) {
- connectionGatewayClient.trackEntity({
+ void connectionGatewayClient.trackEntity({
entity_type: 'chat',
entity_id: id,
action: 'open',
@@ -118,7 +118,7 @@ export default function HttpStreamDebug() {
setChatId(data.chat_id);
}
// Subscribe to the chat entity so the connection gateway routes messages to us
- connectionGatewayClient.trackEntity({
+ void connectionGatewayClient.trackEntity({
entity_type: 'chat',
entity_id: data.chat_id || chatId(),
action: 'open',
diff --git a/apps/web/src/lib/core/component/AI/component/input/ChatInput.tsx b/apps/web/src/lib/core/component/AI/component/input/ChatInput.tsx
index b8a8ea22e3..7c32d0a661 100644
--- a/apps/web/src/lib/core/component/AI/component/input/ChatInput.tsx
+++ b/apps/web/src/lib/core/component/AI/component/input/ChatInput.tsx
@@ -192,7 +192,7 @@ export function ChatInput(props: ChatInputComponentProps) {
!isEmptyInput();
const sendMessage = createCallback(
- async (opts?: { modelOverride?: Model; metaKey?: boolean }) => {
+ (opts?: { modelOverride?: Model; metaKey?: boolean }) => {
if (!canSendMessage()) return;
if (isNativeMobilePlatform() && !hasConsent()) {
@@ -221,7 +221,7 @@ export function ChatInput(props: ChatInputComponentProps) {
toast.failure('Folder upload not supported here');
return;
}
- handleFileFolderDrop(files, directories, (entries) => {
+ void handleFileFolderDrop(files, directories, (entries) => {
uploadQueue.upload(entries.map((e) => e.file));
});
},
diff --git a/apps/web/src/lib/core/component/AI/component/message/AssistantMessage.tsx b/apps/web/src/lib/core/component/AI/component/message/AssistantMessage.tsx
index f0f81527b5..3b666f2493 100644
--- a/apps/web/src/lib/core/component/AI/component/message/AssistantMessage.tsx
+++ b/apps/web/src/lib/core/component/AI/component/message/AssistantMessage.tsx
@@ -4,6 +4,7 @@ import { replaceCitations } from '@core/component/LexicalMarkdown/citationsUtils
import { ENABLE_TTFT } from '@core/constant/featureFlags';
import { createMarkdownFile } from '@core/util/create';
import { PulsingStar } from '@entity/components/PulsingStar';
+import { Telemetry } from '@macro-inc/observability';
import WideFileMd from '@phosphor/file.svg';
import CheckIcon from '@phosphor-icons/core/bold/check-bold.svg?component-solid';
import ClipboardIcon from '@phosphor-icons/core/bold/clipboard-bold.svg?component-solid';
@@ -185,7 +186,13 @@ export function AssistantMessage(props: {
: 'Edit assistant response in Notes'
}
onClick={() => {
- !isLoading() && handleEditInMarkdown();
+ if (isLoading()) return;
+ handleEditInMarkdown().catch((error) => {
+ setIsLoading(false);
+ Telemetry.error(error, {
+ surface: 'assistant-message-edit-in-notes',
+ });
+ });
}}
>
<Show
diff --git a/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.ts b/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.ts
index eff3204b26..359ca5ffd5 100644
--- a/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.ts
+++ b/apps/web/src/lib/core/component/AI/component/tool/calendar/open-tool-event.ts
@@ -43,7 +43,7 @@ export function openToolCalendarEvent(
options?: OpenToolCalendarEventOptions
) {
const occurrenceKey = options?.occurrenceKey;
- openCalendarEventSplit({
+ void openCalendarEventSplit({
eventId: event.eventId,
occurrenceKey,
// An occurrence key anchors the locator range on its own, so the event's
diff --git a/apps/web/src/lib/core/component/AI/util/instructions.ts b/apps/web/src/lib/core/component/AI/util/instructions.ts
index 03fd6838d4..22d41bc5d0 100644
--- a/apps/web/src/lib/core/component/AI/util/instructions.ts
+++ b/apps/web/src/lib/core/component/AI/util/instructions.ts
@@ -1,5 +1,6 @@
import { useSplitLayout } from '@components/app/split-layout/layout';
import { toast } from '@core/component/Toast/Toast';
+import { Telemetry } from '@macro-inc/observability';
import {
useCreateInstructionsMd,
useInstructionsMdIdQuery,
@@ -33,11 +34,16 @@ export function useOpenInstructionsMd() {
// needs to be created
if (id === null) {
- createInstructionsMd().then((id) => {
- const success = open(id);
- if (success) return;
- showFailToast();
- });
+ createInstructionsMd()
+ .then((id) => {
+ const success = open(id);
+ if (success) return;
+ showFailToast();
+ })
+ .catch((error) => {
+ Telemetry.error(error, { surface: 'ai-instructions' });
+ showFailToast();
+ });
return;
}
diff --git a/apps/web/src/lib/core/component/DocumentPreview.tsx b/apps/web/src/lib/core/component/DocumentPreview.tsx
index 0dba02c5f5..adf69e3079 100644
--- a/apps/web/src/lib/core/component/DocumentPreview.tsx
+++ b/apps/web/src/lib/core/component/DocumentPreview.tsx
@@ -242,7 +242,7 @@ function ImageCoverStrip(props: {
const controller = new AbortController();
let objectUrl: string | undefined;
- fetchBinary(presignedUrl, 'blob', { signal: controller.signal }).then(
+ void fetchBinary(presignedUrl, 'blob', { signal: controller.signal }).then(
(result) => {
if (controller.signal.aborted || result.isErr()) return;
const blob = result.value;
@@ -616,7 +616,7 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
};
};
- const handleCopy = () => {
+ const handleCopy = async () => {
try {
let hostname = window.location.hostname.replace('www.', '').toLowerCase();
if (hostname === 'localhost') {
@@ -625,7 +625,7 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
const mentionTarget = calendarMentionTarget();
if (mentionTarget) {
- copyCalendarEventMentionTarget(mentionTarget);
+ await copyCalendarEventMentionTarget(mentionTarget);
return;
}
@@ -640,15 +640,16 @@ export function DocumentPreviewContent(props: DocumentPreviewContentProps) {
).toString();
link += `?${queryParams}`;
}
- navigator.clipboard.writeText(link);
+ await navigator.clipboard.writeText(link);
toast.success('Copied document link to clipboard');
} catch (e) {
console.error(e);
+ toast.failure('Could not copy link');
}
};
const handleCopyBranchName = () => {
- copyBranchNameToClipboard(props.documentInfo.id);
+ void copyBranchNameToClipboard(props.documentInfo.id);
};
const isSplitAlreadyOpen = () => {
diff --git a/apps/web/src/lib/core/component/ItemPreview.tsx b/apps/web/src/lib/core/component/ItemPreview.tsx
index 6cb6e6554d..61f0e62e65 100644
--- a/apps/web/src/lib/core/component/ItemPreview.tsx
+++ b/apps/web/src/lib/core/component/ItemPreview.tsx
@@ -72,7 +72,7 @@ export function useItemPreviewData(entity: Accessor<ItemEntity>) {
}
}
- async function onPreviewClick(
+ function onPreviewClick(
type: ItemType | undefined,
id: string,
fileType?: FileType,
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShell.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
index 9e768bf070..07de3eac32 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/builder/MarkdownShell.tsx
@@ -1,6 +1,7 @@
import { fileFolderDrop } from '@core/directive/fileFolderDrop';
import { isMobile } from '@core/mobile/isMobile';
import { handleFileFolderDrop } from '@core/util/upload';
+import { Telemetry } from '@macro-inc/observability';
import { onElementConnect } from '@solid-primitives/lifecycle';
import { cn } from '@ui';
import {
@@ -187,6 +188,8 @@ export const MarkdownShell: Component<MarkdownShellProps> = (props) => {
undefined,
state.fileDropConfig!.constrainedMediaDimensions
)
+ ).catch((error) =>
+ Telemetry.error(error, { surface: 'markdown-file-drop' })
);
}
: undefined;
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/builder/buildHandleFromConfig.ts b/apps/web/src/lib/core/component/LexicalMarkdown/builder/buildHandleFromConfig.ts
index 5265c364aa..b47232b521 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/builder/buildHandleFromConfig.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/builder/buildHandleFromConfig.ts
@@ -1,5 +1,6 @@
import { handleFileFolderDrop } from '@core/util/upload';
import type { EditorType } from '@macro-inc/lexical-core';
+import { Telemetry } from '@macro-inc/observability';
import type { SerializedEditorState } from 'lexical';
import { createSignal } from 'solid-js';
import { createLexicalWrapper } from '../context/LexicalWrapperContext';
@@ -294,6 +295,8 @@ export function buildHandleFromConfig(config: EditorConfig): EditorHandle {
undefined,
fileDropConfig.constrainedMediaDimensions
)
+ ).catch((error) =>
+ Telemetry.error(error, { surface: 'markdown-file-paste' })
);
},
})
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/collaboration/CollabProvider.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/collaboration/CollabProvider.tsx
index 7efab85eee..3fce865f59 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/collaboration/CollabProvider.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/collaboration/CollabProvider.tsx
@@ -45,7 +45,7 @@ import {
SKIP_SCROLL_INTO_VIEW_TAG,
stripDraftCommentMarks,
} from '@macro-inc/lexical-core';
-import type { Span } from '@macro-inc/observability';
+import { type Span, Telemetry } from '@macro-inc/observability';
import type { NodeKey, UpdateListenerPayload } from 'lexical';
import {
$addUpdateTag,
@@ -431,11 +431,17 @@ export function CollabProvider(props: CollabProviderProps) {
$afterSyncCursorUpdate(loroManager);
}
+ function reportSyncError(error: unknown) {
+ Telemetry.error(error, { surface: 'collab-lexical-to-loro-sync' });
+ }
+
function lexicalStateSyncPlugin() {
return mergeRegister(
props.editor.registerUpdateListener(
({ editorState, tags, mutatedNodes }) => {
- syncLexicalToLoro(editorState, mutatedNodes, tags);
+ syncLexicalToLoro(editorState, mutatedNodes, tags).catch(
+ reportSyncError
+ );
return false;
}
),
@@ -443,7 +449,7 @@ export function CollabProvider(props: CollabProviderProps) {
FORCE_SYNC_COMMAND,
() => {
const stateToSync = loroSyncState(props.editor.getEditorState());
- syncEngine.syncStateToLoro(stateToSync as any);
+ syncEngine.syncStateToLoro(stateToSync as any).catch(reportSyncError);
return true;
},
COMMAND_PRIORITY_NORMAL
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.tsx
index c9f46edd1b..042d7da731 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/core/BlockLink.tsx
@@ -3,6 +3,7 @@ import { useSplitLayout } from '@components/app/split-layout/layout';
import { type BlockAlias, type BlockName, useMaybeBlockId } from '@core/block';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
+import { Telemetry } from '@macro-inc/observability';
import { createCallback } from '@solid-primitives/rootless';
import type { ParentProps } from 'solid-js';
@@ -35,6 +36,16 @@ async function openLocation<T extends BlockNameWithLocations>(
await blockHandle?.goToLocationFromParams(params ?? {});
}
+function openLocationInBackground<T extends BlockNameWithLocations>(
+ blockName: T,
+ id: string,
+ params?: Record<string, string>
+) {
+ openLocation(blockName, id, params).catch((error) =>
+ Telemetry.error(error, { surface: 'block-link', blockName })
+ );
+}
+
export function openDocument(
blockOrFileType: string,
id: string,
@@ -55,7 +66,7 @@ export function openDocument(
isBlockNameWithLocation(targetBlock) &&
!inNewSplit
) {
- openLocation(targetBlock, id, params);
+ openLocationInBackground(targetBlock, id, params);
return;
}
@@ -68,7 +79,7 @@ export function openDocument(
);
if (isBlockNameWithLocation(targetBlock)) {
- openLocation(targetBlock, id, params);
+ openLocationInBackground(targetBlock, id, params);
}
return result;
}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/ChannelMessageThreadCard.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/ChannelMessageThreadCard.tsx
index 4720d91e56..789157468e 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/ChannelMessageThreadCard.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/ChannelMessageThreadCard.tsx
@@ -1,6 +1,7 @@
import { navigateToChannelMessage } from '@block-channel/utils/link';
import { ReadonlyThread } from '@channel/StandaloneThread';
import { useGlobalBlockOrchestrator } from '@components/app/GlobalAppState';
+import { Telemetry } from '@macro-inc/observability';
type ChannelMessageThreadCardProps = {
channelId: string;
@@ -22,6 +23,8 @@ export function ChannelMessageThreadCard(props: ChannelMessageThreadCardProps) {
props.channelId,
clickedMessageId,
isReply ? props.messageId : undefined
+ ).catch((error) =>
+ Telemetry.error(error, { surface: 'channel-message-thread-card' })
);
}}
/>
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx
index e5e4c77e76..61038e0006 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentCard.tsx
@@ -386,7 +386,7 @@ function DocumentCardInner(props: DocumentCardDecoratorProps) {
openDocument(props.blockName, props.documentId, props.blockParams, true);
});
- const handleCopy = () => {
+ const handleCopy = async () => {
try {
let hostname = window.location.hostname.replace('www.', '').toLowerCase();
if (hostname === 'localhost') {
@@ -398,10 +398,11 @@ function DocumentCardInner(props: DocumentCardDecoratorProps) {
const queryParams = new URLSearchParams(props.blockParams).toString();
link += `?${queryParams}`;
}
- navigator.clipboard.writeText(link);
+ await navigator.clipboard.writeText(link);
toast.success('Copied document link to clipboard');
} catch (e) {
console.error(e);
+ toast.failure('Could not copy link');
}
};
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx
index b86ad5297e..c7375a5a89 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/DocumentMention.tsx
@@ -715,7 +715,7 @@ function DocumentMentionInner(props: DocumentMentionDecoratorProps) {
setPreviewCardOpen(true);
return;
}
- openCalendarEventSplit({
+ void openCalendarEventSplit({
...target.target,
openInNewSplit: openInNewSplitForMention(e?.shiftKey, e != null),
});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx
index 69aa711961..072d817543 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownImage.tsx
@@ -108,7 +108,7 @@ export function MarkdownImage(props: ImageDecoratorProps) {
setImageUrl(props.url);
return;
}
- getMediaUrl({
+ void getMediaUrl({
type: props.srcType,
id: props.id,
url: props.url,
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownVideo.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownVideo.tsx
index 66e31d77fd..5e01ba3550 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownVideo.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/MarkdownVideo.tsx
@@ -94,7 +94,7 @@ export function MarkdownVideo(props: VideoDecoratorProps) {
setVideoUrl(props.url);
return;
}
- getMediaUrl({
+ void getMediaUrl({
type: props.srcType,
id: props.id,
url: props.url,
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/paste/usePasteNode.ts b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/paste/usePasteNode.ts
index 61c753c8a2..21d5dff4ba 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/paste/usePasteNode.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/decorator/paste/usePasteNode.ts
@@ -48,12 +48,13 @@ export function usePasteNode(props: PasteNodeDecoratorProps) {
});
};
- const copyText = () => {
+ const copyText = async () => {
try {
- navigator.clipboard.writeText(props.content);
+ await navigator.clipboard.writeText(props.content);
toast.success(`Copied ${origin()} text to clipboard`);
} catch (e) {
console.error('Failed to copy pasted text to clipboard', e);
+ toast.failure('Could not copy text');
}
};
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/FloatingLinkMenu.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/FloatingLinkMenu.tsx
index cb2be74f28..319c5ca5d0 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/FloatingLinkMenu.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/FloatingLinkMenu.tsx
@@ -172,12 +172,15 @@ export function FloatingLinkMenu(props: {
openExternalUrl(url);
};
- const copyLink = () => {
+ const copyLink = async () => {
if (!pendingLinkInfo()) return;
try {
- navigator.clipboard.writeText(pendingLinkInfo()!.url || '');
- toast.success('Copied link to clipboard');
- } catch {}
+ await navigator.clipboard.writeText(pendingLinkInfo()!.url || '');
+ } catch {
+ toast.failure('Could not copy link');
+ return;
+ }
+ toast.success('Copied link to clipboard');
};
const handleEditClick = () => {
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
index 3b65b615ec..34cc6039be 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/component/menu/MentionsMenu/MentionsMenu.tsx
@@ -18,6 +18,7 @@ import { useDateSearch } from '@core/util/dateSearch/useDateSearch';
import { debouncedDependent } from '@core/util/debounce';
import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';
import type { EmailEntity } from '@entity';
+import { Telemetry } from '@macro-inc/observability';
import type { HistoryItem as Item } from '@queries/history/history';
import { Key } from '@solid-primitives/keyed';
import { createLazyMemo } from '@solid-primitives/memo';
@@ -548,7 +549,12 @@ function MentionsMenuInner(props: MentionsMenuProps) {
onSelect: () => {
const selectedItem = controller.selectedItem();
if (selectedItem) {
- itemAction(selectedItem);
+ itemAction(selectedItem).catch((error) =>
+ Telemetry.error(error, {
+ surface: 'mentions-menu',
+ itemKind: selectedItem.kind,
+ })
+ );
} else {
closeMenu();
}
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/directive/floatWithSelection.ts b/apps/web/src/lib/core/component/LexicalMarkdown/directive/floatWithSelection.ts
index 3302dc5fd3..185108dcee 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/directive/floatWithSelection.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/directive/floatWithSelection.ts
@@ -12,6 +12,7 @@ import {
type Placement,
shift,
} from '@floating-ui/dom';
+import { Telemetry } from '@macro-inc/observability';
import type { Accessor, JSX } from 'solid-js';
import { createEffect, createSignal, onCleanup, onMount } from 'solid-js';
import { iosSafePadding, iosSizeMiddleware } from './iosFloatingMiddleware';
@@ -136,34 +137,35 @@ export function floatWithSelection(
});
}
+ const reportPositionError = (error: unknown) =>
+ Telemetry.error(error, { surface: 'float-with-selection' });
+
+ const placeInBackground = (selection: Selection | null | undefined) => {
+ setInitialFloatingPosition(selection).catch(reportPositionError);
+ };
+
+ const repositionInBackground = () => {
+ if (currentAnchor()) {
+ updatePosition().catch(reportPositionError);
+ }
+ };
+
const selectionChangeHandler = () => {
let selection = document.getSelection();
if (!selection || selection.rangeCount === 0) return;
setCurrentAnchor(selection.getRangeAt(0));
- setInitialFloatingPosition(selection);
+ placeInBackground(selection);
};
- const scrollHandler = () => {
- if (currentAnchor()) {
- updatePosition();
- }
- };
+ const scrollHandler = repositionInBackground;
let scrollParent: Element | Document | null = null;
- const resizeObserver = new ResizeObserver(() => {
- if (currentAnchor()) {
- updatePosition();
- }
- });
+ const resizeObserver = new ResizeObserver(repositionInBackground);
- const mutationObserver = new MutationObserver(() => {
- if (currentAnchor()) {
- updatePosition();
- }
- });
+ const mutationObserver = new MutationObserver(repositionInBackground);
onMount(() => {
- setInitialFloatingPosition(accessor()?.selection);
+ placeInBackground(accessor()?.selection);
if (accessor()?.moveWithSelection) {
document.addEventListener('selectionchange', selectionChangeHandler);
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/editing/entityDrop.ts b/apps/web/src/lib/core/component/LexicalMarkdown/editing/entityDrop.ts
index fdeafb7d56..a8dc24e794 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/editing/entityDrop.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/editing/entityDrop.ts
@@ -141,7 +141,7 @@ export function useEditorEntityDrop(props: {
dndDragMove.clear();
// Only soup entity drags insert mentions (not e.g. sidebar favorite drags).
if (!isEntityDragEvent(event)) return;
- dndDragEnd(event);
+ void dndDragEnd(event);
});
onDragMove((event) => {
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.ts b/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.ts
index 77147e818c..6329d47ee2 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/editing/registerMarkdownEditing.ts
@@ -18,6 +18,7 @@ import {
type PeerIdValidator,
peerIdPlugin,
} from '@macro-inc/lexical-core';
+import { Telemetry } from '@macro-inc/observability';
import type { Accessor } from 'solid-js';
import type { MarkdownEditorErrors } from '../constants';
import type { LexicalWrapper } from '../context/LexicalWrapperContext';
@@ -285,7 +286,7 @@ export function registerMarkdownEditing(options: MarkdownEditingOptions) {
event: DragEvent,
blockName?: BlockName
) {
- handleFileFolderDrop(
+ void dropFilesIntoEditor(
fileEntries,
folderEntries,
createFilesReadyHandler(editor, filesBlockId, blockName, () =>
@@ -296,4 +297,14 @@ export function registerMarkdownEditing(options: MarkdownEditingOptions) {
};
}
+async function dropFilesIntoEditor(
+ ...args: Parameters<typeof handleFileFolderDrop>
+) {
+ try {
+ await handleFileFolderDrop(...args);
+ } catch (error) {
+ Telemetry.error(error, { surface: 'markdown-file-drop' });
+ }
+}
+
export type MarkdownEditing = ReturnType<typeof registerMarkdownEditing>;
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checkbox-to-task/checkboxToTaskPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checkbox-to-task/checkboxToTaskPlugin.ts
index 32b9d08c08..bd66146d41 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checkbox-to-task/checkboxToTaskPlugin.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/checkbox-to-task/checkboxToTaskPlugin.ts
@@ -143,7 +143,7 @@ function registerCheckboxToTaskPlugin(
return false;
}
- processCheckboxes(editor, checkboxes, options, pluginOptions);
+ void processCheckboxes(editor, checkboxes, options, pluginOptions);
return true;
},
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/media/mediaPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/media/mediaPlugin.ts
index 4a8bbdce63..a8fcc68e99 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/media/mediaPlugin.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/media/mediaPlugin.ts
@@ -21,6 +21,7 @@ import {
type MediaType,
type VideoNode,
} from '@macro-inc/lexical-core';
+import { Telemetry } from '@macro-inc/observability';
import { fetchBinaryDocumentData } from '@queries/storage/binary-document';
import { fileExtension } from '@service-storage/util/filename';
import {
@@ -331,7 +332,7 @@ function registerMediaPlugin(editor: LexicalEditor) {
editor.dispatchCommand(UPLOAD_MEDIA_START_COMMAND, [key, mediaType]);
- uploadStaticFiles(
+ await uploadStaticFiles(
[file],
(id) => {
cachedUploads.set(uploadKey, id);
@@ -398,7 +399,10 @@ function registerMediaPlugin(editor: LexicalEditor) {
$safeInsertMediaNode(node);
const nodeKey = node.getKey();
- handleUpload(payload.file, nodeKey, payload.url, mediaType);
+ handleUpload(payload.file, nodeKey, payload.url, mediaType).catch(
+ (error) =>
+ Telemetry.error(error, { surface: 'media-upload', mediaType })
+ );
return true;
}
@@ -560,7 +564,12 @@ function registerMediaPlugin(editor: LexicalEditor) {
? 'video'
: null;
if (type) {
- addMediaFromFile(editor, file, type);
+ addMediaFromFile(editor, file, type).catch((error) =>
+ Telemetry.error(error, {
+ surface: 'media-upload',
+ mediaType: type,
+ })
+ );
}
}
input.remove();
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
index 0696d21d15..28ccb564a3 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
@@ -322,7 +322,7 @@ function $deleteSelectedMentions(sourceDocumentId?: string) {
if (!$isGroupMentionNode(node)) {
const mentionUuid = node.getMentionUuid();
if (mentionUuid && sourceDocumentId) {
- untrackMention(
+ void untrackMention(
sourceDocumentId,
mentionUuid,
$mentionItemFromNode(node).itemType
@@ -664,7 +664,11 @@ function registerMentionsPlugin(
if (mutation === 'destroyed') {
const mentionUuid = node.getMentionUuid();
if (mentionUuid && sourceDocumentId) {
- untrackMention(sourceDocumentId, mentionUuid, 'agent_session');
+ void untrackMention(
+ sourceDocumentId,
+ mentionUuid,
+ 'agent_session'
+ );
}
onRemoveMention?.($mentionItemFromNode(node));
}
@@ -925,7 +929,7 @@ function registerMentionsPlugin(
(node.getBlockName() !== 'database' ||
!databaseReferenceRemains(mentionUuid))
) {
- untrackMention(sourceDocumentId, mentionUuid, itemType);
+ void untrackMention(sourceDocumentId, mentionUuid, itemType);
}
if (onRemoveMention) {
onRemoveMention({
@@ -963,7 +967,7 @@ function registerMentionsPlugin(
if (node) {
const mentionUuid = node.getMentionUuid();
if (mentionUuid && sourceDocumentId) {
- untrackMention(sourceDocumentId, mentionUuid, 'user');
+ void untrackMention(sourceDocumentId, mentionUuid, 'user');
}
if (onRemoveMention) {
onRemoveMention({
@@ -1001,7 +1005,7 @@ function registerMentionsPlugin(
if (node) {
const mentionUuid = node.getMentionUuid();
if (mentionUuid && sourceDocumentId) {
- untrackMention(sourceDocumentId, mentionUuid, 'contact');
+ void untrackMention(sourceDocumentId, mentionUuid, 'contact');
}
if (onRemoveMention) {
onRemoveMention({
@@ -1036,7 +1040,7 @@ function registerMentionsPlugin(
if (node) {
const mentionUuid = node.getMentionUuid();
if (mentionUuid && sourceDocumentId) {
- untrackMention(sourceDocumentId, mentionUuid, 'date');
+ void untrackMention(sourceDocumentId, mentionUuid, 'date');
}
if (onRemoveMention) {
onRemoveMention({
@@ -1101,7 +1105,7 @@ function registerMentionsPlugin(
if (mutation === 'destroyed') {
const mentionUuid = node.getMentionUuid();
if (mentionUuid && sourceDocumentId) {
- untrackMention(sourceDocumentId, mentionUuid, 'foreign');
+ void untrackMention(sourceDocumentId, mentionUuid, 'foreign');
}
onRemoveMention?.($mentionItemFromNode(node));
} else if (mutation === 'created') {
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/utils/fileUploadUtils.ts b/apps/web/src/lib/core/component/LexicalMarkdown/utils/fileUploadUtils.ts
index 675c7e0155..f5d552efa9 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/utils/fileUploadUtils.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/utils/fileUploadUtils.ts
@@ -150,7 +150,7 @@ async function onFilesReady(
blockId,
onDocumentMention: () => {},
disableMentionTracking: false,
- });
+ }).catch((error) => Telemetry.error(error, { surface: 'file-upload' }));
}
} else if (result.type === 'folder') {
const item = await documentUploadToItem(result);
@@ -166,7 +166,7 @@ async function onFilesReady(
blockId,
onDocumentMention: () => {},
disableMentionTracking: false,
- });
+ }).catch((error) => Telemetry.error(error, { surface: 'file-upload' }));
}
}
diff --git a/apps/web/src/lib/core/component/References.tsx b/apps/web/src/lib/core/component/References.tsx
index 5eee52a6d3..9132a33d54 100644
--- a/apps/web/src/lib/core/component/References.tsx
+++ b/apps/web/src/lib/core/component/References.tsx
@@ -8,6 +8,7 @@ import { getDisplayNameParts, tryMacroId } from '@core/user';
import { compareDateDesc, type DateValue } from '@core/util/date';
import { useSplitNavigationHandler } from '@core/util/useSplitNavigationHandler';
import { formatRelativeTimestamp } from '@entity';
+import { Telemetry } from '@macro-inc/observability';
import {
isAccessiblePreviewItem,
type PreviewItem,
@@ -257,7 +258,7 @@ export function References(props: ReferenceProps) {
{
preferNewSplit: true,
}
- );
+ ).catch((error) => Telemetry.error(error, { surface: 'references' }));
};
const navigateToGenericReference = (
diff --git a/apps/web/src/lib/core/component/TopBar/ShareButton.tsx b/apps/web/src/lib/core/component/TopBar/ShareButton.tsx
index eb26e00146..a4a10a6288 100644
--- a/apps/web/src/lib/core/component/TopBar/ShareButton.tsx
+++ b/apps/web/src/lib/core/component/TopBar/ShareButton.tsx
@@ -790,7 +790,7 @@ function MobileShareDrawer(props: MobileShareDrawerProps) {
if (accessLevel === null) {
props.removeChannelAccess(recipient.channel_id);
} else if (accessLevel !== recipient.access_level) {
- props.setChannelPermissions(
+ void props.setChannelPermissions(
recipient.channel_id,
accessLevel
);
@@ -922,7 +922,7 @@ export function ShareModal(props: ShareModalProps) {
const copyLink = createCallback(() => {
if (props.copyLink) return props.copyLink();
- copyEntityLink(shareUrl(props.blockAlias, props.id), {
+ void copyEntityLink(shareUrl(props.blockAlias, props.id), {
subtext: RESTRICTED_SHARE_DESCRIPTIONS[props.itemType]
? undefined
: SHARE_LINK_SUBTEXT,
@@ -999,7 +999,7 @@ export function ShareModal(props: ShareModalProps) {
channelSharePermissions: [{ operation: 'remove', channelId }],
});
if (result.isOk()) {
- refetch();
+ void refetch();
toast.success('Removed channel access');
} else {
toast.alert('Failed to remove channel access', {
@@ -1011,7 +1011,7 @@ export function ShareModal(props: ShareModalProps) {
channelSharePermissions: [{ operation: 'remove', channelId }],
});
if (result.isOk()) {
- refetch();
+ void refetch();
toast.success('Removed channel access');
} else {
toast.alert('Failed to remove channel access', {
@@ -1023,7 +1023,7 @@ export function ShareModal(props: ShareModalProps) {
channelSharePermissions: [{ operation: 'remove', channelId }],
});
if (result.isOk()) {
- refetch();
+ void refetch();
toast.success('Removed channel access', {
subtext: 'Channel no longer has access to this project',
});
@@ -1074,7 +1074,7 @@ export function ShareModal(props: ShareModalProps) {
},
});
if (!result.isErr()) {
- refetch();
+ void refetch();
toast.success('Removed channel access', {
subtext: 'Channel no longer has access to this chat',
});
@@ -1097,7 +1097,7 @@ export function ShareModal(props: ShareModalProps) {
},
});
if (!result.isErr()) {
- refetch();
+ void refetch();
toast.success('Removed channel access', {
subtext: 'Channel no longer has access to this document',
});
@@ -1120,7 +1120,7 @@ export function ShareModal(props: ShareModalProps) {
},
});
if (!result.isErr()) {
- refetch();
+ void refetch();
toast.success('Removed folder access');
} else {
toast.alert('Failed to remove folder access', {
@@ -1230,7 +1230,7 @@ export function ShareModal(props: ShareModalProps) {
}
if (result && result.isOk()) {
- refetch();
+ void refetch();
if (!hideSuccessToast) {
toast.success('Changed channel access level', {
subtext: accessLevelText(accessLevel),
@@ -1333,7 +1333,7 @@ export function ShareModal(props: ShareModalProps) {
return;
}
- refetch();
+ void refetch();
const scope = getTeamShareScope(sharePermission.teamShareAccessLevel);
if (props.itemType === 'call') {
setCallRecordTeamShareCache(props.id, shared);
@@ -1422,7 +1422,7 @@ export function ShareModal(props: ShareModalProps) {
return;
}
- refetch();
+ void refetch();
if (scope === 'NONE') {
toast.success(`Disabled link sharing for this ${entityLabel}`, {
subtext: getLinkShareScopeCopy('NONE').description,
@@ -1719,13 +1719,13 @@ export function ShareModal(props: ShareModalProps) {
permissions={recipient.access_level}
setPermissions={(accessLevel) => {
if (accessLevel === null) {
- removeChannelAccess(
+ void removeChannelAccess(
recipient.channel_id
);
} else if (
accessLevel !== recipient.access_level
) {
- setChannelPermissions(
+ void setChannelPermissions(
recipient.channel_id,
accessLevel
);
diff --git a/apps/web/src/lib/core/constant/SettingsState.test.tsx b/apps/web/src/lib/core/constant/SettingsState.test.tsx
index c1bef8411c..dd965310ca 100644
--- a/apps/web/src/lib/core/constant/SettingsState.test.tsx
+++ b/apps/web/src/lib/core/constant/SettingsState.test.tsx
@@ -101,7 +101,7 @@ beforeEach(() => {
afterEach(cleanup);
describe('settings entry points', () => {
- it('routes desktop tab selections without prewriting entries and retains A-B-A history', () => {
+ it('routes desktop tab selections without prewriting entries and retains A-B-A history', async () => {
mocks.mobile = false;
mocks.hasSettingsSplit = true;
const { state } = mountSettings();
@@ -123,16 +123,20 @@ describe('settings entry points', () => {
const pane = router.panes()[0]!;
const currentTab = () =>
router.entry(pane)?.location.route.matches[0]?.params.tab;
+ const navigations: ReturnType<typeof router.navigatePane>[] = [];
const navigateTab = (tab: string) => {
expect(mocks.updateCurrentEntry).not.toHaveBeenCalled();
- router.navigatePane(pane, `/settings/${tab.toLowerCase()}`);
+ navigations.push(
+ router.navigatePane(pane, `/settings/${tab.toLowerCase()}`)
+ );
};
state.selectTab('Appearance', navigateTab);
state.selectTab('Account', navigateTab);
+ await Promise.all(navigations);
expect(router.history(pane)?.entries).toHaveLength(3);
- router.navigatePane(pane, -1);
+ await router.navigatePane(pane, -1);
expect(currentTab()).toBe('appearance');
- router.navigatePane(pane, -1);
+ await router.navigatePane(pane, -1);
expect(currentTab()).toBe('account');
router.dispose();
});
diff --git a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx
index a8b96c6664..66685fd5ed 100644
--- a/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx
+++ b/apps/web/src/lib/core/context/quickAccess/QuickAccessSource.tsx
@@ -1317,15 +1317,15 @@ export function createQuickAccessValue(): QuickAccessContextValue {
setManualRefreshRevision((revision) => revision + 1);
void cachedChannelsQuery.refetch();
}
- historyQuery.refetch();
- crmCompaniesQuery.refetch();
- crmContactsQuery.refetch();
- snippetsQuery.refetch();
- skillsQuery.refetch();
+ void historyQuery.refetch();
+ void crmCompaniesQuery.refetch();
+ void crmContactsQuery.refetch();
+ void snippetsQuery.refetch();
+ void skillsQuery.refetch();
void agentSessionsQuery.refetch();
if (databasesFlag().enabled) void databasesQuery.refetch();
if (formsFlag().enabled) void formsQuery.refetch();
- initiativesQuery.refetch();
+ void initiativesQuery.refetch();
};
return {
diff --git a/apps/web/src/lib/core/cross-tab/tab-leader.ts b/apps/web/src/lib/core/cross-tab/tab-leader.ts
index 5006626d3e..a26cadee17 100644
--- a/apps/web/src/lib/core/cross-tab/tab-leader.ts
+++ b/apps/web/src/lib/core/cross-tab/tab-leader.ts
@@ -1,3 +1,4 @@
+import { Telemetry } from '@macro-inc/observability';
import { type Accessor, createSignal, onCleanup } from 'solid-js';
import { Tab } from 'tab-election';
@@ -17,13 +18,17 @@ export const createTabLeaderSignal = (namespace: string): Accessor<boolean> => {
const [isLeader, setIsLeader] = createSignal<boolean>(false);
const tab = new Tab(namespace);
- tab.waitForLeadership(() => {
- setIsLeader(true);
+ tab
+ .waitForLeadership(() => {
+ setIsLeader(true);
- return () => {
- setIsLeader(false);
- };
- });
+ return () => {
+ setIsLeader(false);
+ };
+ })
+ .catch((error) =>
+ Telemetry.error(error, { surface: 'tab-leader', namespace })
+ );
onCleanup(() => {
tab.close();
diff --git a/apps/web/src/lib/core/heic/workerPool.ts b/apps/web/src/lib/core/heic/workerPool.ts
index acadb0dbf3..7c9c41f608 100644
--- a/apps/web/src/lib/core/heic/workerPool.ts
+++ b/apps/web/src/lib/core/heic/workerPool.ts
@@ -3,6 +3,7 @@
* Internal implementation detail, not exposed to consumers
*/
+import { Telemetry } from '@macro-inc/observability';
import shortUUID from 'short-uuid';
import {
ERROR_MESSAGES,
@@ -112,19 +113,23 @@ export class HeicWorkerPool {
this.taskQueue = [];
this.availableWorkers = [];
- this.checkWebCodecsSupport().then(() => {
- const supported =
- this.webCodecsSupportedMimeTypes &&
- this.webCodecsSupportedMimeTypes.length > 0;
- if (supported) {
- HeicLogger.info(
- 'WebCodecs support detected:',
- this.webCodecsSupportedMimeTypes
- );
- } else {
- HeicLogger.info('WebCodecs support not available');
- }
- });
+ this.checkWebCodecsSupport()
+ .then(() => {
+ const supported =
+ this.webCodecsSupportedMimeTypes &&
+ this.webCodecsSupportedMimeTypes.length > 0;
+ if (supported) {
+ HeicLogger.info(
+ 'WebCodecs support detected:',
+ this.webCodecsSupportedMimeTypes
+ );
+ } else {
+ HeicLogger.info('WebCodecs support not available');
+ }
+ })
+ .catch((error) =>
+ Telemetry.error(error, { surface: 'heic-worker-pool' })
+ );
this.initialize();
}
diff --git a/apps/web/src/lib/core/internal/BlockLoader.tsx b/apps/web/src/lib/core/internal/BlockLoader.tsx
index e22ca158a1..4aa79c56db 100644
--- a/apps/web/src/lib/core/internal/BlockLoader.tsx
+++ b/apps/web/src/lib/core/internal/BlockLoader.tsx
@@ -2,6 +2,7 @@ import { useSharedAccessUpdates } from '@app/features/access-requests/access-req
import { shareEntity } from '@app/features/access-requests/core/types';
import { useAnalytics } from '@app/lib/analytics/analytics-context';
import type { OwnedBlockHandle } from '@core/orchestrator';
+import { Telemetry } from '@macro-inc/observability';
import { useQueryClient } from '@queries/client';
import { blockNameToItemType } from '@service-storage/client';
import type { AccessLevel as UserAccessLevel } from '@service-storage/generated/schemas/accessLevel';
@@ -198,13 +199,20 @@ Check that the load function does not return a preload source when the intent is
if (!isNested && data && props.definition.openTrackingEnabled !== false) {
const trackOpened = () => {
// we need to pass in a client accessor since the mutation is dynamically imported outside a query context provider
- import('./trackBlockOpened').then(({ track }) => {
- track({
- itemId: props.id,
- blockName: data.__block,
- client: useQueryClient,
- });
- });
+ import('./trackBlockOpened')
+ .then(({ track }) => {
+ track({
+ itemId: props.id,
+ blockName: data.__block,
+ client: useQueryClient,
+ });
+ })
+ .catch((error) =>
+ Telemetry.error(error, {
+ surface: 'track-block-opened',
+ blockName: data.__block,
+ })
+ );
analytics.pageView(data.__block);
analytics.track('open_entity', {
diff --git a/apps/web/src/lib/core/internal/trackBlockOpened.ts b/apps/web/src/lib/core/internal/trackBlockOpened.ts
index b374bdda33..16534f6d35 100644
--- a/apps/web/src/lib/core/internal/trackBlockOpened.ts
+++ b/apps/web/src/lib/core/internal/trackBlockOpened.ts
@@ -1,3 +1,4 @@
+import { Telemetry } from '@macro-inc/observability';
import { useUpsertToHistoryMutation } from '@queries/history/history';
import {
hasSoupEntity,
@@ -61,6 +62,17 @@ function shouldTrackInUserHistory(
);
}
+async function fetchOpenedSoupEntity(
+ itemId: string,
+ itemType: ItemType & SoupEntityTag
+) {
+ try {
+ await refetchSoupEntity(itemId, itemType);
+ } catch (error) {
+ Telemetry.error(error, { surface: 'track-block-opened', itemType });
+ }
+}
+
/**
* Tracks opening of a block and updates history accordingly.
* We have this in a separate file to prevent cyclic dependencies.
@@ -79,7 +91,7 @@ export function track({
optimisticUpdateSoupItemViewedAt(itemId);
const inSoup = hasSoupEntity(itemId);
if (!inSoup && isSoupEntityTag(itemType)) {
- refetchSoupEntity(itemId, itemType);
+ void fetchOpenedSoupEntity(itemId, itemType);
}
if (!shouldTrackInUserHistory(itemType)) return;
diff --git a/apps/web/src/lib/core/messages/create-message-composer.ts b/apps/web/src/lib/core/messages/create-message-composer.ts
index eee29f604e..85c4d45e1d 100644
--- a/apps/web/src/lib/core/messages/create-message-composer.ts
+++ b/apps/web/src/lib/core/messages/create-message-composer.ts
@@ -54,7 +54,7 @@ export function createMessageComposer(options: ComposerOptions) {
: undefined,
onClose: (snapshot) => {
typingTracker.stop();
- options.callbacks.onClose?.(snapshot);
+ return options.callbacks.onClose?.(snapshot);
},
},
});
diff --git a/apps/web/src/lib/core/signal/mention.ts b/apps/web/src/lib/core/signal/mention.ts
index 3e3bbaa65e..0cbc8a4ec2 100644
--- a/apps/web/src/lib/core/signal/mention.ts
+++ b/apps/web/src/lib/core/signal/mention.ts
@@ -38,7 +38,7 @@ export async function trackMention(
return;
}
- queryClient.invalidateQueries({
+ void queryClient.invalidateQueries({
queryKey: attachmentReferencesKeys.list(targetType, targetId).queryKey,
});
if (isCrmTarget(targetType)) void refreshCrmAssociatedSoupQueries();
@@ -69,7 +69,7 @@ export async function untrackMention(
console.error('Failed to untrack document mention', response);
}
- queryClient.invalidateQueries({
+ void queryClient.invalidateQueries({
queryKey: attachmentReferencesKeys.list._def,
});
if (isCrmTarget(targetType)) void refreshCrmAssociatedSoupQueries();
diff --git a/apps/web/src/lib/core/util/cache.ts b/apps/web/src/lib/core/util/cache.ts
index a0fa433a2f..a9a6f73190 100644
--- a/apps/web/src/lib/core/util/cache.ts
+++ b/apps/web/src/lib/core/util/cache.ts
@@ -80,11 +80,13 @@ export function cache<Fn extends (...args: any[]) => Promise<any>>(
expiresAt,
};
- result.then((value) => {
- if (value.isErr()) {
- cache.delete(key);
- }
- });
+ result
+ .then((value) => {
+ if (value.isErr()) {
+ cache.delete(key);
+ }
+ })
+ .catch(() => cache.delete(key));
cache.set(key, cacheEntry);
return result;
diff --git a/apps/web/src/lib/core/util/channels.ts b/apps/web/src/lib/core/util/channels.ts
index cc33f785ce..85087d3208 100644
--- a/apps/web/src/lib/core/util/channels.ts
+++ b/apps/web/src/lib/core/util/channels.ts
@@ -70,8 +70,8 @@ export function useSendMessageToPeople() {
.catch(() => null);
if (!messageResponse) return;
- invalidateListChannels();
- invalidateContacts();
+ void invalidateListChannels();
+ void invalidateContacts();
const navigateToChannel = async () => {
replaceSplit({
diff --git a/apps/web/src/lib/core/util/create.ts b/apps/web/src/lib/core/util/create.ts
index 29d7f437d4..43b1c62635 100644
--- a/apps/web/src/lib/core/util/create.ts
+++ b/apps/web/src/lib/core/util/create.ts
@@ -2,11 +2,12 @@ import { analytics } from '@app/lib/analytics';
import { DEFAULT_CHAT_NAME } from '@block-chat/definition';
import type { CodeFileExtension } from '@block-code/util/languageSupport';
import { PaywallKey, usePaywallState } from '@core/constant/PaywallState';
+import { Telemetry } from '@macro-inc/observability';
import { PROPERTY_OPTION_IDS, SYSTEM_PROPERTY_IDS } from '@property/constants';
import { invalidateUserQuota } from '@queries/auth';
import { postNewHistoryItem } from '@queries/history/history';
import { setPreviewOnCreate } from '@queries/preview/preview';
-import { refetchSoupEntity } from '@queries/soup/cache';
+import { refetchSoupEntity, type SoupEntityTag } from '@queries/soup/cache';
import { seedDocumentLoadBundle } from '@queries/storage/documentLoad/documentLoadBundle';
import { cognitionApiServiceClient } from '@service-cognition/client';
import type { CreateChatRequest } from '@service-cognition/generated/schemas';
@@ -27,6 +28,15 @@ import {
} from './languageQuery';
import { resolveUploadContentType } from './uploadContentType';
+function refreshCreatedSoupEntity(entityId: string, entityType: SoupEntityTag) {
+ refetchSoupEntity(entityId, entityType, {
+ ownTouch: true,
+ refreshGraphql: true,
+ }).catch((error) =>
+ Telemetry.error(error, { surface: 'create-entity', entityType })
+ );
+}
+
type CreateMarkdownFileArgs = {
title?: string;
content?: string;
@@ -48,7 +58,7 @@ export async function createMarkdownFile(
projectId: args?.projectId,
});
- invalidateUserQuota();
+ void invalidateUserQuota();
if (result.isErr()) return;
@@ -66,10 +76,7 @@ export async function createMarkdownFile(
name: args?.title ?? '',
fileType: 'md',
});
- refetchSoupEntity(documentId, 'document', {
- ownTouch: true,
- refreshGraphql: true,
- });
+ refreshCreatedSoupEntity(documentId, 'document');
analytics.track('create_entity', {
entityType: 'md',
@@ -150,7 +157,7 @@ async function createTaskResponse(args?: CreateTaskArgs) {
propertyValues,
});
- invalidateUserQuota();
+ void invalidateUserQuota();
if (result.isErr()) return;
@@ -170,10 +177,7 @@ async function createTaskResponse(args?: CreateTaskArgs) {
subType: { type: 'task', is_completed: false },
});
if (args?.revalidateSoup !== false)
- refetchSoupEntity(documentId, 'document', {
- ownTouch: true,
- refreshGraphql: true,
- });
+ refreshCreatedSoupEntity(documentId, 'document');
analytics.track('create_entity', {
entityType: 'task',
@@ -219,7 +223,7 @@ export async function createSnippet(
projectId: args?.projectId,
});
- invalidateUserQuota();
+ void invalidateUserQuota();
if (result.isErr()) return;
@@ -232,10 +236,7 @@ export async function createSnippet(
fileType: 'md',
subType: { type: 'snippet' },
});
- refetchSoupEntity(documentId, 'document', {
- ownTouch: true,
- refreshGraphql: true,
- });
+ refreshCreatedSoupEntity(documentId, 'document');
analytics.track('create_entity', {
entityType: 'snippet',
@@ -270,7 +271,7 @@ export async function createSkill(
projectId: args?.projectId,
});
- invalidateUserQuota();
+ void invalidateUserQuota();
if (result.isErr()) return;
@@ -283,10 +284,7 @@ export async function createSkill(
fileType: 'md',
subType: { type: 'skill' },
});
- refetchSoupEntity(documentId, 'document', {
- ownTouch: true,
- refreshGraphql: true,
- });
+ refreshCreatedSoupEntity(documentId, 'document');
analytics.track('create_entity', {
entityType: 'skill',
@@ -357,7 +355,7 @@ export async function createCodeFileFromText({
sha: sha,
});
- invalidateUserQuota();
+ void invalidateUserQuota();
// TODO: this is kind of odd, since there's an actual code we could use for the paywall, 402 Payment Required
if (maybeCode.isErr() && maybeCode.error[0].message.includes('403')) {
@@ -374,17 +372,14 @@ export async function createCodeFileFromText({
});
if (uploadResult.isErr())
return err([{ code: 'SERVER_ERROR', message: 'Failed to upload file' }]);
- postNewHistoryItem('document', document.metadata.documentId);
+ void postNewHistoryItem('document', document.metadata.documentId);
setPreviewOnCreate({
itemId: document.metadata.documentId,
itemType: 'document',
name: title ?? 'New Code File',
fileType: finalExtension,
});
- refetchSoupEntity(document.metadata.documentId, 'document', {
- ownTouch: true,
- refreshGraphql: true,
- });
+ refreshCreatedSoupEntity(document.metadata.documentId, 'document');
analytics.track('create_entity', {
entityType: 'code',
@@ -414,7 +409,7 @@ export async function createCanvasFileFromJsonString(args: {
sha: sha,
projectId,
});
- invalidateUserQuota();
+ void invalidateUserQuota();
if (maybeCanvas.isErr()) return { error: 'Document creation failed.' };
const canvas = maybeCanvas.value;
@@ -427,17 +422,14 @@ export async function createCanvasFileFromJsonString(args: {
if (uploadResult.isErr()) return { error: 'Failed to upload file.' };
- postNewHistoryItem('document', canvas.metadata.documentId);
+ void postNewHistoryItem('document', canvas.metadata.documentId);
setPreviewOnCreate({
itemId: canvas.metadata.documentId,
itemType: 'document',
name: title ?? 'New Canvas',
fileType: 'canvas',
});
- refetchSoupEntity(canvas.metadata.documentId, 'document', {
- ownTouch: true,
- refreshGraphql: true,
- });
+ refreshCreatedSoupEntity(canvas.metadata.documentId, 'document');
analytics.track('create_entity', {
entityType: 'canvas',
@@ -460,7 +452,7 @@ export async function createChat(
const maybeChat = await cognitionApiServiceClient.createChat(args ?? {});
- invalidateUserQuota();
+ void invalidateUserQuota();
if (maybeChat.isErr()) {
if (isPaymentError(maybeChat)) {
showPaywall(PaywallKey.CHAT_LIMIT);
@@ -468,16 +460,13 @@ export async function createChat(
return { error: 'Failed to create chat.' };
}
const chat = maybeChat.value;
- postNewHistoryItem('chat', chat.id);
+ void postNewHistoryItem('chat', chat.id);
setPreviewOnCreate({
itemId: chat.id,
itemType: 'chat',
name: args?.name ?? DEFAULT_CHAT_NAME,
});
- refetchSoupEntity(chat.id, 'chat', {
- ownTouch: true,
- refreshGraphql: true,
- });
+ refreshCreatedSoupEntity(chat.id, 'chat');
analytics.track('create_entity', {
entityType: 'chat',
@@ -496,7 +485,7 @@ export async function createStaticFile(file: File): Promise<string> {
file_name: file.name,
content_type: contentType,
});
- invalidateUserQuota();
+ void invalidateUserQuota();
if (result.isErr()) throw new Error('Failed to upload file');
const { upload_url, id } = result.value;
diff --git a/apps/web/src/lib/core/util/upload.ts b/apps/web/src/lib/core/util/upload.ts
index 8a4e86ee29..ee09f53750 100644
--- a/apps/web/src/lib/core/util/upload.ts
+++ b/apps/web/src/lib/core/util/upload.ts
@@ -622,7 +622,7 @@ export async function handleFileFolderDrop(
]);
if (folderEntries.length > 0) {
- toast.promise(resultPromise, {
+ void toast.promise(resultPromise, {
loading: 'Preparing folder upload...',
});
}
@@ -664,7 +664,7 @@ export async function handleFolderSelect(
const resultPromise = Promise.allSettled(zipEntryPromises);
if (zipEntryPromises.length > 0) {
- toast.promise(resultPromise, {
+ void toast.promise(resultPromise, {
loading: 'Preparing folder upload...',
});
}
diff --git a/apps/web/src/lib/core/util/uploadFile.ts b/apps/web/src/lib/core/util/uploadFile.ts
index e67521fcb1..d3172c15f8 100644
--- a/apps/web/src/lib/core/util/uploadFile.ts
+++ b/apps/web/src/lib/core/util/uploadFile.ts
@@ -71,7 +71,7 @@ export async function createStaticUploadFile(
file_name: file.name,
content_type: contentType,
});
- invalidateUserQuota();
+ void invalidateUserQuota();
if (result.isErr()) throw new Error('Failed to upload file');
const { upload_url, id } = result.value;