1
0
mirror of https://github.com/uetchy/namae.git synced 2025-08-20 18:08:11 +09:00

chore: add ga events

This commit is contained in:
2020-03-05 22:09:12 +09:00
parent 0fa08f57f3
commit 769548ccc9
6 changed files with 77 additions and 28 deletions

View File

@@ -10,16 +10,47 @@ export function initGA(): void {
}
}
export function sendQueryStatistics(queryLength: number): void {
export function track({
category,
action,
label = undefined,
value = undefined,
}: {
category: string;
action: string;
label?: string;
value?: number;
}) {
if (isProduction) {
ReactGA.event({
category: 'Search',
action: 'New search invoked',
value: queryLength,
category,
action,
label,
value,
});
}
}
export function sendQueryEvent(query: string): void {
track({category: 'Search', action: 'search', label: query});
}
export function sendExampleQueryEvent(query: string): void {
track({category: 'Search', action: 'tryExampleQuery', label: query});
}
export function sendExpandEvent(): void {
track({category: 'Result', action: 'expand'});
}
export function sendAcceptSuggestionEvent(): void {
track({category: 'Suggestion', action: 'accept'});
}
export function sendShuffleSuggestionEvent(): void {
track({category: 'Suggestion', action: 'shuffle'});
}
export function initSentry(): void {
if (isProduction) {
Sentry.init({