Skip to content

Commit 47b610f

Browse files
feat!: re-add sdk version headers (#344)
Co-authored-by: Talisson Costa <talisson.odcosta@gmail.com>
1 parent 1411b85 commit 47b610f

File tree

5 files changed

+34
-1
lines changed

5 files changed

+34
-1
lines changed

.husky/pre-commit

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/sh
2+
npm run precommit

flagsmith-core.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,10 @@ const Flagsmith = class {
838838
options.headers['Flagsmith-Application-Version'] = this.applicationMetadata.version;
839839
}
840840

841+
if (SDK_VERSION) {
842+
options.headers['Flagsmith-SDK-User-Agent'] = `flagsmith-js-sdk/${SDK_VERSION}`
843+
}
844+
841845
if (headers) {
842846
Object.assign(options.headers, headers);
843847
}

package-lock.json

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
"postinstall": "patch-package",
1515
"prepublish": "npx in-publish && npm run build || echo",
1616
"test": "jest --env=jsdom",
17-
"checknodeversion": "npx ls-engines"
17+
"checknodeversion": "npx ls-engines",
18+
"prepare": "husky",
19+
"precommit": "npm run typecheck && npm run prebuild"
1820
},
1921
"repository": {
2022
"type": "git",
@@ -50,6 +52,7 @@
5052
"eslint-plugin-react": "7.28.0",
5153
"eslint-plugin-react-hooks": "4.3.0",
5254
"fork-ts-checker-webpack-plugin": "^7.2.1",
55+
"husky": "^9.1.7",
5356
"in-publish": "^2.0.1",
5457
"jest": "^29.7.0",
5558
"jest-environment-jsdom": "^29.7.0",

test/init.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ describe('Flagsmith.init', () => {
307307
headers: expect.objectContaining({
308308
'Flagsmith-Application-Name': 'Test App',
309309
'Flagsmith-Application-Version': '1.2.3',
310+
'Flagsmith-SDK-User-Agent': `flagsmith-js-sdk/${SDK_VERSION}`,
310311
}),
311312
}),
312313
);

0 commit comments

Comments
 (0)