-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugin): support id as a function (asyncID) (#43)
- Loading branch information
1 parent
8a78c43
commit 6b6809e
Showing
1 changed file
with
6 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |