Skip to content

Commit ef18623

Browse files
committed
track in-app ai consent approval and use context query client
1 parent 902e5ee commit ef18623

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

apps/code/src/renderer/features/ai-approval/components/AiApprovalScreen.test.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ vi.mock("@renderer/trpc/client", () => ({
3636
trpcClient: {},
3737
}));
3838

39-
vi.mock("@utils/queryClient", async () => {
40-
const { QueryClient: TestQueryClient } = await import(
41-
"@tanstack/react-query"
42-
);
43-
return { queryClient: new TestQueryClient() };
44-
});
45-
4639
import { AiApprovalScreen } from "./AiApprovalScreen";
4740

4841
function renderInTheme(isAdmin: boolean) {

apps/code/src/renderer/features/ai-approval/components/AiApprovalScreen.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@ import { GearSix, Robot, SignOut, WarningCircle } from "@phosphor-icons/react";
88
import { Button, Callout, Flex, Spinner, Text } from "@radix-ui/themes";
99
import { SHORTCUTS } from "@renderer/constants/keyboard-shortcuts";
1010
import { ANALYTICS_EVENTS } from "@shared/types/analytics";
11-
import { useMutation } from "@tanstack/react-query";
11+
import { useMutation, useQueryClient } from "@tanstack/react-query";
1212
import { track } from "@utils/analytics";
13-
import { queryClient } from "@utils/queryClient";
1413
import { motion } from "framer-motion";
1514
import { useEffect } from "react";
1615
import { useHotkeys } from "react-hotkeys-hook";
@@ -24,12 +23,14 @@ export function AiApprovalScreen({ orgName, isAdmin }: AiApprovalScreenProps) {
2423
const logoutMutation = useLogoutMutation();
2524
const openSettings = useSettingsDialogStore((s) => s.open);
2625
const client = useAuthenticatedClient();
26+
const queryClient = useQueryClient();
2727

2828
const approveMutation = useMutation({
2929
mutationFn: async () => {
3030
await client.approveAiDataProcessing();
3131
},
3232
onSuccess: async () => {
33+
track(ANALYTICS_EVENTS.AI_CONSENT_GRANTED_INAPP);
3334
await queryClient.invalidateQueries({
3435
queryKey: authKeys.currentUsers(),
3536
});

apps/code/src/shared/types/analytics.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,7 @@ export const ANALYTICS_EVENTS = {
656656
ONBOARDING_ABANDONED: "Onboarding abandoned",
657657
AI_CONSENT_GATE_SHOWN: "Ai consent gate shown",
658658
AI_CONSENT_APPROVED: "Ai consent approved",
659+
AI_CONSENT_GRANTED_INAPP: "Ai consent granted in-app",
659660

660661
// Setup / onboarding events
661662
SETUP_DISCOVERY_STARTED: "Setup discovery started",
@@ -768,6 +769,7 @@ export type EventPropertyMap = {
768769
[ANALYTICS_EVENTS.ONBOARDING_ABANDONED]: OnboardingAbandonedProperties;
769770
[ANALYTICS_EVENTS.AI_CONSENT_GATE_SHOWN]: AiConsentGateShownProperties;
770771
[ANALYTICS_EVENTS.AI_CONSENT_APPROVED]: never;
772+
[ANALYTICS_EVENTS.AI_CONSENT_GRANTED_INAPP]: never;
771773

772774
// Setup / onboarding events
773775
[ANALYTICS_EVENTS.SETUP_DISCOVERY_STARTED]: SetupDiscoveryStartedProperties;

0 commit comments

Comments
 (0)