Skip to content

Commit

Permalink
Capture analytics on user facing errors
Browse files Browse the repository at this point in the history
- needed for product analytics
  • Loading branch information
mtsgrd committed Nov 28, 2024
1 parent c55e576 commit a32c468
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions apps/desktop/src/lib/notifications/toasts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { isStr } from '@gitbutler/ui/utils/string';
import posthog from 'posthog-js';
import { writable, type Writable } from 'svelte/store';
import type { MessageStyle } from '$lib/shared/InfoMessage.svelte';

Expand All @@ -15,6 +16,9 @@ export const toastStore: Writable<Toast[]> = writable([]);
let idCounter = 0;

export function showToast(toast: Toast) {
if (toast.error) {
posthog.capture('toast:show_error', { error_title: toast.title });
}
toast.message = toast.message?.replace(/^ */gm, '');
toastStore.update((items) => [
...items.filter((t) => toast.id === undefined || t.id !== toast.id),
Expand Down

0 comments on commit a32c468

Please sign in to comment.