Skip to content

Commit 9d25dac

Browse files
committed
feat: event tracking errors
1 parent 9230024 commit 9d25dac

File tree

2 files changed

+53
-5
lines changed

2 files changed

+53
-5
lines changed

studio/src/components/onboarding/step-1.tsx

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,19 @@ export const Step1 = () => {
6262
const { mutate, isPending } = useMutation(createOnboarding, {
6363
onSuccess: (d) => {
6464
if (d.response?.code !== EnumStatusCode.OK) {
65+
const description = d.response?.details ?? 'We had issues with storing your data. Please try again.';
6566
toast({
66-
description: d.response?.details ?? 'We had issues with storing your data. Please try again.',
67+
description,
6768
duration: 3000,
6869
});
70+
captureOnboardingEvent(posthog, {
71+
name: 'onboarding_step_failed',
72+
options: {
73+
step_name: 'welcome',
74+
error_category: 'resource',
75+
error_message: description,
76+
},
77+
});
6978
return;
7079
}
7180

@@ -85,10 +94,19 @@ export const Step1 = () => {
8594
router.push('/onboarding/2');
8695
},
8796
onError: (error) => {
97+
const description = error.details.toString() ?? 'We had issues with storing your data. Please try again.';
8898
toast({
89-
description: error.details.toString() ?? 'We had issues with storing your data. Please try again.',
99+
description,
90100
duration: 3000,
91101
});
102+
captureOnboardingEvent(posthog, {
103+
name: 'onboarding_step_failed',
104+
options: {
105+
step_name: 'welcome',
106+
error_category: 'resource',
107+
error_message: description,
108+
},
109+
});
92110
},
93111
});
94112

studio/src/components/onboarding/step-2.tsx

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export const Step2 = () => {
138138
return () => clearTimeout(timer);
139139
}, [pollingEpoch]);
140140

141-
const { data, isError } = useQuery(
141+
const { data, isError, error } = useQuery(
142142
getFederatedGraphByName,
143143
{ name: 'demo', namespace: 'default' },
144144
{
@@ -149,8 +149,38 @@ export const Step2 = () => {
149149
const status = getDemoGraphStatus({ data, isPolling, isError });
150150

151151
useEffect(() => {
152-
if (status === 'ok') setIsPolling(false);
153-
}, [status]);
152+
switch (status) {
153+
case 'ok': {
154+
setIsPolling(false);
155+
break;
156+
}
157+
case 'fail':
158+
case 'error': {
159+
captureOnboardingEvent(posthog, {
160+
name: 'onboarding_step_failed',
161+
options: {
162+
step_name: 'create_graph',
163+
error_category: 'resource',
164+
error_message: 'Demo federated graph not created',
165+
},
166+
});
167+
break;
168+
}
169+
}
170+
}, [status, posthog]);
171+
172+
useEffect(() => {
173+
if (!isError) return;
174+
175+
captureOnboardingEvent(posthog, {
176+
name: 'onboarding_step_failed',
177+
options: {
178+
step_name: 'create_graph',
179+
error_category: 'resource',
180+
error_message: error.message,
181+
},
182+
});
183+
}, [isError, error, posthog]);
154184

155185
return (
156186
<OnboardingContainer>

0 commit comments

Comments
 (0)