1 |
|
2 | var Mixpanel = require('./lib/mixpanel-node');
|
3 |
|
4 |
|
5 | var mixpanel = Mixpanel.init('962dbca1bbc54701d402c94d65b4a20e');
|
6 | mixpanel.set_config({ debug: true });
|
7 |
|
8 |
|
9 | mixpanel.track("my event", {
|
10 | distinct_id: "some unique client id",
|
11 | as: "many",
|
12 | properties: "as",
|
13 | you: "want"
|
14 | });
|
15 | mixpanel.track("played_game");
|
16 |
|
17 |
|
18 | mixpanel.people.set("billybob", {
|
19 | $first_name: "Billy",
|
20 | $last_name: "Bob",
|
21 | $created: (new Date('jan 1 2013')).toISOString(),
|
22 | plan: "premium",
|
23 | games_played: 1,
|
24 | points: 0
|
25 | });
|
26 |
|
27 |
|
28 |
|
29 | mixpanel.people.set("billybob", {
|
30 | plan: "premium",
|
31 | games_played: 1
|
32 | }, {
|
33 | $ignore_time: true
|
34 | });
|
35 |
|
36 |
|
37 | mixpanel.people.set("billybob", "plan", "free");
|
38 |
|
39 |
|
40 | mixpanel.people.set_once("billybob", "first_game_play", (new Date('jan 1 2013')).toISOString());
|
41 |
|
42 |
|
43 | mixpanel.people.increment("billybob", "games_played");
|
44 |
|
45 |
|
46 | mixpanel.people.increment("billybob", "points", 15);
|
47 |
|
48 |
|
49 | mixpanel.people.increment("billybob", {"points": 10, "games_played": 1});
|
50 |
|
51 |
|
52 | mixpanel.people.append("billybob", "awards", "Great Player");
|
53 |
|
54 |
|
55 | mixpanel.people.append("billybob", {"awards": "Great Player", "levels_finished": "Level 4"});
|
56 |
|
57 |
|
58 | mixpanel.people.track_charge("billybob", 39.99);
|
59 |
|
60 |
|
61 | mixpanel.people.clear_charges("billybob");
|
62 |
|
63 |
|
64 | mixpanel.people.delete_user("billybob");
|
65 |
|
66 |
|
67 |
|
68 | mixpanel.track("test", function(err) { if (err) { throw err; } });
|
69 |
|
70 |
|
71 | var mixpanel_importer = Mixpanel.init('valid mixpanel token', {
|
72 | key: "valid api key for project"
|
73 | });
|
74 | mixpanel_importer.set_config({ debug: true });
|
75 |
|
76 |
|
77 | mixpanel_importer.track('old event', { gender: '' });
|
78 |
|
79 | mixpanel_importer.import("old event", new Date(2012, 4, 20, 12, 34, 56), {
|
80 | distinct_id: 'billybob',
|
81 | gender: 'male'
|
82 | });
|
83 |
|
84 |
|
85 | mixpanel_importer.import_batch([
|
86 | {
|
87 | event: 'old event',
|
88 | properties: {
|
89 | time: new Date(2012, 4, 20, 12, 34, 56),
|
90 | distinct_id: 'billybob',
|
91 | gender: 'male'
|
92 | }
|
93 | },
|
94 | {
|
95 | event: 'another old event',
|
96 | properties: {
|
97 | time: new Date(2012, 4, 21, 11, 33, 55),
|
98 | distinct_id: 'billybob',
|
99 | color: 'red'
|
100 | }
|
101 | }
|
102 | ]);
|