Skip to content

Commit 02dedae

Browse files
committed
Update analytics for receipt scanning
1 parent b6a0172 commit 02dedae

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/app/groups/[groupId]/expenses/create-from-receipt-button.tsx

+7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
ReceiptExtractedInfo,
66
extractExpenseInformationFromImage,
77
} from '@/app/groups/[groupId]/expenses/create-from-receipt-button-actions'
8+
import { useAnalytics } from '@/components/track-page'
89
import { Badge } from '@/components/ui/badge'
910
import { Button } from '@/components/ui/button'
1011
import {
@@ -54,9 +55,11 @@ export function CreateFromReceiptButton({
5455
| (ReceiptExtractedInfo & { url: string; width?: number; height?: number })
5556
>(null)
5657
const isDesktop = useMediaQuery('(min-width: 640px)')
58+
const sendEvent = useAnalytics()
5759

5860
const handleFileChange = async (file: File) => {
5961
const upload = async () => {
62+
sendEvent({ event: 'expense: scan receipt', props: { groupId } })
6063
try {
6164
setPending(true)
6265
console.log('Uploading image…')
@@ -204,6 +207,10 @@ export function CreateFromReceiptButton({
204207
disabled={pending || !receiptInfo}
205208
onClick={() => {
206209
if (!receiptInfo) return
210+
sendEvent({
211+
event: 'expense: create from receipt',
212+
props: { groupId },
213+
})
207214
router.push(
208215
`/groups/${groupId}/expenses/create?amount=${
209216
receiptInfo.amount

src/components/track-page.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ type Event =
99
| { event: 'group: create'; props: {} }
1010
| { event: 'group: update'; props: { groupId: string } }
1111
| { event: 'expense: create'; props: { groupId: string } }
12+
| { event: 'expense: scan receipt'; props: { groupId: string } }
13+
| { event: 'expense: create from receipt'; props: { groupId: string } }
1214
| { event: 'expense: update'; props: { groupId: string; expenseId: string } }
1315
| { event: 'expense: delete'; props: { groupId: string; expenseId: string } }
1416
| { event: 'group: export expenses'; props: { groupId: string } }

0 commit comments

Comments
 (0)