Skip to content

Commit 16e8cc8

Browse files
feat(convex): add throw error button to convex example (#3256)
Add a "Throw Error" button to test PostHog error tracking's first-party Convex integration without depending on posthog.captureException.
1 parent 1acd6fd commit 16e8cc8

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

examples/example-convex/convex/example.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,15 @@ export const testCaptureException = mutation({
115115
},
116116
})
117117

118+
export const testThrowError = mutation({
119+
args: {
120+
errorMessage: v.string(),
121+
},
122+
handler: async (_ctx, args) => {
123+
throw new Error(args.errorMessage)
124+
},
125+
})
126+
118127
// --- Feature flag methods (actions) ---
119128

120129
const featureFlagArgs = {

examples/example-convex/src/App.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ function App() {
122122
const groupIdentifyM = useMutation(api.example.testGroupIdentify)
123123
const aliasM = useMutation(api.example.testAlias)
124124
const captureExceptionM = useMutation(api.example.testCaptureException)
125+
const throwErrorM = useMutation(api.example.testThrowError)
125126

126127
const agentManualA = useAction(api.convexAgent.manualCapture.generate)
127128
const agentTracedA = useAction(api.convexAgent.withTracing.generate)
@@ -431,6 +432,18 @@ function App() {
431432
>
432433
Capture Exception
433434
</button>
435+
<button
436+
{...btnProps('throwError')}
437+
onClick={() =>
438+
run('throwError', () =>
439+
throwErrorM({
440+
errorMessage: errorMsg,
441+
})
442+
)
443+
}
444+
>
445+
Throw Error
446+
</button>
434447
</div>
435448
</Section>
436449

0 commit comments

Comments
 (0)