mirror of
https://github.com/logto-io/logto.git
synced 2025-02-17 22:04:19 -05:00
feat(core): report oidc exceptions to the appInsights (#5978)
report oidc exceptions to the appInsights
This commit is contained in:
parent
0748a22efb
commit
a495ab00ba
1 changed files with 5 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
import { appInsights } from '@logto/app-insights/node';
|
||||
import { condObject, isObject } from '@silverhand/essentials';
|
||||
import i18next from 'i18next';
|
||||
import type { Middleware } from 'koa';
|
||||
|
@ -6,6 +7,7 @@ import { z } from 'zod';
|
|||
|
||||
import { EnvSet } from '#src/env-set/index.js';
|
||||
import { getConsoleLogFromContext } from '#src/utils/console.js';
|
||||
import { buildAppInsightsTelemetry } from '#src/utils/request.js';
|
||||
|
||||
/**
|
||||
* Supplementary URIs for oidc-provider errors.
|
||||
|
@ -88,6 +90,9 @@ export default function koaOidcErrorHandler<StateT, ContextT>(): Middleware<Stat
|
|||
throw error;
|
||||
}
|
||||
|
||||
// Report oidc exceptions to ApplicationInsights
|
||||
void appInsights.trackException(error, buildAppInsightsTelemetry(ctx));
|
||||
|
||||
// Mimic oidc-provider's error handling, thus we can use the unified logic below.
|
||||
// See https://github.com/panva/node-oidc-provider/blob/37d0a6cfb3c618141a44cbb904ce45659438f821/lib/shared/error_handler.js
|
||||
ctx.status = error.statusCode || 500;
|
||||
|
|
Loading…
Add table
Reference in a new issue