cloudflare-next-intl 0.9.36 → 0.9.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,33 +1,6 @@
1
- import reportError from './report_error.js';
2
- import stringifyUnknown from './stringify_unknown.js';
3
- async function resolveRequestContext() {
4
- try {
5
- const { headers } = await import('next/headers.js');
6
- const headerList = await headers();
7
- return {
8
- path: headerList.get('x-pathname') ?? undefined,
9
- userAgent: headerList.get('user-agent') ?? undefined,
10
- referer: headerList.get('referer') ?? undefined,
11
- };
12
- }
13
- catch {
14
- return {};
15
- }
16
- }
1
+ import { reportClientErrorCore } from './report_client_error_core.js';
17
2
  export default function createServerErrorAction(config) {
18
3
  return async function reportClientError(error, classOrMethodName, params) {
19
- const requestContext = await resolveRequestContext();
20
- const isPlainParamsObject = typeof params === 'object' && params !== null && !Array.isArray(params);
21
- const mergedParams = params === undefined
22
- ? { requestContext }
23
- : isPlainParamsObject
24
- ? { ...params, requestContext }
25
- : { params, requestContext };
26
- await reportError(config, {
27
- error: stringifyUnknown(error, true),
28
- classOrMethodName,
29
- params: mergedParams,
30
- isClient: true,
31
- });
4
+ await reportClientErrorCore(config, error, classOrMethodName, params);
32
5
  };
33
6
  }
@@ -0,0 +1,3 @@
1
+ import type { ReportErrorConfig } from './report_error.js';
2
+ export declare function setErrorHandlingActionConfig(next: ReportErrorConfig | undefined): void;
3
+ export declare function getErrorHandlingActionConfig(): ReportErrorConfig | undefined;
@@ -0,0 +1,7 @@
1
+ let config;
2
+ export function setErrorHandlingActionConfig(next) {
3
+ config = next;
4
+ }
5
+ export function getErrorHandlingActionConfig() {
6
+ return config;
7
+ }
@@ -10,4 +10,5 @@ export { defaultIgnoredConsoleErrors } from './default_ignored_console_errors.js
10
10
  export { default as isStaleDeployError, defaultStaleDeployPatterns, setStaleDeployPatterns, getStaleDeployPatterns, } from './is_stale_deploy_error.js';
11
11
  export { default as clearClientCache } from './clear_client_cache.js';
12
12
  export { default as useStaleDeployRecovery, shouldRecoverFromStaleDeploy } from './use_stale_deploy_recovery.js';
13
+ export { setErrorHandlingActionConfig, getErrorHandlingActionConfig } from './error_handling_action_config.js';
13
14
  export type { ErrorHandlingParams, ErrorHandlingRoutingConfig } from '../types/types.js';
@@ -8,3 +8,4 @@ export { defaultIgnoredConsoleErrors } from './default_ignored_console_errors.js
8
8
  export { default as isStaleDeployError, defaultStaleDeployPatterns, setStaleDeployPatterns, getStaleDeployPatterns, } from './is_stale_deploy_error.js';
9
9
  export { default as clearClientCache } from './clear_client_cache.js';
10
10
  export { default as useStaleDeployRecovery, shouldRecoverFromStaleDeploy } from './use_stale_deploy_recovery.js';
11
+ export { setErrorHandlingActionConfig, getErrorHandlingActionConfig } from './error_handling_action_config.js';
@@ -0,0 +1,2 @@
1
+ import type { ErrorHandlingParams } from '../types/types.js';
2
+ export default function reportClientError(error: unknown, classOrMethodName: string, params?: ErrorHandlingParams['params']): Promise<void>;
@@ -0,0 +1,6 @@
1
+ 'use server';
2
+ import { getErrorHandlingActionConfig } from './error_handling_action_config.js';
3
+ import { reportClientErrorCore } from './report_client_error_core.js';
4
+ export default async function reportClientError(error, classOrMethodName, params) {
5
+ await reportClientErrorCore(getErrorHandlingActionConfig(), error, classOrMethodName, params);
6
+ }
@@ -0,0 +1,3 @@
1
+ import type { ErrorHandlingParams } from '../types/types.js';
2
+ import { type ReportErrorConfig } from './report_error.js';
3
+ export declare function reportClientErrorCore(config: ReportErrorConfig | undefined, error: unknown, classOrMethodName: string, params?: ErrorHandlingParams['params']): Promise<void>;
@@ -0,0 +1,31 @@
1
+ import reportError from './report_error.js';
2
+ import stringifyUnknown from './stringify_unknown.js';
3
+ async function resolveRequestContext() {
4
+ try {
5
+ const { headers } = await import('next/headers.js');
6
+ const headerList = await headers();
7
+ return {
8
+ path: headerList.get('x-pathname') ?? undefined,
9
+ userAgent: headerList.get('user-agent') ?? undefined,
10
+ referer: headerList.get('referer') ?? undefined,
11
+ };
12
+ }
13
+ catch {
14
+ return {};
15
+ }
16
+ }
17
+ export async function reportClientErrorCore(config, error, classOrMethodName, params) {
18
+ const requestContext = await resolveRequestContext();
19
+ const isPlainParamsObject = typeof params === 'object' && params !== null && !Array.isArray(params);
20
+ const mergedParams = params === undefined
21
+ ? { requestContext }
22
+ : isPlainParamsObject
23
+ ? { ...params, requestContext }
24
+ : { params, requestContext };
25
+ await reportError(config, {
26
+ error: stringifyUnknown(error, true),
27
+ classOrMethodName,
28
+ params: mergedParams,
29
+ isClient: true,
30
+ });
31
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cloudflare-next-intl",
3
- "version": "0.9.36",
3
+ "version": "0.9.37",
4
4
  "description": "Optimized Next Intl Package Special for App Router and Cloudflare",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -206,6 +206,10 @@
206
206
  "types": "./dist/src/error_handling/create_server_error_action.d.ts",
207
207
  "import": "./dist/src/error_handling/create_server_error_action.js"
208
208
  },
209
+ "./reportClientError": {
210
+ "types": "./dist/src/error_handling/report_client_error_action.d.ts",
211
+ "import": "./dist/src/error_handling/report_client_error_action.js"
212
+ },
209
213
  "./isStaleDeployError": {
210
214
  "types": "./dist/src/error_handling/is_stale_deploy_error.d.ts",
211
215
  "import": "./dist/src/error_handling/is_stale_deploy_error.js"