diff --git a/src/helpers.js b/src/helpers.js index 236908b..ee03616 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -65,8 +65,10 @@ export function isRouteIgnored (name) { return config.ignoreRoutes.indexOf(name) !== -1 } -export function isRoute (route) { - // just check some random properties that we know - // are inside the route object - return route.query && route.params +export function isRoute (data) { + return data.query && data.params +} + +export function isRouter (data) { + return data.currentRoute } \ No newline at end of file diff --git a/src/lib/page.js b/src/lib/page.js index c29fbda..149e24b 100644 --- a/src/lib/page.js +++ b/src/lib/page.js @@ -6,13 +6,23 @@ import { getQueryString, isRouteIgnored, getRouteAnalytics, - isRoute + isRoute, + isRouter } from '../helpers' export default function page (...args) { + let route + + if (isRouter(args[0])) { + route = args[0].currentRoute + } + if (isRoute(args[0])) { + route = args[0] + } + + if (route) { const { transformQueryString } = config.autoTracking - const route = args[0] const queryString = getQueryString(route.query) const path = route.path + (transformQueryString ? queryString : '')