@astrojs/telemetry
Advanced tools
+3
-2
@@ -28,2 +28,5 @@ import fs from "node:fs"; | ||
| class GlobalConfig { | ||
| project; | ||
| dir; | ||
| file; | ||
| constructor(project) { | ||
@@ -34,4 +37,2 @@ this.project = project; | ||
| } | ||
| dir; | ||
| file; | ||
| _store; | ||
@@ -38,0 +39,0 @@ get store() { |
+0
-1
@@ -14,3 +14,2 @@ export type AstroTelemetryOptions = { | ||
| private config; | ||
| private debug; | ||
| private isCI; | ||
@@ -17,0 +16,0 @@ private env; |
+19
-14
| import { randomBytes } from "node:crypto"; | ||
| import { isCI } from "ci-info"; | ||
| import debug from "debug"; | ||
| import { GlobalConfig } from "./config.js"; | ||
| import * as KEY from "./config-keys.js"; | ||
| import { GlobalConfig } from "./config.js"; | ||
| import { post } from "./post.js"; | ||
@@ -10,10 +9,10 @@ import { getProjectInfo } from "./project-info.js"; | ||
| const VALID_TELEMETRY_NOTICE_DATE = "2023-08-25"; | ||
| function getDebug() { | ||
| return globalThis._astroGlobalDebug; | ||
| } | ||
| class AstroTelemetry { | ||
| constructor(opts) { | ||
| this.opts = opts; | ||
| } | ||
| opts; | ||
| _anonymousSessionId; | ||
| _anonymousProjectInfo; | ||
| config = new GlobalConfig({ name: "astro" }); | ||
| debug = debug("astro:telemetry"); | ||
| isCI = isCI; | ||
@@ -33,2 +32,5 @@ env = process.env; | ||
| } | ||
| constructor(opts) { | ||
| this.opts = opts; | ||
| } | ||
| /** | ||
@@ -84,8 +86,9 @@ * Get value from either the global config or the provided fallback. | ||
| async notify(callback) { | ||
| const debug = getDebug(); | ||
| if (this.isDisabled || this.isCI) { | ||
| this.debug(`[notify] telemetry has been disabled`); | ||
| debug?.("telemetry", `[notify] telemetry has been disabled`); | ||
| return; | ||
| } | ||
| if (this.isValidNotice()) { | ||
| this.debug(`[notify] last notified on ${this.notifyDate}`); | ||
| debug?.("telemetry", `[notify] last notified on ${this.notifyDate}`); | ||
| return; | ||
@@ -96,3 +99,3 @@ } | ||
| this.config.set(KEY.TELEMETRY_ENABLED, enabled); | ||
| this.debug(`[notify] telemetry has been ${enabled ? "enabled" : "disabled"}`); | ||
| debug?.("telemetry", `[notify] telemetry has been ${enabled ? "enabled" : "disabled"}`); | ||
| } | ||
@@ -104,4 +107,5 @@ async record(event = []) { | ||
| } | ||
| const debug = getDebug(); | ||
| if (this.isDisabled) { | ||
| this.debug("[record] telemetry has been disabled"); | ||
| debug?.("telemetry", "[record] telemetry has been disabled"); | ||
| return Promise.resolve(); | ||
@@ -120,5 +124,6 @@ } | ||
| } | ||
| if (this.debug.enabled) { | ||
| this.debug({ context, meta }); | ||
| this.debug(JSON.stringify(events, null, 2)); | ||
| const debugOutput = process.env.DEBUG?.includes("astro:telemetry") || process.env.DEBUG?.includes("astro:*") || process.env.DEBUG === "*"; | ||
| if (debugOutput && debug) { | ||
| debug("telemetry", { context, meta }); | ||
| debug("telemetry", JSON.stringify(events, null, 2)); | ||
| return Promise.resolve(); | ||
@@ -131,3 +136,3 @@ } | ||
| }).catch((err) => { | ||
| this.debug(`Error sending event: ${err.message}`); | ||
| debug?.("telemetry", `Error sending event: ${err.message}`); | ||
| }); | ||
@@ -134,0 +139,0 @@ } |
+7
-8
| { | ||
| "name": "@astrojs/telemetry", | ||
| "version": "3.3.0", | ||
| "version": "3.3.1", | ||
| "type": "module", | ||
@@ -26,14 +26,12 @@ "types": "./dist/index.d.ts", | ||
| "dependencies": { | ||
| "ci-info": "^4.2.0", | ||
| "debug": "^4.4.0", | ||
| "ci-info": "^4.4.0", | ||
| "dlv": "^1.1.3", | ||
| "dset": "^3.1.4", | ||
| "is-docker": "^3.0.0", | ||
| "is-wsl": "^3.1.0", | ||
| "is-docker": "^4.0.0", | ||
| "is-wsl": "^3.1.1", | ||
| "which-pm-runs": "^1.1.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/debug": "^4.1.12", | ||
| "@types/dlv": "^1.1.5", | ||
| "@types/node": "^18.17.8", | ||
| "@types/node": "^22.10.6", | ||
| "@types/which-pm-runs": "^1.0.2", | ||
@@ -52,4 +50,5 @@ "astro-scripts": "0.0.14" | ||
| "dev": "astro-scripts dev \"src/**/*.ts\"", | ||
| "test": "astro-scripts test \"test/**/*.test.js\"" | ||
| "test": "astro-scripts test \"test/**/*.test.ts\"", | ||
| "typecheck:tests": "tsc --build tsconfig.test.json" | ||
| } | ||
| } |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
20652
1.34%6
-14.29%4
-20%486
1.04%8
60%+ Added
- Removed
- Removed
- Removed
Updated
Updated
Updated