make-mp-data 1.4.4 → 1.5.0

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.
@@ -0,0 +1,129 @@
1
+ /**
2
+ * This is the default configuration file for the data generator in SIMPLE mode
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
+
10
+
11
+ const Chance = require('chance');
12
+ const chance = new Chance();
13
+ const dayjs = require("dayjs");
14
+ const utc = require("dayjs/plugin/utc");
15
+ dayjs.extend(utc);
16
+ const { uid, comma } = require('ak-tools');
17
+ const { pickAWinner, weighNumRange, date, integer } = require('../src/utils');
18
+
19
+
20
+ /** @type {import('../types').Config} */
21
+ const config = {
22
+ token: "",
23
+ seed: "mirror me",
24
+ numDays: 30, //how many days worth of data
25
+ numEvents: 10000, //how many events
26
+ numUsers: 1000, //how many users
27
+ format: 'json', //csv or json
28
+ region: "US",
29
+ hasAnonIds: true, //if true, anonymousIds are created for each user
30
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
31
+
32
+ events: [
33
+ {
34
+ event: "foo",
35
+ weight: 10,
36
+ properties: {}
37
+ },
38
+ {
39
+ event: "bar",
40
+ weight: 9,
41
+ properties: {}
42
+ },
43
+ {
44
+ event: "baz",
45
+ weight: 8,
46
+ properties: {}
47
+ },
48
+ {
49
+ event: "qux",
50
+ weight: 7,
51
+ properties: {}
52
+ },
53
+ {
54
+ event: "garply",
55
+ weight: 6,
56
+ properties: {}
57
+ },
58
+ {
59
+ event: "durtle",
60
+ weight: 5,
61
+ properties: {}
62
+ },
63
+ {
64
+ event: "linny",
65
+ weight: 4,
66
+ properties: {}
67
+ },
68
+ {
69
+ event: "fonk",
70
+ weight: 3,
71
+ properties: {}
72
+ },
73
+ {
74
+ event: "crumn",
75
+ weight: 2,
76
+ properties: {}
77
+ },
78
+ {
79
+ event: "yak",
80
+ weight: 1,
81
+ properties: {}
82
+ }
83
+ ],
84
+ superProps: {
85
+ color: ["red", "orange", "yellow", "green", "blue", "indigo", "violet"],
86
+ deleteMe: ["hello", "world", "i", "should", "be", "deleted"],
87
+ updateMe: weighNumRange(1, 10)
88
+ },
89
+ userProps: {
90
+ title: chance.profession.bind(chance),
91
+ luckyNumber: weighNumRange(42, 420),
92
+ spiritAnimal: ["duck", "dog", "otter", "penguin", "cat", "elephant", "lion", "cheetah", "giraffe", "zebra", "rhino", "hippo", "whale", "dolphin", "shark", "octopus", "squid", "jellyfish", "starfish", "seahorse", "crab", "lobster", "shrimp", "clam", "snail", "slug", "butterfly", "moth", "bee", "wasp", "ant", "beetle", "ladybug", "caterpillar", "centipede", "millipede", "scorpion", "spider", "tarantula", "tick", "mite", "mosquito", "fly", "dragonfly", "damselfly", "grasshopper", "cricket", "locust", "mantis", "cockroach", "termite", "praying mantis", "walking stick", "stick bug", "leaf insect", "lacewing", "aphid", "cicada", "thrips", "psyllid", "scale insect", "whitefly", "mealybug", "planthopper", "leafhopper", "treehopper", "flea", "louse", "bedbug", "flea beetle", "weevil", "longhorn beetle", "leaf beetle", "tiger beetle", "ground beetle", "lady beetle", "firefly", "click beetle", "rove beetle", "scarab beetle", "dung beetle", "stag beetle", "rhinoceros beetle", "hercules beetle", "goliath beetle", "jewel beetle", "tortoise beetle"]
93
+ },
94
+
95
+ scdProps: {},
96
+ mirrorProps: {
97
+ "newlyCreated": {
98
+ events: "*",
99
+ strategy: "create",
100
+ values: ["fickle", "buckle", "tickle", "mackle"]
101
+
102
+ },
103
+ "deleteMe": {
104
+ events: "*",
105
+ strategy: "delete",
106
+ values: ["ignored"]
107
+ },
108
+ "fillMe": {
109
+ events: "*",
110
+ strategy: "fill",
111
+ values: ["deal", "with", "it"]
112
+ },
113
+ "updateMe": {
114
+ events: "*",
115
+ strategy: "update",
116
+ values: weighNumRange(11, 20)
117
+ },
118
+ },
119
+ groupKeys: [],
120
+ groupProps: {},
121
+ lookupTables: [],
122
+ hook: function (record, type, meta) {
123
+ return record;
124
+ }
125
+ };
126
+
127
+
128
+
129
+ module.exports = config;
package/schemas/simple.js CHANGED
@@ -14,7 +14,7 @@ const dayjs = require("dayjs");
14
14
  const utc = require("dayjs/plugin/utc");
