make-mp-data 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -26,5 +26,5 @@ npx make-mp-data ecommSpec.js --token 1234 --numDays 30 --numUsers 1000 --numEve
26
26
 
27
27
  see `--help` for a full list of options
28
28
 
29
- see `./examples/` for a few `dataModel.js`` examples
29
+ see `./models/` for a few `dataModel.js`` examples
30
30
 
package/index.js CHANGED
@@ -460,12 +460,12 @@ if (require.main === module) {
460
460
  if (complex) {
461
461
  log(`... using default COMPLEX configuration [everything] ...\n`);
462
462
  log(`... for more simple data, don't use the --complex flag ...\n`);
463
- config = require("./examples/complex.js");
463
+ config = require(path.resolve(__dirname, "./models/complex.js"));
464
464
  }
465
465
  else {
466
466
  log(`... using default SIMPLE configuration [events + users] ...\n`);
467
467
  log(`... for more complex data, use the --complex flag ...\n`);
468
- config = require("./examples/simple.js");
468
+ config = require(path.resolve(__dirname, "./models/simple.js"));
469
469
  }
470
470
  }
471
471
 
@@ -0,0 +1,177 @@
1
+ /**
2
+ * This is the default configuration file for the data generator
3
+ * notice how the config object is structured, and see it's type definition in ./types.d.ts
4
+ * feel free to modify this file to customize the data you generate
5
+ * see helper functions in utils.js for more ways to generate data
6
+ */
7
+
8
+
9
+ const Chance = require('chance');
10
+ const chance = new Chance();
11
+ const { weightedRange, makeProducts, date, makeHashTags } = require('../utils.js');
12
+
13
+ /** @type {import('../types.js').Config} */
14
+ const config = {
15
+ token: "",
16
+ seed: "quite complex",
17
+ numDays: 30, //how many days worth of data
18
+ numEvents: 100000, //how many events
19
+ numUsers: 1000, //how many users
20
+ format: 'csv', //csv or json
21
+ region: "US",
22
+ anonIds: true, //if true, anonymousIds are created for each user
23
+ sessionIds: true, //if true, sessionIds are created for each user
24
+
25
+ events: [
26
+ {
27
+ "event": "checkout",
28
+ "weight": 2,
29
+ "properties": {
30
+ amount: weightedRange(5, 500, 1000, .25),
31
+ currency: ["USD", "CAD", "EUR", "BTC", "ETH", "JPY"],
32
+ cart: makeProducts,
33
+ }
34
+ },
35
+ {
36
+ "event": "add to cart",
37
+ "weight": 4,
38
+ "properties": {
39
+ isFeaturedItem: [true, false, false],
40
+ amount: weightedRange(5, 500, 1000, .25),
41
+ rating: weightedRange(1, 5),
42
+ reviews: weightedRange(0, 35),
43
+ product_id: weightedRange(1, 1000)
44
+ }
45
+ },
46
+ {
47
+ "event": "page view",
48
+ "weight": 10,
49
+ "properties": {
50
+ page: ["/", "/", "/help", "/account", "/watch", "/listen", "/product", "/people", "/peace"],
51
+ utm_source: ["$organic", "$organic", "$organic", "$organic", "google", "google", "google", "facebook", "facebook", "twitter", "linkedin"],
52
+ }
53
+ },
54
+ {
55
+ "event": "watch video",
56
+ "weight": 8,
57
+ "properties": {
58
+ category: ["funny", "educational", "inspirational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"],
59
+ hashTags: makeHashTags,
60
+ watchTimeSec: weightedRange(10, 600, 1000, .25),
61
+ quality: ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"],
62
+ format: ["mp4", "avi", "mov", "mpg"],
63
+ uploader_id: chance.guid.bind(chance)
64
+
65
+ }
66
+ },
67
+ {
68
+ "event": "view item",
69
+ "weight": 8,
70
+ "properties": {
71
+ product_id: weightedRange(1, 1000),
72
+ colors: ["light", "dark", "custom", "dark"]
73
+ }
74
+ },
75
+ {
76
+ "event": "save item",
77
+ "weight": 5,
78
+ "properties": {
79
+ product_id: weightedRange(1, 1000),
80
+ colors: ["light", "dark", "custom", "dark"]
81
+ }
82
+ },
83
+ {
84
+ "event": "sign up",
85
+ "isFirstEvent": true,
86
+ "weight": 0,
87
+ "properties": {
88
+ variant: ["A", "B", "C", "Control"],
89
+ experiment: ["no password", "social sign in", "new tutorial"],
90
+ }
91
+ }
92
+ ],
93
+ superProps: {
94
+ platform: ["web", "mobile", "web", "mobile", "web", "kiosk", "smartTV"],
95
+ // emotions: generateEmoji(),
96
+
97
+ },
98
+ /*
99
+ user properties work the same as event properties
100
+ each key should be an array or function reference
101
+ */
102
+ userProps: {
103
+ title: chance.profession.bind(chance),
104
+ luckyNumber: weightedRange(42, 420),
105
+ // vibe: generateEmoji(),
106
+ spiritAnimal: chance.animal.bind(chance)
107
+ },
108
+
109
+ scdProps: {
110
+ plan: ["free", "free", "free", "free", "basic", "basic", "basic", "premium", "premium", "enterprise"],
111
+ MRR: weightedRange(0, 10000, 1000, .15),
112
+ NPS: weightedRange(0, 10, 150, 2),
113
+ marketingOptIn: [true, true, false],
114
+ dateOfRenewal: date(100, false),
115
+ },
116
+
117
+ /*
118
+ for group analytics keys, we need an array of arrays [[],[],[]]
119
+ each pair represents a group_key and the number of profiles for that key
120
+ */
121
+ groupKeys: [
122
+ ['company_id', 350],
123
+
124
+ ],
125
+ groupProps: {
126
+ company_id: {
127
+ $name: () => { return chance.company(); },
128
+ $email: () => { return `CSM: ${chance.pickone(["AK", "Jessica", "Michelle", "Dana", "Brian", "Dave"])}`; },
129
+ "# of employees": weightedRange(3, 10000),
130
+ "sector": ["tech", "finance", "healthcare", "education", "government", "non-profit"],
131
+ "segment": ["enterprise", "SMB", "mid-market"],
132
+ }
133
+ },
134
+
135
+ lookupTables: [
136
+ {
137
+ key: "product_id",
138
+ entries: 1000,
139
+ attributes: {
140
+ category: [
141
+ "Books",
142
+ "Movies",
143
+ "Music",
144
+ "Games",
145
+ "Electronics",
146
+ "Computers",
147
+ "Smart Home",
148
+ "Home",
149
+ "Garden & Tools",
150
+ "Pet Supplies",
151
+ "Food & Grocery",
152
+ "Beauty",
153
+ "Health",
154
+ "Toys",
155
+ "Kids",
156
+ "Baby",
157
+ "Handmade",
158
+ "Sports",
159
+ "Outdoors",
160
+ "Automotive",
161
+ "Industrial",
162
+ "Entertainment",
163
+ "Art"
164
+ ],
165
+ "demand": ["high", "medium", "medium", "low"],
166
+ "supply": ["high", "medium", "medium", "low"],
167
+ "manufacturer": chance.company.bind(chance),
168
+ "price": weightedRange(5, 500, 1000, .25),
169
+ "rating": weightedRange(1, 5),
170
+ "reviews": weightedRange(0, 35)
171
+ }
172
+
173
+ }
174
+ ],
175
+ };
176
+
177
+ module.exports = config;
@@ -0,0 +1,102 @@
1
+ const Chance = require('chance');
2
+ const chance = new Chance();
3
+
4
+ const config = {
5
+ token: "",
6
+ secret: "",
7
+ seed: "get nesty!",
8
+ events: ['watch video', 'upload video', 'like video', 'dislike video', 'subscribe'],
9
+ eventProperties: {
10
+ videoMeta: generateVideoMeta
11
+ },
12
+ userProperties: {
13
+ userMeta: generateUserMeta
14
+
15
+ },
16
+
17
+ groupKeys: [],
18
+ groupProperties: {}
19
+ };
20
+
21
+ let formats = ['2160p', '1440p', '1080p', '720p', '480p', '360p', '240p'];
22
+ let ratios = ['4:3', '16:10', '16:9'];
23
+ let containers = ["WEBM", ["MPG", "MP2", "MPEG"], ["MP4", "M4P", "M4V"], ["AVI", "WMV"], ["MOV", "QT"], ["FLV", "SWF"], "AVCHD"];
24
+ let hashtags = ["#AK", "#bitcoin", "#cureForMiley", "#faceValue", "#blm", "#fwiw", "#inappropriateFuneralSongs", "#jurassicPork", "#lolCats", "#wheatForSheep", "#momTexts", "#myWeirdGymStory", "#poppy", "#resist", "#tbt", "#wilson", "#worstGiftEver", "#yolo", "#phish", "#crypto", "#memes", "#wrongMovie", "#careerEndingTwitterTypos", "#twoThingsThatDontMix"];
25
+ let platforms = ["Web", "Mobile Web", "Native (Android)", "Native (iOS)", "Native (Desktop)", "IoT"];
26
+ let plans = ['free', 'premium', 'casual', 'influencer'];
27
+ let categories = ["Product reviews video", "How-to videos", "Vlogs", "Gaming videos", "Comedy/skit videos", "Haul videos", "Memes/tags", "Favorites/best of", "Educational videos", "Unboxing videos", "Q&A videos", "Collection", "Prank videos"];
28
+ let marketingChannels = ["Organic", "Organic", "Organic", "Organic", "Instagram Ads", "Facebook Ads", "Google Ads", "Youtube Ads", "Instagram Post", "Instagram Post", "Facebook Post"];
29
+
30
+
31
+ function generateVideoMeta() {
32
+
33
+ let videoTemplate = {
34
+ videoFormatInfo: {
35
+ availableFormats: chance.pickset(formats, int(1, formats.length)),
36
+ availableAspectRatios: chance.pickset(ratios, int(1, ratios.length)),
37
+ availableContainerFormats: chance.pickset(containers, int(1, containers.length)),
38
+ observedLatencyTimestamps: chance.pickset([].range(1, 300000), int(1, 40))
39
+ },
40
+ videoStats: {
41
+ numerOfPlays: int(10, 10000000),
42
+ isReccommendedVideo: chance.bool(),
43
+ inPlaylists: chance.pickset(hashtags, int(1, hashtags.length)),
44
+ likers: chance.n(chance.guid, int(3, 100)),
45
+ dislikers: chance.n(chance.guid, int(3, 100)),
46
+ },
47
+ videoContentInfo: {
48
+ categories: {
49
+ hashtags: chance.pickset(hashtags, int(1, 10)),
50
+ category: chance.pickone(categories),
51
+ },
52
+ availibility: {
53
+ hasAdvertisements: chance.bool(),
54
+ canBeSeenOnPlans: chance.pickset(plans, int(1, plans.length)),
55
+ releaseInfo: {
56
+ isReleased: chance.bool({ likelihood: 90 }),
57
+ relaseDate: chance.date({ year: 2021 })
58
+ }
59
+ }
60
+
61
+ },
62
+ uploaderInfo: {
63
+ platform: chance.pickone(platforms),
64
+ uuid: chance.guid(),
65
+ plan: chance.pickone(plans)
66
+ },
67
+ viewerInfo: {
68
+ platform: chance.pickone(platforms),
69
+ uuid: chance.guid(),
70
+ plan: chance.pickone(plans)
71
+ }
72
+ };
73
+
74
+ return videoTemplate;
75
+ }
76
+
77
+ function generateUserMeta() {
78
+
79
+ let userTemplate = {
80
+ favoriteNumber: chance.prime(),
81
+ attributionChain: chance.pickset(marketingChannels, int(1, 10)),
82
+ importantUserDates: {
83
+ firstSeenDate: chance.date({ year: 2010 }),
84
+ firstPurchaseDate: chance.date({ year: 2011 }),
85
+ firstSubscribeDate: chance.date({ year: 2011 }),
86
+ lastPurchaseDate: chance.date({ year: 2012 })
87
+
88
+ },
89
+ plan: chance.pickone(plans),
90
+ followers: chance.n(chance.guid, int(1, 100)),
91
+ follows: chance.n(chance.guid, int(1, 100))
92
+ };
93
+
94
+ return userTemplate;
95
+ }
96
+
97
+
98
+ function int(min, max) {
99
+ return chance.integer({ min, max });
100
+ }
101
+
102
+ module.exports = config;
@@ -0,0 +1,133 @@
1
+ const Chance = require('chance');
2
+ const chance = new Chance();
3
+ const dayjs = require("dayjs");
4
+ const utc = require("dayjs/plugin/utc");
5
+ dayjs.extend(utc);
6
+ const { uid, comma } = require('ak-tools');
7
+ const { weighList, weightedRange, date, integer } = require('../utils')
8
+
9
+ const itemCategories = ["Books", "Movies", "Music", "Games", "Electronics", "Computers", "Smart Home", "Home", "Garden", "Pet", "Beauty", "Health", "Toys", "Kids", "Baby", "Handmade", "Sports", "Outdoors", "Automotive", "Industrial", "Entertainment", "Art", "Food", "Appliances", "Office", "Wedding", "Software"];
10
+
11
+ const videoCategories = ["funny", "educational", "inspirational", "music", "news", "sports", "cooking", "DIY", "travel", "gaming"];
12
+
13
+ /** @type {import('../types').Config} */
14
+ const config = {
15
+ token: "",
16
+ seed: "simple is best",
17
+ numDays: 30, //how many days worth of data
18
+ numEvents: 50000, //how many events
19
+ numUsers: 500, //how many users
20
+ format: 'csv', //csv or json
21
+ region: "US",
22
+ anonIds: false, //if true, anonymousIds are created for each user
23
+ sessionIds: false, //if true, sessionIds are created for each user
24
+
25
+ events: [
26
+ {
27
+ "event": "checkout",
28
+ "weight": 2,
29
+ "properties": {
30
+ amount: weightedRange(5, 500, 1000, .25),
31
+ currency: ["USD", "CAD", "EUR", "BTC", "ETH", "JPY"],
32
+ coupon: ["none", "none", "none", "none", "10%OFF", "20%OFF", "10%OFF", "20%OFF", "30%OFF", "40%OFF", "50%OFF"],
33
+ numItems: weightedRange(1, 10),
34
+
35
+ }
36
+ },
37
+ {
38
+ "event": "add to cart",
39
+ "weight": 4,
40
+ "properties": {
41
+ amount: weightedRange(5, 500, 1000, .25),
42
+ rating: weightedRange(1, 5),
43
+ reviews: weightedRange(0, 35),
44
+ isFeaturedItem: [true, false, false],
45
+ itemCategory: weighList(itemCategories, integer(0, 27)),
46
+ dateItemListed: date(30, true, 'YYYY-MM-DD'),
47
+ itemId: integer(1000, 9999),
48
+ }
49
+ },
50
+ {
51
+ "event": "page view",
52
+ "weight": 10,
53
+ "properties": {
54
+ page: ["/", "/", "/help", "/account", "/watch", "/listen", "/product", "/people", "/peace"],
55
+ utm_source: ["$organic", "$organic", "$organic", "$organic", "google", "google", "google", "facebook", "facebook", "twitter", "linkedin"],
56
+ }
57
+ },
58
+ {
59
+ "event": "watch video",
60
+ "weight": 8,
61
+ "properties": {
62
+ videoCategory: weighList(videoCategories, integer(0, 9)),
63
+ isFeaturedItem: [true, false, false],
64
+ watchTimeSec: weightedRange(10, 600, 1000, .25),
65
+ quality: ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"],
66
+ format: ["mp4", "avi", "mov", "mpg"],
67
+ uploader_id: chance.guid.bind(chance)
68
+
69
+ }
70
+ },
71
+ {
72
+ "event": "view item",
73
+ "weight": 8,
74
+ "properties": {
75
+ isFeaturedItem: [true, false, false],
76
+ itemCategory: weighList(itemCategories, integer(0, 27)),
77
+ dateItemListed: date(30, true, 'YYYY-MM-DD'),
78
+ itemId: integer(1000, 9999),
79
+ }
80
+ },
81
+ {
82
+ "event": "save item",
83
+ "weight": 5,
84
+ "properties": {
85
+ isFeaturedItem: [true, false, false],
86
+ itemCategory: weighList(itemCategories, integer(0, 27)),
87
+ dateItemListed: date(30, true, 'YYYY-MM-DD'),
88
+ itemId: integer(1000, 9999),
89
+ }
90
+ },
91
+ {
92
+ "event": "sign up",
93
+ "isFirstEvent": true,
94
+ "weight": 0,
95
+ "properties": {
96
+ variants: ["A", "B", "C", "Control"],
97
+ flows: ["new", "existing", "loyal", "churned"],
98
+ flags: ["on", "off"],
99
+ experiment_ids: ["1234", "5678", "9012", "3456", "7890"],
100
+ multiVariate: [true, false]
101
+ }
102
+ }
103
+ ],
104
+ superProps: {
105
+ platform: ["web", "mobile", "web", "mobile", "web", "web", "kiosk", "smartTV"],
106
+ currentTheme: ["light", "dark", "custom", "light", "dark"],
107
+ // emotions: generateEmoji(),
108
+
109
+ },
110
+ /*
111
+ user properties work the same as event properties
112
+ each key should be an array or function reference
113
+ */
114
+ userProps: {
115
+ title: chance.profession.bind(chance),
116
+ luckyNumber: weightedRange(42, 420),
117
+ spiritAnimal: chance.animal.bind(chance)
118
+ },
119
+
120
+ scdProps: { },
121
+
122
+ /*
123
+ for group analytics keys, we need an array of arrays [[],[],[]]
124
+ each pair represents a group_key and the number of profiles for that key
125
+ */
126
+ groupKeys: [],
127
+ groupProps: {},
128
+ lookupTables: [],
129
+ };
130
+
131
+
132
+
133
+ module.exports = config;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-mp-data",
3
- "version": "1.2.0",
3
+ "version": "1.2.02",
4
4
  "description": "builds all mixpanel primitives for a given project",
5
5
  "main": "index.js",
6
6
  "types": "types.d.ts",
package/tests/e2e.test.js CHANGED
@@ -8,9 +8,9 @@ require('dotenv').config();
8
8
  const { execSync } = require("child_process");
9
9
  const u = require('ak-tools');
10
10
 
11
- const simple = require('../examples/simple');
12
- const complex = require('../examples/complex');
13
- const deep = require('../examples/deepNest');
11
+ const simple = require('../models/simple.js');
12
+ const complex = require('../models/complex.js');
13
+ const deep = require('../models/deepNest.js');
14
14
 
15
15
  const timeout = 60000;
16
16
  const testToken = process.env.TEST_TOKEN;
@@ -90,7 +90,7 @@ describe('cli', () => {
90
90
 
91
91
  test('works as CLI (custom)', async () => {
92
92
  console.log('custom CLI TEST');
93
- const run = execSync(`node ./index.js ./examples/deepNest.js`);
93
+ const run = execSync(`node ./index.js ./models/deepNest.js`);
94
94
  expect(run.toString().trim().includes('have a wonderful day :)')).toBe(true);
95
95
  const csvs = (await u.ls('./data')).filter(a => a.includes('.csv'));
96
96
  expect(csvs.length).toBe(3);