@payloadcms/plugin-sentry 3.2.2-canary.a11698b → 3.2.2-canary.d2399ed

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,MAAM,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAA;AACxB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,YAAY,kBACP,aAAa,cACpB,MAAM,KAAG,MA+DjB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAY,MAAM,EAAE,MAAM,SAAS,CAAA;AAE/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAE/C,OAAO,EAAE,aAAa,EAAE,CAAA;AACxB;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,YAAY,kBACP,aAAa,cACpB,MAAM,KAAG,MA6DjB,CAAA"}
package/dist/index.js CHANGED
@@ -41,33 +41,31 @@
41
41
  afterError: [
42
42
  ...config.hooks?.afterError ?? [],
43
43
  async (args)=>{
44
- if ('status' in args.error) {
45
- const apiError = args.error;
46
- if (apiError.status >= 500 || captureErrors.includes(apiError.status)) {
47
- let context = {
48
- extra: {
49
- errorCollectionSlug: args.collection?.slug
50
- },
51
- ...args.req.user && {
52
- user: {
53
- id: args.req.user.id,
54
- collection: args.req.user.collection,
55
- email: args.req.user.email,
56
- ip_address: args.req.headers?.get('X-Forwarded-For') ?? undefined,
57
- username: args.req.user.username
58
- }
44
+ const status = args.error.status ?? 500;
45
+ if (status >= 500 || captureErrors.includes(status)) {
46
+ let context = {
47
+ extra: {
48
+ errorCollectionSlug: args.collection?.slug
49
+ },
50
+ ...args.req.user && {
51
+ user: {
52
+ id: args.req.user.id,
53
+ collection: args.req.user.collection,
54
+ email: args.req.user.email,
55
+ ip_address: args.req.headers?.get('X-Forwarded-For') ?? undefined,
56
+ username: args.req.user.username
59
57
  }
60
- };
61
- if (options?.context) {
62
- context = await options.context({
63
- ...args,
64
- defaultContext: context
65
- });
66
- }
67
- const id = Sentry.captureException(args.error, context);
68
- if (debug) {
69
- args.req.payload.logger.info(`Captured exception ${id} to Sentry, error msg: ${args.error.message}`);
70
58
  }
59
+ };
60
+ if (options?.context) {
61
+ context = await options.context({
62
+ ...args,
63
+ defaultContext: context
64
+ });
65
+ }
66
+ const id = Sentry.captureException(args.error, context);
67
+ if (debug) {
68
+ args.req.payload.logger.info(`Captured exception ${id} to Sentry, error msg: ${args.error.message}`);
71
69
  }
72
70
  }
73
71
  }
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, Config } 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 =\n (pluginOptions: PluginOptions) =>\n (config: Config): Config => {\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 if ('status' in args.error) {\n const apiError = args.error as APIError\n if (apiError.status >= 500 || captureErrors.includes(apiError.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 email: args.req.user.email,\n ip_address: args.req.headers?.get('X-Forwarded-For') ?? undefined,\n username: args.req.user.username,\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":["sentryPlugin","pluginOptions","config","enabled","options","Sentry","captureErrors","debug","admin","components","providers","hooks","afterError","args","error","apiError","status","includes","context","extra","errorCollectionSlug","collection","slug","req","user","id","email","ip_address","headers","get","undefined","username","defaultContext","captureException","payload","logger","info","message"],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,MAAMA,eACX,CAACC,gBACD,CAACC;QACC,MAAM,EAAEC,UAAU,IAAI,EAAEC,UAAU,CAAC,CAAC,EAAEC,MAAM,EAAE,GAAGJ;QAEjD,IAAI,CAACE,WAAW,CAACE,QAAQ;YACvB,OAAOH;QACT;QAEA,MAAM,EAAEI,gBAAgB,EAAE,EAAEC,QAAQ,KAAK,EAAE,GAAGH;QAE9C,OAAO;YACL,GAAGF,MAAM;YACTM,OAAO;gBACL,GAAGN,OAAOM,KAAK;gBACfC,YAAY;oBACV,GAAGP,OAAOM,KAAK,EAAEC,UAAU;oBAC3BC,WAAW;2BACLR,OAAOM,KAAK,EAAEC,YAAYC,aAAa,EAAE;wBAC7C;qBACD;gBACH;YACF;YACAC,OAAO;gBACLC,YAAY;uBACNV,OAAOS,KAAK,EAAEC,cAAc,EAAE;oBAClC,OAAOC;wBACL,IAAI,YAAYA,KAAKC,KAAK,EAAE;4BAC1B,MAAMC,WAAWF,KAAKC,KAAK;4BAC3B,IAAIC,SAASC,MAAM,IAAI,OAAOV,cAAcW,QAAQ,CAACF,SAASC,MAAM,GAAG;gCACrE,IAAIE,UAAiC;oCACnCC,OAAO;wCACLC,qBAAqBP,KAAKQ,UAAU,EAAEC;oCACxC;oCACA,GAAIT,KAAKU,GAAG,CAACC,IAAI,IAAI;wCACnBA,MAAM;4CACJC,IAAIZ,KAAKU,GAAG,CAACC,IAAI,CAACC,EAAE;4CACpBJ,YAAYR,KAAKU,GAAG,CAACC,IAAI,CAACH,UAAU;4CACpCK,OAAOb,KAAKU,GAAG,CAACC,IAAI,CAACE,KAAK;4CAC1BC,YAAYd,KAAKU,GAAG,CAACK,OAAO,EAAEC,IAAI,sBAAsBC;4CACxDC,UAAUlB,KAAKU,GAAG,CAACC,IAAI,CAACO,QAAQ;wCAClC;oCACF,CAAC;gCACH;gCAEA,IAAI3B,SAASc,SAAS;oCACpBA,UAAU,MAAMd,QAAQc,OAAO,CAAC;wCAC9B,GAAGL,IAAI;wCACPmB,gBAAgBd;oCAClB;gCACF;gCAEA,MAAMO,KAAKpB,OAAO4B,gBAAgB,CAACpB,KAAKC,KAAK,EAAEI;gCAE/C,IAAIX,OAAO;oCACTM,KAAKU,GAAG,CAACW,OAAO,CAACC,MAAM,CAACC,IAAI,CAC1B,CAAC,mBAAmB,EAAEX,GAAG,uBAAuB,EAAEZ,KAAKC,KAAK,CAACuB,OAAO,CAAC,CAAC;gCAE1E;4BACF;wBACF;oBACF;iBACD;YACH;QACF;IACF,EAAC"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import type { ScopeContext } from '@sentry/types'\nimport type { APIError, Config } 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 =\n (pluginOptions: PluginOptions) =>\n (config: Config): Config => {\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 email: args.req.user.email,\n ip_address: args.req.headers?.get('X-Forwarded-For') ?? undefined,\n username: args.req.user.username,\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"],"names":["sentryPlugin","pluginOptions","config","enabled","options","Sentry","captureErrors","debug","admin","components","providers","hooks","afterError","args","status","error","includes","context","extra","errorCollectionSlug","collection","slug","req","user","id","email","ip_address","headers","get","undefined","username","defaultContext","captureException","payload","logger","info","message"],"mappings":"AAMA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,MAAMA,eACX,CAACC,gBACD,CAACC;QACC,MAAM,EAAEC,UAAU,IAAI,EAAEC,UAAU,CAAC,CAAC,EAAEC,MAAM,EAAE,GAAGJ;QAEjD,IAAI,CAACE,WAAW,CAACE,QAAQ;YACvB,OAAOH;QACT;QAEA,MAAM,EAA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AACqB,OAAO,CAAC,CAAC;4BAE1E;wBACF;oBACF;iBACD;YACH;QACF;IACF,EAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-sentry",
3
- "version": "3.2.2-canary.a11698b",
3
+ "version": "3.2.2-canary.d2399ed",
4
4
  "description": "Sentry plugin for Payload",
5
5
  "keywords": [
6
6
  "payload",
@@ -50,12 +50,12 @@
50
50
  "@types/react": "npm:types-react@19.0.0-rc.1",
51
51
  "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
52
52
  "@payloadcms/eslint-config": "3.0.0",
53
- "payload": "3.2.2-canary.a11698b"
53
+ "payload": "3.2.2-canary.d2399ed"
54
54
  },
55
55
  "peerDependencies": {
56
56
  "react": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
57
57
  "react-dom": "^19.0.0 || ^19.0.0-rc-65a56d0e-20241020",
58
- "payload": "3.2.2-canary.a11698b"
58
+ "payload": "3.2.2-canary.d2399ed"
59
59
  },
60
60
  "homepage:": "https://payloadcms.com",
61
61
  "overrides": {