Add plausible
This commit is contained in:
parent
48f2c97487
commit
4857800fca
14 changed files with 118 additions and 6 deletions
19
frontend/src/lib/analytics.ts
Normal file
19
frontend/src/lib/analytics.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import { track } from '@plausible-analytics/tracker';
|
||||
|
||||
export function trackEvent(name: string, props?: Record<string, string | number | boolean>) {
|
||||
const stringProps: Record<string, string> | undefined = props
|
||||
? Object.fromEntries(Object.entries(props).map(([k, v]) => [k, String(v)]))
|
||||
: undefined;
|
||||
track(name, { props: stringProps });
|
||||
}
|
||||
|
||||
export function trackRevenue(
|
||||
name: string,
|
||||
amountPence: number,
|
||||
props?: Record<string, string | number | boolean>
|
||||
) {
|
||||
const stringProps = props
|
||||
? Object.fromEntries(Object.entries(props).map(([k, v]) => [k, String(v)]))
|
||||
: undefined;
|
||||
track(name, { props: stringProps, revenue: { amount: amountPence / 100, currency: 'GBP' } });
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue