File tree 3 files changed +307
-273
lines changed
3 files changed +307
-273
lines changed Original file line number Diff line number Diff line change @@ -7,25 +7,24 @@ const SEGMENT_USE_ROUTER = <%= options.useRouter %>
7
7
const SEGMENT_SETTINGS = < %= JSON . stringify ( options . settings ) % >
8
8
9
9
export default function (context, inject) {
10
+ const { app , store } = context
10
11
11
12
const options = {
12
13
writeKey : SEGMENT_WRITE_KEY ,
13
14
disabled : SEGMENT_DISABLED ,
14
15
settings : SEGMENT_SETTINGS
15
16
}
16
17
17
- if ( SEGMENT_USE_ROUTER ) {
18
- options . router = context . app . router
18
+ if (SEGMENT_USE_ROUTER && app . router ) {
19
+ options . router = app . router
19
20
}
20
21
21
22
Vue.use(Segment, options)
22
23
23
- return new Promise((resolve) => {
24
- Vue . $segment . ready ( ( ) => {
25
- context . $segment = Vue . $segment
26
- inject ( 'segment' , Vue . $segment )
27
- resolve ( )
28
- } )
29
- } )
24
+ if (store) {
25
+ store . $segment = Vue . $segment
26
+ }
30
27
28
+ context.$segment = Vue.$segment
29
+ inject('segment', Vue.$segment)
31
30
}
Original file line number Diff line number Diff line change @@ -20,6 +20,9 @@ export default {
20
20
methods: {
21
21
loadSegment () {
22
22
this .$segment .load (process .env .SEGMENT_WRITE_KEY )
23
+ this .$segment .ready (() => {
24
+ console .log (' ready' )
25
+ })
23
26
}
24
27
}
25
28
}
You can’t perform that action at this time.
0 commit comments