evergreen-sdk 1.0.0 → 1.0.1
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/package.json +2 -2
- package/src/index.ts +26 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "evergreen-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Evergreen Trace Backend SDK",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,4 +17,4 @@
|
|
|
17
17
|
"@types/ws": "^8.5.5",
|
|
18
18
|
"typescript": "^5.0.0"
|
|
19
19
|
}
|
|
20
|
-
}
|
|
20
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -23,6 +23,19 @@ let ws: WebSocket | null = null;
|
|
|
23
23
|
let isConnected = false;
|
|
24
24
|
const pendingTelemetry: any[] = [];
|
|
25
25
|
|
|
26
|
+
function getTelemetryWsUrl(): string {
|
|
27
|
+
const explicit = process.env.EVERGREEN_TRACE_WS_URL;
|
|
28
|
+
if (explicit && explicit.trim()) return explicit.trim();
|
|
29
|
+
return "ws://localhost:4321";
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function shouldDebugTelemetryConnection(): boolean {
|
|
33
|
+
return (
|
|
34
|
+
process.env.EVERGREEN_TRACE_DEBUG === "1" ||
|
|
35
|
+
process.env.EVERGREEN_TRACE_DEBUG === "true"
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
26
39
|
// Connect to the VS Code Extension Hub
|
|
27
40
|
function connect() {
|
|
28
41
|
if (
|
|
@@ -31,11 +44,23 @@ function connect() {
|
|
|
31
44
|
)
|
|
32
45
|
return;
|
|
33
46
|
|
|
47
|
+
const url = getTelemetryWsUrl();
|
|
48
|
+
const debug = shouldDebugTelemetryConnection();
|
|
49
|
+
|
|
34
50
|
try {
|
|
35
|
-
|
|
51
|
+
if (debug) {
|
|
52
|
+
// eslint-disable-next-line no-console
|
|
53
|
+
console.log(`🌲 Evergreen Trace: connecting to ${url}`);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
ws = new WebSocket(url);
|
|
36
57
|
|
|
37
58
|
ws.on("open", () => {
|
|
38
59
|
isConnected = true;
|
|
60
|
+
if (debug) {
|
|
61
|
+
// eslint-disable-next-line no-console
|
|
62
|
+
console.log(`🌲 Evergreen Trace: connected to ${url}`);
|
|
63
|
+
}
|
|
39
64
|
// Flush any telemetry that was emitted before the socket became ready.
|
|
40
65
|
while (pendingTelemetry.length > 0) {
|
|
41
66
|
const queued = pendingTelemetry.shift();
|