Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "2492c3e", "specHash": "fa39a3f", "version": "10.9.0" }
{ "engineHash": "2fabf30", "specHash": "576cd17", "version": "10.9.0" }
126 changes: 80 additions & 46 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions src/networking/boxNetworkClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,21 @@ export class BoxNetworkClient implements NetworkClient {
}
}

function getBoxBundleVersion(): string | null {
if (typeof process !== 'undefined' && process.env?.NPM_BOX_VERSION) {
return process.env.NPM_BOX_VERSION;
}

if (
typeof globalThis !== 'undefined' &&
(globalThis as any).__BOX_PACKAGE_VERSION
) {
return (globalThis as any).__BOX_PACKAGE_VERSION;
}

return null;
}

function constructBoxUAHeader() {
const analyticsIdentifiers = {
agent: `box-javascript-generated-sdk/${sdkVersion}`,
Expand All @@ -441,6 +456,12 @@ function constructBoxUAHeader() {
: `Node/${process.version.replace('v', '')}`,
} as Record<string, string>;

// Add bundle information if box-node-sdk is used through npm-box meta-package
const bundleVersion = getBoxBundleVersion();
if (bundleVersion) {
analyticsIdentifiers['bundle'] = `box/${bundleVersion}`;
}

return Object.keys(analyticsIdentifiers)
.map((k) => `${k}=${analyticsIdentifiers[k]}`)
.join('; ');
Expand Down
Loading
Loading