mirror of
https://github.com/coollabsio/coolify-docs.git
synced 2026-06-19 07:35:55 +00:00
feat: korrektly click analytics
This commit is contained in:
@@ -19,6 +19,7 @@ const isLoading = ref(false)
|
||||
const selectedIndex = ref(0)
|
||||
const searchInputRef = ref<HTMLInputElement | null>(null)
|
||||
const searchError = ref<string | null>(null)
|
||||
const searchQueryId = ref<string | null>(null)
|
||||
|
||||
// Korrektly SDK configuration
|
||||
const korrektlyConfig = {
|
||||
@@ -60,6 +61,7 @@ const clearSearch = () => {
|
||||
searchResults.value = []
|
||||
selectedIndex.value = 0
|
||||
searchError.value = null
|
||||
searchQueryId.value = null
|
||||
isLoading.value = false
|
||||
}
|
||||
|
||||
@@ -161,6 +163,9 @@ const performSearch = async (query: string) => {
|
||||
// The API returns { success, data: { results: [...] } }
|
||||
const results = response?.data?.results || response?.results || response?.chunks || []
|
||||
|
||||
// Capture search_query_id for click tracking
|
||||
searchQueryId.value = response?.data?.search_query_id || null
|
||||
|
||||
searchResults.value = results.map((chunk: any) => transformSearchResult(chunk))
|
||||
|
||||
selectedIndex.value = 0
|
||||
@@ -248,7 +253,27 @@ const createBreadcrumb = (hierarchy: string[], url: string): string => {
|
||||
: urlParts.join(' / ')
|
||||
}
|
||||
|
||||
const trackClick = async (chunkId: string, position: number) => {
|
||||
if (!korrektlySDK || !searchQueryId.value || !korrektlyConfig.datasetId) {
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await korrektlySDK.trackClick(korrektlyConfig.datasetId, {
|
||||
search_query_id: searchQueryId.value,
|
||||
chunk_id: chunkId,
|
||||
position,
|
||||
})
|
||||
} catch (error) {
|
||||
// Log error but don't block navigation
|
||||
console.error('Failed to track click:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const navigateToResult = (result: SearchResult) => {
|
||||
// Track click in fire-and-forget manner
|
||||
trackClick(result.id, selectedIndex.value)
|
||||
|
||||
window.location.href = result.url
|
||||
closeSearch()
|
||||
}
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@
|
||||
"transform-openapi": "tsx scripts/convert-openapi.ts"
|
||||
},
|
||||
"dependencies": {
|
||||
"@korrektly/sdk": "^0.1.1",
|
||||
"@korrektly/sdk": "^0.1.4",
|
||||
"@vueuse/core": "12.5.0",
|
||||
"globe.gl": "2.39.7",
|
||||
"vitepress-openapi": "0.0.3-alpha.78"
|
||||
|
||||
Reference in New Issue
Block a user