create-db 1.0.3-pr46-feat-add-sslmode-17243005030.0 → 1.0.3-pr48-DC-4894-posthog-fix-17267174922.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.
Files changed (3) hide show
  1. package/analytics.js +10 -8
  2. package/index.js +31 -7
  3. package/package.json +1 -1
package/analytics.js CHANGED
@@ -8,10 +8,8 @@ class EventCaptureError extends Error {
8
8
 
9
9
  class PosthogEventCapture {
10
10
  async capture(eventName, properties = {}) {
11
- const POSTHOG_CAPTURE_URL = process.env.POSTHOG_API_HOST
12
- ? process.env.POSTHOG_API_HOST + "/capture"
13
- : "https://proxyhog.prisma-data.net/capture";
14
- const POSTHOG_KEY = process.env.POSTHOG_API_KEY || "phc_cmc85avbWyuJ2JyKdGPdv7dxXli8xLdWDBPbvIXWJfs";
11
+ const POSTHOG_CAPTURE_URL = process.env.POSTHOG_API_HOST + "/capture";
12
+ const POSTHOG_KEY = process.env.POSTHOG_API_KEY;
15
13
 
16
14
  const payload = {
17
15
  api_key: POSTHOG_KEY,
@@ -35,11 +33,15 @@ class PosthogEventCapture {
35
33
  if (!response.ok) {
36
34
  throw new EventCaptureError(eventName, response.statusText);
37
35
  }
36
+
37
+ // Log success message
38
+ console.log(`${eventName}: Success`);
38
39
  } catch (error) {
39
- // Silently fail analytics to not disrupt user experience
40
- if (process.env.NODE_ENV === "development") {
41
- console.error("Analytics error:", error.message);
42
- }
40
+ // Log all analytics errors for debugging
41
+ console.error(`${eventName}: Failed - ${error.message}`);
42
+
43
+ // Re-throw the error so calling code can handle it if needed
44
+ throw error;
43
45
  }
44
46
  }
45
47
  }
package/index.js CHANGED
@@ -269,7 +269,9 @@ async function promptForRegion(defaultRegion) {
269
269
  region: region,
270
270
  "selection-method": "interactive",
271
271
  });
272
- } catch (error) {}
272
+ } catch (error) {
273
+ console.error("Failed to send region_selected analytics:", error.message);
274
+ }
273
275
 
274
276
  return region;
275
277
  }
@@ -310,7 +312,12 @@ async function createDatabase(name, region, returnJson = false) {
310
312
  "error-type": "rate_limit",
311
313
  "status-code": 429,
312
314
  });
313
- } catch (error) {}
315
+ } catch (error) {
316
+ console.error(
317
+ "Failed to send database_creation_failed analytics:",
318
+ error.message
319
+ );
320
+ }
314
321
 
315
322
  process.exit(1);
316
323
  }
@@ -339,7 +346,12 @@ async function createDatabase(name, region, returnJson = false) {
339
346
  "error-type": "invalid_json",
340
347
  "status-code": resp.status,
341
348
  });
342
- } catch {}
349
+ } catch (error) {
350
+ console.error(
351
+ "Failed to send database_creation_failed analytics:",
352
+ error.message
353
+ );
354
+ }
343
355
  process.exit(1);
344
356
  }
345
357
 
@@ -363,7 +375,7 @@ async function createDatabase(name, region, returnJson = false) {
363
375
  const directDbName = directConnDetails?.database || "postgres";
364
376
  const directConn =
365
377
  directConnDetails && directHost
366
- ? `postgresql://${directUser}:${directPass}@${directHost}${directPort}/${directDbName}?sslmode=require`
378
+ ? `postgresql://${directUser}:${directPass}@${directHost}${directPort}/${directDbName}`
367
379
  : null;
368
380
 
369
381
  const claimUrl = `${CLAIM_DB_WORKER_URL}?projectID=${projectId}&utm_source=${CLI_NAME}&utm_medium=cli`;
@@ -403,7 +415,12 @@ async function createDatabase(name, region, returnJson = false) {
403
415
  "error-type": "api_error",
404
416
  "error-message": result.error.message,
405
417
  });
406
- } catch (error) {}
418
+ } catch (error) {
419
+ console.error(
420
+ "Failed to send database_creation_failed analytics:",
421
+ error.message
422
+ );
423
+ }
407
424
  process.exit(1);
408
425
  }
409
426
 
@@ -474,7 +491,9 @@ async function main() {
474
491
  platform: process.platform,
475
492
  arch: process.arch,
476
493
  });
477
- } catch (error) {}
494
+ } catch (error) {
495
+ console.error("Failed to send cli_command_ran analytics:", error.message);
496
+ }
478
497
 
479
498
  const { flags } = await parseArgs();
480
499
 
@@ -504,7 +523,12 @@ async function main() {
504
523
  region: region,
505
524
  "selection-method": "flag",
506
525
  });
507
- } catch (error) {}
526
+ } catch (error) {
527
+ console.error(
528
+ "Failed to send region_selected analytics:",
529
+ error.message
530
+ );
531
+ }
508
532
  }
509
533
 
510
534
  if (flags.interactive) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-db",
3
- "version": "1.0.3-pr46-feat-add-sslmode-17243005030.0",
3
+ "version": "1.0.3-pr48-DC-4894-posthog-fix-17267174922.0",
4
4
  "description": "Instantly create a temporary Prisma Postgres database with one command, then claim and persist it in your Prisma Data Platform project when ready.",
5
5
  "main": "index.js",
6
6
  "author": "",