diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 0000000..da23e2c --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1,2 @@ +#!/bin/sh +npm run precommit diff --git a/flagsmith-core.ts b/flagsmith-core.ts index b3a0f4f..877e946 100644 --- a/flagsmith-core.ts +++ b/flagsmith-core.ts @@ -829,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); } diff --git a/lib/flagsmith/package.json b/lib/flagsmith/package.json index 63712b9..8ae5bb1 100644 --- a/lib/flagsmith/package.json +++ b/lib/flagsmith/package.json @@ -1,6 +1,6 @@ { "name": "flagsmith", - "version": "9.3.2", + "version": "10.0.0", "description": "Feature flagging to support continuous development", "main": "./index.js", "module": "./index.mjs", diff --git a/lib/react-native-flagsmith/package.json b/lib/react-native-flagsmith/package.json index ec41851..0ce9685 100644 --- a/lib/react-native-flagsmith/package.json +++ b/lib/react-native-flagsmith/package.json @@ -1,6 +1,6 @@ { "name": "react-native-flagsmith", - "version": "9.3.2", + "version": "10.0.0", "description": "Feature flagging to support continuous development", "main": "./index.js", "repository": { diff --git a/package-lock.json b/package-lock.json index e8d5025..4922056 100644 --- a/package-lock.json +++ b/package-lock.json @@ -35,6 +35,7 @@ "eslint-plugin-react": "7.28.0", "eslint-plugin-react-hooks": "4.3.0", "fork-ts-checker-webpack-plugin": "^7.2.1", + "husky": "^9.1.7", "in-publish": "^2.0.1", "jest": "^29.7.0", "jest-environment-jsdom": "^29.7.0", @@ -6204,6 +6205,22 @@ "node": ">=10.17.0" } }, + "node_modules/husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true, + "license": "MIT", + "bin": { + "husky": "bin.js" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/typicode" + } + }, "node_modules/iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", @@ -15150,6 +15167,12 @@ "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", "dev": true }, + "husky": { + "version": "9.1.7", + "resolved": "https://registry.npmjs.org/husky/-/husky-9.1.7.tgz", + "integrity": "sha512-5gs5ytaNjBrh5Ow3zrvdUUY+0VxIuWVL4i9irt6friV+BqdCfmV11CQTWMiBYWHbXhco+J1kHfTOUkePhCDvMA==", + "dev": true + }, "iconv-lite": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.3.tgz", diff --git a/package.json b/package.json index 80e3379..d9ac800 100644 --- a/package.json +++ b/package.json @@ -1,88 +1,91 @@ { - "name": "flagsmith", - "description": "Feature flagging to support continuous development", - "main": "./flagsmith/index.js", - "scripts": { - "typecheck": "tsc", - "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", - "dev": "nodemon", - "generatetypes": "curl https://raw.githubusercontent.com/Flagsmith/flagsmith/refs/heads/main/sdk/evaluation-context.json -o evaluation-context.json && npx quicktype -o evaluation-context.ts --src-lang schema --just-types --no-prefer-types --nice-property-names evaluation-context.json && rm evaluation-context.json", - "postinstall": "patch-package", - "prepublish": "npx in-publish && npm run build || echo", - "test": "jest --env=jsdom", - "checknodeversion": "npx ls-engines" - }, - "repository": { - "type": "git", - "url": "https://github.com/Flagsmith/flagsmith-js-client/" - }, - "keywords": [ - "react native", - "feature flagger", - "continuous deployment" - ], - "author": "SSG", - "license": "BSD-3-Clause", - "bugs": { - "url": "https://github.com/Flagsmith/flagsmith-js-client/issues" - }, - "homepage": "https://flagsmith.com", - "devDependencies": { - "@babel/preset-env": "^7.24.0", - "@babel/preset-typescript": "^7.23.3", - "@rollup/plugin-commonjs": "^21.0.2", - "@rollup/plugin-node-resolve": "^13.3.0", - "@rollup/plugin-replace": "^4.0.0", - "@rollup/plugin-typescript": "^8.3.4", - "@testing-library/react": "^14.2.1", - "@types/jest": "^29.5.12", - "@types/react": "^17.0.39", - "@typescript-eslint/eslint-plugin": "5.4.0", - "@typescript-eslint/parser": "5.4.0", - "eslint": "^7.6.0", - "eslint-config-prettier": "^8.3.0", - "eslint-plugin-import": "2.27.5", - "eslint-plugin-prettier": "^3.4.0", - "eslint-plugin-react": "7.28.0", - "eslint-plugin-react-hooks": "4.3.0", - "fork-ts-checker-webpack-plugin": "^7.2.1", - "in-publish": "^2.0.1", - "jest": "^29.7.0", - "jest-environment-jsdom": "^29.7.0", - "nodemon": "^3.1.7", - "patch-package": "^6.5.0", - "quicktype": "^23.0.170", - "react": "^18.2.0", - "react-dom": "^18.2.0", - "rollup": "^2.77.0", - "rollup-plugin-dts": "^4.2.0", - "rollup-plugin-peer-deps-external": "^2.2.4", - "rollup-plugin-terser": "^7.0.2", - "tiny-replace-files": "^1.0.2", - "ts-jest": "^29.1.2", - "ts-loader": "^9.2.7", - "tslib": "^2.4.0", - "typescript": "^4.6.2" - }, - "peerDependencies": { - "react": "^17.0.2", - "react-dom": "^17.0.2" - }, - "dependencies": { - "@babel/preset-react": "^7.24.1", - "encoding": "^0.1.12", - "fast-deep-equal": "^3.1.3", - "fs-extra": "^11.2.0", - "isomorphic-unfetch": "^3.0.0", - "react-native-sse": "^1.1.0", - "reconnecting-eventsource": "^1.5.0" - }, - "types": "./index.d.ts", - "engines": { - "node": ">= 14.14" - } + "name": "flagsmith", + "description": "Feature flagging to support continuous development", + "main": "./flagsmith/index.js", + "scripts": { + "typecheck": "tsc", + "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", + "dev": "nodemon", + "generatetypes": "curl https://raw.githubusercontent.com/Flagsmith/flagsmith/refs/heads/main/sdk/evaluation-context.json -o evaluation-context.json && npx quicktype -o evaluation-context.ts --src-lang schema --just-types --no-prefer-types --nice-property-names evaluation-context.json && rm evaluation-context.json", + "postinstall": "patch-package", + "prepublish": "npx in-publish && npm run build || echo", + "test": "jest --env=jsdom", + "checknodeversion": "npx ls-engines", + "prepare": "husky", + "precommit": "npm run typecheck && npm run prebuild" + }, + "repository": { + "type": "git", + "url": "https://github.com/Flagsmith/flagsmith-js-client/" + }, + "keywords": [ + "react native", + "feature flagger", + "continuous deployment" + ], + "author": "SSG", + "license": "BSD-3-Clause", + "bugs": { + "url": "https://github.com/Flagsmith/flagsmith-js-client/issues" + }, + "homepage": "https://flagsmith.com", + "devDependencies": { + "@babel/preset-env": "^7.24.0", + "@babel/preset-typescript": "^7.23.3", + "@rollup/plugin-commonjs": "^21.0.2", + "@rollup/plugin-node-resolve": "^13.3.0", + "@rollup/plugin-replace": "^4.0.0", + "@rollup/plugin-typescript": "^8.3.4", + "@testing-library/react": "^14.2.1", + "@types/jest": "^29.5.12", + "@types/react": "^17.0.39", + "@typescript-eslint/eslint-plugin": "5.4.0", + "@typescript-eslint/parser": "5.4.0", + "eslint": "^7.6.0", + "eslint-config-prettier": "^8.3.0", + "eslint-plugin-import": "2.27.5", + "eslint-plugin-prettier": "^3.4.0", + "eslint-plugin-react": "7.28.0", + "eslint-plugin-react-hooks": "4.3.0", + "fork-ts-checker-webpack-plugin": "^7.2.1", + "husky": "^9.1.7", + "in-publish": "^2.0.1", + "jest": "^29.7.0", + "jest-environment-jsdom": "^29.7.0", + "nodemon": "^3.1.7", + "patch-package": "^6.5.0", + "quicktype": "^23.0.170", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "rollup": "^2.77.0", + "rollup-plugin-dts": "^4.2.0", + "rollup-plugin-peer-deps-external": "^2.2.4", + "rollup-plugin-terser": "^7.0.2", + "tiny-replace-files": "^1.0.2", + "ts-jest": "^29.1.2", + "ts-loader": "^9.2.7", + "tslib": "^2.4.0", + "typescript": "^4.6.2" + }, + "peerDependencies": { + "react": "^17.0.2", + "react-dom": "^17.0.2" + }, + "dependencies": { + "@babel/preset-react": "^7.24.1", + "encoding": "^0.1.12", + "fast-deep-equal": "^3.1.3", + "fs-extra": "^11.2.0", + "isomorphic-unfetch": "^3.0.0", + "react-native-sse": "^1.1.0", + "reconnecting-eventsource": "^1.5.0" + }, + "types": "./index.d.ts", + "engines": { + "node": ">= 14.14" + } } diff --git a/test/init.test.ts b/test/init.test.ts index aa1823d..6d9d66e 100644 --- a/test/init.test.ts +++ b/test/init.test.ts @@ -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}`, }), }), ); diff --git a/utils/version.ts b/utils/version.ts index 01abe05..4346f83 100644 --- a/utils/version.ts +++ b/utils/version.ts @@ -1,2 +1,2 @@ // Auto-generated by write-version.js -export const SDK_VERSION = "9.3.2"; +export const SDK_VERSION = "10.0.0";