Refactor billing code and add error monitoring

Refactored the code that retrieves the billing customer id by renaming the function getBillingCustomerId to getCustomerId. Also, bolstered error handling: implemented exception capture in particular scenarios across multiple files. If an error occurs, it's now captured and reported to the configured provider.
This commit is contained in:
giancarlo
2024-04-25 13:19:46 +07:00
parent 8d04624b1d
commit 03d06b64ba
10 changed files with 60 additions and 14 deletions

View File

@@ -32,6 +32,7 @@ The `enhanceAction` function takes two arguments:
The options object can contain the following properties:
- `captcha` - If true, the action will require a captcha to be passed to the body as `captchaToken`
- `schema` - A zod schema that the data will be validated against
- `captureException` - If true, the action will capture exceptions and report them to the configured provider. It is `true` by default.
When successfully called, the action will return the result of the action function.
@@ -70,10 +71,11 @@ export const POST = enhanceRouteHandler(({ request, body, user }) => {
// "user" is the user object from the session
// "request" is the raw request object passed by POST
// if "captcha" is true, the action will require a captcha
// if "captureException" is true, the action will capture exceptions and report them to the configured provider
}, {
captcha: true,
captureException: true,
schema: z.object({
id: z.number()
}),