mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-22 20:01:57 +00:00
[Beta] Clean URLs for analytics
This commit is contained in:
@@ -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 = (
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user