diff --git a/api/sdk.api.md b/api/sdk.api.md index 8f6b3b9..e703e56 100644 --- a/api/sdk.api.md +++ b/api/sdk.api.md @@ -64,6 +64,8 @@ export interface ConfidenceOptions { // @public export interface Configuration { + // (undocumented) + readonly clientSecret: string; readonly environment: 'client' | 'backend'; // Warning: (ae-forgotten-export) The symbol "EventSenderEngine" needs to be exported by the entry point index.d.ts // diff --git a/packages/sdk/src/Confidence.test.ts b/packages/sdk/src/Confidence.test.ts index e31bd03..2f89d63 100644 --- a/packages/sdk/src/Confidence.test.ts +++ b/packages/sdk/src/Confidence.test.ts @@ -23,6 +23,7 @@ describe('Confidence', () => { beforeEach(() => { confidence = new Confidence({ + clientSecret: 'secret', timeout: 10, environment: 'client', logger: {}, diff --git a/packages/sdk/src/Confidence.ts b/packages/sdk/src/Confidence.ts index 900308e..fbab81b 100644 --- a/packages/sdk/src/Confidence.ts +++ b/packages/sdk/src/Confidence.ts @@ -293,6 +293,7 @@ export class Confidence implements EventSender, Trackable, FlagResolver { value: defaultValue, }; } else { + this.showLoggerLink(path, this.getContext()); evaluation = this.currentFlags.evaluate(path, defaultValue); } if (!this.currentFlags || !Value.equal(this.currentFlags.context, this.getContext())) { @@ -313,13 +314,15 @@ export class Confidence implements EventSender, Trackable, FlagResolver { getFlag(path: string, defaultValue: number): Promise<number>; getFlag<T extends Value>(path: string, defaultValue: T): Promise<T>; async getFlag<T extends Value>(path: string, defaultValue: any): Promise<T> { - const clientKey = this.config.clientSecret; - const flag = (await this.evaluateFlag(path, defaultValue)).value; - const context = this._context; - this.config.logger.debug?.( - `Resolve debug: https://app.confidence.spotify.com/flags/resolver-test?client-key=${clientKey}&flag=flags/${flag}&context=${context}`, + return (await this.evaluateFlag(path, defaultValue)).value; + } + + private showLoggerLink(flag: string, context: Context) { + this.config.logger.info?.( + `Resolve debug: https://app.confidence.spotify.com/flags/resolver-test?client-key=${ + this.config.clientSecret + }&flag=flags/${flag}&context=${JSON.stringify(context)}`, ); - return flag; } /**