- Add NoteCoUsage model and co-usage tracking when viewing notes - Add creationSource field to notes (form/quick/import) - Add dashboard metrics API (/api/metrics) - Add centrality calculation (/api/centrality) - Add feature flags system for toggling features - Add multiline QuickAdd with smart paste type detection - Add internal link suggestions while editing notes - Add type inference for automatic note type detection - Add comprehensive tests for type-inference and link-suggestions Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
26 lines
804 B
TypeScript
26 lines
804 B
TypeScript
'use client'
|
|
|
|
import { useEffect } from 'react'
|
|
import { addToRecentlyViewed, getRecentlyViewedIds } from '@/lib/usage'
|
|
|
|
export function TrackNoteView({ noteId }: { noteId: string }) {
|
|
useEffect(() => {
|
|
addToRecentlyViewed(noteId)
|
|
|
|
// Track co-usage with previously viewed notes
|
|
const recentIds = getRecentlyViewedIds()
|
|
// Track co-usage with up to 3 most recent notes (excluding current)
|
|
const previousNotes = recentIds.filter(id => id !== noteId).slice(0, 3)
|
|
|
|
for (const prevNoteId of previousNotes) {
|
|
fetch('/api/usage/co-usage', {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify({ fromNoteId: prevNoteId, toNoteId: noteId }),
|
|
}).catch(() => {}) // Silently fail
|
|
}
|
|
}, [noteId])
|
|
|
|
return null
|
|
}
|