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.
- package/dist/src/error_handling/create_server_error_action.js +2 -29
- package/dist/src/error_handling/error_handling_action_config.d.ts +3 -0
- package/dist/src/error_handling/error_handling_action_config.js +7 -0
- package/dist/src/error_handling/index.d.ts +1 -0
- package/dist/src/error_handling/index.js +1 -0
- package/dist/src/error_handling/report_client_error_action.d.ts +2 -0
- package/dist/src/error_handling/report_client_error_action.js +6 -0
- package/dist/src/error_handling/report_client_error_core.d.ts +3 -0
- package/dist/src/error_handling/report_client_error_core.js +31 -0
- package/package.json +5 -1
|
@@ -1,33 +1,6 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
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
|
}
|
|
@@ -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,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.
|
|
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"
|