Skip to content

Commit

Permalink
chore: disable capture unless property
Browse files Browse the repository at this point in the history
  • Loading branch information
urmauur committed Dec 13, 2024
1 parent 6f919e4 commit c9027a9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
22 changes: 10 additions & 12 deletions web/containers/Layout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,6 @@ import {
reduceTransparentAtom,
} from '@/helpers/atoms/Setting.atom'

if (typeof window !== 'undefined') {
posthog.init(POSTHOG_KEY, {
api_host: POSTHOG_HOST,
autocapture: false,
person_profiles: 'always',
persistence: 'localStorage',
})
}

const BaseLayout = () => {
const setMainViewState = useSetAtom(mainViewStateAtom)
const importModelStage = useAtomValue(getImportModelStageAtom)
Expand All @@ -72,6 +63,15 @@ const BaseLayout = () => {

useEffect(() => {
if (productAnalytic) {
posthog.init(POSTHOG_KEY, {
api_host: POSTHOG_HOST,
autocapture: false,
capture_pageview: false,
capture_pageleave: false,
disable_session_recording: true,
person_profiles: 'always',
persistence: 'localStorage',
})
posthog.opt_in_capturing()
posthog.register({ app_version: VERSION })
} else {
Expand Down Expand Up @@ -101,9 +101,7 @@ const BaseLayout = () => {
setShowProductAnalyticPrompt(false)
if (isAllowed) {
posthog.opt_in_capturing()
posthog.capture('user_opt_in', { timestamp: new Date() })
} else {
posthog.capture('user_opt_out', { timestamp: new Date() })
posthog.opt_out_capturing()
}
}
Expand Down Expand Up @@ -176,7 +174,7 @@ const BaseLayout = () => {
<p className="text-[hsla(var(--text-secondary))]">
To improve Jan, we collect anonymous data to understand feature
usage. Your chats and personal information are never tracked. You
can change this anytime in &nbsp;
can change this anytime in&nbsp;
<span className="font-semibold">{`Settings > Privacy.`}</span>
</p>
<p className="mt-6 text-[hsla(var(--text-secondary))]">
Expand Down
2 changes: 0 additions & 2 deletions web/screens/Settings/Privacy/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@ const Privacy = () => {
onChange={(e) => {
if (e.target.checked) {
posthog.opt_in_capturing()
posthog.capture('user_opt_in', { timestamp: new Date() })
} else {
posthog.capture('user_opt_out', { timestamp: new Date() })
posthog.opt_out_capturing()
}
setProductAnalytic(e.target.checked)
Expand Down

0 comments on commit c9027a9

Please sign in to comment.