1
0
mirror of https://github.com/uetchy/namae.git synced 2025-03-17 12:30:32 +09:00

chore: update analytics

This commit is contained in:
uetchy 2020-03-07 12:06:55 +09:00
parent ea61ecc9dc
commit 095895f7cf
3 changed files with 16 additions and 12 deletions

View File

@ -7,10 +7,10 @@ import BarLoader from 'react-spinners/BarLoader';
import {GoInfo} from 'react-icons/go'; import {GoInfo} from 'react-icons/go';
import {IoIosFlash} from 'react-icons/io'; import {IoIosFlash} from 'react-icons/io';
import {useTranslation} from 'react-i18next'; import {useTranslation} from 'react-i18next';
import {sendError, sendExpandEvent} from '../../util/analytics'; import {OutboundLink} from 'react-ga';
import {sendError, sendExpandEvent} from '../../util/analytics';
import {mobile} from '../../util/css'; import {mobile} from '../../util/css';
import {ExternalLink} from '../Links';
const COLORS = { const COLORS = {
available: '#6e00ff', available: '#6e00ff',
@ -210,7 +210,12 @@ export const Result: React.FC<{
<ResultIcon>{icon}</ResultIcon> <ResultIcon>{icon}</ResultIcon>
<ResultName> <ResultName>
{link ? ( {link ? (
<ExternalLink href={link}>{content}</ExternalLink> <OutboundLink
to={link}
eventLabel={link.split('/')[2]}
target="_blank">
{content}
</OutboundLink>
) : ( ) : (
content content
)} )}

View File

@ -20,7 +20,7 @@ const Search: React.FC<{query: string}> = ({query}) => {
id: string; id: string;
}>; }>;
}; };
const repos = response.items; const repos = response.items || [];
return ( return (
<> <>

View File

@ -10,14 +10,13 @@ export function initHistoryWithGA() {
ReactGA.initialize('UA-28919359-15'); ReactGA.initialize('UA-28919359-15');
ReactGA.pageview(window.location.pathname + window.location.search); ReactGA.pageview(window.location.pathname + window.location.search);
history.listen((location) => { history.listen((location) => {
ReactGA.set({page: location.pathname}); ReactGA.pageview(location.pathname + location.search);
ReactGA.pageview(location.pathname);
}); });
} }
return history; return history;
} }
export function track({ export function trackEvent({
category, category,
action, action,
label = undefined, label = undefined,
@ -39,23 +38,23 @@ export function track({
} }
export function sendQueryEvent(query: string): void { export function sendQueryEvent(query: string): void {
track({category: 'Search', action: 'search', label: query}); trackEvent({category: 'Search', action: 'search', label: query});
} }
export function sendExampleQueryEvent(query: string): void { export function sendExampleQueryEvent(query: string): void {
track({category: 'Search', action: 'tryExampleQuery', label: query}); trackEvent({category: 'Search', action: 'tryExampleQuery', label: query});
} }
export function sendExpandEvent(): void { export function sendExpandEvent(): void {
track({category: 'Result', action: 'expand'}); trackEvent({category: 'Result', action: 'expand'});
} }
export function sendAcceptSuggestionEvent(): void { export function sendAcceptSuggestionEvent(): void {
track({category: 'Suggestion', action: 'accept'}); trackEvent({category: 'Suggestion', action: 'accept'});
} }
export function sendShuffleSuggestionEvent(): void { export function sendShuffleSuggestionEvent(): void {
track({category: 'Suggestion', action: 'shuffle'}); trackEvent({category: 'Suggestion', action: 'shuffle'});
} }
export function initSentry(): void { export function initSentry(): void {