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

feat: Resolve Debug to redirect to UI tool on web #209

Merged
merged 4 commits into from
Dec 3, 2024
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
2 changes: 2 additions & 0 deletions api/sdk.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
1 change: 1 addition & 0 deletions packages/sdk/src/Confidence.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ describe('Confidence', () => {

beforeEach(() => {
confidence = new Confidence({
clientSecret: 'secret',
timeout: 10,
environment: 'client',
logger: {},
Expand Down
12 changes: 12 additions & 0 deletions packages/sdk/src/Confidence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ export interface Configuration {
/** Flag Resolver Client
* @internal */
readonly flagResolverClient: FlagResolverClient;
/* @internal */
readonly clientSecret: string;
}

/**
Expand Down Expand Up @@ -291,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())) {
Expand All @@ -314,6 +317,14 @@ export class Confidence implements EventSender, Trackable, FlagResolver {
return (await this.evaluateFlag(path, defaultValue)).value;
}

private showLoggerLink(flag: string, context: Context) {
this.config.logger.info?.(
`See resolves for '${flag}' in Confidence: https://app.confidence.spotify.com/flags/resolver-test?client-key=${
this.config.clientSecret
}&flag=flags/${flag}&context=${encodeURIComponent(JSON.stringify(context))}`,
);
}

/**
* Creates a Confidence instance
* @param clientSecret - clientSecret found on the Confidence console
Expand Down Expand Up @@ -374,6 +385,7 @@ export class Confidence implements EventSender, Trackable, FlagResolver {
eventSenderEngine,
timeout,
logger,
clientSecret,
});
}
}
Expand Down