From 9c0eba46a49d194c2eabb58c849603450d9d6464 Mon Sep 17 00:00:00 2001 From: Stefan Buck Date: Tue, 16 Apr 2024 14:33:55 +0200 Subject: [PATCH] feat: set User-Agent version based on package version (#197) --- package.json | 1 + src/api/SnykApiClient.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 29aaa7c..901448b 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "backstage-plugin-snyk", "main": "dist/index.js", "types": "dist/index.d.ts", + "version": "0.0.0-development", "license": "Apache-2.0", "publishConfig": { "access": "public", diff --git a/src/api/SnykApiClient.ts b/src/api/SnykApiClient.ts index 1269beb..e82bc2c 100644 --- a/src/api/SnykApiClient.ts +++ b/src/api/SnykApiClient.ts @@ -25,6 +25,7 @@ import { mockedDepGraphs } from "../utils/mockedDepGraphs"; import { mockedProjectDetails } from "../utils/mockedProjectDetails"; import { IssuesCount } from "../types/types"; import { Issue } from "../types/unifiedIssuesTypes"; +const pkg = require('../../package.json'); const DEFAULT_PROXY_PATH_BASE = ""; type Options = { @@ -80,7 +81,7 @@ export class SnykApiClient implements SnykApi { private headers = { "Content-Type": "application/json", - "User-Agent": "tech-services/backstage-plugin/1.0", + "User-Agent": `tech-services/backstage-plugin/${pkg.version || "0.0.0-development"}`, }; constructor(options: Options) {