Browse Source

[Beta] Clean URLs for analytics

main
Dan Abramov 2 years ago
parent
commit
5b8126a115
  1. 3
      beta/src/components/Layout/Feedback.tsx
  2. 3
      beta/src/pages/_app.tsx

3
beta/src/components/Layout/Feedback.tsx

@ -8,8 +8,9 @@ import {ga} from '../../utils/analytics';
export function Feedback({onSubmit = () => {}}: {onSubmit?: () => void}) {
const {asPath} = useRouter();
const cleanedPath = asPath.split(/[\?\#]/)[0];
// Reset on route changes.
return <SendFeedback key={asPath} onSubmit={onSubmit} />;
return <SendFeedback key={cleanedPath} onSubmit={onSubmit} />;
}
const thumbsUpIcon = (

3
beta/src/pages/_app.tsx

@ -42,7 +42,8 @@ export default function MyApp({Component, pageProps}: AppProps) {
useEffect(() => {
const handleRouteChange = (url: string) => {
ga('set', 'page', url);
const cleanedUrl = url.split(/[\?\#]/)[0];
ga('set', 'page', cleanedUrl);
ga('send', 'pageview');
};
router.events.on('routeChangeComplete', handleRouteChange);

Loading…
Cancel
Save