Skip to content

Commit

Permalink
feat(plugin): support id as a function (asyncID) (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ricardogobbosouza authored and pi0 committed Mar 8, 2019
1 parent 8a78c43 commit 6b6809e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/plugin.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import Vue from 'vue'
import VueAnalytics from 'vue-analytics'

export default (ctx, inject) => {
export default async (ctx, inject) => {
const options = <%= serialize(options) %>

if (typeof options.asyncID === 'function') {
options.id = await options.asyncID(ctx)
}

Vue.use(VueAnalytics, {...{ router: ctx.app.router }, ...options})

ctx.$ga = Vue.$ga
inject('ga', Vue.$ga)
}

0 comments on commit 6b6809e

Please sign in to comment.