@@ -15,47 +15,56 @@ For testing purpose, don't forget to [turn it off yourself](https://support.goog
1515### Browser
1616```
1717 <script src="https://unpkg.com/vue/dist/vue.js"></script>
18- <script src="https://unpkg.com/vue-mixpanel@1 .0.7 /index.js"></script>
18+ <script src="https://unpkg.com/vue-mixpanel@2 .0.0 /index.js"></script>
1919```
2020### Package Managers
2121```
2222npm install vue-mixpanel --save
2323yarn add vue-mixpanel --save
24-
25- // require
26- var Vue = require('vue')
27- Vue.use(require('vue-mixpanel'), {
28- token: YOUR_TOKEN
29- })
30-
31- // import
32- import Vue from 'vue'
33- import VueMixpanel from 'vue-mixpanel'
34- Vue.use(VueMixpanel, {
35- token: YOUR_TOKEN
36- })
3724```
3825
3926### How does it work?
4027
41- - Initialize it by using the token given by your [ Mixpanel] ( https://mixpanel.com/ ) account in the ` Vue .use()` inside you ` main.js `
42- - Start using their public API through ` this.$ mixpanel ` in your components.
28+ - Initialize it by using the token given by your [ Mixpanel] ( https://mixpanel.com/ ) account in the ` app .use()` inside you ` main.js `
29+ - Start using their public API with ` inject ` through ` this.mixpanel ` in your components.
4330
4431## Example Usage
4532
46- #### Initialize with config
33+ > If you're using Vue 2 or below, please check the version [ 1.1.0] ( https://github.com/Loschcode/vue-mixpanel/releases/tag/1.1.0 )
34+
35+ #### Initialize with configuration
4736```
48- Vue.use(VueMixpanel, {
37+ import App from './App.vue'
38+ import VueMixpanel from 'vue-mixpanel'
39+
40+ const app = createApp(App)
41+ app.use(VueMixpanel, {
4942 token: YOUR_TOKEN,
5043 config: {
5144 debug: true
5245 }
5346})
47+ app.mount('#app')
48+ ```
49+
50+ Then, you can use it in your components like so
51+
52+ ```
53+ <script>
54+ export default {
55+ inject: ['mixpanel'],
56+ name: 'App',
57+
58+ created () {
59+ this.mixpanel.track('test')
60+ }
61+ }
62+ </script>
5463```
5564
5665#### Track an event
5766```
58- this.$ mixpanel.track('event name', {
67+ this.mixpanel.track('event name', {
5968 distinct_id: 'unique client id',
6069 property_1: 'value 1',
6170 property_2: 'value 2',
@@ -65,12 +74,12 @@ this.$mixpanel.track('event name', {
6574
6675#### Create an alias
6776```
68- this.$ mixpanel.alias('distinct_id', 'your_alias');
77+ this.mixpanel.alias('distinct_id', 'your_alias');
6978```
7079
7180#### Increment a numeric property
7281```
73- this.$ mixpanel.people.increment('13793', 'games_played');
82+ this.mixpanel.people.increment('13793', 'games_played');
7483```
7584
7685## License
0 commit comments