Skip to content

Commit dcf5e78

Browse files
committed
config initialize added
1 parent e84703e commit dcf5e78

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

README.md

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,17 @@ Vue.use(VueMixpanel, {
3535

3636
## Example Usage
3737

38-
#### track an event
38+
#### Initialize with config
39+
```
40+
Vue.use(VueMixpanel, {
41+
token: YOUR_TOKEN,
42+
config: {
43+
debug: true
44+
}
45+
})
46+
```
47+
48+
#### Track an event
3949
```
4050
this.$mixpanel.track('event name', {
4151
distinct_id: 'unique client id',
@@ -45,12 +55,12 @@ this.$mixpanel.track('event name', {
4555
});
4656
```
4757

48-
#### create an alias
58+
#### Create an alias
4959
```
5060
this.$mixpanel.alias('distinct_id', 'your_alias');
5161
```
5262

53-
#### increment a numeric property
63+
#### Increment a numeric property
5464
```
5565
this.$mixpanel.people.increment('13793', 'games_played');
5666
```

index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@ import Mixpanel from 'mixpanel'
1010

1111
let VueMixpanel = {}
1212

13-
VueMixpanel.install = function (Vue, options) {
14-
Vue.prototype.$mixpanel = Mixpanel.init(options.token)
13+
VueMixpanel.install = function (Vue, { config, token }) {
14+
Vue.prototype.$mixpanel = Mixpanel.init(token)
15+
16+
const endConfig = config || {}
17+
if (endConfig.length > 0) Vue.prototype.$mixpanel.set_config(endConfig)
1518
}
1619

1720
export default VueMixpanel

0 commit comments

Comments
 (0)