feat(memoro/web, shared-utils): add MemoroEvents analytics tracking

Define 25+ Memoro-specific events in shared-utils analytics (recording, memo CRUD, spaces, invites, playback, themes).
Integrate tracking in web app services, components, and stores.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Till JS 2026-04-01 15:18:30 +02:00
parent 304c1e8b7c
commit 1bc134ed6e
7 changed files with 54 additions and 0 deletions

View file

@ -2,6 +2,7 @@
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import Icon from '$lib/components/Icon.svelte'; import Icon from '$lib/components/Icon.svelte';
import Text from '$lib/components/atoms/Text.svelte'; import Text from '$lib/components/atoms/Text.svelte';
import { MemoroEvents } from '@manacore/shared-utils/analytics';
let { src, duration }: { src: string; duration?: number } = $props(); let { src, duration }: { src: string; duration?: number } = $props();
@ -44,6 +45,7 @@
audio.pause(); audio.pause();
} else { } else {
audio.play(); audio.play();
MemoroEvents.playbackStarted();
} }
isPlaying = !isPlaying; isPlaying = !isPlaying;
} }

View file

@ -16,6 +16,7 @@ import {
} from '$lib/data/local-store'; } from '$lib/data/local-store';
import type { Memo, Tag, Memory } from '$lib/types/memo.types'; import type { Memo, Tag, Memory } from '$lib/types/memo.types';
import { getCachedUrl, setCachedUrl, cleanupExpiredUrls } from '$lib/utils/indexedDBCache'; import { getCachedUrl, setCachedUrl, cleanupExpiredUrls } from '$lib/utils/indexedDBCache';
import { MemoroEvents } from '@manacore/shared-utils/analytics';
// ─── Type mappers ────────────────────────────────────────────── // ─── Type mappers ──────────────────────────────────────────────
@ -269,6 +270,7 @@ export class MemoService {
async deleteMemo(memoId: string): Promise<void> { async deleteMemo(memoId: string): Promise<void> {
await memoCollection.delete(memoId); await memoCollection.delete(memoId);
MemoroEvents.memoDeleted();
} }
async addTagToMemo(memoId: string, tagId: string): Promise<void> { async addTagToMemo(memoId: string, tagId: string): Promise<void> {

View file

@ -4,6 +4,7 @@
*/ */
import { env } from '$lib/config/env'; import { env } from '$lib/config/env';
import { MemoroEvents } from '@manacore/shared-utils/analytics';
const API = () => env.server.memoroUrl.replace(/\/$/, ''); const API = () => env.server.memoroUrl.replace(/\/$/, '');
@ -137,6 +138,7 @@ class SpaceService {
}); });
await throwOnError(r, 'Error creating space'); await throwOnError(r, 'Error creating space');
const d = await r.json(); const d = await r.json();
MemoroEvents.spaceCreated();
return mapSpace(d.space); return mapSpace(d.space);
} }
@ -156,6 +158,7 @@ class SpaceService {
headers: headers(token), headers: headers(token),
}); });
await throwOnError(r, 'Error deleting space'); await throwOnError(r, 'Error deleting space');
MemoroEvents.spaceDeleted();
return true; return true;
} }
@ -165,6 +168,7 @@ class SpaceService {
headers: headers(token), headers: headers(token),
}); });
await throwOnError(r, 'Error leaving space'); await throwOnError(r, 'Error leaving space');
MemoroEvents.spaceLeft();
return true; return true;
} }
@ -184,6 +188,7 @@ class SpaceService {
body: JSON.stringify({ memoId }), body: JSON.stringify({ memoId }),
}); });
await throwOnError(r, 'Error linking memo to space'); await throwOnError(r, 'Error linking memo to space');
MemoroEvents.memoLinkedToSpace();
return true; return true;
} }
@ -194,6 +199,7 @@ class SpaceService {
body: JSON.stringify({ memoId }), body: JSON.stringify({ memoId }),
}); });
await throwOnError(r, 'Error unlinking memo from space'); await throwOnError(r, 'Error unlinking memo from space');
MemoroEvents.memoUnlinkedFromSpace();
return true; return true;
} }
@ -219,6 +225,7 @@ class SpaceService {
}); });
await throwOnError(r, 'Error inviting user to space'); await throwOnError(r, 'Error inviting user to space');
const d = await r.json(); const d = await r.json();
MemoroEvents.inviteSent();
return d.invite?.id ?? d.inviteId; return d.invite?.id ?? d.inviteId;
} }
@ -247,6 +254,7 @@ class SpaceService {
body: JSON.stringify({ inviteId }), body: JSON.stringify({ inviteId }),
}); });
await throwOnError(r, 'Error accepting invite'); await throwOnError(r, 'Error accepting invite');
MemoroEvents.inviteAccepted();
return true; return true;
} }
@ -257,6 +265,7 @@ class SpaceService {
body: JSON.stringify({ inviteId }), body: JSON.stringify({ inviteId }),
}); });
await throwOnError(r, 'Error declining invite'); await throwOnError(r, 'Error declining invite');
MemoroEvents.inviteDeclined();
return true; return true;
} }

View file

