mirror of
https://github.com/QuivrHQ/quivr.git
synced 2024-12-15 01:21:48 +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";
|
"use client";
|
||||||
|
|
||||||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
||||||
import { posthog } from 'posthog-js';
|
import { posthog } from "posthog-js";
|
||||||
import { PostHogProvider } from 'posthog-js/react';
|
import { PostHogProvider } from "posthog-js/react";
|
||||||
import { PropsWithChildren, useEffect } from "react";
|
import { PropsWithChildren, useEffect } from "react";
|
||||||
|
|
||||||
import { Menu } from "@/lib/components/Menu/Menu";
|
import { Menu } from "@/lib/components/Menu/Menu";
|
||||||
@ -17,17 +17,16 @@ import { usePageTracking } from "@/services/analytics/june/usePageTracking";
|
|||||||
|
|
||||||
import "../lib/config/LocaleConfig/i18n";
|
import "../lib/config/LocaleConfig/i18n";
|
||||||
|
|
||||||
if (process.env.NEXT_PUBLIC_POSTHOG_KEY != null && process.env.NEXT_PUBLIC_POSTHOG_HOST != null) {
|
if (
|
||||||
posthog.init(
|
process.env.NEXT_PUBLIC_POSTHOG_KEY != null &&
|
||||||
process.env.NEXT_PUBLIC_POSTHOG_KEY,
|
process.env.NEXT_PUBLIC_POSTHOG_HOST != null
|
||||||
{
|
) {
|
||||||
api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
|
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
|
||||||
opt_in_site_apps: true
|
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.
|
// This wrapper is used to make effect calls at a high level in app rendering.
|
||||||
const App = ({ children }: PropsWithChildren): JSX.Element => {
|
const App = ({ children }: PropsWithChildren): JSX.Element => {
|
||||||
const { fetchAllBrains, fetchDefaultBrain, fetchPublicPrompts } =
|
const { fetchAllBrains, fetchDefaultBrain, fetchPublicPrompts } =
|
||||||
@ -42,6 +41,7 @@ const App = ({ children }: PropsWithChildren): JSX.Element => {
|
|||||||
void fetchAllBrains();
|
void fetchAllBrains();
|
||||||
void fetchDefaultBrain();
|
void fetchDefaultBrain();
|
||||||
void fetchPublicPrompts();
|
void fetchPublicPrompts();
|
||||||
|
posthog.identify(session.user.id, { email: session.user.email });
|
||||||
}
|
}
|
||||||
}, [session]);
|
}, [session]);
|
||||||
|
|
||||||
|
@ -1,14 +1,11 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { usePostHog } from 'posthog-js/react';
|
import { usePostHog } from "posthog-js/react";
|
||||||
|
|
||||||
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
import { useSupabase } from "@/lib/context/SupabaseProvider";
|
||||||
|
|
||||||
|
|
||||||
import { useJune } from "./useJune";
|
import { useJune } from "./useJune";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
|
||||||
export const useEventTracking = () => {
|
export const useEventTracking = () => {
|
||||||
const analytics = useJune();
|
const analytics = useJune();
|
||||||
@ -19,9 +16,7 @@ export const useEventTracking = () => {
|
|||||||
event: string,
|
event: string,
|
||||||
properties?: Record<string, unknown>
|
properties?: Record<string, unknown>
|
||||||
): Promise<void> => {
|
): Promise<void> => {
|
||||||
|
|
||||||
posthog.capture(event, properties);
|
posthog.capture(event, properties);
|
||||||
posthog.identify(session?.user.id, { email: session?.user.email });
|
|
||||||
if (analytics === undefined) {
|
if (analytics === undefined) {
|
||||||
console.log("No analytics found");
|
console.log("No analytics found");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user