experiments in a post-browser web
10
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix(tools): normalize browser visit types to source enum in import tool

+39
+1
tools/browser-import/src/importers/bookmarks.ts
··· 79 79 title: entry.title, 80 80 folderPath: entry.folderPath, 81 81 dateAdded: entry.dateAdded, 82 + source: 'bookmark', 82 83 sourceProfile: profileName, 83 84 sourceBrowser: browserName, 84 85 importedAt: importTimestamp,
+37
tools/browser-import/src/importers/history.ts
··· 12 12 runInTransaction, 13 13 } from '../datastore.js'; 14 14 15 + /** 16 + * Map browser-specific visit type codes to the normalized source enum. 17 + * 18 + * Firefox visit types: 1=LINK, 2=TYPED, 3=BOOKMARK, 4=EMBED, 5=REDIRECT_PERMANENT, 19 + * 6=REDIRECT_TEMPORARY, 7=DOWNLOAD, 8=FRAMED_LINK 20 + * 21 + * Chrome core transition types (transition & 0xFF): 22 + * 0=LINK, 1=TYPED, 2=AUTO_BOOKMARK, 3=AUTO_SUBFRAME, 4=MANUAL_SUBFRAME, 23 + * 5=GENERATED, 6=AUTO_TOPLEVEL, 7=FORM_SUBMIT, 8=RELOAD, 9=KEYWORD 24 + */ 25 + function mapVisitTypeToSource( 26 + visitType: number | undefined, 27 + browser: BrowserName, 28 + ): 'typed' | 'bookmark' | 'link' | 'direct' { 29 + if (visitType === undefined) return 'direct'; 30 + 31 + if (browser === 'firefox') { 32 + switch (visitType) { 33 + case 2: return 'typed'; 34 + case 3: return 'bookmark'; 35 + case 1: return 'link'; 36 + default: return 'direct'; 37 + } 38 + } 39 + 40 + // Chrome / Brave (Chromium-based) 41 + switch (visitType) { 42 + case 1: return 'typed'; 43 + case 2: // AUTO_BOOKMARK 44 + case 9: return 'bookmark'; // KEYWORD 45 + case 0: return 'link'; 46 + default: return 'direct'; 47 + } 48 + } 49 + 15 50 export function importHistory( 16 51 entries: HistoryEntry[], 17 52 browserName: BrowserName, ··· 58 93 recordVisit(existingId, visit.timestamp, { 59 94 eventType: 'visit', 60 95 visitType: visit.visitType, 96 + source: mapVisitTypeToSource(visit.visitType, browserName), 61 97 sourceBrowser: browserName, 62 98 }); 63 99 } ··· 95 131 recordVisit(itemId, visit.timestamp, { 96 132 eventType: 'visit', 97 133 visitType: visit.visitType, 134 + source: mapVisitTypeToSource(visit.visitType, browserName), 98 135 sourceBrowser: browserName, 99 136 }); 100 137 }
+1
tools/browser-import/src/importers/sessions.ts
··· 58 58 59 59 const metadata: Record<string, unknown> = { 60 60 title: tab.title, 61 + source: 'direct', 61 62 sourceProfile: profileName, 62 63 sourceBrowser: browserName, 63 64 importedAt: importTimestamp,