Skip to content

Commit 76c68af

Browse files
posthog events
1 parent 8ba9bb2 commit 76c68af

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

packages/web/src/app/api/(server)/ee/oauth/register/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { z } from 'zod';
1010
const registerRequestSchema = z.object({
1111
client_name: z.string().min(1),
1212
redirect_uris: z.array(z.string().url()).min(1),
13-
logo_uri: z.string().nullish(),
13+
logo_uri: z.string().url().nullish(),
1414
});
1515

1616
export const POST = apiHandler(async (request: NextRequest) => {

packages/web/src/app/oauth/authorize/components/consentScreen.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import { isServiceError } from '@/lib/utils';
66
import { ClientIcon } from './clientIcon';
77
import Image from 'next/image';
88
import logo from '@/public/logo_512.png';
9-
import { useState } from 'react';
9+
import { useEffect, useState } from 'react';
10+
import useCaptureEvent from '@/hooks/useCaptureEvent';
1011

1112
interface ConsentScreenProps {
1213
clientId: string;
@@ -30,8 +31,14 @@ export function ConsentScreen({
3031
userEmail,
3132
}: ConsentScreenProps) {
3233
const [pending, setPending] = useState<'approve' | 'deny' | null>(null);
34+
const captureEvent = useCaptureEvent();
35+
36+
useEffect(() => {
37+
captureEvent('wa_oauth_consent_viewed', { clientId, clientName });
38+
}, [captureEvent, clientId, clientName]);
3339

3440
const onApprove = async () => {
41+
captureEvent('wa_oauth_authorization_approved', { clientId, clientName });
3542
setPending('approve');
3643
const result = await approveAuthorization({ clientId, redirectUri, codeChallenge, resource, state });
3744
if (isServiceError(result)) {
@@ -42,6 +49,7 @@ export function ConsentScreen({
4249
};
4350

4451
const onDeny = async () => {
52+
captureEvent('wa_oauth_authorization_denied', { clientId, clientName });
4553
setPending('deny');
4654
const result = await denyAuthorization({ redirectUri, state });
4755
if (isServiceError(result)) {

packages/web/src/lib/posthogEvents.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,18 @@ export type PosthogEventMap = {
286286
source: string;
287287
method: string;
288288
},
289+
//////////////////////////////////////////////////////////////////
290+
wa_oauth_consent_viewed: {
291+
clientId: string,
292+
clientName: string,
293+
},
294+
wa_oauth_authorization_approved: {
295+
clientId: string,
296+
clientName: string,
297+
},
298+
wa_oauth_authorization_denied: {
299+
clientId: string,
300+
clientName: string,
301+
},
289302
}
290303
export type PosthogEvent = keyof PosthogEventMap;

0 commit comments

Comments
 (0)