Skip to content

Commit

Permalink
Add @spruce release to user-agent (#155)
Browse files Browse the repository at this point in the history
_This revision is dependent on a previous branches / PRs. These will
need to be reviewed and merged first:_
- #153
- #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.
  • Loading branch information
austin-denoble committed Jan 13, 2024
1 parent 11edf9f commit 28110ff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release-spruce-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-spruce.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions src/utils/user-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}
Expand Down
3 changes: 2 additions & 1 deletion src/version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "@pinecone-database/pinecone",
"version": "1.1.3"
"version": "1.1.3",
"release": ""
}

0 comments on commit 28110ff

Please sign in to comment.