make-mp-data 1.0.3 → 1.0.5

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.
Files changed (3) hide show
  1. package/default.js +1 -1
  2. package/index.js +20 -12
  3. package/package.json +1 -1
package/default.js CHANGED
@@ -94,7 +94,7 @@ const config = {
94
94
  each pair represents a group_key and the number of profiles for that key
95
95
  */
96
96
  groupKeys: [
97
- ['company_id', 250],
97
+ ['company_id', 350],
98
98
 
99
99
  ],
100
100
  groupProps: {
package/index.js CHANGED
@@ -53,7 +53,7 @@ if (suppliedConfig) {
53
53
  config = require(path.resolve(suppliedConfig));
54
54
  } else {
55
55
  console.log(`... using default configuration ...\n`);
56
- config = require(path.resolve("./default.js"));
56
+ config = require("./default.js");
57
57
  }
58
58
 
59
59
  //override config with cli params
@@ -115,7 +115,7 @@ async function main(config) {
115
115
  const firstEvents = events.filter((e) => e.isFirstEvent);
116
116
  const eventData = [];
117
117
  const userProfilesData = [];
118
- const scdTableData = [];
118
+ let scdTableData = [];
119
119
  const groupProfilesData = [];
120
120
  const lookupTableData = [];
121
121
  const avgEvPerUser = Math.floor(numEvents / numUsers);
@@ -158,6 +158,9 @@ async function main(config) {
158
158
  );
159
159
  }
160
160
  }
161
+ //flatten SCD
162
+ scdTableData = scdTableData.flat();
163
+
161
164
  console.log("\n");
162
165
 
163
166
  // make group profiles
@@ -205,13 +208,18 @@ async function main(config) {
205
208
  for (const pair of pairs) {
206
209
  const [paths, data] = pair;
207
210
  for (const path of paths) {
208
- if (format === "csv") {
209
- console.log(`writing ${path}`);
210
- const csv = Papa.unparse(data, {});
211
- await touch(path, csv);
212
- console.log(`\tdone\n`);
213
- } else {
214
- await touch(path, data, true);
211
+ let datasetsToWrite;
212
+ if (data?.[0]?.["key"]) datasetsToWrite = data.map(d => d.data);
213
+ else datasetsToWrite = [data];
214
+ for (const writeData of datasetsToWrite) {
215
+ if (format === "csv") {
216
+ console.log(`writing ${path}`);
217
+ const csv = Papa.unparse(writeData, {});
218
+ await touch(path, csv);
219
+ console.log(`\tdone\n`);
220
+ } else {
221
+ await touch(path, data, true);
222
+ }
215
223
  }
216
224
  }
217
225
  }
@@ -379,10 +387,10 @@ main(config)
379
387
  groups: comma(groupSuccess || 0),
380
388
  bytes: bytesHuman(bytes || 0)
381
389
  };
382
- console.table(stats);
390
+ if (bytes > 0) console.table(stats);
383
391
  console.log(`\nfiles written to ${folder}...`);
384
- console.log("\t" + files.flat().join('\t\n'));
385
- console.log(`------------------SUMMARY------------------\n\n\n`);
392
+ console.log("\t" + files.flat().join('\n\t'));
393
+ console.log(`\n------------------SUMMARY------------------\n\n\n`);
386
394
  })
387
395
  .catch((e) => {
388
396
  console.log(`------------------ERROR------------------`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-mp-data",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "builds all mixpanel primitives for a given project",
5
5
  "main": "index.js",
6
6
  "scripts": {