Skip to content

Commit

Permalink
fix: switch to posthog
Browse files Browse the repository at this point in the history
  • Loading branch information
riderx committed Aug 21, 2024
1 parent 83d7cd2 commit 71cc82d
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 7 deletions.
Binary file modified bun.lockb
Binary file not shown.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"langchain": "^0.1.37",
"marked": "^14.0.0",
"openai": "^4.55.9",
"posthog-js": "^1.157.2",
"sharp": "^0.33.4",
"sitemap": "^8.0.0",
"vue": "^3.4.38"
Expand Down
7 changes: 0 additions & 7 deletions src/layouts/Layout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ const isLocalhost = Astro.url.origin.includes('localhost:')
/>
)
}
<script type="text/javascript">
(function(c,l,a,r,i,t,y){
c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
})(window, document, "clarity", "script", "m67pzzvbrn");
</script>
<script defer data-website-id="66bcb7fa4038d5b1e5ea89eb" data-domain="capgo.app" src="https://datafa.st/js/script.js"></script>
{
!isLocalhost && (
Expand Down
35 changes: 35 additions & 0 deletions src/services/posthog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import posthog from 'posthog-js'
import "posthog-js/dist/recorder"
import "posthog-js/dist/surveys"
import "posthog-js/dist/exception-autocapture"
import "posthog-js/dist/tracing-headers"
import "posthog-js/dist/web-vitals"

export function posthigLoader() {
posthog.init('phc_NXDyDajQaTQVwb25DEhIVZfxVUn4R0Y348Z7vWYHZUi', { api_host: 'https://eu.i.posthog.com', person_profiles: 'identified_only' })
}


export function pushEvent(nameEvent: string): void {
posthog.capture(nameEvent);
}

export function setUser(uuid: string, data: {
nickname?: string
phone?: string
email?: string
avatar?: string
}): void {
// console.log('setUser')
posthog.identify(
uuid,
{ email: data.email, name: data.nickname},
);
posthog.setPersonProperties(
{ avatar: data.avatar }
)
}

export function reset(): void {
posthog.reset()
}

0 comments on commit 71cc82d

Please sign in to comment.