make-mp-data 1.5.5 → 1.5.51

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.
@@ -179,26 +179,35 @@ function day(start, end) {
179
179
  * @param {ValueValid} value
180
180
  */
181
181
  function choose(value) {
182
- // let wasFunctionCalled = false;
183
182
  const chance = getChance();
184
183
 
185
184
  try {
186
185
  // Keep resolving the value if it's a function
187
186
  while (typeof value === 'function') {
188
- value = value();
189
- // wasFunctionCalled = true;
187
+ value = value();
190
188
  }
191
189
 
192
- // allow functions which create arrays of objects to pass through
193
- // if (Array.isArray(value) && wasFunctionCalled && value.length > 1 && value[0] === null) {
194
- // return value.slice(1);
195
- // }
190
+
191
+ // [[],[],[]] should pick one
192
+ if (Array.isArray(value) && Array.isArray(value[0])) {
193
+ return chance.pickone(value);
194
+ }
196
195
 
197
- // Now, if the resolved value is an array, use chance.pickone
198
- if (Array.isArray(value) && hasSameKeys(value)) {
196
+ // [[{}],[{}],[{}]] should return all
197
+ if (Array.isArray(value) && typeof value[0] === "object" && hasSameKeys(value)) {
199
198
  return value;
200
199
  }
201
200
 
201
+ // ["","",""] should pick-a-winner
202
+ if (Array.isArray(value) && typeof value[0] === "string") {
203
+ value = pickAWinner(value)();
204
+ }
205
+
206
+ // [0,1,2] should pick one
207
+ if (Array.isArray(value) && typeof value[0] === "number") {
208
+ return chance.pickone(value);
209
+ }
210
+
202
211
  if (Array.isArray(value)) {
203
212
  return chance.pickone(value);
204
213
  }
@@ -216,8 +225,9 @@ function choose(value) {
216
225
  }
217
226
  catch (e) {
218
227
  console.error(`\n\nerror on value: ${value};\n\n`, e, '\n\n');
228
+ if (process.env?.NODE_ENV === 'dev') debugger;
219
229
  throw e;
220
- return '';
230
+
221
231
  }
222
232
  }
223
233
 
@@ -13,7 +13,7 @@ const u = require('ak-tools');
13
13
 
14
14
  /** @type {import('../types.js').Dungeon} */
15
15
  const config = {
16
- token: "4a68e9ff118e595172b6478dfa88da7c",
16
+ token: "",
17
17
  seed: "quite complexus",
18
18
  numDays: 30, //how many days worth of data
19
19
  numEvents: 100_000, //how many events
@@ -169,21 +169,21 @@ const config = {
169
169
  NPS: {
170
170
  type: "user",
171
171
  frequency: "day",
172
- values: u.weighNumRange(1, 10, 2, 150),
172
+ values: weighNumRange(1, 10, 2, 150),
173
173
  timing: 'fuzzy',
174
174
  max: 10
175
175
  },
176
176
  MRR: {
177
177
  type: "company_id",
178
178
  frequency: "month",
179
- values: u.weighNumRange(0, 10000, .15),
179
+ values: weighNumRange(0, 10000, .15),
180
180
  timing: 'fixed',
181
181
  max: 10
182
182
  },
183
183
  AccountHealthScore: {
184
184
  type: "company_id",
185
185
  frequency: "week",
186
- values: u.weighNumRange(1, 10, .15),
186
+ values: weighNumRange(1, 10, .15),
187
187
  timing: 'fixed',
188
188
  max: 40
189
189
  },
@@ -233,6 +233,20 @@ const config = {
233
233
  "isVerified": [true, true, false, false, false],
234
234
  }
235
235
  },
236
+ groupEvents: [{
237
+ attribute_to_user: false,
238
+ event: "card charged",
239
+ weight: 1,
240
+ frequency: 30,
241
+ group_key: "company_id",
242
+ group_size: 500,
243
+ properties: {
244
+ amount: weighNumRange(5, 500, .25),
245
+ currency: ["USD", "USD", "USD", "CAD", "EUR", "EUR", "BTC", "BTC", "ETH", "JPY"],
246
+ plan: ["basic", "premium", "enterprise"],
247
+ "payment method": []
248
+ }
249
+ }],
236
250
 
237
251
  lookupTables: [
238
252
  {
package/index.js CHANGED
@@ -1059,7 +1059,7 @@ async function userLoop(config, storage, concurrency = 1) {
1059
1059
  usersEvents.push(...data);
1060
1060
  // await eventData.hookPush(data, { profile });
1061
1061
  } else {
1062
- const data = await makeEvent(distinct_id, userFirstEventTime, u.choose(config.events), user.anonymousIds, user.sessionIds, {}, config.groupKeys, true);
1062
+ const data = await makeEvent(distinct_id, userFirstEventTime, u.pick(config.events), user.anonymousIds, user.sessionIds, {}, config.groupKeys, true);
1063
1063
  numEventsPreformed++;
1064
1064
  usersEvents.push(data);
1065
1065
  // await eventData.hookPush(data);
@@ -1231,6 +1231,7 @@ async function sendToMixpanel(config, storage) {
1231
1231
  scdDataToImport = files.filter(f => f.includes(`-SCD-${scdKey}`));
1232
1232
  }
1233
1233
 
1234
+ /** @type {import('mixpanel-import').Options} */
1234
1235
  const options = {
1235
1236
  recordType: "scd",
1236
1237
  scdKey,
@@ -1663,8 +1664,10 @@ if (NODE_ENV !== "prod") {
1663
1664
  bytes: bytesHuman(bytes || 0),
1664
1665
  };
1665
1666
  if (bytes > 0) console.table(stats);
1666
- log(`\nlog written to log.json\n`);
1667
- writeFileSync(path.resolve(folder, "log.json"), JSON.stringify(data?.importResults, null, 2));
1667
+ if (Object.keys(data?.importResults).length) {
1668
+ log(`\nlog written to log.json\n`);
1669
+ writeFileSync(path.resolve(folder, "log.json"), JSON.stringify(data?.importResults, null, 2));
1670
+ }
1668
1671
  // log(" " + files?.flat().join("\n "));
1669
1672
  log(`\n----------------SUMMARY-----------------\n\n\n`);
1670
1673
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-mp-data",
3
- "version": "1.5.05",
3
+ "version": "1.5.051",
4
4
  "description": "builds all mixpanel primitives for a given project",
5
5
  "main": "index.js",
6
6
  "types": "types.d.ts",
File without changes