Skip to content

Commit 3481c77

Browse files
committed
track in-app ai consent approval and use context query client
1 parent af40e3a commit 3481c77

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
@@ -743,6 +743,7 @@ export const ANALYTICS_EVENTS = {
743743
ONBOARDING_ABANDONED: "Onboarding abandoned",
744744
AI_CONSENT_GATE_SHOWN: "Ai consent gate shown",
745745
AI_CONSENT_APPROVED: "Ai consent approved",
746+
AI_CONSENT_GRANTED_INAPP: "Ai consent granted in-app",
746747

747748
// Setup / onboarding events
748749
SETUP_DISCOVERY_STARTED: "Setup discovery started",
@@ -864,6 +865,7 @@ export type EventPropertyMap = {
864865
[ANALYTICS_EVENTS.ONBOARDING_ABANDONED]: OnboardingAbandonedProperties;
865866
[ANALYTICS_EVENTS.AI_CONSENT_GATE_SHOWN]: AiConsentGateShownProperties;
866867
[ANALYTICS_EVENTS.AI_CONSENT_APPROVED]: never;
868+
[ANALYTICS_EVENTS.AI_CONSENT_GRANTED_INAPP]: never;
867869

868870
// Setup / onboarding events
869871
[ANALYTICS_EVENTS.SETUP_DISCOVERY_STARTED]: SetupDiscoveryStartedProperties;

0 commit comments

Comments
 (0)