15
15
  dayjs.extend(utc);
16
16
  const { uid, comma } = require('ak-tools');
17
- const { pickAWinner, weightedRange, date, integer } = require('../core/utils');
17
+ const { pickAWinner, weighNumRange, date, integer, weighChoices } = require('../src/utils');
18
18
 
19
19
  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"];
20
20
 
@@ -29,8 +29,8 @@ const config = {
29
29
  numUsers: 500, //how many users
30
30
  format: 'csv', //csv or json
31
31
  region: "US",
32
- anonIds: false, //if true, anonymousIds are created for each user
33
- sessionIds: false, //if true, sessionIds are created for each user
32
+ hasAnonIds: false, //if true, anonymousIds are created for each user
33
+ hasSessionIds: false, //if true, hasSessionIds are created for each user
34
34
  hasAdSpend: false,
35
35
 
36
36
  hasLocation: true,
@@ -40,17 +40,17 @@ const config = {
40
40
  hasBrowser: true,
41
41
  hasCampaigns: true,
42
42
  isAnonymous: false,
43
-
43
+
44
44
 
45
45
  events: [
46
46
  {
47
47
  event: "checkout",
48
48
  weight: 2,
49
49
  properties: {
50
- amount: weightedRange(5, 500, .25),
51
- currency: ["USD", "CAD", "EUR", "BTC", "ETH", "JPY"],
52
- coupon: ["none", "none", "none", "none", "10%OFF", "20%OFF", "10%OFF", "20%OFF", "30%OFF", "40%OFF", "50%OFF"],
53
- numItems: weightedRange(1, 10),
50
+ amount: weighNumRange(5, 500, .25),
51
+ currency: pickAWinner(["USD", "CAD", "EUR", "BTC", "ETH", "JPY"], 0),
52
+ coupon: weighChoices(["none", "none", "none", "none", "10%OFF", "20%OFF", "10%OFF", "20%OFF", "30%OFF", "40%OFF", "50%OFF"]),
53
+ numItems: weighNumRange(1, 10),
54
54
 
55
55
  }
56
56
  },
@@ -58,21 +58,20 @@ const config = {
58
58
  event: "add to cart",
59
59
  weight: 4,
60
60
  properties: {
61
- amount: weightedRange(5, 500, .25),
62
- rating: weightedRange(1, 5),
63
- reviews: weightedRange(0, 35),
61
+ amount: weighNumRange(5, 500, .25),
62
+ rating: weighNumRange(1, 5),
63
+ reviews: weighNumRange(0, 35),
64
64
  isFeaturedItem: [true, false, false],
65
65
  itemCategory: pickAWinner(itemCategories, integer(0, 27)),
66
66
  dateItemListed: date(30, true, 'YYYY-MM-DD'),
67
- itemId: integer(1000, 9999),
68
67
  }
69
68
  },
70
69
  {
71
70
  event: "page view",
72
71
  weight: 10,
73
72
  properties: {
74
- page: ["/", "/", "/help", "/account", "/watch", "/listen", "/product", "/people", "/peace"],
75
- utm_source: ["$organic", "$organic", "$organic", "$organic", "google", "google", "google", "facebook", "facebook", "twitter", "linkedin"],
73
+ page: pickAWinner(["/", "/", "/help", "/account", "/watch", "/listen", "/product", "/people", "/peace"]),
74
+ utm_source: pickAWinner(["$organic", "$organic", "$organic", "$organic", "google", "google", "google", "facebook", "facebook", "twitter", "linkedin"]),
76
75
  }
77
76
  },
78
77
  {
@@ -81,7 +80,7 @@ const config = {
81
80
  properties: {
82
81
  videoCategory: pickAWinner(videoCategories, integer(0, 9)),
83
82
  isFeaturedItem: [true, false, false],
84
- watchTimeSec: weightedRange(10, 600, .25),
83
+ watchTimeSec: weighNumRange(10, 600, .25),
85
84
  quality: ["2160p", "1440p", "1080p", "720p", "480p", "360p", "240p"],
86
85
  format: ["mp4", "avi", "mov", "mpg"],
87
86
  uploader_id: chance.guid.bind(chance)
@@ -95,7 +94,6 @@ const config = {
95
94
  isFeaturedItem: [true, false, false],
96
95
  itemCategory: pickAWinner(itemCategories, integer(0, 27)),
97
96
  dateItemListed: date(30, true, 'YYYY-MM-DD'),
98
- itemId: integer(1000, 9999),
99
97
  }
100
98
  },
101
99
  {
@@ -105,7 +103,6 @@ const config = {
105
103
  isFeaturedItem: [true, false, false],
106
104
  itemCategory: pickAWinner(itemCategories, integer(0, 27)),
107
105
  dateItemListed: date(30, true, 'YYYY-MM-DD'),
108
- itemId: integer(1000, 9999),
109
106
  }
110
107
  },
111
108
  {
@@ -123,9 +120,7 @@ const config = {
123
120
  ],
124
121
  superProps: {
125
122
  platform: ["web", "mobile", "web", "mobile", "web", "web", "kiosk", "smartTV"],
126
- currentTheme: ["light", "dark", "custom", "light", "dark"],
127
- // emotions: generateEmoji(),
128
-
123
+ currentTheme: weighChoices(["light", "dark", "custom", "light", "dark"]),
129
124
  },
130
125
  /*
131
126
  user properties work the same as event properties
@@ -133,20 +128,11 @@ const config = {
133
128
  */
134
129
  userProps: {
135
130
  title: chance.profession.bind(chance),
136
- luckyNumber: weightedRange(42, 420),
137
- spiritAnimal: ["duck", "dog", "otter", "penguin", "cat", "elephant", "lion", "cheetah", "giraffe", "zebra", "rhino", "hippo", "whale", "dolphin", "shark", "octopus", "squid", "jellyfish", "starfish", "seahorse", "crab", "lobster", "shrimp", "clam", "snail", "slug", "butterfly", "moth", "bee", "wasp", "ant", "beetle", "ladybug", "caterpillar", "centipede", "millipede", "scorpion", "spider", "tarantula", "tick", "mite", "mosquito", "fly", "dragonfly", "damselfly", "grasshopper", "cricket", "locust", "mantis", "cockroach", "termite", "praying mantis", "walking stick", "stick bug", "leaf insect", "lacewing", "aphid", "cicada", "thrips", "psyllid", "scale insect", "whitefly", "mealybug", "planthopper", "leafhopper", "treehopper", "flea", "louse", "bedbug", "flea beetle", "weevil", "longhorn beetle", "leaf beetle", "tiger beetle", "ground beetle", "lady beetle", "firefly", "click beetle", "rove beetle", "scarab beetle", "dung beetle", "stag beetle", "rhinoceros beetle", "hercules beetle", "goliath beetle", "jewel beetle", "tortoise beetle"]
131
+ luckyNumber: weighNumRange(42, 420, .3),
132
+ spiritAnimal: pickAWinner(["duck", "dog", "otter", "penguin", "cat", "elephant", "lion", "cheetah", "giraffe", "zebra", "rhino", "hippo", "whale", "dolphin", "shark", "octopus", "squid", "jellyfish", "starfish", "seahorse", "crab", "lobster", "shrimp", "clam", "snail", "slug", "butterfly", "moth", "bee", "wasp", "ant", "beetle", "ladybug", "caterpillar", "centipede", "millipede", "scorpion", "spider", "tarantula", "tick", "mite", "mosquito", "fly", "dragonfly", "damselfly", "grasshopper", "cricket", "locust", "mantis", "cockroach", "termite", "praying mantis", "walking stick", "stick bug", "leaf insect", "lacewing", "aphid", "cicada", "thrips", "psyllid", "scale insect", "whitefly", "mealybug", "planthopper", "leafhopper", "treehopper", "flea", "louse", "bedbug", "flea beetle", "weevil", "longhorn beetle", "leaf beetle", "tiger beetle", "ground beetle", "lady beetle", "firefly", "click beetle", "rove beetle", "scarab beetle", "dung beetle", "stag beetle", "rhinoceros beetle", "hercules beetle", "goliath beetle", "jewel beetle", "tortoise beetle"])
138
133
  },
139
-
140
134
  scdProps: {},
141
- mirrorProps: {
142
- isBot: { events: "*", values: [false, false, false, false, true] },
143
- profit: { events: ["checkout"], values: [4, 2, 42, 420] },
144
- watchTimeSec: {
145
- events: ["watch video"],
146
- values: weightedRange(50, 1200, 6)
147
- }
148
-
149
- },
135
+ mirrorProps: {},
150
136
 
151
137
  /*
152
138
  for group analytics keys, we need an array of arrays [[],[],[]]
package/scratch.mjs CHANGED
@@ -1,29 +1,49 @@
1
- import main from "./core/index.js";
2
- import amir from './customers/amir.js';
1
+ /*
2
+ ----
3
+ TO DOs
4
+ ----
5
+ */
6
+
7
+ //!feature: fixedTimeFunnel? if set this funnel will occur for all users at the same time ['cards charged', 'charge complete']
8
+ //!feature: churn ... is churnFunnel, possible to return, etc
9
+ //!feature: send SCD data to mixpanel (blocked on dev)
10
+ //!feature: send and map lookup tables to mixpanel (also blocked on dev)
11
+ //!bug: using --mc flag reverts to --complex for some reason
12
+
13
+
14
+ import main from "./index.js";
15
+
3
16
  import simple from './schemas/simple.js';
4
17
  import funnels from './schemas/funnels.js';
5
18
  import foobar from './schemas/foobar.js';
6
19
  import complex from './schemas/complex.js';
7
- import deepNest from './schemas/deepNest.js';
20
+ import adspend from './schemas/adspend.js'
21
+
8
22
  import anon from './schemas/anon.js';
9
23
  import execSync from 'child_process';
24
+ import mirror from './schemas/mirror.js'
25
+ // import mds from './dungeons/modern-data-stack.js'
26
+ import big from './schemas/big.js'
10
27
 
28
+ const numEvents = 1000;
11
29
 
12
30
  /** @type {main.Config} */
13
31
  const spec = {
14
- ...complex,
15
- writeToDisk: false,
32
+ ...big,
33
+ writeToDisk: true,
16
34
  verbose: true,
17
35
  makeChart: false,
18
- numUsers: 100,
19
- numEvents: 10000,
20
- numDays: 90,
21
- token: ""
36
+ // format: "csv",
37
+ // numEvents,
38
+ // numUsers: numEvents / 100,
39
+
22
40
  };
23
41
 
24
42
 
25
43
  execSync.execSync('npm run prune');
26
- const { eventData,
44
+ const RESULT = await main(spec);
45
+ const {
46
+ eventData,
27
47
  groupProfilesData,
28
48
  lookupTableData,
29
49
  mirrorEventData,
@@ -32,5 +52,7 @@ const { eventData,
32
52
  importResults,
33
53
  files,
34
54
  adSpendData
35
- } = await main(spec);
55
+ } = RESULT;
56
+
57
+
36
58
  debugger;
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable no-unused-vars */
2
2
  // @ts-check
3
- const module = require('../core/index.js');
3
+ const module = require('../index.js/index.js');
4
4
 
5
5
  module({})
package/scripts/new.sh ADDED
@@ -0,0 +1,68 @@
1
+ #!/bin/bash
2
+
3
+ # Ensure the ./path directory exists
4
+ mkdir -p ./dungeons
5
+
6
+ # Generate a random file name with .js extension
7
+ random_file_name=$(mktemp ./dungeons/my-file-XXXXXXXX.js)
8
+
9
+ # Initial text to write to the file
10
+ initial_text='
11
+ const SEED = "my-seed";
12
+ const dayjs = require("dayjs");
13
+ const utc = require("dayjs/plugin/utc");
14
+ dayjs.extend(utc);
15
+ require("dotenv").config();
16
+ const u = require("../src/utils");
17
+ const v = require("ak-tools");
18
+ const chance = u.initChance(SEED);
19
+ const num_users = 25_000
20
+ const days = 100
21
+
22
+ /** @type {import("../types").Config} */
23
+ const config = {
24
+ token: "",
25
+ seed: SEED,
26
+ numDays: days,
27
+ numEvents: num_users * 100,
28
+ numUsers: num_users,
29
+ hasAnonIds: true,
30
+ hasSessionIds: true,
31
+
32
+ hasLocation: true,
33
+ hasAndroidDevices: true,
34
+ hasIOSDevices: true,
35
+ hasDesktopDevices: true,
36
+ hasBrowser: true,
37
+ hasCampaigns: true,
38
+ isAnonymous: false,
39
+ hasAdSpend: true,
40
+
41
+ hasAvatar: true,
42
+ makeChart: false,
43
+
44
+ batchSize: 500_000,
45
+ concurrency: 500,
46
+ writeToDisk: false,
47
+
48
+ funnels: [],
49
+ events: [],
50
+ superProps: {},
51
+ userProps: {},
52
+ scdProps: {},
53
+ mirrorProps: {},
54
+ groupKeys: [],
55
+ groupProps: {},
56
+ lookupTables: [],
57
+ hook: function(record, type, meta) {
58
+ return record;
59
+ }
60
+ };
61
+
62
+ module.exports = config;'
63
+
64
+ # Write the initial text to the new file
65
+ echo "$initial_text" > "$random_file_name"
66
+
67
+ # Output the name of the created file
68
+ echo "File created: $random_file_name"
@@ -15,7 +15,6 @@ by ak@mixpanel.com
15
15
 
16
16
  function cliParams() {
17
17
  console.log(hero);
18
- // @ts-ignore
19
18
  const args = yargs(process.argv.splice(2))
20
19
  .scriptName("make-mp-data")
21
20
  .usage(`\nusage:\nnpx $0 [dataModel.js] [options]
@@ -85,6 +84,13 @@ DATA MODEL: https://github.com/ak--47/make-mp-data/blob/main/default.js
85
84
  describe: 'either US or EU',
86
85
  type: 'string'
87
86
  })
87
+ .option('concurrency', {
88
+ alias: 'conn',
89
+ default: 500,
90
+ demandOption: false,
91
+ describe: 'concurrency level for data generation',
92
+ type: 'number'
93
+ })
88
94
  .options("complex", {
89
95
  demandOption: false,
90
96
  default: false,
@@ -101,7 +107,7 @@ DATA MODEL: https://github.com/ak--47/make-mp-data/blob/main/default.js
101
107
  type: 'boolean',
102
108
  coerce: boolCoerce
103
109
  })
104
- .option("sessionIds", {
110
+ .option("hasSessionIds", {
105
111
  demandOption: false,
106
112
  default: false,
107
113
  describe: 'create session ids in the data',
@@ -109,7 +115,7 @@ DATA MODEL: https://github.com/ak--47/make-mp-data/blob/main/default.js
109
115
  type: 'boolean',
110
116
  coerce: boolCoerce
111
117
  })
112
- .option("anonIds", {
118
+ .option("hasAnonIds", {
113
119
  demandOption: false,
114
120
  default: false,
115
121
  describe: 'create anonymous ids in the data',
@@ -187,6 +193,7 @@ DATA MODEL: https://github.com/ak--47/make-mp-data/blob/main/default.js
187
193
  type: 'boolean',
188
194
  coerce: boolCoerce
189
195
  })
196
+
190
197
  .help()
191
198
  .wrap(null)
192
199
  .argv;