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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,6 @@ buck-out/
android/app/libs
android/keystores/debug.keystore
*.js.map

# Utils
utils/version.ts
5 changes: 5 additions & 0 deletions flagsmith-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import setDynatraceValue from './utils/set-dynatrace-value';
import { EvaluationContext } from './evaluation-context';
import { isTraitEvaluationContext, toEvaluationContext, toTraitEvaluationContextObject } from './utils/types';
import { ensureTrailingSlash } from './utils/ensureTrailingSlash';
import { SDK_VERSION } from './utils/version';

enum FlagSource {
"NONE" = "NONE",
Expand Down Expand Up @@ -828,6 +829,10 @@ const Flagsmith = class {
options.headers['Flagsmith-Application-Version'] = this.applicationMetadata.version;
}

if (SDK_VERSION) {
options.headers['Flagsmith-SDK-user-agent'] = `flagsmith-js-sdk/${SDK_VERSION}`
}

if (headers) {
Object.assign(options.headers, headers);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/flagsmith/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "flagsmith",
"version": "9.3.0",
"version": "9.3.1",
"description": "Feature flagging to support continuous development",
"main": "./index.js",
"module": "./index.mjs",
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
"main": "./flagsmith/index.js",
"scripts": {
"typecheck": "tsc",
"build": "npm run generatetypes && npm run bundle && npm run typecheck",
"prebuild": "node scripts/write-version.js",
"build": "npm run prebuild && npm run bundle && npm run typecheck",
"bundle": "rollup -c && node ./move-react.js",
"deploy": "npm run build && npm test && cd ./lib/flagsmith/ && npm publish && cd ../../lib/react-native-flagsmith && npm publish",
"deploy:beta": "npm run build && npm test && cd ./lib/flagsmith/ && npm publish --tag beta && cd ../../lib/react-native-flagsmith && npm publish --tag beta",
Expand Down
10 changes: 10 additions & 0 deletions scripts/write-version.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const fs = require('fs');
const path = require('path');
const pkg = require('../lib/flagsmith/package.json');

const content = `// Auto-generated by write-version.js
export const SDK_VERSION = "${pkg.version}";
`;

fs.writeFileSync(path.join(__dirname, '../utils/version.ts'), content);
3 changes: 2 additions & 1 deletion test/init.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { waitFor } from '@testing-library/react';
import {defaultState, FLAGSMITH_KEY, getFlagsmith, getStateToCheck, identityState} from './test-constants';
import { promises as fs } from 'fs';

import { SDK_VERSION } from '../utils/version'
describe('Flagsmith.init', () => {
beforeEach(() => {
// Avoid mocks, but if you need to add them here
Expand Down Expand Up @@ -292,6 +292,7 @@ describe('Flagsmith.init', () => {
headers: expect.objectContaining({
'Flagsmith-Application-Name': 'Test App',
'Flagsmith-Application-Version': '1.2.3',
'Flagsmith-SDK-user-agent': `flagsmith-js-sdk/${SDK_VERSION}`,
}),
}),
);
Expand Down
2 changes: 2 additions & 0 deletions utils/version.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Auto-generated by write-version.js
export const SDK_VERSION = "9.3.1";