Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
fix(trackers): lifecycle hook error
Browse files Browse the repository at this point in the history
window.ga was initialized after plugin api causing an error for a missing ga property

closes #106
  • Loading branch information
MatteoGabriele committed Apr 5, 2018
1 parent 355f059 commit 9ae46af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 0 additions & 7 deletions src/create-trackers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ import { getTracker } from './helpers'
export default function createTrackers () {
const ids = getId()

if (!window.ga) {
window.ga = window.ga || function () {
(ga.q = ga.q || []).push(arguments)
}
ga.l = Number(new Date())
}

if (config.debug.enabled) {
window.ga_debug = {
trace: config.debug.trace
Expand Down
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import analyticsMiddleware from './vuex-middleware'
export default function install (Vue, options = {}) {
update(options)

if (!window.ga) {
window.ga = window.ga || function () {
(window.ga.q = window.ga.q || []).push(arguments)
}
window.ga.l = Number(new Date())
}

Vue.directive('ga', ga)

Vue.prototype.$ga = Vue.$ga = lib
Expand Down

0 comments on commit 9ae46af

Please sign in to comment.