This repository was archived by the owner on Mar 21, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +24
-19
lines changed Expand file tree Collapse file tree 1 file changed +24
-19
lines changed Original file line number Diff line number Diff line change @@ -25,25 +25,11 @@ export default function page (...args) {
2525 }
2626
2727 if ( route ) {
28- const {
29- router,
30- autoTracking : {
31- transformQueryString,
32- prependBase
33- }
34- } = config
35-
36- const queryString = getQueryString ( route . query )
37- const base = router && router . options . base
38- const needsBase = prependBase && base
39-
40- let path = route . path + ( transformQueryString ? queryString : '' )
41- path = needsBase ? getBasePath ( base , path ) : path
42-
43- set ( 'page' , path )
44- query ( 'send' , 'pageview' )
28+ trackRoute ( route )
4529 } else {
46- set ( 'page' , args [ 0 ] . page )
30+ // We can call with `page('/my/path')`
31+ let page = typeof args [ 0 ] === 'object' ? args [ 0 ] . page : args [ 0 ]
32+ set ( 'page' , page )
4733 query ( 'send' , 'pageview' , ...args )
4834 }
4935}
@@ -68,7 +54,26 @@ export function trackRoute (route) {
6854 return
6955 }
7056
71- page ( proxy ? proxy ( route ) : route )
57+ if ( proxy ) {
58+ page ( proxy ( route ) )
59+ } else {
60+ const {
61+ router,
62+ autoTracking : {
63+ transformQueryString,
64+ prependBase
65+ }
66+ } = config
67+
68+ const queryString = getQueryString ( route . query )
69+ const base = router && router . options . base
70+ const needsBase = prependBase && base
71+
72+ let path = route . path + ( transformQueryString ? queryString : '' )
73+ path = needsBase ? getBasePath ( base , path ) : path
74+
75+ page ( path )
76+ }
7277}
7378
7479export function autoTracking ( ) {
You can’t perform that action at this time.
0 commit comments