From bc54389603c3a31dce72a9767157306c20fbc491 Mon Sep 17 00:00:00 2001 From: Rohan Chaturvedi Date: Thu, 2 Nov 2023 15:09:06 +0530 Subject: [PATCH] feat: posthog (#99) * feat: added posthog analytics --- docker-compose.yml | 1 + frontend/Dockerfile | 1 + frontend/Dockerfile.dev | 6 +++--- frontend/apollo/client.ts | 2 ++ .../app/[team]/apps/[app]/members/page.tsx | 4 ++-- frontend/app/[team]/apps/[app]/page.tsx | 4 ++-- frontend/app/[team]/apps/[app]/tokens/page.tsx | 4 +++- frontend/app/[team]/newdevice/page.tsx | 2 +- frontend/app/[team]/settings/page.tsx | 2 +- frontend/app/[team]/tokens/page.tsx | 4 +++- frontend/app/providers.tsx | 11 ++++++++++- frontend/app/webauth/[requestCode]/page.tsx | 4 ++-- frontend/components/apps/NewAppDialog.tsx | 2 +- .../components/apps/tokens/SecretTokens.tsx | 4 +++- .../components/auth/UnlockKeyringDialog.tsx | 2 +- .../environments/SecretPropertyDiffs.tsx | 18 ++++++++++++------ frontend/components/environments/SecretRow.tsx | 12 ++++++------ frontend/components/logs/SecretLogs.tsx | 10 +++------- .../components/onboarding/AccountPassword.tsx | 4 ++-- .../onboarding/AccountSeedChecker.tsx | 2 +- .../components/onboarding/AccountSeedGen.tsx | 2 +- frontend/contexts/organisationContext.tsx | 12 ++++++++++++ frontend/next.config.js | 6 +++--- frontend/package.json | 1 + frontend/scripts/replace-variable.sh | 1 + frontend/utils/posthog.ts | 15 +++++++++++++++ frontend/yarn.lock | 12 ++++++++++++ staging-docker-compose.yml | 1 + 28 files changed, 106 insertions(+), 43 deletions(-) create mode 100644 frontend/utils/posthog.ts diff --git a/docker-compose.yml b/docker-compose.yml index e8fe87030..1d625ca43 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -31,6 +31,7 @@ services: BACKEND_API_BASE: "http://backend:8000" NEXT_PUBLIC_BACKEND_API_BASE: "${HTTP_PROTOCOL}${HOST}/service" NEXT_PUBLIC_NEXTAUTH_PROVIDERS: "${SSO_PROVIDERS}" + NEXT_PUBLIC_POSTHOG_KEY: "${NEXT_PUBLIC_POSTHOG_KEY}" networks: - phase-net diff --git a/frontend/Dockerfile b/frontend/Dockerfile index a4284a8b5..fa921d4d4 100644 --- a/frontend/Dockerfile +++ b/frontend/Dockerfile @@ -33,6 +33,7 @@ COPY --chown=app:app . . ARG NEXT_PUBLIC_BACKEND_API_BASE=BAKED_NEXT_PUBLIC_BACKEND_API_BASE ARG NEXT_PUBLIC_NEXTAUTH_PROVIDERS=BAKED_NEXT_PUBLIC_NEXTAUTH_PROVIDERS ARG NEXT_PUBLIC_APP_HOST=BAKED_NEXT_PUBLIC_APP_HOST +ARG NEXT_PUBLIC_POSTHOG_KEY=BAKED_NEXT_PUBLIC_POSTHOG_KEY RUN yarn build # ---- Release ---- diff --git a/frontend/Dockerfile.dev b/frontend/Dockerfile.dev index fec896a13..841c6b542 100644 --- a/frontend/Dockerfile.dev +++ b/frontend/Dockerfile.dev @@ -6,12 +6,12 @@ WORKDIR /app # Copy over package files COPY package.json ./ -COPY package-lock.json ./ +COPY yarn.lock ./ # Install dependencies -RUN npm install +RUN yarn install --frozen-lockfile --no-cache && yarn cache clean # Copy all files COPY . . -CMD ["npm", "run", "dev"] \ No newline at end of file +CMD ["yarn", "dev"] \ No newline at end of file diff --git a/frontend/apollo/client.ts b/frontend/apollo/client.ts index 2bbfac83d..e38a0a603 100644 --- a/frontend/apollo/client.ts +++ b/frontend/apollo/client.ts @@ -5,8 +5,10 @@ import { signOut, SignOutParams } from 'next-auth/react' import { UrlUtils } from '@/utils/auth' import axios from 'axios' import { toast } from 'react-toastify' +import posthog from 'posthog-js' export const handleSignout = async (options?: SignOutParams | undefined) => { + posthog.reset() const response = await axios.post( UrlUtils.makeUrl(process.env.NEXT_PUBLIC_BACKEND_API_BASE!, 'logout'), {}, diff --git a/frontend/app/[team]/apps/[app]/members/page.tsx b/frontend/app/[team]/apps/[app]/members/page.tsx index d1a63f3c4..38918692e 100644 --- a/frontend/app/[team]/apps/[app]/members/page.tsx +++ b/frontend/app/[team]/apps/[app]/members/page.tsx @@ -410,7 +410,7 @@ export default function Members({ params }: { params: { team: string; app: strin minLength={16} required autoFocus - className="custom w-full text-zinc-800 font-mono dark:text-white bg-zinc-100 dark:bg-zinc-800 rounded-md" + className="custom w-full text-zinc-800 font-mono dark:text-white bg-zinc-100 dark:bg-zinc-800 rounded-md ph-no-capture" /> -
+