@spotlightjs/spotlight 4.4.0 → 4.5.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/dist/instrument.d.ts +1 -0
- package/dist/overlay/assets/main.js +69 -69
- package/dist/run.cjs +44693 -0
- package/dist/run.d.ts +1 -0
- package/dist/run.js +44654 -0
- package/dist/sidecar.cjs +7 -1
- package/dist/sidecar.js +2 -2
- package/package.json +14 -18
- package/bin/instrument.js +0 -107
- package/bin/run.js +0 -63
- package/dist/overlay.cjs +0 -1
- package/dist/overlay.d.ts +0 -1
- package/dist/overlay.js +0 -1
package/dist/sidecar.cjs
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
+
const sidecar = require("@spotlightjs/sidecar");
|
|
4
|
+
Object.defineProperty(exports, "setupSidecar", {
|
|
5
|
+
enumerable: true,
|
|
6
|
+
get: () => sidecar.setupSidecar
|
|
7
|
+
});
|
package/dist/sidecar.js
CHANGED
package/package.json
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spotlightjs/spotlight",
|
|
3
3
|
"description": "Spotlight - Sentry for development. Containing the overlay and the sidecar.",
|
|
4
|
-
"version": "4.
|
|
4
|
+
"version": "4.5.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"files": [
|
|
8
|
-
"dist"
|
|
9
|
-
"bin"
|
|
8
|
+
"dist"
|
|
10
9
|
],
|
|
11
10
|
"bin": {
|
|
12
|
-
"spotlight": "./
|
|
11
|
+
"spotlight": "./dist/run.js"
|
|
13
12
|
},
|
|
14
|
-
"main": "./dist/
|
|
15
|
-
"module": "./dist/
|
|
16
|
-
"types": "./dist/
|
|
13
|
+
"main": "./dist/sidecar.cjs",
|
|
14
|
+
"module": "./dist/sidecar.js",
|
|
15
|
+
"types": "./dist/sidecar.d.ts",
|
|
17
16
|
"exports": {
|
|
18
17
|
".": {
|
|
19
|
-
"types": "./dist/
|
|
20
|
-
"import": "./dist/
|
|
21
|
-
"require": "./dist/
|
|
18
|
+
"types": "./dist/sidecar.d.ts",
|
|
19
|
+
"import": "./dist/sidecar.js",
|
|
20
|
+
"require": "./dist/sidecar.cjs"
|
|
22
21
|
},
|
|
23
22
|
"./sidecar": {
|
|
24
23
|
"types": "./dist/sidecar.d.ts",
|
|
@@ -29,8 +28,8 @@
|
|
|
29
28
|
"dependencies": {
|
|
30
29
|
"@sentry/node": "^10.22.0",
|
|
31
30
|
"import-meta-resolve": "^4.1.0",
|
|
32
|
-
"@spotlightjs/
|
|
33
|
-
"@spotlightjs/
|
|
31
|
+
"@spotlightjs/overlay": "4.5.0",
|
|
32
|
+
"@spotlightjs/sidecar": "2.4.1"
|
|
34
33
|
},
|
|
35
34
|
"devDependencies": {
|
|
36
35
|
"@types/node": "^22.15.21",
|
|
@@ -46,12 +45,9 @@
|
|
|
46
45
|
"node": ">=20"
|
|
47
46
|
},
|
|
48
47
|
"scripts": {
|
|
49
|
-
"start": "./
|
|
50
|
-
"dev": "
|
|
48
|
+
"start": "node --disable-warning=ExperimentalWarning --experimental-transform-types --watch ./src/run.ts",
|
|
49
|
+
"dev": "node --disable-warning=ExperimentalWarning --experimental-transform-types --watch ./src/run.ts",
|
|
51
50
|
"build:sea": "fossilize -m dist/overlay/manifest.json",
|
|
52
|
-
"build": "vite build && vite build --config vite.overlay.config.ts &&
|
|
53
|
-
"build:watch": "vite build --watch",
|
|
54
|
-
"yalc:publish": "yalc publish --push --sig --private",
|
|
55
|
-
"clean": "rimraf dist"
|
|
51
|
+
"build": "vite build && vite build --config vite.overlay.config.ts && pnpm build:sea && tsc"
|
|
56
52
|
}
|
|
57
53
|
}
|
package/bin/instrument.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { consoleLoggingIntegration, getClient, init } from "@sentry/node";
|
|
2
|
-
import { parseCLIArgs } from "@spotlightjs/sidecar/cli";
|
|
3
|
-
import { DEFAULT_PORT } from "@spotlightjs/sidecar/constants";
|
|
4
|
-
|
|
5
|
-
// Parse CLI arguments to determine the port this Spotlight instance will use
|
|
6
|
-
const { port: instancePort } = parseCLIArgs();
|
|
7
|
-
|
|
8
|
-
// Check if SENTRY_SPOTLIGHT points to this instance
|
|
9
|
-
const spotlightEnv = process.env.SENTRY_SPOTLIGHT;
|
|
10
|
-
let disableSpotlight = false;
|
|
11
|
-
|
|
12
|
-
// Note: If port is set to 0 (dynamic port assignment), we cannot detect the actual port
|
|
13
|
-
// before starting the server, so we cannot prevent the feedback loop in that case.
|
|
14
|
-
// The server will be assigned a port by the OS after it starts, and if SENTRY_SPOTLIGHT
|
|
15
|
-
// happens to point to that same port, a feedback loop may occur.
|
|
16
|
-
if (spotlightEnv && instancePort !== 0) {
|
|
17
|
-
let targetPort;
|
|
18
|
-
let targetHost;
|
|
19
|
-
|
|
20
|
-
// SENTRY_SPOTLIGHT can be:
|
|
21
|
-
// 1. A full URL like "http://localhost:8969"
|
|
22
|
-
// 2. A truthy value (true, t, y, yes, on, 1) which means use the default URL
|
|
23
|
-
const TRUTHY_ENV_VALUES = new Set(["true", "t", "y", "yes", "on", "1"]);
|
|
24
|
-
const isTruthy = TRUTHY_ENV_VALUES.has(spotlightEnv.toLowerCase());
|
|
25
|
-
|
|
26
|
-
if (isTruthy) {
|
|
27
|
-
// Use default Spotlight URL
|
|
28
|
-
targetHost = "localhost";
|
|
29
|
-
targetPort = DEFAULT_PORT;
|
|
30
|
-
} else {
|
|
31
|
-
// Try to parse as URL
|
|
32
|
-
try {
|
|
33
|
-
const spotlightUrl = new URL(spotlightEnv);
|
|
34
|
-
targetHost = spotlightUrl.hostname;
|
|
35
|
-
targetPort = spotlightUrl.port ? Number(spotlightUrl.port) : spotlightUrl.protocol === "https:" ? 443 : 80;
|
|
36
|
-
} catch (_err) {
|
|
37
|
-
// If we can't parse it, we can't determine if it's a feedback loop, so do nothing
|
|
38
|
-
targetPort = null;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Only disable if we successfully determined the target and it matches our instance
|
|
43
|
-
if (targetPort !== null && targetPort !== undefined) {
|
|
44
|
-
const isLocalhost = targetHost === "localhost" || targetHost === "127.0.0.1" || targetHost === "::1";
|
|
45
|
-
|
|
46
|
-
if (isLocalhost && targetPort === instancePort) {
|
|
47
|
-
disableSpotlight = true;
|
|
48
|
-
console.warn(
|
|
49
|
-
`⚠️ [Spotlight] SENTRY_SPOTLIGHT is set to ${spotlightEnv} which points to this Spotlight instance (port ${instancePort}). Disabling Spotlight integration to prevent feedback loop.`,
|
|
50
|
-
);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const sentry = init({
|
|
56
|
-
dsn: "https://51bcd92dba1128934afd1c5726c84442@o1.ingest.us.sentry.io/4508404727283713",
|
|
57
|
-
environment: process.env.NODE_ENV || "development",
|
|
58
|
-
release: `spotlight@${process.env.npm_package_version}`,
|
|
59
|
-
debug: Boolean(process.env.SENTRY_DEBUG),
|
|
60
|
-
|
|
61
|
-
tracesSampleRate: 1,
|
|
62
|
-
enableLogs: true,
|
|
63
|
-
...(disableSpotlight && { spotlight: false }),
|
|
64
|
-
|
|
65
|
-
integrations: [
|
|
66
|
-
consoleLoggingIntegration({
|
|
67
|
-
levels: ["log", "info", "warn", "error", "debug"],
|
|
68
|
-
}),
|
|
69
|
-
],
|
|
70
|
-
|
|
71
|
-
beforeSendTransaction: event => {
|
|
72
|
-
event.server_name = undefined; // Server name might contain PII
|
|
73
|
-
return event;
|
|
74
|
-
},
|
|
75
|
-
|
|
76
|
-
beforeSend: event => {
|
|
77
|
-
const exceptions = event.exception?.values;
|
|
78
|
-
if (!exceptions) {
|
|
79
|
-
return event;
|
|
80
|
-
}
|
|
81
|
-
for (const exception of exceptions) {
|
|
82
|
-
if (!exception.stacktrace) {
|
|
83
|
-
continue;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
for (const frame of exception.stacktrace.frames) {
|
|
87
|
-
if (!frame.filename) {
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
92
|
-
frame.filename = frame.filename?.replace(homeDir, "~");
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
event.server_name = undefined; // Server name might contain PII
|
|
97
|
-
return event;
|
|
98
|
-
},
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
function shutdown() {
|
|
102
|
-
sentry.close();
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
process.on("SIGINT", shutdown);
|
|
106
|
-
process.on("SIGTERM", shutdown);
|
|
107
|
-
// process.on("beforeExit", shutdown);
|
package/bin/run.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import { readFileSync } from "node:fs";
|
|
3
|
-
import Module from "node:module";
|
|
4
|
-
import { join } from "node:path";
|
|
5
|
-
import { fileURLToPath } from "node:url";
|
|
6
|
-
import { setContext, startSpan } from "@sentry/node";
|
|
7
|
-
import { main } from "@spotlightjs/sidecar/cli";
|
|
8
|
-
import "./instrument.js";
|
|
9
|
-
const require = Module.createRequire(import.meta.url);
|
|
10
|
-
let sea = null;
|
|
11
|
-
try {
|
|
12
|
-
// This is to maintain compatibility with Node 20.11- as
|
|
13
|
-
// the `node:sea` module is added in Node 20.12+
|
|
14
|
-
sea = require("node:sea");
|
|
15
|
-
} catch {
|
|
16
|
-
sea = { isSea: () => false };
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const homeDir = process.env.HOME || process.env.USERPROFILE;
|
|
20
|
-
setContext("CLI", {
|
|
21
|
-
sea: sea.isSea(),
|
|
22
|
-
// TODO: Be less naive with path obscuring
|
|
23
|
-
argv: process.argv.map(arg => arg.replace(homeDir, "~")),
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const withTracing =
|
|
27
|
-
(fn, spanArgs = {}) =>
|
|
28
|
-
(...args) =>
|
|
29
|
-
startSpan({ name: fn.name, attributes: { args }, ...spanArgs }, () => fn(...args));
|
|
30
|
-
|
|
31
|
-
const readAsset = withTracing(
|
|
32
|
-
sea.isSea()
|
|
33
|
-
? name => Buffer.from(sea.getRawAsset(name))
|
|
34
|
-
: (() => {
|
|
35
|
-
const ASSET_DIR = join(fileURLToPath(import.meta.url), "../../dist/overlay/");
|
|
36
|
-
|
|
37
|
-
return name => readFileSync(join(ASSET_DIR, name));
|
|
38
|
-
})(),
|
|
39
|
-
{ name: "readAsset", op: "cli.asset.read" },
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
startSpan({ name: "Spotlight CLI", op: "cli" }, async () => {
|
|
43
|
-
await startSpan({ name: "Setup Sidecar", op: "cli.setup.sidecar" }, async () => {
|
|
44
|
-
const MANIFEST_NAME = "manifest.json";
|
|
45
|
-
const ENTRY_POINT_NAME = "src/index.html";
|
|
46
|
-
const filesToServe = Object.create(null);
|
|
47
|
-
|
|
48
|
-
startSpan({ name: "Setup Server Assets", op: "cli.setup.sidecar.assets" }, () => {
|
|
49
|
-
// Following the guide here: https://vite.dev/guide/backend-integration.html
|
|
50
|
-
const manifest = JSON.parse(readAsset(MANIFEST_NAME));
|
|
51
|
-
filesToServe[ENTRY_POINT_NAME] = readAsset(ENTRY_POINT_NAME);
|
|
52
|
-
const entries = Object.values(manifest);
|
|
53
|
-
for (const entry of entries) {
|
|
54
|
-
filesToServe[entry.file] = readAsset(entry.file);
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
await main({
|
|
59
|
-
basePath: process.cwd(),
|
|
60
|
-
filesToServe,
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
package/dist/overlay.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("@spotlightjs/overlay");Object.keys(t).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(exports,e)&&Object.defineProperty(exports,e,{enumerable:!0,get:()=>t[e]})});
|
package/dist/overlay.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@spotlightjs/overlay";
|
package/dist/overlay.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "@spotlightjs/overlay";
|