@strapi/plugin-sentry 5.12.1 → 5.12.2
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/admin/index.js +19 -122
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs +15 -120
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/package.json.js +121 -0
- package/dist/admin/package.json.js.map +1 -0
- package/dist/admin/package.json.mjs +102 -0
- package/dist/admin/package.json.mjs.map +1 -0
- package/dist/admin/pluginId.js +6 -0
- package/dist/admin/pluginId.js.map +1 -0
- package/dist/admin/pluginId.mjs +4 -0
- package/dist/admin/pluginId.mjs.map +1 -0
- package/dist/admin/{chunks/dk-C64Vk1_X.js → translations/dk.json.js} +2 -2
- package/dist/admin/translations/dk.json.js.map +1 -0
- package/dist/admin/{chunks/dk-2c1X5YD1.mjs → translations/dk.json.mjs} +1 -1
- package/dist/admin/translations/dk.json.mjs.map +1 -0
- package/dist/admin/{chunks/en-CzMdlTs0.js → translations/en.json.js} +2 -2
- package/dist/admin/translations/en.json.js.map +1 -0
- package/dist/admin/{chunks/en-DDCHBy0-.mjs → translations/en.json.mjs} +1 -1
- package/dist/admin/translations/en.json.mjs.map +1 -0
- package/dist/admin/{chunks/es-l4HaM-C0.js → translations/es.json.js} +2 -2
- package/dist/admin/translations/es.json.js.map +1 -0
- package/dist/admin/{chunks/es-BnizV7-a.mjs → translations/es.json.mjs} +1 -1
- package/dist/admin/translations/es.json.mjs.map +1 -0
- package/dist/admin/{chunks/fr-rJIDC4Jx.js → translations/fr.json.js} +2 -2
- package/dist/admin/translations/fr.json.js.map +1 -0
- package/dist/admin/{chunks/fr-BsXNdB-N.mjs → translations/fr.json.mjs} +1 -1
- package/dist/admin/translations/fr.json.mjs.map +1 -0
- package/dist/admin/{chunks/ko-CoJrUsj1.js → translations/ko.json.js} +2 -2
- package/dist/admin/translations/ko.json.js.map +1 -0
- package/dist/admin/{chunks/ko-BrDfWiIr.mjs → translations/ko.json.mjs} +1 -1
- package/dist/admin/translations/ko.json.mjs.map +1 -0
- package/dist/admin/{chunks/pl-DbPKh3_6.js → translations/pl.json.js} +2 -2
- package/dist/admin/translations/pl.json.js.map +1 -0
- package/dist/admin/{chunks/pl-6JvJwTZm.mjs → translations/pl.json.mjs} +1 -1
- package/dist/admin/translations/pl.json.mjs.map +1 -0
- package/dist/admin/{chunks/ru-CgCHTIu5.js → translations/ru.json.js} +2 -2
- package/dist/admin/translations/ru.json.js.map +1 -0
- package/dist/admin/{chunks/ru-B4OA2fUb.mjs → translations/ru.json.mjs} +1 -1
- package/dist/admin/translations/ru.json.mjs.map +1 -0
- package/dist/admin/{chunks/sv-DrckibdJ.js → translations/sv.json.js} +2 -2
- package/dist/admin/translations/sv.json.js.map +1 -0
- package/dist/admin/{chunks/sv-OPAT8f7H.mjs → translations/sv.json.mjs} +1 -1
- package/dist/admin/translations/sv.json.mjs.map +1 -0
- package/dist/admin/{chunks/tr-DMgP5sU_.js → translations/tr.json.js} +2 -2
- package/dist/admin/translations/tr.json.js.map +1 -0
- package/dist/admin/{chunks/tr-C8CxtgGx.mjs → translations/tr.json.mjs} +1 -1
- package/dist/admin/translations/tr.json.mjs.map +1 -0
- package/dist/admin/{chunks/uk-B2xQjt3Y.js → translations/uk.json.js} +2 -2
- package/dist/admin/translations/uk.json.js.map +1 -0
- package/dist/admin/{chunks/uk-DTdvxZPe.mjs → translations/uk.json.mjs} +1 -1
- package/dist/admin/translations/uk.json.mjs.map +1 -0
- package/dist/admin/{chunks/vi-CpPssghl.js → translations/vi.json.js} +2 -2
- package/dist/admin/translations/vi.json.js.map +1 -0
- package/dist/admin/{chunks/vi-D0rPKKIu.mjs → translations/vi.json.mjs} +1 -1
- package/dist/admin/translations/vi.json.mjs.map +1 -0
- package/dist/admin/{chunks/zh-TX10GrSY.js → translations/zh.json.js} +2 -2
- package/dist/admin/translations/zh.json.js.map +1 -0
- package/dist/admin/{chunks/zh-MmnOh-xz.mjs → translations/zh.json.mjs} +1 -1
- package/dist/admin/translations/zh.json.mjs.map +1 -0
- package/dist/admin/utils/prefixPluginTranslations.js +11 -0
- package/dist/admin/utils/prefixPluginTranslations.js.map +1 -0
- package/dist/admin/utils/prefixPluginTranslations.mjs +9 -0
- package/dist/admin/utils/prefixPluginTranslations.mjs.map +1 -0
- package/dist/server/bootstrap.js +13 -0
- package/dist/server/bootstrap.js.map +1 -0
- package/dist/server/bootstrap.mjs +11 -0
- package/dist/server/bootstrap.mjs.map +1 -0
- package/dist/server/config.js +13 -0
- package/dist/server/config.js.map +1 -0
- package/dist/server/config.mjs +11 -0
- package/dist/server/config.mjs.map +1 -0
- package/dist/server/index.js +4 -134
- package/dist/server/index.js.map +1 -1
- package/dist/server/index.mjs +3 -114
- package/dist/server/index.mjs.map +1 -1
- package/dist/server/middlewares/sentry.js +39 -0
- package/dist/server/middlewares/sentry.js.map +1 -0
- package/dist/server/middlewares/sentry.mjs +37 -0
- package/dist/server/middlewares/sentry.mjs.map +1 -0
- package/dist/server/services/index.js +10 -0
- package/dist/server/services/index.js.map +1 -0
- package/dist/server/services/index.mjs +8 -0
- package/dist/server/services/index.mjs.map +1 -0
- package/dist/server/services/sentry.js +83 -0
- package/dist/server/services/sentry.js.map +1 -0
- package/dist/server/services/sentry.mjs +62 -0
- package/dist/server/services/sentry.mjs.map +1 -0
- package/package.json +2 -2
- package/dist/admin/chunks/dk-2c1X5YD1.mjs.map +0 -1
- package/dist/admin/chunks/dk-C64Vk1_X.js.map +0 -1
- package/dist/admin/chunks/en-CzMdlTs0.js.map +0 -1
- package/dist/admin/chunks/en-DDCHBy0-.mjs.map +0 -1
- package/dist/admin/chunks/es-BnizV7-a.mjs.map +0 -1
- package/dist/admin/chunks/es-l4HaM-C0.js.map +0 -1
- package/dist/admin/chunks/fr-BsXNdB-N.mjs.map +0 -1
- package/dist/admin/chunks/fr-rJIDC4Jx.js.map +0 -1
- package/dist/admin/chunks/ko-BrDfWiIr.mjs.map +0 -1
- package/dist/admin/chunks/ko-CoJrUsj1.js.map +0 -1
- package/dist/admin/chunks/pl-6JvJwTZm.mjs.map +0 -1
- package/dist/admin/chunks/pl-DbPKh3_6.js.map +0 -1
- package/dist/admin/chunks/ru-B4OA2fUb.mjs.map +0 -1
- package/dist/admin/chunks/ru-CgCHTIu5.js.map +0 -1
- package/dist/admin/chunks/sv-DrckibdJ.js.map +0 -1
- package/dist/admin/chunks/sv-OPAT8f7H.mjs.map +0 -1
- package/dist/admin/chunks/tr-C8CxtgGx.mjs.map +0 -1
- package/dist/admin/chunks/tr-DMgP5sU_.js.map +0 -1
- package/dist/admin/chunks/uk-B2xQjt3Y.js.map +0 -1
- package/dist/admin/chunks/uk-DTdvxZPe.mjs.map +0 -1
- package/dist/admin/chunks/vi-CpPssghl.js.map +0 -1
- package/dist/admin/chunks/vi-D0rPKKIu.mjs.map +0 -1
- package/dist/admin/chunks/zh-MmnOh-xz.mjs.map +0 -1
- package/dist/admin/chunks/zh-TX10GrSY.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"es.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"es.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fr.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fr.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ko.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ko.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pl.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pl.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ru.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ru.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sv.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sv.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tr.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tr.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uk.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"uk.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vi.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vi.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zh.json.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zh.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const prefixPluginTranslations = (trad, pluginId)=>{
|
|
4
|
+
return Object.keys(trad).reduce((acc, current)=>{
|
|
5
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
|
6
|
+
return acc;
|
|
7
|
+
}, {});
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
exports.prefixPluginTranslations = prefixPluginTranslations;
|
|
11
|
+
//# sourceMappingURL=prefixPluginTranslations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefixPluginTranslations.js","sources":["../../../admin/src/utils/prefixPluginTranslations.ts"],"sourcesContent":["type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n"],"names":["prefixPluginTranslations","trad","pluginId","Object","keys","reduce","acc","current"],"mappings":";;AAEMA,MAAAA,wBAAAA,GAA2B,CAACC,IAAmBC,EAAAA,QAAAA,GAAAA;AAInD,IAAA,OAAOC,OAAOC,IAAI,CAACH,MAAMI,MAAM,CAAC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;AACpCD,QAAAA,GAAG,CAAC,CAAC,EAAEJ,QAAAA,CAAS,CAAC,EAAEK,OAAQ,CAAA,CAAC,CAAC,GAAGN,IAAI,CAACM,OAAQ,CAAA;QAC7C,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN;;;;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const prefixPluginTranslations = (trad, pluginId)=>{
|
|
2
|
+
return Object.keys(trad).reduce((acc, current)=>{
|
|
3
|
+
acc[`${pluginId}.${current}`] = trad[current];
|
|
4
|
+
return acc;
|
|
5
|
+
}, {});
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export { prefixPluginTranslations };
|
|
9
|
+
//# sourceMappingURL=prefixPluginTranslations.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prefixPluginTranslations.mjs","sources":["../../../admin/src/utils/prefixPluginTranslations.ts"],"sourcesContent":["type TradOptions = Record<string, string>;\n\nconst prefixPluginTranslations = (trad: TradOptions, pluginId: string): TradOptions => {\n if (!pluginId) {\n throw new TypeError(\"pluginId can't be empty\");\n }\n return Object.keys(trad).reduce((acc, current) => {\n acc[`${pluginId}.${current}`] = trad[current];\n return acc;\n }, {} as TradOptions);\n};\n\nexport { prefixPluginTranslations };\n"],"names":["prefixPluginTranslations","trad","pluginId","Object","keys","reduce","acc","current"],"mappings":"AAEMA,MAAAA,wBAAAA,GAA2B,CAACC,IAAmBC,EAAAA,QAAAA,GAAAA;AAInD,IAAA,OAAOC,OAAOC,IAAI,CAACH,MAAMI,MAAM,CAAC,CAACC,GAAKC,EAAAA,OAAAA,GAAAA;AACpCD,QAAAA,GAAG,CAAC,CAAC,EAAEJ,QAAAA,CAAS,CAAC,EAAEK,OAAQ,CAAA,CAAC,CAAC,GAAGN,IAAI,CAACM,OAAQ,CAAA;QAC7C,OAAOD,GAAAA;AACT,KAAA,EAAG,EAAC,CAAA;AACN;;;;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var sentry = require('./middlewares/sentry.js');
|
|
4
|
+
|
|
5
|
+
var bootstrap = (async ({ strapi })=>{
|
|
6
|
+
// Initialize the Sentry service exposed by this plugin
|
|
7
|
+
sentry({
|
|
8
|
+
strapi
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
module.exports = bootstrap;
|
|
13
|
+
//# sourceMappingURL=bootstrap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.js","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import type { Core } from '@strapi/strapi';\nimport initSentryMiddleware from './middlewares/sentry';\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n // Initialize the Sentry service exposed by this plugin\n initSentryMiddleware({ strapi });\n};\n"],"names":["strapi","initSentryMiddleware"],"mappings":";;;;AAGA,gBAAe,CAAA,OAAO,EAAEA,MAAM,EAA2B,GAAA;;IAEvDC,MAAqB,CAAA;AAAED,QAAAA;AAAO,KAAA,CAAA;AAChC,CAAA;;;;"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import initSentryMiddleware from './middlewares/sentry.mjs';
|
|
2
|
+
|
|
3
|
+
var bootstrap = (async ({ strapi })=>{
|
|
4
|
+
// Initialize the Sentry service exposed by this plugin
|
|
5
|
+
initSentryMiddleware({
|
|
6
|
+
strapi
|
|
7
|
+
});
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
export { bootstrap as default };
|
|
11
|
+
//# sourceMappingURL=bootstrap.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bootstrap.mjs","sources":["../../server/src/bootstrap.ts"],"sourcesContent":["import type { Core } from '@strapi/strapi';\nimport initSentryMiddleware from './middlewares/sentry';\n\nexport default async ({ strapi }: { strapi: Core.Strapi }) => {\n // Initialize the Sentry service exposed by this plugin\n initSentryMiddleware({ strapi });\n};\n"],"names":["strapi","initSentryMiddleware"],"mappings":";;AAGA,gBAAe,CAAA,OAAO,EAAEA,MAAM,EAA2B,GAAA;;IAEvDC,oBAAqB,CAAA;AAAED,QAAAA;AAAO,KAAA,CAAA;AAChC,CAAA;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../server/src/config.ts"],"sourcesContent":["import type { NodeOptions } from '@sentry/node';\n\nexport interface Config {\n dsn: string | null;\n sendMetadata: boolean;\n init: NodeOptions;\n}\n\nexport default {\n default: {\n dsn: null,\n sendMetadata: true,\n init: {},\n } satisfies Config,\n validator() {},\n};\n"],"names":["default","dsn","sendMetadata","init","validator"],"mappings":";;AAQA,aAAe;IACbA,OAAS,EAAA;QACPC,GAAK,EAAA,IAAA;QACLC,YAAc,EAAA,IAAA;AACdC,QAAAA,IAAAA,EAAM;AACR,KAAA;IACAC,SAAa,CAAA,GAAA;AACf,CAAE;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../../server/src/config.ts"],"sourcesContent":["import type { NodeOptions } from '@sentry/node';\n\nexport interface Config {\n dsn: string | null;\n sendMetadata: boolean;\n init: NodeOptions;\n}\n\nexport default {\n default: {\n dsn: null,\n sendMetadata: true,\n init: {},\n } satisfies Config,\n validator() {},\n};\n"],"names":["default","dsn","sendMetadata","init","validator"],"mappings":"AAQA,aAAe;IACbA,OAAS,EAAA;QACPC,GAAK,EAAA,IAAA;QACLC,YAAc,EAAA,IAAA;AACdC,QAAAA,IAAAA,EAAM;AACR,KAAA;IACAC,SAAa,CAAA,GAAA;AACf,CAAE;;;;"}
|
package/dist/server/index.js
CHANGED
|
@@ -1,143 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
var n = Object.create(null);
|
|
7
|
-
if (e) {
|
|
8
|
-
Object.keys(e).forEach(function (k) {
|
|
9
|
-
if (k !== 'default') {
|
|
10
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
11
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return e[k]; }
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
n.default = e;
|
|
19
|
-
return Object.freeze(n);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
var Sentry__namespace = /*#__PURE__*/_interopNamespaceDefault(Sentry);
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Programmatic sentry middleware. We do not want to expose it in the plugin
|
|
26
|
-
*/ var initSentryMiddleware = (({ strapi })=>{
|
|
27
|
-
const sentryService = strapi.plugin('sentry').service('sentry');
|
|
28
|
-
sentryService.init();
|
|
29
|
-
const sentry = sentryService.getInstance();
|
|
30
|
-
if (!sentry) {
|
|
31
|
-
// initialization failed
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
strapi.server.use(async (ctx, next)=>{
|
|
35
|
-
try {
|
|
36
|
-
await next();
|
|
37
|
-
} catch (error) {
|
|
38
|
-
if (error instanceof Error) {
|
|
39
|
-
sentryService.sendError(error, (scope)=>{
|
|
40
|
-
scope.addEventProcessor((event)=>{
|
|
41
|
-
// Parse Koa context to add error metadata
|
|
42
|
-
return sentry.Handlers.parseRequest(event, ctx.request, {
|
|
43
|
-
// Don't parse the transaction name, we'll do it manually
|
|
44
|
-
transaction: false
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
// Manually add transaction name
|
|
48
|
-
scope.setTag('transaction', `${ctx.method} ${ctx._matchedRoute}`);
|
|
49
|
-
// Manually add Strapi version
|
|
50
|
-
scope.setTag('strapi_version', strapi.config.info.strapi);
|
|
51
|
-
scope.setTag('method', ctx.method);
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
var bootstrap = (async ({ strapi })=>{
|
|
60
|
-
// Initialize the Sentry service exposed by this plugin
|
|
61
|
-
initSentryMiddleware({
|
|
62
|
-
strapi
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
const createSentryService = (strapi)=>{
|
|
67
|
-
let isReady = false;
|
|
68
|
-
let instance = null;
|
|
69
|
-
// Retrieve user config and merge it with the default one
|
|
70
|
-
const config = strapi.config.get('plugin::sentry');
|
|
71
|
-
return {
|
|
72
|
-
/**
|
|
73
|
-
* Initialize Sentry service
|
|
74
|
-
*/ init () {
|
|
75
|
-
// Make sure there isn't a Sentry instance already running
|
|
76
|
-
if (instance != null) {
|
|
77
|
-
return this;
|
|
78
|
-
}
|
|
79
|
-
// Don't init Sentry if no DSN was provided
|
|
80
|
-
if (!config.dsn) {
|
|
81
|
-
strapi.log.info('@strapi/plugin-sentry is disabled because no Sentry DSN was provided');
|
|
82
|
-
return this;
|
|
83
|
-
}
|
|
84
|
-
try {
|
|
85
|
-
Sentry__namespace.init({
|
|
86
|
-
dsn: config.dsn,
|
|
87
|
-
environment: strapi.config.get('environment'),
|
|
88
|
-
...config.init
|
|
89
|
-
});
|
|
90
|
-
// Store the successfully initialized Sentry instance
|
|
91
|
-
instance = Sentry__namespace;
|
|
92
|
-
isReady = true;
|
|
93
|
-
} catch (error) {
|
|
94
|
-
strapi.log.warn('Could not set up Sentry, make sure you entered a valid DSN');
|
|
95
|
-
}
|
|
96
|
-
return this;
|
|
97
|
-
},
|
|
98
|
-
/**
|
|
99
|
-
* Expose Sentry instance through a getter
|
|
100
|
-
*/ getInstance () {
|
|
101
|
-
return instance;
|
|
102
|
-
},
|
|
103
|
-
/**
|
|
104
|
-
* Higher level method to send exception events to Sentry
|
|
105
|
-
*/ sendError (error, configureScope) {
|
|
106
|
-
// Make sure Sentry is ready
|
|
107
|
-
if (!isReady || !instance) {
|
|
108
|
-
strapi.log.warn("Sentry wasn't properly initialized, cannot send event");
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
instance.withScope((scope)=>{
|
|
112
|
-
// Configure the Sentry scope using the provided callback
|
|
113
|
-
if (configureScope && config.sendMetadata) {
|
|
114
|
-
configureScope(scope);
|
|
115
|
-
}
|
|
116
|
-
// Actually send the Error to Sentry
|
|
117
|
-
instance?.captureException(error);
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
};
|
|
122
|
-
var sentry = (({ strapi })=>createSentryService(strapi));
|
|
123
|
-
|
|
124
|
-
var services = {
|
|
125
|
-
sentry
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
var config = {
|
|
129
|
-
default: {
|
|
130
|
-
dsn: null,
|
|
131
|
-
sendMetadata: true,
|
|
132
|
-
init: {}
|
|
133
|
-
},
|
|
134
|
-
validator () {}
|
|
135
|
-
};
|
|
3
|
+
var bootstrap = require('./bootstrap.js');
|
|
4
|
+
var index$1 = require('./services/index.js');
|
|
5
|
+
var config = require('./config.js');
|
|
136
6
|
|
|
137
7
|
var index = (()=>({
|
|
138
8
|
bootstrap,
|
|
139
9
|
config,
|
|
140
|
-
services
|
|
10
|
+
services: index$1
|
|
141
11
|
}));
|
|
142
12
|
|
|
143
13
|
module.exports = index;
|
package/dist/server/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../server/src/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../server/src/index.ts"],"sourcesContent":["import bootstrap from './bootstrap';\nimport services from './services';\nimport config from './config';\n\nexport default () => ({\n bootstrap,\n config,\n services,\n});\n"],"names":["bootstrap","config","services"],"mappings":";;;;;;AAIA,YAAe,CAAA,KAAO;AACpBA,QAAAA,SAAAA;AACAC,QAAAA,MAAAA;AACAC,kBAAAA;AACF,KAAA,CAAC;;;;"}
|
package/dist/server/index.mjs
CHANGED
|
@@ -1,117 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Programmatic sentry middleware. We do not want to expose it in the plugin
|
|
5
|
-
*/ var initSentryMiddleware = (({ strapi })=>{
|
|
6
|
-
const sentryService = strapi.plugin('sentry').service('sentry');
|
|
7
|
-
sentryService.init();
|
|
8
|
-
const sentry = sentryService.getInstance();
|
|
9
|
-
if (!sentry) {
|
|
10
|
-
// initialization failed
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
strapi.server.use(async (ctx, next)=>{
|
|
14
|
-
try {
|
|
15
|
-
await next();
|
|
16
|
-
} catch (error) {
|
|
17
|
-
if (error instanceof Error) {
|
|
18
|
-
sentryService.sendError(error, (scope)=>{
|
|
19
|
-
scope.addEventProcessor((event)=>{
|
|
20
|
-
// Parse Koa context to add error metadata
|
|
21
|
-
return sentry.Handlers.parseRequest(event, ctx.request, {
|
|
22
|
-
// Don't parse the transaction name, we'll do it manually
|
|
23
|
-
transaction: false
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
// Manually add transaction name
|
|
27
|
-
scope.setTag('transaction', `${ctx.method} ${ctx._matchedRoute}`);
|
|
28
|
-
// Manually add Strapi version
|
|
29
|
-
scope.setTag('strapi_version', strapi.config.info.strapi);
|
|
30
|
-
scope.setTag('method', ctx.method);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
throw error;
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
var bootstrap = (async ({ strapi })=>{
|
|
39
|
-
// Initialize the Sentry service exposed by this plugin
|
|
40
|
-
initSentryMiddleware({
|
|
41
|
-
strapi
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
const createSentryService = (strapi)=>{
|
|
46
|
-
let isReady = false;
|
|
47
|
-
let instance = null;
|
|
48
|
-
// Retrieve user config and merge it with the default one
|
|
49
|
-
const config = strapi.config.get('plugin::sentry');
|
|
50
|
-
return {
|
|
51
|
-
/**
|
|
52
|
-
* Initialize Sentry service
|
|
53
|
-
*/ init () {
|
|
54
|
-
// Make sure there isn't a Sentry instance already running
|
|
55
|
-
if (instance != null) {
|
|
56
|
-
return this;
|
|
57
|
-
}
|
|
58
|
-
// Don't init Sentry if no DSN was provided
|
|
59
|
-
if (!config.dsn) {
|
|
60
|
-
strapi.log.info('@strapi/plugin-sentry is disabled because no Sentry DSN was provided');
|
|
61
|
-
return this;
|
|
62
|
-
}
|
|
63
|
-
try {
|
|
64
|
-
Sentry.init({
|
|
65
|
-
dsn: config.dsn,
|
|
66
|
-
environment: strapi.config.get('environment'),
|
|
67
|
-
...config.init
|
|
68
|
-
});
|
|
69
|
-
// Store the successfully initialized Sentry instance
|
|
70
|
-
instance = Sentry;
|
|
71
|
-
isReady = true;
|
|
72
|
-
} catch (error) {
|
|
73
|
-
strapi.log.warn('Could not set up Sentry, make sure you entered a valid DSN');
|
|
74
|
-
}
|
|
75
|
-
return this;
|
|
76
|
-
},
|
|
77
|
-
/**
|
|
78
|
-
* Expose Sentry instance through a getter
|
|
79
|
-
*/ getInstance () {
|
|
80
|
-
return instance;
|
|
81
|
-
},
|
|
82
|
-
/**
|
|
83
|
-
* Higher level method to send exception events to Sentry
|
|
84
|
-
*/ sendError (error, configureScope) {
|
|
85
|
-
// Make sure Sentry is ready
|
|
86
|
-
if (!isReady || !instance) {
|
|
87
|
-
strapi.log.warn("Sentry wasn't properly initialized, cannot send event");
|
|
88
|
-
return;
|
|
89
|
-
}
|
|
90
|
-
instance.withScope((scope)=>{
|
|
91
|
-
// Configure the Sentry scope using the provided callback
|
|
92
|
-
if (configureScope && config.sendMetadata) {
|
|
93
|
-
configureScope(scope);
|
|
94
|
-
}
|
|
95
|
-
// Actually send the Error to Sentry
|
|
96
|
-
instance?.captureException(error);
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
var sentry = (({ strapi })=>createSentryService(strapi));
|
|
102
|
-
|
|
103
|
-
var services = {
|
|
104
|
-
sentry
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
var config = {
|
|
108
|
-
default: {
|
|
109
|
-
dsn: null,
|
|
110
|
-
sendMetadata: true,
|
|
111
|
-
init: {}
|
|
112
|
-
},
|
|
113
|
-
validator () {}
|
|
114
|
-
};
|
|
1
|
+
import bootstrap from './bootstrap.mjs';
|
|
2
|
+
import services from './services/index.mjs';
|
|
3
|
+
import config from './config.mjs';
|
|
115
4
|
|
|
116
5
|
var index = (()=>({
|
|
117
6
|
bootstrap,
|