Skip to content

Commit 6b6809e

Browse files
ricardogobbosouzapi0
authored andcommitted
feat(plugin): support id as a function (asyncID) (#43)
1 parent 8a78c43 commit 6b6809e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/plugin.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
import Vue from 'vue'
22
import VueAnalytics from 'vue-analytics'
33

4-
export default (ctx, inject) => {
4+
export default async (ctx, inject) => {
55
const options = <%= serialize(options) %>
66

7+
if (typeof options.asyncID === 'function') {
8+
options.id = await options.asyncID(ctx)
9+
}
10+
711
Vue.use(VueAnalytics, {...{ router: ctx.app.router }, ...options})
8-
12+
913
ctx.$ga = Vue.$ga
1014
inject('ga', Vue.$ga)
1115
}

0 commit comments

Comments
 (0)