Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/web/src/astro/index.astro
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ const paramsStr = JSON.stringify(Astro.params);
beforeSend: window.webAnalyticsBeforeSend,
});
const path = this.dataset.pathname;
pageview({ route: computeRoute(path ?? '', params), path });
pageview({
route: computeRoute(path ?? '', params),
path,
title: document.title,
});
} catch (err) {
throw new Error(`Failed to parse WebAnalytics properties: ${err}`);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/web/src/generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,13 @@ function track(
function pageview({
route,
path,
title,
}: {
route?: string | null;
path?: string;
title?: string;
}): void {
window.va?.('pageview', { route, path });
window.va?.('pageview', { route, path, title });
}

export { inject, track, pageview, computeRoute };
Expand Down
7 changes: 6 additions & 1 deletion packages/web/src/react/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function Analytics(
route?: string | null;
path?: string | null;
basePath?: string;
title?: string;
}
): null {
useEffect(() => {
Expand All @@ -55,7 +56,11 @@ function Analytics(
useEffect(() => {
// explicitely track page view, since we disabled auto tracking
if (props.route && props.path) {
pageview({ route: props.route, path: props.path });
pageview({
route: props.route,
path: props.path,
title: document.title,
});
}
}, [props.route, props.path]);

Expand Down
1 change: 1 addition & 0 deletions packages/web/src/remix/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export function Analytics(props: Omit<AnalyticsProps, 'route'>): JSX.Element {
{...props}
basePath={getBasePath()}
framework="remix"
title={document.title}
/>
);
}
Expand Down
6 changes: 5 additions & 1 deletion packages/web/src/sveltekit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ function injectAnalytics(props: Omit<AnalyticsProps, 'framework'> = {}): void {
page.subscribe(({ route, url }) => {
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- route could be undefined in layout.js file
if (route?.id) {
pageview({ route: route.id, path: url.pathname });
pageview({
route: route.id,
path: url.pathname,
title: document.title,
});
}
});
}
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/vue/create-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function createComponent(
pageview({
route: computeRoute(route.path, route.params),
path: route.path,
title: document.title,
});
};
changeRoute();
Expand Down