-
-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
189 additions
and
586 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { Search } from "./Search"; | ||
|
||
export { Search }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export const ossSuggestions = [ | ||
'What languages are supported?', | ||
'How do I write an Orama plugin?', | ||
'How do I perform vector search with OSS Orama?', | ||
] | ||
|
||
export const cloudSuggestions = [ | ||
'What is an Orama index?', | ||
'How do I perform vector search with Orama Cloud?', | ||
'What is an answer session?', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import type { OramaClient } from "@oramacloud/client" | ||
|
||
export function getCurrentCategory() { | ||
const url = new URL(window.location.href).pathname | ||
|
||
if (url.startsWith('/cloud')) return 'Cloud' | ||
if (url.startsWith('/open-source')) return 'Open Source' | ||
|
||
return null | ||
} | ||
|
||
export function getOramaUserId() { | ||
if (typeof document === 'undefined' || typeof window === 'undefined') return | ||
|
||
const cookies = document.cookie.split(';') | ||
const oid = cookies.find(cookie => cookie.startsWith('oid=')) | ||
|
||
if (oid) { | ||
return oid.split('=')[1] | ||
} | ||
|
||
return undefined | ||
} | ||
|
||
export function userSessionRefresh(client: OramaClient, userId: string, updateCallback: (userId: string) => void) { | ||
const currentUserId = getOramaUserId(); | ||
if (currentUserId !== userId) { | ||
console.log('User ID changed:', currentUserId); | ||
client.reset(); | ||
updateCallback(currentUserId); | ||
} | ||
} | ||
|
||
export function searchSessionTracking(client: OramaClient, userId: string) { | ||
if (!window?.posthog) return | ||
try { | ||
if (userId) { | ||
// TODO: remove this console.log | ||
console.log('Identifying user with Cookie ID:', userId) | ||
client.identify(userId); | ||
} else { | ||
// TODO: remove this console.log | ||
console.log('Identifying session with PostHog:', window.posthog.get_distinct_id()) | ||
client.alias(window.posthog.get_distinct_id()); | ||
} | ||
} catch (error) { | ||
console.log(`Error setting identity: ${error}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
interface Window { | ||
posthog: { | ||
identify: (userId: string) => void | ||
get_distinct_id: () => string | ||
capture: (event: string, properties?: any) => void | ||
} | ||
} |
Oops, something went wrong.