Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit 9ae46af

Browse files
fix(trackers): lifecycle hook error
window.ga was initialized after plugin api causing an error for a missing ga property closes #106
1 parent 355f059 commit 9ae46af

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/create-trackers.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ import { getTracker } from './helpers'
66
export default function createTrackers () {
77
const ids = getId()
88

9-
if (!window.ga) {
10-
window.ga = window.ga || function () {
11-
(ga.q = ga.q || []).push(arguments)
12-
}
13-
ga.l = Number(new Date())
14-
}
15-
169
if (config.debug.enabled) {
1710
window.ga_debug = {
1811
trace: config.debug.trace

src/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,13 @@ import analyticsMiddleware from './vuex-middleware'
99
export default function install (Vue, options = {}) {
1010
update(options)
1111

12+
if (!window.ga) {
13+
window.ga = window.ga || function () {
14+
(window.ga.q = window.ga.q || []).push(arguments)
15+
}
16+
window.ga.l = Number(new Date())
17+
}
18+
1219
Vue.directive('ga', ga)
1320

1421
Vue.prototype.$ga = Vue.$ga = lib

0 commit comments

Comments
 (0)