make-mp-data 3.0.3 → 3.0.4

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.
@@ -187,15 +187,15 @@ const config = {
187
187
  weight: 1,
188
188
  isFirstEvent: true,
189
189
  properties: {
190
- "signup_method": u.pickAWinner(["email", "google", "apple", "sso"]),
191
- "referred_by": u.pickAWinner(["organic", "friend", "ad", "influencer"]),
190
+ "signup_method": ["email", "google", "apple", "sso"],
191
+ "referred_by": ["organic", "friend", "ad", "influencer"],
192
192
  }
193
193
  },
194
194
  {
195
195
  event: "post created",
196
196
  weight: 12,
197
197
  properties: {
198
- "post_type": u.pickAWinner(["text", "image", "video", "poll", "link"]),
198
+ "post_type": ["text", "image", "video", "poll", "link"],
199
199
  "character_count": u.weighNumRange(1, 280),
200
200
  "has_media": u.pickAWinner([true, false], 0.4),
201
201
  "hashtag_count": u.weighNumRange(0, 10, 0.5),
@@ -205,23 +205,23 @@ const config = {
205
205
  event: "post viewed",
206
206
  weight: 30,
207
207
  properties: {
208
- "post_type": u.pickAWinner(["text", "image", "video", "poll", "link"]),
208
+ "post_type": ["text", "image", "video", "poll", "link"],
209
209
  "view_duration_sec": u.weighNumRange(1, 120, 0.3, 5),
210
- "source": u.pickAWinner(["feed", "explore", "search", "profile", "notification"]),
210
+ "source": ["feed", "explore", "search", "profile", "notification"],
211
211
  }
212
212
  },
213
213
  {
214
214
  event: "post liked",
215
215
  weight: 18,
216
216
  properties: {
217
- "post_type": u.pickAWinner(["text", "image", "video", "poll", "link"]),
217
+ "post_type": ["text", "image", "video", "poll", "link"],
218
218
  }
219
219
  },
220
220
  {
221
221
  event: "post shared",
222
222
  weight: 6,
223
223
  properties: {
224
- "share_destination": u.pickAWinner(["repost", "dm", "external", "copy_link"]),
224
+ "share_destination": ["repost", "dm", "external", "copy_link"],
225
225
  }
226
226
  },
227
227
  {
@@ -236,21 +236,21 @@ const config = {
236
236
  event: "user followed",
237
237
  weight: 8,
238
238
  properties: {
239
- "discovery_source": u.pickAWinner(["suggested", "search", "post", "profile", "mutual"]),
239
+ "discovery_source": ["suggested", "search", "post", "profile", "mutual"],
240
240
  }
241
241
  },
242
242
  {
243
243
  event: "user unfollowed",
244
244
  weight: 2,
245
245
  properties: {
246
- "reason": u.pickAWinner(["content_quality", "too_frequent", "lost_interest", "offensive"]),
246
+ "reason": ["content_quality", "too_frequent", "lost_interest", "offensive"],
247
247
  }
248
248
  },
249
249
  {
250
250
  event: "story viewed",
251
251
  weight: 15,
252
252
  properties: {
253
- "story_type": u.pickAWinner(["photo", "video", "text"]),
253
+ "story_type": ["photo", "video", "text"],
254
254
  "view_duration_sec": u.weighNumRange(1, 30, 0.5, 5),
255
255
  "completed": u.pickAWinner([true, false], 0.6),
256
256
  }
@@ -259,7 +259,7 @@ const config = {
259
259
  event: "story created",
260
260
  weight: 5,
261
261
  properties: {
262
- "story_type": u.pickAWinner(["photo", "video", "text"]),
262
+ "story_type": ["photo", "video", "text"],
263
263
  "has_filter": u.pickAWinner([true, false], 0.5),
264
264
  "has_sticker": u.pickAWinner([true, false], 0.3),
265
265
  }
@@ -268,7 +268,7 @@ const config = {
268
268
  event: "search performed",
269
269
  weight: 7,
270
270
  properties: {
271
- "search_type": u.pickAWinner(["users", "hashtags", "posts"]),
271
+ "search_type": ["users", "hashtags", "posts"],
272
272
  "results_count": u.weighNumRange(0, 50, 0.5, 10),
273
273
  }
274
274
  },
@@ -276,7 +276,7 @@ const config = {
276
276
  event: "notification received",
277
277
  weight: 12,
278
278
  properties: {
279
- "notification_type": u.pickAWinner(["like", "follow", "comment", "mention", "trending"]),
279
+ "notification_type": ["like", "follow", "comment", "mention", "trending"],
280
280
  "clicked": u.pickAWinner([true, false], 0.4),
281
281
  }
282
282
  },
@@ -284,7 +284,7 @@ const config = {
284
284
  event: "dm sent",
285
285
  weight: 8,
286
286
  properties: {
287
- "message_type": u.pickAWinner(["text", "image", "voice", "link"]),
287
+ "message_type": ["text", "image", "voice", "link"],
288
288
  "conversation_length": u.weighNumRange(1, 100),
289
289
  }
290
290
  },
@@ -292,8 +292,8 @@ const config = {
292
292
  event: "ad viewed",
293
293
  weight: 10,
294
294
  properties: {
295
- "ad_format": u.pickAWinner(["feed_native", "story", "banner", "video"]),
296
- "ad_category": u.pickAWinner(["retail", "tech", "food", "finance", "entertainment"]),
295
+ "ad_format": ["feed_native", "story", "banner", "video"],
296
+ "ad_category": ["retail", "tech", "food", "finance", "entertainment"],
297
297
  "view_duration_sec": u.weighNumRange(1, 30, 0.3),
298
298
  }
299
299
  },
@@ -301,38 +301,38 @@ const config = {
301
301
  event: "ad clicked",
302
302
  weight: 2,
303
303
  properties: {
304
- "ad_format": u.pickAWinner(["feed_native", "story", "banner", "video"]),
305
- "ad_category": u.pickAWinner(["retail", "tech", "food", "finance", "entertainment"]),
304
+ "ad_format": ["feed_native", "story", "banner", "video"],
305
+ "ad_category": ["retail", "tech", "food", "finance", "entertainment"],
306
306
  }
307
307
  },
308
308
  {
309
309
  event: "report submitted",
310
310
  weight: 1,
311
311
  properties: {
312
- "report_type": u.pickAWinner(["spam", "harassment", "misinformation", "hate_speech", "other"]),
313
- "content_type": u.pickAWinner(["post", "comment", "user", "dm"]),
312
+ "report_type": ["spam", "harassment", "misinformation", "hate_speech", "other"],
313
+ "content_type": ["post", "comment", "user", "dm"],
314
314
  }
315
315
  },
316
316
  {
317
317
  event: "profile updated",
318
318
  weight: 3,
319
319
  properties: {
320
- "field_updated": u.pickAWinner(["bio", "avatar", "display_name", "privacy_settings", "interests"]),
320
+ "field_updated": ["bio", "avatar", "display_name", "privacy_settings", "interests"],
321
321
  }
322
322
  },
323
323
  {
324
324
  event: "creator subscription started",
325
325
  weight: 2,
326
326
  properties: {
327
- "tier": u.pickAWinner(["basic", "premium", "vip"]),
327
+ "tier": ["basic", "premium", "vip"],
328
328
  "price_usd": u.pickAWinner([4.99, 9.99, 19.99]),
329
329
  }
330
330
  },
331
331
  ],
332
332
 
333
333
  superProps: {
334
- app_version: u.pickAWinner(["4.0", "4.1", "4.2", "4.3", "5.0"]),
335
- account_type: u.pickAWinner(["personal", "creator", "business"]),
334
+ app_version: ["4.0", "4.1", "4.2", "4.3", "5.0"],
335
+ account_type: ["personal", "creator", "business"],
336
336
  },
337
337
 
338
338
  userProps: {
@@ -340,7 +340,7 @@ const config = {
340
340
  "following_count": u.weighNumRange(0, 5000, 0.3, 100),
341
341
  "bio_length": u.weighNumRange(0, 160),
342
342
  "verified": u.pickAWinner([true, false], 0.05),
343
- "content_niche": u.pickAWinner(["lifestyle", "tech", "food", "fitness", "travel", "comedy", "news", "art"]),
343
+ "content_niche": ["lifestyle", "tech", "food", "fitness", "travel", "comedy", "news", "art"],
344
344
  },
345
345
 
346
346
  groupKeys: [
@@ -351,7 +351,7 @@ const config = {
351
351
  community_id: {
352
352
  "name": () => `${chance.word()} ${chance.pickone(["Hub", "Circle", "Squad", "Zone", "Space"])}`,
353
353
  "member_count": u.weighNumRange(50, 5000, 0.3, 200),
354
- "category": u.pickAWinner(["technology", "entertainment", "sports", "politics", "art", "science"]),
354
+ "category": ["technology", "entertainment", "sports", "politics", "art", "science"],
355
355
  "is_moderated": u.pickAWinner([true, false], 0.7),
356
356
  }
357
357
  },
@@ -65,7 +65,7 @@ const config = {
65
65
  ]),
66
66
  "watch time": u.weighNumRange(1, 65, .89, 100),
67
67
 
68
- "category": u.pickAWinner([
68
+ "category": [
69
69
  "comedy",
70
70
  "educational",
71
71
  "music",
@@ -73,15 +73,15 @@ const config = {
73
73
  "news",
74
74
  "gaming",
75
75
  "travel",
76
- ]),
77
- quality: u.pickAWinner([
76
+ ],
77
+ quality: [
78
78
  "240p",
79
79
  "360p",
80
80
  "480p",
81
81
  "720p",
82
82
  "1080p",
83
83
  "4k",
84
- ], 4),
84
+ ],
85
85
  autoplay: [
86
86
  true,
87
87
  false,
@@ -120,13 +120,13 @@ const config = {
120
120
  weight: 3,
121
121
  properties: {
122
122
  video_id: u.pickAWinner(videoIds),
123
- "share network": u.pickAWinner([
123
+ "share network": [
124
124
  "facebook",
125
125
  "twitter",
126
126
  "reddit",
127
127
  "email",
128
128
  "whatsapp",
129
- ]),
129
+ ],
130
130
  },
131
131
  },
132
132
  {
@@ -174,18 +174,18 @@ const config = {
174
174
  event: "create playlist",
175
175
  weight: 4,
176
176
  properties: {
177
- "play list name": u.pickAWinner([
177
+ "play list name": [
178
178
  "favorites",
179
179
  "watch later",
180
180
  "my music",
181
181
  "funny videos",
182
182
  "educational",
183
- ]),
184
- privacy: u.pickAWinner([
183
+ ],
184
+ privacy: [
185
185
  "public",
186
186
  "private",
187
187
  "unlisted",
188
- ]),
188
+ ],
189
189
  },
190
190
  },
191
191
  {
@@ -204,11 +204,11 @@ const config = {
204
204
  event: "account login",
205
205
  weight: 9,
206
206
  properties: {
207
- "log in method": u.pickAWinner([
207
+ "log in method": [
208
208
  "email",
209
209
  "google",
210
210
  "facebook",
211
- ]),
211
+ ],
212
212
  success: [
213
213
  true,
214
214
  false,
@@ -232,11 +232,11 @@ const config = {
232
232
  }
233
233
  ],
234
234
  superProps: {
235
- platform: u.pickAWinner([
235
+ platform: [
236
236
  "web",
237
237
  "ios",
238
238
  "android",
239
- ]),
239
+ ],
240
240
  network_type: [
241
241
  "wifi",
242
242
  "cellular",
@@ -256,13 +256,13 @@ const config = {
256
256
  "45-54",
257
257
  "55+",
258
258
  ],
259
- preferred_genre: u.pickAWinner([
259
+ preferred_genre: [
260
260
  "comedy",
261
261
  "action",
262
262
  "drama",
263
263
  "sci-fi",
264
264
  "horror",
265
- ]),
265
+ ],
266
266
  upload_count: [
267
267
  0,
268
268
  1,
package/index.js CHANGED
@@ -276,7 +276,7 @@ async function generateGroupProfiles(context) {
276
276
  const groupContainer = storage.groupProfilesData[i];
277
277
 
278
278
  if (!groupContainer) {
279
- console.warn(`Warning: No storage container found for group key: ${groupKey}`);
279
+ if (config.verbose) console.warn(`Warning: No storage container found for group key: ${groupKey}`);
280
280
  continue;
281
281
  }
282
282
 
@@ -319,7 +319,7 @@ async function generateLookupTables(context) {
319
319
  const lookupContainer = storage.lookupTableData[i];
320
320
 
321
321
  if (!lookupContainer) {
322
- console.warn(`Warning: No storage container found for lookup table: ${key}`);
322
+ if (config.verbose) console.warn(`Warning: No storage container found for lookup table: ${key}`);
323
323
  continue;
324
324
  }
325
325
 
@@ -551,7 +551,6 @@ async function extractFileInfo(storage, config) {
551
551
  }
552
552
  } catch (error) {
553
553
  // If scanning fails, just return empty array
554
- console.warn('Warning: Could not scan data directory for files:', error.message);
555
554
  }
556
555
  }
557
556
 
@@ -106,7 +106,7 @@ export function validateDungeonConfig(config) {
106
106
  token = null,
107
107
  region = "US",
108
108
  writeToDisk = false,
109
- verbose = true,
109
+ verbose = false,
110
110
  soup = {},
111
111
  hook = (record) => record,
112
112
  hasAdSpend = false,
@@ -166,15 +166,17 @@ export function validateDungeonConfig(config) {
166
166
  throw new Error('Hook string did not evaluate to a function');
167
167
  }
168
168
  } catch (error) {
169
- console.warn(`\u26a0\ufe0f Failed to convert hook string to function: ${error.message}`);
170
- console.warn('Using default pass-through hook');
169
+ if (config.verbose !== false) {
170
+ console.warn(`\u26a0\ufe0f Failed to convert hook string to function: ${error.message}`);
171
+ console.warn('Using default pass-through hook');
172
+ }
171
173
  hook = (record) => record;
172
174
  }
173
175
  }
174
176
 
175
177
  // Ensure hook is a function
176
178
  if (typeof hook !== 'function') {
177
- console.warn('\u26a0\ufe0f Hook is not a function, using default pass-through hook');
179
+ if (config.verbose !== false) console.warn('\u26a0\ufe0f Hook is not a function, using default pass-through hook');
178
180
  hook = (record) => record;
179
181
  }
180
182
 
@@ -337,7 +339,7 @@ function transformSCDPropsWithoutCredentials(config) {
337
339
  }
338
340
 
339
341
  // UI job without credentials - convert SCD props to regular props
340
- console.log('\u26a0\ufe0f Service account credentials missing - converting SCD properties to static properties');
342
+ if (config.verbose !== false) console.log('\u26a0\ufe0f Service account credentials missing - converting SCD properties to static properties');
341
343
 
342
344
  // Ensure userProps and groupProps exist
343
345
  if (!config.userProps) config.userProps = {};
@@ -356,20 +358,20 @@ function transformSCDPropsWithoutCredentials(config) {
356
358
  if (type === "user") {
357
359
  // Add to userProps
358
360
  config.userProps[propKey] = values;
359
- console.log(` \u2713 Converted user SCD property: ${propKey}`);
361
+ if (config.verbose !== false) console.log(` \u2713 Converted user SCD property: ${propKey}`);
360
362
  } else {
361
363
  // Add to groupProps for the specific group type
362
364
  if (!config.groupProps[type]) {
363
365
  config.groupProps[type] = {};
364
366
  }
365
367
  config.groupProps[type][propKey] = values;
366
- console.log(` \u2713 Converted group SCD property: ${propKey} (${type})`);
368
+ if (config.verbose !== false) console.log(` \u2713 Converted group SCD property: ${propKey} (${type})`);
367
369
  }
368
370
  }
369
371
 
370
372
  // Clear out scdProps since we've converted everything
371
373
  config.scdProps = {};
372
- console.log('\u2713 SCD properties converted to static properties\n');
374
+ if (config.verbose !== false) console.log('\u2713 SCD properties converted to static properties\n');
373
375
  }
374
376
 
375
377
  export { inferFunnels, transformSCDPropsWithoutCredentials };
@@ -6,7 +6,6 @@
6
6
  /** @typedef {import('../../types').Context} Context */
7
7
 
8
8
  import dayjs from "dayjs";
9
- import path from "path";
10
9
  import { comma, ls, rm } from "ak-tools";
11
10
  import * as u from "../utils/utils.js";
12
11
  import mp from "mixpanel-import";
@@ -22,8 +21,6 @@ export async function sendToMixpanel(context) {
22
21
  adSpendData,
23
22
  eventData,
24
23
  groupProfilesData,
25
- lookupTableData,
26
- mirrorEventData,
27
24
  scdTableData,
28
25
  userProfilesData,
29
26
  groupEventData
@@ -41,7 +38,7 @@ export async function sendToMixpanel(context) {
41
38
 
42
39
  const importResults = { events: {}, users: {}, groups: [] };
43
40
  const isBATCH_MODE = context.isBatchMode();
44
- const NODE_ENV = process.env.NODE_ENV || "unknown";
41
+ _verbose = config.verbose !== false;
45
42
 
46
43
  /** @type {import('mixpanel-import').Creds} */
47
44
  const creds = { token };
@@ -255,9 +252,10 @@ export async function sendToMixpanel(context) {
255
252
  }
256
253
 
257
254
  /**
258
- * Simple logging function
255
+ * Logging function that respects verbose config
259
256
  * @param {string} message - Message to log
260
257
  */
258
+ let _verbose = true;
261
259
  function log(message) {
262
- console.log(message);
260
+ if (_verbose) console.log(message);
263
261
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "make-mp-data",
3
- "version": "3.0.3",
3
+ "version": "3.0.4",
4
4
  "description": "builds all mixpanel primitives for a given project",
5
5
  "type": "module",
6
6
  "main": "index.js",