mirror of
https://github.com/StanGirard/quivr.git
synced 2024-11-27 10:20:32 +03:00
feat: 🎸 posthog (#1936)
identify init # Description Please include a summary of the changes and the related issue. Please also include relevant motivation and context. ## Checklist before requesting a review Please delete options that are not relevant. - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my code - [ ] I have commented hard-to-understand areas - [ ] I have ideally added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged ## Screenshots (if appropriate):
This commit is contained in:
parent
c95e0ec00c
commit
5beb5c6829
@ -1,8 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||
import { posthog } from 'posthog-js';
|
||||
import { PostHogProvider } from 'posthog-js/react';
|
||||
import { posthog } from "posthog-js";
|
||||
import { PostHogProvider } from "posthog-js/react";
|
||||
import { PropsWithChildren, useEffect } from "react";
|
||||
|
||||
import { Menu } from "@/lib/components/Menu/Menu";
|
||||
@ -17,17 +17,16 @@ import { usePageTracking } from "@/services/analytics/june/usePageTracking";
|
||||
|
||||
import "../lib/config/LocaleConfig/i18n";
|
||||
|
||||
if (process.env.NEXT_PUBLIC_POSTHOG_KEY != null && process.env.NEXT_PUBLIC_POSTHOG_HOST != null) {
|
||||
posthog.init(
|
||||
process.env.NEXT_PUBLIC_POSTHOG_KEY,
|
||||
{
|
||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
||||
opt_in_site_apps: true
|
||||
},
|
||||
);
|
||||
if (
|
||||
process.env.NEXT_PUBLIC_POSTHOG_KEY != null &&
|
||||
process.env.NEXT_PUBLIC_POSTHOG_HOST != null
|
||||
) {
|
||||
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
|
||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
||||
opt_in_site_apps: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// This wrapper is used to make effect calls at a high level in app rendering.
|
||||
const App = ({ children }: PropsWithChildren): JSX.Element => {
|
||||
const { fetchAllBrains, fetchDefaultBrain, fetchPublicPrompts } =
|
||||
@ -42,6 +41,7 @@ const App = ({ children }: PropsWithChildren): JSX.Element => {
|
||||
void fetchAllBrains();
|
||||
void fetchDefaultBrain();
|
||||
void fetchPublicPrompts();
|
||||
posthog.identify(session.user.id, { email: session.user.email });
|
||||
}
|
||||
}, [session]);
|
||||
|
||||
|
@ -1,14 +1,11 @@
|
||||
"use client";
|
||||
|
||||
import { usePostHog } from 'posthog-js/react';
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
|
||||
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
||||
|
||||
|
||||
import { useJune } from "./useJune";
|
||||
|
||||
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||
export const useEventTracking = () => {
|
||||
const analytics = useJune();
|
||||
@ -19,9 +16,7 @@ export const useEventTracking = () => {
|
||||
event: string,
|
||||
properties?: Record<string, unknown>
|
||||
): Promise<void> => {
|
||||
|
||||
posthog.capture(event, properties);
|
||||
posthog.identify(session?.user.id, { email: session?.user.email });
|
||||
if (analytics === undefined) {
|
||||
console.log("No analytics found");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user