create-db 1.0.4-pr48-DC-4894-posthog-fix-17271643844.0 → 1.0.4-pr48-DC-4894-posthog-fix-17272348089.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.
- package/index.js +25 -8
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -10,21 +10,31 @@ import { select, spinner, intro, outro, log, cancel } from "@clack/prompts";
|
|
|
10
10
|
import chalk from "chalk";
|
|
11
11
|
import terminalLink from "terminal-link";
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
const CREATE_DB_WORKER_URL =
|
|
14
|
+
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
|
|
15
|
+
const CLAIM_DB_WORKER_URL =
|
|
16
|
+
process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
|
|
17
|
+
|
|
18
|
+
async function sendAnalyticsToWorker(
|
|
19
|
+
eventName,
|
|
20
|
+
properties,
|
|
21
|
+
{ timeoutMs = 2000 }
|
|
22
|
+
) {
|
|
23
|
+
const controller = new AbortController();
|
|
24
|
+
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
14
25
|
try {
|
|
15
26
|
await fetch(`${CREATE_DB_WORKER_URL}/analytics`, {
|
|
16
27
|
method: "POST",
|
|
17
28
|
headers: { "Content-Type": "application/json" },
|
|
18
29
|
body: JSON.stringify({ eventName, properties }),
|
|
30
|
+
signal: controller.signal,
|
|
19
31
|
});
|
|
20
|
-
} catch (error) {
|
|
32
|
+
} catch (error) {
|
|
33
|
+
} finally {
|
|
34
|
+
clearTimeout(timer);
|
|
35
|
+
}
|
|
21
36
|
}
|
|
22
37
|
|
|
23
|
-
const CREATE_DB_WORKER_URL =
|
|
24
|
-
process.env.CREATE_DB_WORKER_URL || "https://create-db-temp.prisma.io";
|
|
25
|
-
const CLAIM_DB_WORKER_URL =
|
|
26
|
-
process.env.CLAIM_DB_WORKER_URL || "https://create-db.prisma.io";
|
|
27
|
-
|
|
28
38
|
async function detectUserLocation() {
|
|
29
39
|
try {
|
|
30
40
|
const response = await fetch("https://ipapi.co/json/", {
|
|
@@ -52,7 +62,6 @@ async function detectUserLocation() {
|
|
|
52
62
|
}
|
|
53
63
|
}
|
|
54
64
|
|
|
55
|
-
// Region coordinates (latitude, longitude)
|
|
56
65
|
const REGION_COORDINATES = {
|
|
57
66
|
"ap-southeast-1": { lat: 1.3521, lng: 103.8198 }, // Singapore
|
|
58
67
|
"ap-northeast-1": { lat: 35.6762, lng: 139.6503 }, // Tokyo
|
|
@@ -573,6 +582,14 @@ async function createDatabase(name, region, userAgent, returnJson = false) {
|
|
|
573
582
|
)
|
|
574
583
|
)
|
|
575
584
|
);
|
|
585
|
+
|
|
586
|
+
try {
|
|
587
|
+
await sendAnalyticsToWorker("create_db:database_created", {
|
|
588
|
+
command: CLI_NAME,
|
|
589
|
+
region,
|
|
590
|
+
utm_source: CLI_NAME,
|
|
591
|
+
});
|
|
592
|
+
} catch {}
|
|
576
593
|
}
|
|
577
594
|
|
|
578
595
|
async function main() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-db",
|
|
3
|
-
"version": "1.0.4-pr48-DC-4894-posthog-fix-
|
|
3
|
+
"version": "1.0.4-pr48-DC-4894-posthog-fix-17272348089.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": "",
|