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:
@@ -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({
|
||||
|
Reference in New Issue
Block a user