This repository was archived by the owner on Mar 21, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 8 files changed +38
-19
lines changed Expand file tree Collapse file tree 8 files changed +38
-19
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ window.ga = jest.fn()
66let $vm
77
88beforeEach ( ( ) => {
9+ window . ga . mockClear ( )
10+
911 Vue . use ( VueAnalytics , {
1012 id : 'UA-1234-5'
1113 } )
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ window.ga = jest.fn()
66let $vm
77
88beforeEach ( ( ) => {
9+ window . ga . mockClear ( )
10+
911 Vue . config . errorHandler = jest . fn ( )
1012
1113 Vue . use ( VueAnalytics , {
Original file line number Diff line number Diff line change @@ -30,6 +30,8 @@ window.ga = jest.fn()
3030let $vm
3131
3232beforeEach ( done => {
33+ window . ga . mockClear ( )
34+
3335 Vue . use ( VueRouter )
3436
3537 const router = new VueRouter ( {
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ window.ga = jest.fn()
66let $vm
77
88beforeEach ( ( ) => {
9+ window . ga . mockClear ( )
10+
911 Vue . use ( VueAnalytics , {
1012 id : 'UA-1234-5'
1113 } )
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ window.ga = jest.fn()
66let $vm
77
88beforeEach ( ( ) => {
9+ window . ga . mockClear ( )
10+
911 Vue . use ( VueAnalytics , {
1012 id : 'UA-1234-5'
1113 } )
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ window.ga = jest.fn()
66let $vm
77
88beforeEach ( ( ) => {
9+ window . ga . mockClear ( )
10+
911 Vue . use ( VueAnalytics , {
1012 id : 'UA-1234-5'
1113 } )
Original file line number Diff line number Diff line change @@ -6,6 +6,8 @@ window.ga = jest.fn()
66let $vm
77
88beforeEach ( ( ) => {
9+ window . ga . mockClear ( )
10+
911 Vue . use ( VueAnalytics , {
1012 id : 'UA-1234-5'
1113 } )
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