@payloadcms/plugin-sentry 0.0.6 → 3.0.0-canary.a14e066

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/README.md CHANGED
@@ -1,120 +1,7 @@
1
- # Sentry Plugin for Payload
1
+ # Payload Sentry Plugin
2
2
 
3
- This plugin seamlessly integrates [Sentry](https://sentry.io/) with [Payload](https://github.com/payloadcms/payload) for performance monitoring and error tracking.
3
+ This plugin allows you to integrate [Sentry](https://sentry.io/) seamlessly with your [Payload](https://github.com/payloadcms/payload) application.
4
4
 
5
- ## Installation
6
-
7
- ```bash
8
- yarn add @payloadcms/plugin-sentry
9
- # OR
10
- npm i @payloadcms/plugin-sentry
11
- ```
12
-
13
- ## Basic Usage
14
-
15
- 1. Import `sentry` from `'@payloadcms/plugin-sentry'`
16
- 2. Add it to the `plugins` array of your [Payload config](https://payloadcms.com/docs/configuration/overview)
17
- 3. Pass in your Data Source Name (DSN)
18
- 4. Pass [additional options](#additional-options) - _not required_
19
-
20
- ```js
21
- import { buildConfig } from 'payload/config'
22
- import { sentry } from '@payloadcms/plugin-sentry'
23
- import { Pages, Media } from './collections'
24
-
25
- const config = buildConfig({
26
- collections: [Pages, Media],
27
- plugins: [
28
- sentry({
29
- dsn: 'https://61edebas777889984d323d777@o4505289711681536.ingest.sentry.io/4505357433352176',
30
- }),
31
- ],
32
- })
33
-
34
- export default config
35
- ```
36
-
37
- ## Options
38
-
39
- ### Data Source Name (DSN) and where to find it
40
-
41
- - `dsn` : string | required
42
-
43
- Sentry automatically assigns a DSN when you create a project, the unique DSN informs Sentry where to send events so they are associated with the correct project.
44
-
45
- #### :rotating_light: You can find the DSN in your project settings by navigating to [Project] > Settings > Client Keys (DSN) in [sentry.io](sentry.io).
46
-
47
- ### Additional Options
48
-
49
- - `enabled`: boolean | optional
50
-
51
- Set to false to disable the plugin. Defaults to true.
52
-
53
- - `init` : ClientOptions | optional
54
-
55
- Sentry allows a variety of options to be passed into the Sentry.init() function, see the full list of options [here](https://docs.sentry.io/platforms/node/guides/express/configuration/options).
56
-
57
- - `requestHandler` : RequestHandlerOptions | optional
58
-
59
- Accepts options that let you decide what data should be included in the event sent to Sentry, checkout the options [here](https://docs.sentry.io/platforms/node/guides/express/configuration/options).
60
-
61
- - `captureErrors`: number[] | optional
62
-
63
- By default, `Sentry.errorHandler` will capture only errors with a status code of 500 or higher. To capture additional error codes, pass the values as numbers in an array.
64
-
65
- You can configure any of these options by passing them to the plugin under options:
66
-
67
- ```js
68
- import { buildConfig } from 'payload/config'
69
- import { sentry } from '@payloadcms/plugin-sentry'
70
- import { Pages, Media } from './collections'
71
-
72
- const config = buildConfig({
73
- collections: [Pages, Media],
74
- plugins: [
75
- sentry({
76
- dsn: 'https://61edebas777889984d323d777@o4505289711681536.ingest.sentry.io/4505357433352176',
77
- options: {
78
- init: {
79
- debug: true,
80
- environment: 'development',
81
- tracesSampleRate: 1.0,
82
- },
83
- requestHandler: {
84
- serverName: false,
85
- user: ['email'],
86
- },
87
- captureErrors: [400, 403, 404],
88
- },
89
- }),
90
- ],
91
- })
92
-
93
- export default config
94
- ```
95
-
96
- To learn more about these options and when to use them, visit the [Sentry Docs](https://docs.sentry.io/platforms/node/guides/express/configuration/options).
97
-
98
- ## TypeScript
99
-
100
- All types can be directly imported:
101
-
102
- ```js
103
- import { PluginOptions } from '@payloadcms/plugin-sentry/types'
104
- ```
105
-
106
- ## Development
107
-
108
- To actively develop or debug this plugin you can either work directly within the demo directory of this repo, or link your own project.
109
-
110
- #### Internal Demo
111
-
112
- This repo includes a demo of Payload that installs the plugin directly from the source code. This is the easiest way to get started. To spin up this demo, follow these steps:
113
-
114
- 1. First clone the repo
115
- 2. Then, `cd plugin-sentry && yarn && cd dev && yarn && yarn dev`
116
- 3. Now open `http://localhost:3000/admin` in your browser
117
- 4. Create a new user and sign in
118
- 5. Use the buttons to throw test errors
119
-
120
- That's it! Changes made in `./src` will be reflected in the demo.
5
+ - [Source code](https://github.com/payloadcms/payload/tree/main/packages/plugin-sentry)
6
+ - [Documentation](https://payloadcms.com/docs/plugins/sentry)
7
+ - [Documentation source](https://github.com/payloadcms/payload/tree/main/docs/plugins/sentry.mdx)
@@ -0,0 +1,2 @@
1
+ export { AdminErrorBoundary } from '../providers/AdminErrorBoundary.js';
2
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/exports/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { AdminErrorBoundary } from '../providers/AdminErrorBoundary.js';
2
+
3
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/exports/client.ts"],"sourcesContent":["export { AdminErrorBoundary } from '../providers/AdminErrorBoundary.js'\n"],"names":["AdminErrorBoundary"],"mappings":"AAAA,SAASA,kBAAkB,QAAQ,qCAAoC"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,27 @@
1
- export { sentry } from './plugin';
2
- export type { PluginOptions } from './types';
1
+ import type { Config } from 'payload';
2
+ import type { PluginOptions } from './types.js';
3
+ export { PluginOptions };
4
+ /**
5
+ * @example
6
+ * ```ts
7
+ * import * as Sentry from '@sentry/nextjs'
8
+ *
9
+ * sentryPlugin({
10
+ * options: {
11
+ * captureErrors: [400, 403],
12
+ * context: ({ defaultContext, req }) => {
13
+ * return {
14
+ * ...defaultContext,
15
+ * tags: {
16
+ * locale: req.locale,
17
+ * },
18
+ * }
19
+ * },
20
+ * debug: true,
21
+ * },
22
+ * Sentry,
23
+ * })
24
+ * ```
25
+ */
26
+ export declare const sentryPlugin: (pluginOptions: PluginOptions) => (config: Config) => Config;
3
27
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,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,MA+DjB,CAAA"}
package/dist/index.js CHANGED
@@ -1,13 +1,79 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "sentry", {
6
- enumerable: true,
7
- get: function() {
8
- return _plugin.sentry;
9
- }
10
- });
11
- const _plugin = require("./plugin");
1
+ /**
2
+ * @example
3
+ * ```ts
4
+ * import * as Sentry from '@sentry/nextjs'
5
+ *
6
+ * sentryPlugin({
7
+ * options: {
8
+ * captureErrors: [400, 403],
9
+ * context: ({ defaultContext, req }) => {
10
+ * return {
11
+ * ...defaultContext,
12
+ * tags: {
13
+ * locale: req.locale,
14
+ * },
15
+ * }
16
+ * },
17
+ * debug: true,
18
+ * },
19
+ * Sentry,
20
+ * })
21
+ * ```
22
+ */ export const sentryPlugin = (pluginOptions)=>(config)=>{
23
+ const { enabled = true, options = {}, Sentry } = pluginOptions;
24
+ if (!enabled || !Sentry) {
25
+ return config;
26
+ }
27
+ const { captureErrors = [], debug = false } = options;
28
+ return {
29
+ ...config,
30
+ admin: {
31
+ ...config.admin,
32
+ components: {
33
+ ...config.admin?.components,
34
+ providers: [
35
+ ...config.admin?.components?.providers ?? [],
36
+ '@payloadcms/plugin-sentry/client#AdminErrorBoundary'
37
+ ]
38
+ }
39
+ },
40
+ hooks: {
41
+ afterError: [
42
+ ...config.hooks?.afterError ?? [],
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
+ }
59
+ }
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
+ }
71
+ }
72
+ }
73
+ }
74
+ ]
75
+ }
76
+ };
77
+ };
12
78
 
13
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgeyBzZW50cnkgfSBmcm9tICcuL3BsdWdpbidcbmV4cG9ydCB0eXBlIHsgUGx1Z2luT3B0aW9ucyB9IGZyb20gJy4vdHlwZXMnXG4iXSwibmFtZXMiOlsic2VudHJ5Il0sIm1hcHBpbmdzIjoiOzs7OytCQUFTQTs7O2VBQUFBLGNBQU07Ozt3QkFBUSJ9
79
+ //# sourceMappingURL=index.js.map
@@ -0,0 +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,gBAAg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G,uBAAuB,EAAEZ,KAAKC,KAAK,CAACuB,OAAO,CAAC,CAAC;gCAE1E;4BACF;wBACF;oBACF;iBACD;YACH;QACF;IACF,EAAC"}
@@ -0,0 +1,8 @@
1
+ import type { ReactNode } from 'react';
2
+ /**
3
+ * Captures errored components to Sentry
4
+ */
5
+ export declare const AdminErrorBoundary: ({ children }: {
6
+ children: ReactNode;
7
+ }) => import("react/jsx-runtime").JSX.Element;
8
+ //# sourceMappingURL=AdminErrorBoundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AdminErrorBoundary.d.ts","sourceRoot":"","sources":["../../src/providers/AdminErrorBoundary.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAItC;;GAEG;AACH,eAAO,MAAM,kBAAkB,iBAAkB;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,4CAEvE,CAAA"}
@@ -0,0 +1,12 @@
1
+ 'use client';
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { ErrorBoundary } from '@sentry/nextjs';
4
+ /**
5
+ * Captures errored components to Sentry
6
+ */ export const AdminErrorBoundary = ({ children })=>{
7
+ return /*#__PURE__*/ _jsx(ErrorBoundary, {
8
+ children: children
9
+ });
10
+ };
11
+
12
+ //# sourceMappingURL=AdminErrorBoundary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/providers/AdminErrorBoundary.tsx"],"sourcesContent":["'use client'\n\nimport type { ReactNode } from 'react'\n\nimport { ErrorBoundary } from '@sentry/nextjs'\n\n/**\n * Captures errored components to Sentry\n */\nexport const AdminErrorBoundary = ({ children }: { children: ReactNode }) => {\n return <ErrorBoundary>{children}</ErrorBoundary>\n}\n"],"names":["ErrorBoundary","AdminErrorBoundary","children"],"mappings":"AAAA;;AAIA,SAASA,aAAa,QAAQ,iBAAgB;AAE9C;;CAEC,GACD,OAAO,MAAMC,qBAAqB,CAAC,EAAEC,QAAQ,EAA2B;IACtE,qBAAO,KAACF;kBAAeE;;AACzB,EAAC"}
package/dist/types.d.ts CHANGED
@@ -1,36 +1,45 @@
1
- import type { RequestHandlerOptions } from '@sentry/node/types/handlers';
2
- import type { ClientOptions } from '@sentry/types';
1
+ import type { ScopeContext } from '@sentry/types';
2
+ import type { AfterErrorHookArgs } from 'payload';
3
+ type SentryInstance = {
4
+ captureException: (err: Error, hint: any) => string;
5
+ };
6
+ type ContextArgs = {
7
+ defaultContext: Partial<ScopeContext>;
8
+ } & AfterErrorHookArgs;
3
9
  export interface PluginOptions {
4
- /**
5
- * Sentry DSN (Data Source Name)
6
- * This is required unless enabled is set to false.
7
- * Sentry automatically assigns a DSN when you create a project.
8
- * If you don't have a DSN yet, you can create a new project here: https://sentry.io
9
- */
10
- dsn: null | string;
11
10
  /**
12
11
  * Enable or disable Sentry plugin
13
- * @default false
12
+ * @default true
14
13
  */
15
14
  enabled?: boolean;
16
15
  /**
17
16
  * Options passed directly to Sentry
18
- * @default false
19
17
  */
20
18
  options?: {
21
19
  /**
22
20
  * Sentry will only capture 500 errors by default.
23
21
  * If you want to capture other errors, you can add them as an array here.
22
+ * @default []
24
23
  */
25
24
  captureErrors?: number[];
26
25
  /**
27
- * Passes any valid options to Sentry.init()
26
+ * Set `ScopeContext` for `Sentry.captureException` which includes `user` and other info.
28
27
  */
29
- init?: Partial<ClientOptions>;
28
+ context?: (args: ContextArgs) => Partial<ScopeContext> | Promise<Partial<ScopeContext>>;
30
29
  /**
31
- * Passes any valid options to Sentry.Handlers.requestHandler()
30
+ * Log captured exceptions,
31
+ * @default false
32
32
  */
33
- requestHandler?: RequestHandlerOptions;
33
+ debug?: boolean;
34
34
  };
35
+ /**
36
+ * Instance of Sentry from
37
+ * ```ts
38
+ * import * as Sentry from '@sentry/nextjs'
39
+ * ```
40
+ * This is required unless enabled is set to false.
41
+ */
42
+ Sentry?: SentryInstance;
35
43
  }
44
+ export {};
36
45
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAA;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,WAAW,aAAa;IAC5B;;;;;OAKG;IACH,GAAG,EAAE,IAAI,GAAG,MAAM,CAAA;IAClB;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE;QACR;;;WAGG;QACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;QACxB;;WAEG;QACH,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;QAC7B;;WAEG;QACH,cAAc,CAAC,EAAE,qBAAqB,CAAA;KACvC,CAAA;CACF"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAA;AAEjD,KAAK,cAAc,GAAG;IACpB,gBAAgB,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,KAAK,MAAM,CAAA;CACpD,CAAA;AAED,KAAK,WAAW,GAAG;IACjB,cAAc,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;CACtC,GAAG,kBAAkB,CAAA;AAEtB,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB;;OAEG;IACH,OAAO,CAAC,EAAE;QACR;;;;WAIG;QACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;QACxB;;WAEG;QACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,OAAO,CAAC,YAAY,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,CAAA;QACvF;;;WAGG;QACH,KAAK,CAAC,EAAE,OAAO,CAAA;KAChB,CAAA;IACD;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,cAAc,CAAA;CACxB"}
package/dist/types.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
1
+ export { };
5
2
 
6
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
3
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { ScopeContext } from '@sentry/types'\nimport type { AfterErrorHookArgs } from 'payload'\n\ntype SentryInstance = {\n captureException: (err: Error, hint: any) => string\n}\n\ntype ContextArgs = {\n defaultContext: Partial<ScopeContext>\n} & AfterErrorHookArgs\n\nexport interface PluginOptions {\n /**\n * Enable or disable Sentry plugin\n * @default true\n */\n enabled?: boolean\n /**\n * Options passed directly to Sentry\n */\n options?: {\n /**\n * Sentry will only capture 500 errors by default.\n * If you want to capture other errors, you can add them as an array here.\n * @default []\n */\n captureErrors?: number[]\n /**\n * Set `ScopeContext` for `Sentry.captureException` which includes `user` and other info.\n */\n context?: (args: ContextArgs) => Partial<ScopeContext> | Promise<Partial<ScopeContext>>\n /**\n * Log captured exceptions,\n * @default false\n */\n debug?: boolean\n }\n /**\n * Instance of Sentry from\n * ```ts\n * import * as Sentry from '@sentry/nextjs'\n * ```\n * This is required unless enabled is set to false.\n */\n Sentry?: SentryInstance\n}\n"],"names":[],"mappings":"AAWA,WAkCC"}
package/package.json CHANGED
@@ -1,11 +1,7 @@
1
1
  {
2
2
  "name": "@payloadcms/plugin-sentry",
3
- "version": "0.0.6",
4
- "homepage:": "https://payloadcms.com",
5
- "repository": "git@github.com:payloadcms/plugin-sentry.git",
3
+ "version": "3.0.0-canary.a14e066",
6
4
  "description": "Sentry plugin for Payload",
7
- "main": "dist/index.js",
8
- "types": "dist/index.d.ts",
9
5
  "keywords": [
10
6
  "payload",
11
7
  "cms",
@@ -14,39 +10,58 @@
14
10
  "sentry",
15
11
  "error handling"
16
12
  ],
17
- "author": "dev@payloadcms.com",
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "https://github.com/payloadcms/payload.git",
16
+ "directory": "packages/plugin-sentry"
17
+ },
18
18
  "license": "MIT",
19
+ "author": "Payload <dev@payloadcms.com> (https://payloadcms.com)",
20
+ "type": "module",
21
+ "exports": {
22
+ ".": {
23
+ "import": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ },
27
+ "./client": {
28
+ "import": "./dist/exports/client.js",
29
+ "types": "./dist/exports/client.d.ts",
30
+ "default": "./dist/exports/client.js"
31
+ }
32
+ },
33
+ "main": "./dist/index.js",
34
+ "types": "./dist/index.d.ts",
19
35
  "files": [
20
36
  "dist"
21
37
  ],
22
- "peerDependencies": {
23
- "payload": "^1.10.1 || ^2.0.0",
24
- "react": "^16.8.0 || ^17.0.0 || ^18.0.0"
25
- },
26
38
  "dependencies": {
27
- "@sentry/node": "^7.55.2",
28
- "@sentry/types": "^7.54.0",
29
- "express": "^4.18.2"
39
+ "@sentry/nextjs": "^8.33.1",
40
+ "@sentry/types": "^8.33.1"
30
41
  },
31
42
  "devDependencies": {
32
- "@types/express": "^4.17.9",
33
- "@types/jest": "^29.5.2",
34
- "@types/node": "18.11.3",
35
- "@types/react": "18.0.21",
36
- "copyfiles": "^2.4.1",
37
- "cross-env": "^7.0.3",
38
- "dotenv": "^8.2.0",
39
- "jest": "^29.5.0",
40
- "nodemon": "^2.0.6",
41
- "ts-jest": "^29.1.0",
42
- "webpack": "^5.78.0",
43
- "@payloadcms/eslint-config": "1.0.0",
44
- "payload": "2.1.1"
43
+ "@types/react": "npm:types-react@19.0.0-rc.1",
44
+ "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1",
45
+ "@payloadcms/eslint-config": "3.0.0-beta.112",
46
+ "payload": "3.0.0-canary.a14e066"
47
+ },
48
+ "peerDependencies": {
49
+ "react": "^19.0.0 || ^19.0.0-rc-3edc000d-20240926",
50
+ "react-dom": "^19.0.0 || ^19.0.0-rc-3edc000d-20240926",
51
+ "payload": "3.0.0-canary.a14e066"
52
+ },
53
+ "homepage:": "https://payloadcms.com",
54
+ "overrides": {
55
+ "@types/react": "npm:types-react@19.0.0-rc.1",
56
+ "@types/react-dom": "npm:types-react-dom@19.0.0-rc.1"
45
57
  },
46
58
  "scripts": {
47
- "build": "pnpm build:swc && pnpm build:types",
48
- "build:swc": "swc ./src -d ./dist --config-file .swcrc",
59
+ "build": "pnpm copyfiles && pnpm build:types && pnpm build:swc",
60
+ "build:swc": "swc ./src -d ./dist --config-file .swcrc-build --strip-leading-paths",
49
61
  "build:types": "tsc --emitDeclarationOnly --outDir dist",
50
- "clean": "rimraf {dist,*.tsbuildinfo}"
62
+ "clean": "rimraf {dist,*.tsbuildinfo}",
63
+ "copyfiles": "copyfiles -u 1 \"src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,json}\" dist/",
64
+ "lint": "eslint .",
65
+ "lint:fix": "eslint . --fix"
51
66
  }
52
67
  }
@@ -1,2 +0,0 @@
1
- export declare const captureException: (err: Error) => void;
2
- //# sourceMappingURL=captureException.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"captureException.d.ts","sourceRoot":"","sources":["../src/captureException.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,QAAS,KAAK,KAAG,IAE7C,CAAA"}
@@ -1,55 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "captureException", {
6
- enumerable: true,
7
- get: function() {
8
- return captureException;
9
- }
10
- });
11
- const _node = /*#__PURE__*/ _interop_require_wildcard(require("@sentry/node"));
12
- function _getRequireWildcardCache(nodeInterop) {
13
- if (typeof WeakMap !== "function") return null;
14
- var cacheBabelInterop = new WeakMap();
15
- var cacheNodeInterop = new WeakMap();
16
- return (_getRequireWildcardCache = function(nodeInterop) {
17
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
- })(nodeInterop);
19
- }
20
- function _interop_require_wildcard(obj, nodeInterop) {
21
- if (!nodeInterop && obj && obj.__esModule) {
22
- return obj;
23
- }
24
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
- return {
26
- default: obj
27
- };
28
- }
29
- var cache = _getRequireWildcardCache(nodeInterop);
30
- if (cache && cache.has(obj)) {
31
- return cache.get(obj);
32
- }
33
- var newObj = {};
34
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
35
- for(var key in obj){
36
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
37
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
38
- if (desc && (desc.get || desc.set)) {
39
- Object.defineProperty(newObj, key, desc);
40
- } else {
41
- newObj[key] = obj[key];
42
- }
43
- }
44
- }
45
- newObj.default = obj;
46
- if (cache) {
47
- cache.set(obj, newObj);
48
- }
49
- return newObj;
50
- }
51
- const captureException = (err)=>{
52
- _node.captureException(err);
53
- };
54
-
55
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9jYXB0dXJlRXhjZXB0aW9uLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCAqIGFzIFNlbnRyeSBmcm9tICdAc2VudHJ5L25vZGUnXG5cbmV4cG9ydCBjb25zdCBjYXB0dXJlRXhjZXB0aW9uID0gKGVycjogRXJyb3IpOiB2b2lkID0+IHtcbiAgU2VudHJ5LmNhcHR1cmVFeGNlcHRpb24oZXJyKVxufVxuIl0sIm5hbWVzIjpbImNhcHR1cmVFeGNlcHRpb24iLCJlcnIiLCJTZW50cnkiXSwibWFwcGluZ3MiOiI7Ozs7K0JBRWFBOzs7ZUFBQUE7Ozs4REFGVzs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztBQUVqQixNQUFNQSxtQkFBbUIsQ0FBQ0M7SUFDL0JDLE1BQU9GLGdCQUFnQixDQUFDQztBQUMxQiJ9
@@ -1,7 +0,0 @@
1
- "use strict";
2
- module.exports = {
3
- captureException: ()=>{},
4
- startSentry: ()=>{}
5
- };
6
-
7
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9tb2Nrcy9tb2NrRmlsZS5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJtb2R1bGUuZXhwb3J0cyA9IHtcbiAgY2FwdHVyZUV4Y2VwdGlvbjogKCkgPT4ge30sXG4gIHN0YXJ0U2VudHJ5OiAoKSA9PiB7fSxcbn1cbiJdLCJuYW1lcyI6WyJtb2R1bGUiLCJleHBvcnRzIiwiY2FwdHVyZUV4Y2VwdGlvbiIsInN0YXJ0U2VudHJ5Il0sIm1hcHBpbmdzIjoiO0FBQUFBLE9BQU9DLE9BQU8sR0FBRztJQUNmQyxrQkFBa0IsS0FBTztJQUN6QkMsYUFBYSxLQUFPO0FBQ3RCIn0=
package/dist/plugin.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { Config } from 'payload/config';
2
- import type { PluginOptions } from './types';
3
- export declare const sentry: (pluginOptions: PluginOptions) => (incomingConfig: Config) => Config;
4
- //# sourceMappingURL=plugin.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAE5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAM5C,eAAO,MAAM,MAAM,kBACD,aAAa,sBACZ,MAAM,KAAG,MA2BzB,CAAA"}
package/dist/plugin.js DELETED
@@ -1,40 +0,0 @@
1
- /* eslint-disable no-console */ "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "sentry", {
6
- enumerable: true,
7
- get: function() {
8
- return sentry;
9
- }
10
- });
11
- const _captureException = require("./captureException");
12
- const _startSentry = require("./startSentry");
13
- const _webpack = require("./webpack");
14
- const sentry = (pluginOptions)=>(incomingConfig)=>{
15
- const config = {
16
- ...incomingConfig
17
- };
18
- const webpack = (0, _webpack.extendWebpackConfig)(incomingConfig);
19
- config.admin = {
20
- ...config.admin || {},
21
- webpack
22
- };
23
- if (pluginOptions.enabled === false || !pluginOptions.dsn) {
24
- return config;
25
- }
26
- config.hooks = {
27
- ...incomingConfig.hooks || {},
28
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
- afterError: (err)=>{
30
- (0, _captureException.captureException)(err);
31
- }
32
- };
33
- config.onInit = async (payload)=>{
34
- if (incomingConfig.onInit) await incomingConfig.onInit(payload);
35
- (0, _startSentry.startSentry)(pluginOptions, payload);
36
- };
37
- return config;
38
- };
39
-
40
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9wbHVnaW4udHMiXSwic291cmNlc0NvbnRlbnQiOlsiLyogZXNsaW50LWRpc2FibGUgbm8tY29uc29sZSAqL1xuaW1wb3J0IHR5cGUgeyBDb25maWcgfSBmcm9tICdwYXlsb2FkL2NvbmZpZydcblxuaW1wb3J0IHR5cGUgeyBQbHVnaW5PcHRpb25zIH0gZnJvbSAnLi90eXBlcydcblxuaW1wb3J0IHsgY2FwdHVyZUV4Y2VwdGlvbiB9IGZyb20gJy4vY2FwdHVyZUV4Y2VwdGlvbidcbmltcG9ydCB7IHN0YXJ0U2VudHJ5IH0gZnJvbSAnLi9zdGFydFNlbnRyeSdcbmltcG9ydCB7IGV4dGVuZFdlYnBhY2tDb25maWcgfSBmcm9tICcuL3dlYnB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Db25maWciLCJjb25maWciLCJ3ZWJwYWNrIiwiZXh0ZW5kV2VicGFja0NvbmZpZyIsImFkbWluIiwiZW5hYmxlZCIsImRzbiIsImhvb2tzIiwiYWZ0ZXJFcnJvciIsImVyciIsImNhcHR1cmVFeGNlcHRpb24iLCJvbkluaXQiLCJwYXlsb2FkIiwic3RhcnRTZW50cnkiXSwibWFwcGluZ3MiOiJBQUFBLDZCQUE2Qjs7OzsrQkFTaEJBOzs7ZUFBQUE7OztrQ0FKb0I7NkJBQ0w7eUJBQ1E7QUFFN0IsTUFBTUEsU0FDWCxDQUFDQyxnQkFDRCxDQUFDQztRQUNDLE1BQU1DLFNBQVM7WUFBRSxHQUFHRCxjQUFjO1FBQUM7UUFDbkMsTUFBTUUsVUFBVUMsSUFBQUEsNEJBQW1CLEVBQUNIO1FBRXBDQyxPQUFPRyxLQUFLLEdBQUc7WUFDYixHQUFJSCxPQUFPRyxLQUFLLElBQUksQ0FBQyxDQUFDO1lBQ3RCRjtRQUNGO1FBRUEsSUFBSUgsY0FBY00sT0FBTyxLQUFLLFNBQVMsQ0FBQ04sY0FBY08sR0FBRyxFQUFFO1lBQ3pELE9BQU9MO1FBQ1Q7UUFFQUEsT0FBT00sS0FBSyxHQUFHO1lBQ2IsR0FBSVAsZUFBZU8sS0FBSyxJQUFJLENBQUMsQ0FBQztZQUM5Qiw4REFBOEQ7WUFDOURDLFlBQVksQ0FBQ0M7Z0JBQ1hDLElBQUFBLGtDQUFnQixFQUFDRDtZQUNuQjtRQUNGO1FBRUFSLE9BQU9VLE1BQU0sR0FBRyxPQUFPQztZQUNyQixJQUFJWixlQUFlVyxNQUFNLEVBQUUsTUFBTVgsZUFBZVcsTUFBTSxDQUFDQztZQUN2REMsSUFBQUEsd0JBQVcsRUFBQ2QsZUFBZWE7UUFDN0I7UUFFQSxPQUFPWDtJQUNUIn0=
@@ -1,4 +0,0 @@
1
- import type { Payload } from 'payload';
2
- import type { PluginOptions } from './types';
3
- export declare const startSentry: (pluginOptions: PluginOptions, payload: Payload) => void;
4
- //# sourceMappingURL=startSentry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"startSentry.d.ts","sourceRoot":"","sources":["../src/startSentry.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAKtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAE5C,eAAO,MAAM,WAAW,kBAAmB,aAAa,WAAW,OAAO,KAAG,IAmD5E,CAAA"}
@@ -1,92 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-unused-vars */ "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "startSentry", {
6
- enumerable: true,
7
- get: function() {
8
- return startSentry;
9
- }
10
- });
11
- const _node = /*#__PURE__*/ _interop_require_wildcard(require("@sentry/node"));
12
- function _getRequireWildcardCache(nodeInterop) {
13
- if (typeof WeakMap !== "function") return null;
14
- var cacheBabelInterop = new WeakMap();
15
- var cacheNodeInterop = new WeakMap();
16
- return (_getRequireWildcardCache = function(nodeInterop) {
17
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
18
- })(nodeInterop);
19
- }
20
- function _interop_require_wildcard(obj, nodeInterop) {
21
- if (!nodeInterop && obj && obj.__esModule) {
22
- return obj;
23
- }
24
- if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
25
- return {
26
- default: obj
27
- };
28
- }
29
- var cache = _getRequireWildcardCache(nodeInterop);
30
- if (cache && cache.has(obj)) {
31
- return cache.get(obj);
32
- }
33
- var newObj = {};
34
- var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
35
- for(var key in obj){
36
- if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
37
- var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
38
- if (desc && (desc.get || desc.set)) {
39
- Object.defineProperty(newObj, key, desc);
40
- } else {
41
- newObj[key] = obj[key];
42
- }
43
- }
44
- }
45
- newObj.default = obj;
46
- if (cache) {
47
- cache.set(obj, newObj);
48
- }
49
- return newObj;
50
- }
51
- const startSentry = (pluginOptions, payload)=>{
52
- const { dsn, options } = pluginOptions;
53
- const { express: app } = payload;
54
- if (!dsn || !app) return;
55
- try {
56
- _node.init({
57
- ...options?.init,
58
- dsn: dsn,
59
- integrations: [
60
- ...options?.init?.integrations || [],
61
- new _node.Integrations.Http({
62
- tracing: true
63
- }),
64
- new _node.Integrations.Express({
65
- app
66
- }),
67
- ..._node.autoDiscoverNodePerformanceMonitoringIntegrations()
68
- ]
69
- });
70
- app.use(_node.Handlers.requestHandler(options?.requestHandler || {}));
71
- app.use(_node.Handlers.tracingHandler());
72
- app.use(_node.Handlers.errorHandler({
73
- shouldHandleError (error) {
74
- if (error.status === 500) {
75
- return true;
76
- }
77
- if (options?.captureErrors && typeof error.status === 'number' && options.captureErrors.includes(error.status)) {
78
- return true;
79
- }
80
- return false;
81
- }
82
- }));
83
- app.use(function onError(_err, _req, res, _next) {
84
- res.statusCode = 500;
85
- res.end(res.sentry + '\n');
86
- });
87
- } catch (err) {
88
- console.log('There was an error initializing Sentry, please ensure you entered a valid DSN');
89
- }
90
- };
91
-
92
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9zdGFydFNlbnRyeS50cyJdLCJzb3VyY2VzQ29udGVudCI6WyIvKiBlc2xpbnQtZGlzYWJsZSBAdHlwZXNjcmlwdC1lc2xpbnQvbm8tdW51c2VkLXZhcnMgKi9cbmltcG9ydCB0eXBlIHsgTmV4dEZ1bmN0aW9uLCBSZXF1ZXN0LCBSZXNwb25zZSB9IGZyb20gJ2V4cHJlc3MnXG5pbXBvcnQgdHlwZSBleHByZXNzIGZyb20gJ2V4cHJlc3MnXG5pbXBvcnQgdHlwZSB7IFBheWxvYWQgfSBmcm9tICdwYXlsb2FkJ1xuXG4vKiBlc2xpbn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LENBQUNDLElBQUksQ0FBQztvQkFBRUMsU0FBUztnQkFBSztnQkFDN0MsSUFBSUwsTUFBT0csWUFBWSxDQUFDRyxPQUFPLENBQUM7b0JBQUVQO2dCQUFJO21CQUNuQ0MsTUFBT08saURBQWlEO2FBQzVEO1FBQ0g7UUFFQVIsSUFBSVMsR0FBRyxDQUFDUixNQUFPUyxRQUFRLENBQUNDLGNBQWMsQ0FBQ2IsU0FBU2Esa0JBQWtCLENBQUM7UUFDbkVYLElBQUlTLEdBQUcsQ0FBQ1IsTUFBT1MsUUFBUSxDQUFDRSxjQUFjO1FBRXRDWixJQUFJUyxHQUFHLENBQ0xSLE1BQU9TLFFBQVEsQ0FBQ0csWUFBWSxDQUFDO1lBQzNCQyxtQkFBa0JDLEtBQUs7Z0JBQ3JCLElBQUlBLE1BQU1DLE1BQU0sS0FBSyxLQUFLO29CQUN4QixPQUFPO2dCQUNUO2dCQUNBLElBQ0VsQixTQUFTbUIsaUJBQ1QsT0FBT0YsTUFBTUMsTUFBTSxLQUFLLFlBQ3hCbEIsUUFBUW1CLGFBQWEsQ0FBQ0MsUUFBUSxDQUFDSCxNQUFNQyxNQUFNLEdBQzNDO29CQUNBLE9BQU87Z0JBQ1Q7Z0JBQ0EsT0FBTztZQUNUO1FBQ0Y7UUFHRmhCLElBQUlTLEdBQUcsQ0FBQyxTQUFTVSxRQUNmQyxJQUFhLEVBQ2JDLElBQWEsRUFDYkMsR0FBbUMsRUFDbkNDLEtBQW1CO1lBRW5CRCxJQUFJRSxVQUFVLEdBQUc7WUFDakJGLElBQUlHLEdBQUcsQ0FBQ0gsSUFBSUksTUFBTSxHQUFHO1FBQ3ZCO0lBQ0YsRUFBRSxPQUFPQyxLQUFjO1FBQ3JCQyxRQUFRQyxHQUFHLENBQUM7SUFDZDtBQUNGIn0=
package/dist/webpack.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import type { Config } from 'payload/config';
2
- import type { Configuration as WebpackConfig } from 'webpack';
3
- export declare const extendWebpackConfig: (config: Config) => (webpackConfig: WebpackConfig) => WebpackConfig;
4
- //# sourceMappingURL=webpack.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"webpack.d.ts","sourceRoot":"","sources":["../src/webpack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,KAAK,EAAE,aAAa,IAAI,aAAa,EAAE,MAAM,SAAS,CAAA;AAI7D,eAAO,MAAM,mBAAmB,WACrB,MAAM,qBAAoB,aAAa,KAAK,aAsBpD,CAAA"}
package/dist/webpack.js DELETED
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", {
3
- value: true
4
- });
5
- Object.defineProperty(exports, "extendWebpackConfig", {
6
- enumerable: true,
7
- get: function() {
8
- return extendWebpackConfig;
9
- }
10
- });
11
- const _path = /*#__PURE__*/ _interop_require_default(require("path"));
12
- function _interop_require_default(obj) {
13
- return obj && obj.__esModule ? obj : {
14
- default: obj
15
- };
16
- }
17
- const extendWebpackConfig = (config)=>(webpackConfig)=>{
18
- const existingWebpackConfig = typeof config.admin?.webpack === 'function' ? config.admin.webpack(webpackConfig) : webpackConfig;
19
- const mockModulePath = _path.default.resolve(__dirname, './mocks/mockFile.js');
20
- const newWebpack = {
21
- ...existingWebpackConfig,
22
- resolve: {
23
- ...existingWebpackConfig.resolve || {},
24
- alias: {
25
- ...existingWebpackConfig.resolve?.alias ? existingWebpackConfig.resolve.alias : {},
26
- [_path.default.resolve(__dirname, './captureException')]: mockModulePath,
27
- [_path.default.resolve(__dirname, './startSentry')]: mockModulePath
28
- }
29
- }
30
- };
31
- return newWebpack;
32
- };
33
-
34
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy93ZWJwYWNrLnRzIl0sInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB0eXBlIHsgQ29uZmlnIH0gZnJvbSAncGF5bG9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