@ -4,6 +4,7 @@
*/ */
import { env } from '$lib/config/env'; import { env } from '$lib/config/env';
import { MemoroEvents } from '@manacore/shared-utils/analytics';
const SERVER_URL = env.server.memoroUrl.replace(/\/$/, ''); const SERVER_URL = env.server.memoroUrl.replace(/\/$/, '');
@ -75,6 +76,7 @@ export async function triggerTranscription({
}; };
} }
MemoroEvents.memoCreated(mediaType);
return { success: true }; return { success: true };
} catch (error) { } catch (error) {
return { return {

View file

@ -1,5 +1,6 @@
import { writable } from 'svelte/store'; import { writable } from 'svelte/store';
import { browser } from '$app/environment'; import { browser } from '$app/environment';
import { MemoroEvents } from '@manacore/shared-utils/analytics';
export type ThemeMode = 'light' | 'dark' | 'system'; export type ThemeMode = 'light' | 'dark' | 'system';
export type ThemeVariant = 'lume' | 'nature' | 'ocean' | 'stone'; export type ThemeVariant = 'lume' | 'nature' | 'ocean' | 'stone';
@ -63,6 +64,7 @@ function createThemeStore() {
if (browser) { if (browser) {
localStorage.setItem(THEME_STORAGE_KEY, JSON.stringify(newState)); localStorage.setItem(THEME_STORAGE_KEY, JSON.stringify(newState));
applyTheme(newState); applyTheme(newState);
MemoroEvents.themeChanged(mode);
} }
return newState; return newState;
}); });
@ -73,6 +75,7 @@ function createThemeStore() {
if (browser) { if (browser) {
localStorage.setItem(THEME_STORAGE_KEY, JSON.stringify(newState)); localStorage.setItem(THEME_STORAGE_KEY, JSON.stringify(newState));
applyTheme(newState); applyTheme(newState);
MemoroEvents.themeChanged(variant);
} }
return newState; return newState;
}); });

View file

@ -6,6 +6,7 @@
import RecordingButton from '$lib/components/RecordingButton.svelte'; import RecordingButton from '$lib/components/RecordingButton.svelte';
import BlueprintSelector from '$lib/components/BlueprintSelector.svelte'; import BlueprintSelector from '$lib/components/BlueprintSelector.svelte';
import AdviceCarousel from '$lib/components/AdviceCarousel.svelte'; import AdviceCarousel from '$lib/components/AdviceCarousel.svelte';
import { MemoroEvents } from '@manacore/shared-utils/analytics';
// Standard blueprint ID - matches the mobile app constant // Standard blueprint ID - matches the mobile app constant
const STANDARD_BLUEPRINT_ID = '11111111-2222-3333-4444-555555555555'; const STANDARD_BLUEPRINT_ID = '11111111-2222-3333-4444-555555555555';
@ -14,6 +15,7 @@
function handleSelectBlueprint(blueprintId: string | null) { function handleSelectBlueprint(blueprintId: string | null) {
selectedBlueprintId = blueprintId; selectedBlueprintId = blueprintId;
if (blueprintId) MemoroEvents.blueprintSelected(blueprintId);
} }
async function handleRecordingComplete(audioBlob: Blob) { async function handleRecordingComplete(audioBlob: Blob) {
@ -25,6 +27,7 @@
try { try {
recording.setStatus('uploading'); recording.setStatus('uploading');
MemoroEvents.recordingCompleted($recording.duration);
const audioDuration = $recording.duration; const audioDuration = $recording.duration;

View file

@ -441,6 +441,39 @@ export const SubscriptionEvents = {
trialEnded: (converted: boolean) => trackEvent('trial_ended', { converted }), trialEnded: (converted: boolean) => trackEvent('trial_ended', { converted }),
}; };
/**
* Memoro App Events
*/
export const MemoroEvents = {
memoCreated: (mediaType?: string) =>
trackEvent('memo_created', mediaType ? { media_type: mediaType } : undefined),
memoDeleted: () => trackEvent('memo_deleted'),
memoCombined: (count: number) => trackEvent('memo_combined', { memo_count: count }),
memoQuestioned: () => trackEvent('memo_questioned'),
recordingStarted: () => trackEvent('recording_started'),
recordingCompleted: (durationSeconds: number) =>
trackEvent('recording_completed', { duration_seconds: durationSeconds }),
recordingAppended: () => trackEvent('recording_appended'),
transcriptionRetried: () => trackEvent('transcription_retried'),
headlineRetried: () => trackEvent('headline_retried'),
spaceCreated: () => trackEvent('space_created'),
spaceDeleted: () => trackEvent('space_deleted'),
spaceLeft: () => trackEvent('space_left'),
memoLinkedToSpace: () => trackEvent('memo_linked_to_space'),
memoUnlinkedFromSpace: () => trackEvent('memo_unlinked_from_space'),
inviteSent: () => trackEvent('invite_sent'),
inviteAccepted: () => trackEvent('invite_accepted'),
inviteDeclined: () => trackEvent('invite_declined'),
meetingBotCreated: (platform: string) => trackEvent('meeting_bot_created', { platform }),
meetingBotStopped: () => trackEvent('meeting_bot_stopped'),
recordingToMemo: () => trackEvent('recording_to_memo'),
blueprintSelected: (blueprintId: string) =>
trackEvent('blueprint_selected', { blueprint_id: blueprintId }),
playbackStarted: () => trackEvent('playback_started'),
settingsUpdated: (setting: string) => trackEvent('settings_updated', { setting }),
themeChanged: (theme: string) => trackEvent('theme_changed', { theme }),
};
/** /**
* General App Events * General App Events
*/ */