@payloadcms/plugin-sentry 4.0.0-internal.e16cf59 → 4.0.0-internal.e55ccef
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/LICENSE.md +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2018-
|
|
3
|
+
Copyright (c) 2018-2026 Payload CMS, LLC <info@payloadcms.com>
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Config } from 'payload';
|
|
2
1
|
import type { PluginOptions } from './types.js';
|
|
3
2
|
export { PluginOptions };
|
|
4
3
|
/**
|
|
@@ -23,5 +22,5 @@ export { PluginOptions };
|
|
|
23
22
|
* })
|
|
24
23
|
* ```
|
|
25
24
|
*/
|
|
26
|
-
export declare const sentryPlugin: (
|
|
25
|
+
export declare const sentryPlugin: (options: PluginOptions) => import("payload").Plugin;
|
|
27
26
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAA;AACxB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,YAAY,sDAiEvB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { definePlugin } from 'payload';
|
|
1
2
|
/**
|
|
2
3
|
* @example
|
|
3
4
|
* ```ts
|
|
@@ -19,7 +20,9 @@
|
|
|
19
20
|
* Sentry,
|
|
20
21
|
* })
|
|
21
22
|
* ```
|
|
22
|
-
*/ export const sentryPlugin = (
|
|
23
|
+
*/ export const sentryPlugin = definePlugin({
|
|
24
|
+
slug: '@payloadcms/plugin-sentry',
|
|
25
|
+
plugin: ({ config, options: pluginOptions })=>{
|
|
23
26
|
const { enabled = true, options = {}, Sentry } = pluginOptions;
|
|
24
27
|
if (!enabled || !Sentry) {
|
|
25
28
|
return config;
|
|
@@ -51,9 +54,10 @@
|
|
|
51
54
|
user: {
|
|
52
55
|
id: args.req.user.id,
|
|
53
56
|
collection: args.req.user.collection,
|
|
54
|
-
email
|
|
57
|
+
// Payload types email/username as nullable; Sentry's user expects string | undefined
|
|
58
|
+
email: args.req.user.email ?? undefined,
|
|
55
59
|
ip_address: args.req.headers?.get('X-Forwarded-For') ?? undefined,
|
|
56
|
-
username: args.req.user.username
|
|
60
|
+
username: args.req.user.username ?? undefined
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
63
|
};
|
|
@@ -72,6 +76,7 @@
|
|
|
72
76
|
]
|
|
73
77
|
}
|
|
74
78
|
};
|
|
75
|
-
}
|
|
79
|
+
}
|
|
80
|
+
});
|
|
76
81
|
|
|
77
82
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ScopeContext } from '@sentry/types'\nimport type { APIError
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ScopeContext } from '@sentry/types'\nimport type { APIError } from 'payload'\n\nimport { definePlugin } from 'payload'\n\nimport type { PluginOptions } from './types.js'\n\nexport { PluginOptions }\n/**\n * @example\n * ```ts\n * import * as Sentry from '@sentry/nextjs'\n *\n * sentryPlugin({\n * options: {\n * captureErrors: [400, 403],\n * context: ({ defaultContext, req }) => {\n * return {\n * ...defaultContext,\n * tags: {\n * locale: req.locale,\n * },\n * }\n * },\n * debug: true,\n * },\n * Sentry,\n * })\n * ```\n */\nexport const sentryPlugin = definePlugin<PluginOptions>({\n slug: '@payloadcms/plugin-sentry',\n plugin: ({ config, options: pluginOptions }) => {\n const { enabled = true, options = {}, Sentry } = pluginOptions\n\n if (!enabled || !Sentry) {\n return config\n }\n\n const { captureErrors = [], debug = false } = options\n\n return {\n ...config,\n admin: {\n ...config.admin,\n components: {\n ...config.admin?.components,\n providers: [\n ...(config.admin?.components?.providers ?? []),\n '@payloadcms/plugin-sentry/client#AdminErrorBoundary',\n ],\n },\n },\n hooks: {\n afterError: [\n ...(config.hooks?.afterError ?? []),\n async (args) => {\n const status = (args.error as APIError).status ?? 500\n if (status >= 500 || captureErrors.includes(status)) {\n let context: Partial<ScopeContext> = {\n extra: {\n errorCollectionSlug: args.collection?.slug,\n },\n ...(args.req.user && {\n user: {\n id: args.req.user.id,\n collection: args.req.user.collection,\n // Payload types email/username as nullable; Sentry's user expects string | undefined\n email: args.req.user.email ?? undefined,\n ip_address: args.req.headers?.get('X-Forwarded-For') ?? undefined,\n username: args.req.user.username ?? undefined,\n },\n }),\n }\n\n if (options?.context) {\n context = await options.context({\n ...args,\n defaultContext: context,\n })\n }\n\n const id = Sentry.captureException(args.error, context)\n\n if (debug) {\n args.req.payload.logger.info(\n `Captured exception ${id} to Sentry, error msg: ${args.error.message}`,\n )\n }\n }\n },\n ],\n },\n }\n },\n})\n"],"names":["definePlugin","sentryPlugin","slug","plugin","config","options","pluginOptions","enabled","Sentry","captureErrors","debug","admin","components","providers","hooks","afterError","args","status","error","includes","context","extra","errorCollectionSlug","collection","req","user","id","email","undefined","ip_address","headers","get","username","defaultContext","captureException","payload","logger","info","message"],"mappings":"AAGA,SAASA,YAAY,QAAQ,UAAS;AAKtC;;;;;;;;;;;;;;;;;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S;gCACpBA,UAAU,MAAMf,QAAQe,OAAO,CAAC;oCAC9B,GAAGJ,IAAI;oCACPiB,gBAAgBb;gCAClB;4BACF;4BAEA,MAAMM,KAAKlB,OAAO0B,gBAAgB,CAAClB,KAAKE,KAAK,EAAEE;4BAE/C,IAAIV,OAAO;gCACTM,KAAKQ,GAAG,CAACW,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1B,CAAC,mBAAmB,EAAEX,GAAG,uBAAuB,EAAEV,KAAKE,KAAK,CAACoB,OAAO,EAAE;4BAE1E;wBACF;oBACF;iBACD;YACH;QACF;IACF;AACF,GAAE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@payloadcms/plugin-sentry",
|
|
3
|
-
"version": "4.0.0-internal.
|
|
3
|
+
"version": "4.0.0-internal.e55ccef",
|
|
4
4
|
"description": "Sentry plugin for Payload",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"payload",
|
|
@@ -51,12 +51,12 @@
|
|
|
51
51
|
"@types/react": "19.2.14",
|
|
52
52
|
"@types/react-dom": "19.2.3",
|
|
53
53
|
"@payloadcms/eslint-config": "3.28.0",
|
|
54
|
-
"payload": "4.0.0-internal.
|
|
54
|
+
"payload": "4.0.0-internal.e55ccef"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"react": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
58
58
|
"react-dom": "^19.0.1 || ^19.1.2 || ^19.2.1",
|
|
59
|
-
"payload": "4.0.0-internal.
|
|
59
|
+
"payload": "4.0.0-internal.e55ccef"
|
|
60
60
|
},
|
|
61
61
|
"homepage:": "https://payloadcms.com",
|
|
62
62
|
"scripts": {
|