Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send SDK version #39

Merged
merged 1 commit into from
Nov 16, 2023
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
15 changes: 14 additions & 1 deletion packages/client-http/src/client/ConfidenceClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ describe('ConfidenceClient', () => {
fetchImplementation: mockFetch,
apply: true,
region: 'eu',
sdk: {
id: 'SDK_ID_JS_WEB_PROVIDER',
version: 'TESTING',
},
timeout: 10,
});

Expand Down Expand Up @@ -63,7 +67,12 @@ describe('ConfidenceClient', () => {
body: JSON.stringify({
clientSecret: 'test-secret',
evaluationContext: context,
...options,
apply: options.apply,
sdk: {
id: 'SDK_ID_JS_WEB_PROVIDER',
version: 'TESTING',
},
flags: options.flags,
}),
}),
);
Expand Down Expand Up @@ -91,6 +100,10 @@ describe('ConfidenceClient', () => {
clientSecret: 'test-secret',
evaluationContext: context,
apply: true,
sdk: {
id: 'SDK_ID_JS_WEB_PROVIDER',
version: 'TESTING',
},
}),
}),
);
Expand Down
9 changes: 9 additions & 0 deletions packages/client-http/src/client/ConfidenceClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ type ApplyRequest = {
flags: AppliedFlag[];
sendTime: string;
};
type SDK = {
id: 'SDK_ID_JS_WEB_PROVIDER' | 'SDK_ID_JS_SERVER_PROVIDER';
version: string;
};
type ResolveRequest = {
clientSecret: string;
evaluationContext: ResolveContext;
apply?: boolean;
flags?: string[];
sdk: SDK;
};
type ResolveResponse = {
resolvedFlags: ResolvedFlag[];
Expand All @@ -36,6 +41,7 @@ export type ConfidenceClientOptions = {
apply: boolean;
region: 'eu' | 'us';
baseUrl?: string;
sdk: SDK;
timeout: number;
};
export type AppliedFlag = {
Expand All @@ -48,13 +54,15 @@ export class ConfidenceClient {
private readonly baseUrl: string;
private readonly clientSecret: string;
private readonly timeout: number;
private readonly sdk: SDK;
private readonly fetchImplementation: typeof fetch;

constructor(options: ConfidenceClientOptions) {
this.fetchImplementation = options.fetchImplementation;
this.clientSecret = options.clientSecret;
this.backendApplyEnabled = options.apply;
this.timeout = options.timeout;
this.sdk = options.sdk;
if (options.baseUrl) {
this.baseUrl = options.baseUrl;
} else {
Expand All @@ -66,6 +74,7 @@ export class ConfidenceClient {
clientSecret: this.clientSecret,
evaluationContext: context,
apply: this.backendApplyEnabled,
sdk: this.sdk,
...options,
};
const controller = new AbortController();
Expand Down
4 changes: 4 additions & 0 deletions packages/openfeature-server-provider/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export function createConfidenceServerProvider(options: ConfidenceProviderFactor
const confidenceClient = new ConfidenceClient({
...options,
apply: true,
sdk: {
id: 'SDK_ID_JS_SERVER_PROVIDER',
version: '0.0.0', // x-release-please-version
},
});

return new ConfidenceServerProvider(confidenceClient);
Expand Down
4 changes: 4 additions & 0 deletions packages/openfeature-web-provider/src/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ export function createConfidenceWebProvider(options: ConfidenceWebProviderFactor
const confidenceClient = new ConfidenceClient({
...options,
apply: options.apply === 'backend',
sdk: {
id: 'SDK_ID_JS_WEB_PROVIDER',
version: '0.0.0', // x-release-please-version
Billlynch marked this conversation as resolved.
Show resolved Hide resolved
},
});

return new ConfidenceWebProvider(confidenceClient, {
Expand Down
6 changes: 4 additions & 2 deletions release-please-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@
"component": "openfeature-server-provider",
"changelog-path": "CHANGELOG.md",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true
"bump-patch-for-minor-pre-major": true,
"extra-files": ["src/factory.ts"]
},
"packages/openfeature-web-provider": {
"component": "openfeature-web-provider",
"changelog-path": "CHANGELOG.md",
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": true
"bump-patch-for-minor-pre-major": true,
"extra-files": ["src/factory.ts"]
}
},
"changelog-sections": [
Expand Down
27 changes: 27 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2787,6 +2787,33 @@
dependencies:
"@sinonjs/commons" "^1.7.0"

"@spotify-confidence/client-http@^0.0.3":
version "0.0.3"
resolved "https://registry.yarnpkg.com/@spotify-confidence/client-http/-/client-http-0.0.3.tgz#33d90fa8e22e4968ed5d3a885b4dfc7afd9fa01b"
integrity sha512-gV6+T7/dtQs2PYKI/4PZac09Kq12LB6OBkdWRlb5uUJCjqzX6kcWUjabbz5ifkWSg9vYeOuH9oy/Bn/IMLRKXA==

"@spotify-confidence/[email protected]":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@spotify-confidence/integration-react/-/integration-react-0.1.0.tgz#735e6a0f74d0a855f31024b45c316066589cb53f"
integrity sha512-ryCNI1xeO3FZZjqMM8QNImtm1MgK7f74esytfSnCT3hUkMf7pYbEnZ6/hBdM10QYeiywVagwZioTF/3SMVn2sA==
dependencies:
use-sync-external-store "^1.2.0"

"@spotify-confidence/[email protected]":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@spotify-confidence/openfeature-server-provider/-/openfeature-server-provider-0.1.0.tgz#5409a85691dba7a47bd8f5edf2990e080a9333fe"
integrity sha512-cDOu3FRggxXE8dom5b//Kmi5wPwfOKTXA7V0PXXXQHVNTIODH9A6mfQnovAxijcqnR+0sFYsX61M+6Pj+xFiBw==
dependencies:
"@spotify-confidence/client-http" "^0.0.3"

"@spotify-confidence/[email protected]":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@spotify-confidence/openfeature-web-provider/-/openfeature-web-provider-0.1.0.tgz#5516a33a493b59e551be0d987cea92d442f94e99"
integrity sha512-b096+DLlWlljKIT0NijhJXvRXoMLtEOykzUIh6zDm2dZ+tyu/YuZ5wQXV6GVfFXLeWXyPn5rBzwQNbT2v4+l/w==
dependencies:
"@spotify-confidence/client-http" "^0.0.3"
fast-deep-equal "^3.1.3"

"@spotify/eslint-config-base@^15.0.0":
version "15.0.0"
resolved "https://registry.yarnpkg.com/@spotify/eslint-config-base/-/eslint-config-base-15.0.0.tgz#fa8a003e656b1c14694528a487bb9e974e013e4d"
Expand Down