Skip to content

Commit c1e1db7

Browse files
authored
fix(vue): Do not depend on window.location for SSR environments (#7518)
When rendering in an SSR environment, `window.location` may not be defined. In this case, we should not error but just not start a transaction.
1 parent 1cff697 commit c1e1db7

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/vue/src/router.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ export function vueRouterInstrumentation(
6565

6666
// We have to start the pageload transaction as early as possible (before the router's `beforeEach` hook
6767
// is called) to not miss child spans of the pageload.
68-
if (startTransactionOnPageLoad) {
68+
// We check that window & window.location exists in order to not run this code in SSR environments.
69+
if (startTransactionOnPageLoad && WINDOW && WINDOW.location) {
6970
startTransaction({
7071
name: WINDOW.location.pathname,
7172
op: 'pageload',

0 commit comments

Comments
 (0)