make-mp-data 2.1.1 → 2.1.3

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.
@@ -361,19 +361,30 @@ async function generateFunnelEvents(
361
361
  );
362
362
 
363
363
  if (index === 0) {
364
- funnelStartTime = dayjs(newEvent.time);
364
+ const parsedTime = dayjs(newEvent.time);
365
+ // Validate the first event's time - if invalid, use TimeSoup-generated time as-is
366
+ funnelStartTime = parsedTime.isValid() ? parsedTime : null;
367
+ delete newEvent.relativeTimeMs;
368
+ return newEvent;
369
+ }
370
+
371
+ // If funnelStartTime is invalid, just use the TimeSoup-generated time from makeEvent
372
+ if (!funnelStartTime || !funnelStartTime.isValid()) {
365
373
  delete newEvent.relativeTimeMs;
366
374
  return newEvent;
367
375
  }
368
376
 
369
377
  try {
370
- newEvent.time = dayjs(funnelStartTime)
371
- .add(event.relativeTimeMs, "milliseconds")
372
- .toISOString();
378
+ const computedTime = dayjs(funnelStartTime).add(event.relativeTimeMs, "milliseconds");
379
+ if (computedTime.isValid()) {
380
+ newEvent.time = computedTime.toISOString();
381
+ }
382
+ // If invalid, keep the TimeSoup-generated time from makeEvent
373
383
  delete newEvent.relativeTimeMs;
374
384
  return newEvent;
375
385
  } catch (e) {
376
- console.error("Error setting funnel event time:", e);
386
+ // Graceful fallback: keep the TimeSoup-generated time from makeEvent
387
+ delete newEvent.relativeTimeMs;
377
388
  return newEvent;
378
389
  }
379
390
  }));
@@ -28,22 +28,28 @@ export async function sendToMixpanel(context) {
28
28
  userProfilesData,
29
29
  groupEventData
30
30
  } = storage;
31
-
32
- const {
33
- token,
34
- region,
31
+
32
+ const {
33
+ token,
34
+ region,
35
35
  writeToDisk = true,
36
36
  format,
37
37
  serviceAccount,
38
38
  projectId,
39
- serviceSecret
39
+ serviceSecret,
40
+ verbose = false
40
41
  } = config;
41
-
42
+
42
43
  const importResults = { events: {}, users: {}, groups: [] };
43
44
  const isBATCH_MODE = context.isBatchMode();
44
45
  const isCLI = context.isCLI();
45
46
  const NODE_ENV = process.env.NODE_ENV || "unknown";
46
47
 
48
+ // Create verbose-aware log function
49
+ const log = (message) => {
50
+ if (verbose) console.log(message);
51
+ };
52
+
47
53
  /** @type {import('mixpanel-import').Creds} */
48
54
  const creds = { token };
49
55
  const mpImportFormat = format === "json" ? "jsonl" : "csv";
@@ -59,13 +65,11 @@ export async function sendToMixpanel(context) {
59
65
  dryRun: false,
60
66
  abridged: false,
61
67
  fixJson: false,
62
- showProgress: NODE_ENV === "dev" ? true : false,
68
+ showProgress: verbose,
63
69
  streamFormat: mpImportFormat,
64
- workers: 35
70
+ workers: 35
65
71
  };
66
72
 
67
- if (isCLI) commonOpts.showProgress = true;
68
-
69
73
  // Import events
70
74
  if (eventData || isBATCH_MODE) {
71
75
  log(`importing events to mixpanel...\n`);
@@ -224,10 +228,3 @@ export async function sendToMixpanel(context) {
224
228
  return importResults;
225
229
  }
226
230
 
227
- /**
228
- * Simple logging function
229
- * @param {string} message - Message to log
230
- */
231
- function log(message) {
232
- console.log(message);
233
- }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-mp-data",
3
- "version": "2.1.1",
3
+ "version": "2.1.3",
4
4
  "description": "builds all mixpanel primitives for a given project",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -63,14 +63,14 @@
63
63
  "@google-cloud/functions-framework": "^3.4.2",
64
64
  "@google-cloud/storage": "^7.14.0",
65
65
  "ak-fetch": "^2.0.12",
66
- "ak-gemini": "^1.0.59",
66
+ "ak-gemini": "^1.0.12",
67
67
  "ak-tools": "^1.1.12",
68
68
  "chance": "^1.1.11",
69
69
  "dayjs": "^1.11.11",
70
70
  "dotenv": "^16.4.5",
71
71
  "google-auth-library": "^9.15.0",
72
72
  "hyparquet-writer": "^0.6.1",
73
- "mixpanel-import": "^3.0.0",
73
+ "mixpanel-import": "^3.1.43",
74
74
  "p-limit": "^3.1.0",
75
75
  "seedrandom": "^3.0.5",
76
76
  "sentiment": "^5.0.2",