Skip to content

Commit

Permalink
add analytics urls also to config
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhil-narayana-klevu committed Apr 2, 2024
1 parent b8a46d6 commit 6e330b1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
45 changes: 40 additions & 5 deletions examples/react-klevu-ui/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,15 @@ KlevuConfig.init({
!!localStorage.getItem("klevu-enable-klaviyo") || false,
useConsent: !!localStorage.getItem("klevu-use-consent") || false,
consentGiven: !!localStorage.getItem("klevu-consent-given") || false,
eventsApiV1Url: localStorage.getItem("demo-config")
? JSON.parse(localStorage.getItem("demo-config"))?.eventsApiV1Url
: "",
eventsApiV2Url: localStorage.getItem("demo-config")
? JSON.parse(localStorage.getItem("demo-config"))?.eventsApiV2Url
: "",
recommendationsApiUrl: localStorage.getItem("demo-config")
? JSON.parse(localStorage.getItem("demo-config"))?.recommendationsApiUrl
: "",
})

export const nav = [
Expand All @@ -48,8 +57,37 @@ export function App() {

return (
<KlevuInit
url="https://eucs29v2.ksearchnet.com/cs/v2/search"
apiKey="klevu-164651914788114877"
url={
localStorage.getItem("demo-config")
? JSON.parse(localStorage.getItem("demo-config"))?.url
: "https://eucs29v2.ksearchnet.com/cs/v2/search"
}
eventsApiV1Url={
localStorage.getItem("demo-config")
? JSON.parse(localStorage.getItem("demo-config"))?.eventsApiV1Url
: ""
}
eventsApiV2Url={
localStorage.getItem("demo-config")
? JSON.parse(localStorage.getItem("demo-config"))?.eventsApiV2Url
: ""
}
recommendationsApiUrl={
localStorage.getItem("demo-config")
? JSON.parse(localStorage.getItem("demo-config"))
?.recommendationsApiUrl
: ""
}
apiKey={
localStorage.getItem("demo-config")
? JSON.parse(localStorage.getItem("demo-config"))?.apiKey
: "klevu-164651914788114877"
}
enableKlaviyoConnector={
!!localStorage.getItem("klevu-enable-klaviyo") || false
}
useConsent={!!localStorage.getItem("klevu-use-consent") || false}
consentGiven={!!localStorage.getItem("klevu-consent-given") || false}
settings={{
onItemClick(product, event) {
navigate(`/products/${product.itemGroupId}/${product.id}`)
Expand All @@ -60,9 +98,6 @@ export function App() {
return `/products/${product.itemGroupId}/${product.id}`
},
}}
enableKlaviyoConnector
useConsent={!!localStorage.getItem("klevu-use-consent") || false}
consentGiven={!!localStorage.getItem("klevu-consent-given") || false}
assetsPath="https://resources-webcomponents.klevu.com/latest/klevu-ui"
>
<div>
Expand Down
6 changes: 6 additions & 0 deletions examples/react/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ type Config = {
label: string
emoji: string
}>
recommendationsApiUrl: string
eventsApiV2Url: string
eventsApiV1Url: string
}

let loadedConfig: Config | undefined
Expand Down Expand Up @@ -50,6 +53,9 @@ export const config: Config = {
emoji: "👞",
},
],
eventsApiV1Url: "https://stats.ksearchnet.com/analytics/",
eventsApiV2Url: "https://stats.ksearchnet.com/analytics/collect",
recommendationsApiUrl: "https://config-cdn.ksearchnet.com/recommendations/",
...(loadedConfig ?? {}),
}

Expand Down

0 comments on commit 6e330b1

Please sign in to comment.