diff --git a/src/routes/recipes/[id]/+page.svelte b/src/routes/recipes/[id]/+page.svelte index 2623ea0..f84f10e 100644 --- a/src/routes/recipes/[id]/+page.svelte +++ b/src/routes/recipes/[id]/+page.svelte @@ -355,6 +355,17 @@ } }; document.addEventListener('visibilitychange', onVisibility); + + // Track view per active profile (fire-and-forget). Skipped when no + // profile is active — we'd just be writing rows nobody can sort against later. + if (profileStore.active) { + void fetch(`/api/recipes/${data.recipe.id}/view`, { + method: 'POST', + headers: { 'content-type': 'application/json' }, + body: JSON.stringify({ profile_id: profileStore.active.id }) + }); + } + return () => document.removeEventListener('visibilitychange', onVisibility); });