From 28110ffa81298e98b3b829aeadf69ec5755c1dfb Mon Sep 17 00:00:00 2001 From: Austin DeNoble Date: Tue, 7 Nov 2023 17:08:06 -0500 Subject: [PATCH] Add @spruce release to user-agent (#155) _This revision is dependent on a previous branches / PRs. These will need to be reviewed and merged first:_ - https://github.com/pinecone-io/pinecone-ts-client/pull/153 - https://github.com/pinecone-io/pinecone-ts-client/pull/154 We want to be able to track usage specific to the spruce release of the client. - Update `buildUserAgent` logic to check for `packageInfo.release`, and append to the user agent if present. - Update `release-spruce-dev` and `release-spruce` workflows to add `@spruce` to `version.json` during these specific releases. - [X] New feature (non-breaking change which adds functionality) We will need to release through either the `release-spruce` or `release-spruce-dev` workflows and validate the `version.json` file has the proper info, and the `release` is appended to the user agent header. --- .github/workflows/release-spruce-dev.yml | 2 +- .github/workflows/release-spruce.yml | 2 +- src/utils/user-agent.ts | 5 +++++ src/version.json | 3 ++- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release-spruce-dev.yml b/.github/workflows/release-spruce-dev.yml index c0482bcc..3dda59f3 100644 --- a/.github/workflows/release-spruce-dev.yml +++ b/.github/workflows/release-spruce-dev.yml @@ -37,7 +37,7 @@ jobs: jq --arg newVersion "$devVersion" '.version = $newVersion' package.json > package.tmp && mv package.tmp package.json jq --arg newVersion "$devVersion" '.version = $newVersion' package-lock.json > package-lock.tmp && mv package-lock.tmp package-lock.json jq --arg newVersion "$devVersion" '.packages[""].version = $newVersion' package-lock.json > package-lock.tmp && mv package-lock.tmp package-lock.json - jq --null-input --arg version "$devVersion" '{"name": "@pinecone-database/pinecone", "version": $version}' > src/version.json + jq --null-input --arg version "$devVersion" --arg release "@spruce" '{"name": "@pinecone-database/pinecone", "version": $version, "release": $release}' > src/version.json - name: 'Publish to npm' run: npm publish --tag spruceDev diff --git a/.github/workflows/release-spruce.yml b/.github/workflows/release-spruce.yml index 52c38f54..125cae12 100644 --- a/.github/workflows/release-spruce.yml +++ b/.github/workflows/release-spruce.yml @@ -25,7 +25,7 @@ jobs: jq --arg newVersion "$devVersion" '.version = $newVersion' package.json > package.tmp && mv package.tmp package.json jq --arg newVersion "$devVersion" '.version = $newVersion' package-lock.json > package-lock.tmp && mv package-lock.tmp package-lock.json jq --arg newVersion "$devVersion" '.packages[""].version = $newVersion' package-lock.json > package-lock.tmp && mv package-lock.tmp package-lock.json - jq --null-input --arg version "$devVersion" '{"name": "@pinecone-database/pinecone", "version": $version}' > src/version.json + jq --null-input --arg version "$devVersion" --arg release "@spruce" '{"name": "@pinecone-database/pinecone", "version": $version, "release": $release}' > src/version.json - name: 'Publish to npm' run: npm publish --tag spruce diff --git a/src/utils/user-agent.ts b/src/utils/user-agent.ts index 4e291263..ab1f4a30 100644 --- a/src/utils/user-agent.ts +++ b/src/utils/user-agent.ts @@ -10,6 +10,11 @@ export const buildUserAgent = (isLegacy: boolean) => { 'lang=typescript', ]; + // If there's a release in packageInfo, append to the user agent + if (packageInfo.release && packageInfo.release !== '') { + userAgentParts.push(`release=${packageInfo.release}`); + } + if (isEdge()) { userAgentParts.push('Edge Runtime'); } diff --git a/src/version.json b/src/version.json index 2c3021b8..6dcb452d 100644 --- a/src/version.json +++ b/src/version.json @@ -1,4 +1,5 @@ { "name": "@pinecone-database/pinecone", - "version": "1.1.3" + "version": "1.1.3", + "release": "" }