Skip to content

Commit

Permalink
chore: Add log level to runner logs (#677) RELEASE
Browse files Browse the repository at this point in the history
## Related Issues

descope/etc#6034

## Description
add support for log level to flow runner
  • Loading branch information
asafshen authored Jul 5, 2024
1 parent a557e89 commit e70e146
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion packages/core-js-sdk/src/sdk/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ export type FlowResponse = {
// authentication information response, if response is authenticated
authInfo?: JWTResponse;
lastAuth?: Pick<LastAuth, 'authMethod' | 'oauthProvider'>;
runnerLogs?: { title?: string; log: string }[];
runnerLogs?: {
title?: string;
log: string;
level?: 'info' | 'debug' | 'warn' | 'error';
}[];
};

export type Options = {
Expand Down
11 changes: 8 additions & 3 deletions packages/web-component/src/lib/descope-wc/DescopeWc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,9 +544,14 @@ class DescopeWc extends BaseDescopeWc {
return;
}

sdkResp.data?.runnerLogs?.forEach((l) =>
this.loggerWrapper.info(l.title, l.log),
);
sdkResp.data?.runnerLogs?.forEach((l) => {
const { level, title, log } = l;
if (level && this.loggerWrapper[level]) {
this.loggerWrapper[level](title, log);
} else {
this.loggerWrapper.info(title, log);
}
});
const errorText = sdkResp.data?.screen?.state?.errorText;
if (sdkResp.data?.error) {
this.loggerWrapper.error(
Expand Down

0 comments on commit e70e146

Please sign in to comment.