@tramvai/module-micro-sentry 4.3.0 → 4.4.1
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 +44 -0
- package/lib/browser.js +3 -3
- package/lib/inlineErrorInterceptor.inline.d.ts +2 -0
- package/lib/inlineErrorInterceptor.inline.es.js +48 -0
- package/lib/inlineErrorInterceptor.inline.js +52 -0
- package/lib/providers.browser.js +20 -3
- package/lib/providers.d.ts +1 -0
- package/lib/providers.es.js +50 -0
- package/lib/providers.js +54 -0
- package/lib/server.es.js +30 -2
- package/lib/server.js +30 -0
- package/lib/tokens.browser.js +3 -1
- package/lib/tokens.d.ts +6 -0
- package/lib/tokens.es.js +3 -1
- package/lib/tokens.js +4 -0
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -24,6 +24,42 @@ And make sure to add `SENTRY_DSN` environment on deployed stands. Otherwise modu
|
|
|
24
24
|
|
|
25
25
|
## Explanation
|
|
26
26
|
|
|
27
|
+
### Working with unhandled rejections and global errors
|
|
28
|
+
|
|
29
|
+
Micro-sentry itself does not have the proper logic to intercept global [unhandlerejection](https://developer.mozilla.org/en-US/docs/Web/API/Window/unhandledrejection_event) and [error](https://developer.mozilla.org/en-US/docs/Web/API/Window/error_event) events. In this case, `@tramvai/module-micro-sentry` adds an inline script with custom logic for the `unhandledrejection` and `error` events. Before the micro-sentry package is initialized, all errors are added to an errorQueue, and when micro-sentry is initialized, this queue is cleared, and all caught errors are sent to the `SENTRY_DSN` URL. To create your custom global error handler, you can use the `MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN`. For example:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
// createErrorInterceptor.inline.ts
|
|
33
|
+
|
|
34
|
+
export function createErrorInterceptor() {
|
|
35
|
+
window.onerror = function () {
|
|
36
|
+
// your custom logic
|
|
37
|
+
};
|
|
38
|
+
window.onunhandledrejection = function () {
|
|
39
|
+
// your custom logic
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
import { createApp } from '@tramvai/core';
|
|
46
|
+
import { TramvaiMicroSentryModule } from '@tramvai/module-micro-sentry';
|
|
47
|
+
import { createErrorInterceptor } from './createErrorInterceptor.inline';
|
|
48
|
+
|
|
49
|
+
createApp({
|
|
50
|
+
name: 'sample-application',
|
|
51
|
+
modules: [
|
|
52
|
+
TramvaiMicroSentryModule,
|
|
53
|
+
provide({
|
|
54
|
+
provide: MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN,
|
|
55
|
+
useFactory: ({ microSentryInlineErrorInterceptorKey }) => {
|
|
56
|
+
return `(${createErrorInterceptor})()`;
|
|
57
|
+
},
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
27
63
|
### Environment variables
|
|
28
64
|
|
|
29
65
|
Required:
|
|
@@ -64,3 +100,11 @@ Ready to use instance of micro-sentry
|
|
|
64
100
|
### `MICRO_SENTRY_OPTIONS_TOKEN`
|
|
65
101
|
|
|
66
102
|
Configuration options for micro-sentry
|
|
103
|
+
|
|
104
|
+
### `MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN`
|
|
105
|
+
|
|
106
|
+
Key value for ErrorInterceptor script. This key will be used to save custom logiс to window object.
|
|
107
|
+
|
|
108
|
+
### `MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN`
|
|
109
|
+
|
|
110
|
+
Script for inline error interceptor
|
package/lib/browser.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { declareModule, provide } from '@tramvai/core';
|
|
2
2
|
import { ENV_MANAGER_TOKEN } from '@tramvai/module-common';
|
|
3
|
-
import {
|
|
3
|
+
import { browserProviders } from './providers.browser.js';
|
|
4
4
|
import { MICRO_SENTRY_OPTIONS_TOKEN } from './tokens.browser.js';
|
|
5
|
-
export { MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN } from './tokens.browser.js';
|
|
5
|
+
export { MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN, MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN, MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN } from './tokens.browser.js';
|
|
6
6
|
|
|
7
7
|
const TramvaiMicroSentryModule = declareModule({
|
|
8
8
|
name: 'TramvaiMicroSentryModule',
|
|
9
9
|
providers: [
|
|
10
|
+
...browserProviders,
|
|
10
11
|
provide({
|
|
11
12
|
provide: MICRO_SENTRY_OPTIONS_TOKEN,
|
|
12
13
|
useFactory: ({ envManager }) => {
|
|
@@ -20,7 +21,6 @@ const TramvaiMicroSentryModule = declareModule({
|
|
|
20
21
|
envManager: ENV_MANAGER_TOKEN,
|
|
21
22
|
},
|
|
22
23
|
}),
|
|
23
|
-
...sharedProviders,
|
|
24
24
|
],
|
|
25
25
|
imports: [],
|
|
26
26
|
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Идея взята из https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/loader.js
|
|
2
|
+
/* eslint-disable prefer-rest-params */
|
|
3
|
+
function createErrorInterceptor(namespace) {
|
|
4
|
+
const originalOnError = window.onerror;
|
|
5
|
+
const originalOnUnhandledRejection = window.onunhandledrejection;
|
|
6
|
+
const errorInterceptorNamespace = {
|
|
7
|
+
errorsQueue: [],
|
|
8
|
+
onError(error) {
|
|
9
|
+
this.errorsQueue.push(error);
|
|
10
|
+
},
|
|
11
|
+
clear() {
|
|
12
|
+
window.onerror = originalOnError;
|
|
13
|
+
window.onunhandledrejection = originalOnUnhandledRejection;
|
|
14
|
+
delete window[namespace];
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
window[namespace] = errorInterceptorNamespace;
|
|
18
|
+
window.onerror = function (_message, _source, _lineno, _colno, error) {
|
|
19
|
+
if (error) {
|
|
20
|
+
errorInterceptorNamespace.onError(error);
|
|
21
|
+
}
|
|
22
|
+
if (originalOnError) {
|
|
23
|
+
//@ts-expect-error
|
|
24
|
+
originalOnError.apply(window, arguments);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
window.onunhandledrejection = function (e) {
|
|
28
|
+
let reason = null;
|
|
29
|
+
if ('reason' in e) {
|
|
30
|
+
reason = e.reason;
|
|
31
|
+
//@ts-expect-error
|
|
32
|
+
}
|
|
33
|
+
else if ('detail' in e && 'reason' in e.detail) {
|
|
34
|
+
//@ts-expect-error
|
|
35
|
+
reason = e.detail.reason;
|
|
36
|
+
}
|
|
37
|
+
if (reason) {
|
|
38
|
+
errorInterceptorNamespace.onError(reason);
|
|
39
|
+
}
|
|
40
|
+
if (originalOnUnhandledRejection) {
|
|
41
|
+
//@ts-expect-error
|
|
42
|
+
originalOnUnhandledRejection.apply(window, arguments);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/* eslint-enable prefer-rest-params */
|
|
47
|
+
|
|
48
|
+
export { createErrorInterceptor };
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
// Идея взята из https://github.com/getsentry/sentry-javascript/blob/master/packages/browser/src/loader.js
|
|
6
|
+
/* eslint-disable prefer-rest-params */
|
|
7
|
+
function createErrorInterceptor(namespace) {
|
|
8
|
+
const originalOnError = window.onerror;
|
|
9
|
+
const originalOnUnhandledRejection = window.onunhandledrejection;
|
|
10
|
+
const errorInterceptorNamespace = {
|
|
11
|
+
errorsQueue: [],
|
|
12
|
+
onError(error) {
|
|
13
|
+
this.errorsQueue.push(error);
|
|
14
|
+
},
|
|
15
|
+
clear() {
|
|
16
|
+
window.onerror = originalOnError;
|
|
17
|
+
window.onunhandledrejection = originalOnUnhandledRejection;
|
|
18
|
+
delete window[namespace];
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
window[namespace] = errorInterceptorNamespace;
|
|
22
|
+
window.onerror = function (_message, _source, _lineno, _colno, error) {
|
|
23
|
+
if (error) {
|
|
24
|
+
errorInterceptorNamespace.onError(error);
|
|
25
|
+
}
|
|
26
|
+
if (originalOnError) {
|
|
27
|
+
//@ts-expect-error
|
|
28
|
+
originalOnError.apply(window, arguments);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
window.onunhandledrejection = function (e) {
|
|
32
|
+
let reason = null;
|
|
33
|
+
if ('reason' in e) {
|
|
34
|
+
reason = e.reason;
|
|
35
|
+
//@ts-expect-error
|
|
36
|
+
}
|
|
37
|
+
else if ('detail' in e && 'reason' in e.detail) {
|
|
38
|
+
//@ts-expect-error
|
|
39
|
+
reason = e.detail.reason;
|
|
40
|
+
}
|
|
41
|
+
if (reason) {
|
|
42
|
+
errorInterceptorNamespace.onError(reason);
|
|
43
|
+
}
|
|
44
|
+
if (originalOnUnhandledRejection) {
|
|
45
|
+
//@ts-expect-error
|
|
46
|
+
originalOnUnhandledRejection.apply(window, arguments);
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/* eslint-enable prefer-rest-params */
|
|
51
|
+
|
|
52
|
+
exports.createErrorInterceptor = createErrorInterceptor;
|
package/lib/providers.browser.js
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import { provide, commandLineListTokens } from '@tramvai/core';
|
|
2
2
|
import { ENV_USED_TOKEN } from '@tramvai/module-common';
|
|
3
3
|
import { BrowserMicroSentryClient } from '@micro-sentry/browser';
|
|
4
|
-
import { MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN } from './tokens.browser.js';
|
|
4
|
+
import { MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN, MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN } from './tokens.browser.js';
|
|
5
5
|
|
|
6
6
|
const sharedProviders = [
|
|
7
|
+
provide({
|
|
8
|
+
provide: MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN,
|
|
9
|
+
useValue: '__MICRO_SENTRY_MODULE_INLINE_ERROR_INTERCEPTOR__',
|
|
10
|
+
}),
|
|
11
|
+
];
|
|
12
|
+
const browserProviders = [
|
|
13
|
+
...sharedProviders,
|
|
7
14
|
provide({
|
|
8
15
|
provide: ENV_USED_TOKEN,
|
|
9
16
|
useValue: [{ key: 'SENTRY_DSN' }],
|
|
@@ -19,15 +26,25 @@ const sharedProviders = [
|
|
|
19
26
|
}),
|
|
20
27
|
provide({
|
|
21
28
|
provide: commandLineListTokens.init,
|
|
22
|
-
useFactory: ({ microSentry }) => {
|
|
29
|
+
useFactory: ({ microSentry, microSentryInlineErrorInterceptorKey }) => {
|
|
23
30
|
return function initMicroSentry() {
|
|
31
|
+
var _a;
|
|
32
|
+
const errorInterceptor = window[microSentryInlineErrorInterceptorKey];
|
|
33
|
+
errorInterceptor.onError = (error) => {
|
|
34
|
+
microSentry === null || microSentry === void 0 ? void 0 : microSentry.report(error);
|
|
35
|
+
};
|
|
36
|
+
while ((_a = errorInterceptor === null || errorInterceptor === void 0 ? void 0 : errorInterceptor.errorsQueue) === null || _a === void 0 ? void 0 : _a.length) {
|
|
37
|
+
const error = errorInterceptor.errorsQueue.pop();
|
|
38
|
+
errorInterceptor.onError(error);
|
|
39
|
+
}
|
|
24
40
|
return microSentry;
|
|
25
41
|
};
|
|
26
42
|
},
|
|
27
43
|
deps: {
|
|
28
44
|
microSentry: MICRO_SENTRY_INSTANCE_TOKEN,
|
|
45
|
+
microSentryInlineErrorInterceptorKey: MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN,
|
|
29
46
|
},
|
|
30
47
|
}),
|
|
31
48
|
];
|
|
32
49
|
|
|
33
|
-
export { sharedProviders };
|
|
50
|
+
export { browserProviders, sharedProviders };
|
package/lib/providers.d.ts
CHANGED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { provide, commandLineListTokens } from '@tramvai/core';
|
|
2
|
+
import { ENV_USED_TOKEN } from '@tramvai/module-common';
|
|
3
|
+
import { BrowserMicroSentryClient } from '@micro-sentry/browser';
|
|
4
|
+
import { MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN, MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN } from './tokens.es.js';
|
|
5
|
+
|
|
6
|
+
const sharedProviders = [
|
|
7
|
+
provide({
|
|
8
|
+
provide: MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN,
|
|
9
|
+
useValue: '__MICRO_SENTRY_MODULE_INLINE_ERROR_INTERCEPTOR__',
|
|
10
|
+
}),
|
|
11
|
+
];
|
|
12
|
+
[
|
|
13
|
+
...sharedProviders,
|
|
14
|
+
provide({
|
|
15
|
+
provide: ENV_USED_TOKEN,
|
|
16
|
+
useValue: [{ key: 'SENTRY_DSN' }],
|
|
17
|
+
}),
|
|
18
|
+
provide({
|
|
19
|
+
provide: MICRO_SENTRY_INSTANCE_TOKEN,
|
|
20
|
+
useFactory: ({ microSentryOptions }) => {
|
|
21
|
+
return new BrowserMicroSentryClient(microSentryOptions);
|
|
22
|
+
},
|
|
23
|
+
deps: {
|
|
24
|
+
microSentryOptions: MICRO_SENTRY_OPTIONS_TOKEN,
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
provide({
|
|
28
|
+
provide: commandLineListTokens.init,
|
|
29
|
+
useFactory: ({ microSentry, microSentryInlineErrorInterceptorKey }) => {
|
|
30
|
+
return function initMicroSentry() {
|
|
31
|
+
var _a;
|
|
32
|
+
const errorInterceptor = window[microSentryInlineErrorInterceptorKey];
|
|
33
|
+
errorInterceptor.onError = (error) => {
|
|
34
|
+
microSentry === null || microSentry === void 0 ? void 0 : microSentry.report(error);
|
|
35
|
+
};
|
|
36
|
+
while ((_a = errorInterceptor === null || errorInterceptor === void 0 ? void 0 : errorInterceptor.errorsQueue) === null || _a === void 0 ? void 0 : _a.length) {
|
|
37
|
+
const error = errorInterceptor.errorsQueue.pop();
|
|
38
|
+
errorInterceptor.onError(error);
|
|
39
|
+
}
|
|
40
|
+
return microSentry;
|
|
41
|
+
};
|
|
42
|
+
},
|
|
43
|
+
deps: {
|
|
44
|
+
microSentry: MICRO_SENTRY_INSTANCE_TOKEN,
|
|
45
|
+
microSentryInlineErrorInterceptorKey: MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN,
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export { sharedProviders };
|
package/lib/providers.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@tramvai/core');
|
|
6
|
+
var moduleCommon = require('@tramvai/module-common');
|
|
7
|
+
var browser = require('@micro-sentry/browser');
|
|
8
|
+
var tokens = require('./tokens.js');
|
|
9
|
+
|
|
10
|
+
const sharedProviders = [
|
|
11
|
+
core.provide({
|
|
12
|
+
provide: tokens.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN,
|
|
13
|
+
useValue: '__MICRO_SENTRY_MODULE_INLINE_ERROR_INTERCEPTOR__',
|
|
14
|
+
}),
|
|
15
|
+
];
|
|
16
|
+
[
|
|
17
|
+
...sharedProviders,
|
|
18
|
+
core.provide({
|
|
19
|
+
provide: moduleCommon.ENV_USED_TOKEN,
|
|
20
|
+
useValue: [{ key: 'SENTRY_DSN' }],
|
|
21
|
+
}),
|
|
22
|
+
core.provide({
|
|
23
|
+
provide: tokens.MICRO_SENTRY_INSTANCE_TOKEN,
|
|
24
|
+
useFactory: ({ microSentryOptions }) => {
|
|
25
|
+
return new browser.BrowserMicroSentryClient(microSentryOptions);
|
|
26
|
+
},
|
|
27
|
+
deps: {
|
|
28
|
+
microSentryOptions: tokens.MICRO_SENTRY_OPTIONS_TOKEN,
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
core.provide({
|
|
32
|
+
provide: core.commandLineListTokens.init,
|
|
33
|
+
useFactory: ({ microSentry, microSentryInlineErrorInterceptorKey }) => {
|
|
34
|
+
return function initMicroSentry() {
|
|
35
|
+
var _a;
|
|
36
|
+
const errorInterceptor = window[microSentryInlineErrorInterceptorKey];
|
|
37
|
+
errorInterceptor.onError = (error) => {
|
|
38
|
+
microSentry === null || microSentry === void 0 ? void 0 : microSentry.report(error);
|
|
39
|
+
};
|
|
40
|
+
while ((_a = errorInterceptor === null || errorInterceptor === void 0 ? void 0 : errorInterceptor.errorsQueue) === null || _a === void 0 ? void 0 : _a.length) {
|
|
41
|
+
const error = errorInterceptor.errorsQueue.pop();
|
|
42
|
+
errorInterceptor.onError(error);
|
|
43
|
+
}
|
|
44
|
+
return microSentry;
|
|
45
|
+
};
|
|
46
|
+
},
|
|
47
|
+
deps: {
|
|
48
|
+
microSentry: tokens.MICRO_SENTRY_INSTANCE_TOKEN,
|
|
49
|
+
microSentryInlineErrorInterceptorKey: tokens.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN,
|
|
50
|
+
},
|
|
51
|
+
}),
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
exports.sharedProviders = sharedProviders;
|
package/lib/server.es.js
CHANGED
|
@@ -1,15 +1,43 @@
|
|
|
1
1
|
import { declareModule, provide } from '@tramvai/core';
|
|
2
|
-
import {
|
|
3
|
-
|
|
2
|
+
import { RENDER_SLOTS, ResourceSlot, ResourceType } from '@tramvai/tokens-render';
|
|
3
|
+
import { MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN, MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN, MICRO_SENTRY_INSTANCE_TOKEN } from './tokens.es.js';
|
|
4
|
+
export { MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN, MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN, MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN } from './tokens.es.js';
|
|
5
|
+
import { createErrorInterceptor } from './inlineErrorInterceptor.inline.es.js';
|
|
6
|
+
import { sharedProviders } from './providers.es.js';
|
|
4
7
|
|
|
5
8
|
const TramvaiMicroSentryModule = declareModule({
|
|
6
9
|
name: 'TramvaiMicroSentryModule',
|
|
7
10
|
imports: [],
|
|
8
11
|
providers: [
|
|
12
|
+
...sharedProviders,
|
|
13
|
+
provide({
|
|
14
|
+
provide: MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN,
|
|
15
|
+
useFactory: ({ microSentryInlineErrorInterceptorKey }) => {
|
|
16
|
+
return `(${createErrorInterceptor})('${microSentryInlineErrorInterceptorKey}')`;
|
|
17
|
+
},
|
|
18
|
+
deps: {
|
|
19
|
+
microSentryInlineErrorInterceptorKey: MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN,
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
provide({
|
|
23
|
+
provide: RENDER_SLOTS,
|
|
24
|
+
multi: true,
|
|
25
|
+
useFactory: ({ payload }) => {
|
|
26
|
+
return {
|
|
27
|
+
slot: ResourceSlot.HEAD_CORE_SCRIPTS,
|
|
28
|
+
type: ResourceType.inlineScript,
|
|
29
|
+
payload,
|
|
30
|
+
};
|
|
31
|
+
},
|
|
32
|
+
deps: {
|
|
33
|
+
payload: MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN,
|
|
34
|
+
},
|
|
35
|
+
}),
|
|
9
36
|
provide({
|
|
10
37
|
provide: MICRO_SENTRY_INSTANCE_TOKEN,
|
|
11
38
|
useFactory: () => {
|
|
12
39
|
if (process.env.NODE_ENV === 'development') {
|
|
40
|
+
// eslint-disable-next-line no-console
|
|
13
41
|
console.warn('micro-sentry will work only in browser environment, and will not work in server environment. If you need error logging both on server and client, take a look on @tramvai/module-sentry package');
|
|
14
42
|
}
|
|
15
43
|
return null;
|
package/lib/server.js
CHANGED
|
@@ -3,16 +3,44 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var core = require('@tramvai/core');
|
|
6
|
+
var tokensRender = require('@tramvai/tokens-render');
|
|
6
7
|
var tokens = require('./tokens.js');
|
|
8
|
+
var inlineErrorInterceptor_inline = require('./inlineErrorInterceptor.inline.js');
|
|
9
|
+
var providers = require('./providers.js');
|
|
7
10
|
|
|
8
11
|
const TramvaiMicroSentryModule = core.declareModule({
|
|
9
12
|
name: 'TramvaiMicroSentryModule',
|
|
10
13
|
imports: [],
|
|
11
14
|
providers: [
|
|
15
|
+
...providers.sharedProviders,
|
|
16
|
+
core.provide({
|
|
17
|
+
provide: tokens.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN,
|
|
18
|
+
useFactory: ({ microSentryInlineErrorInterceptorKey }) => {
|
|
19
|
+
return `(${inlineErrorInterceptor_inline.createErrorInterceptor})('${microSentryInlineErrorInterceptorKey}')`;
|
|
20
|
+
},
|
|
21
|
+
deps: {
|
|
22
|
+
microSentryInlineErrorInterceptorKey: tokens.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN,
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
core.provide({
|
|
26
|
+
provide: tokensRender.RENDER_SLOTS,
|
|
27
|
+
multi: true,
|
|
28
|
+
useFactory: ({ payload }) => {
|
|
29
|
+
return {
|
|
30
|
+
slot: tokensRender.ResourceSlot.HEAD_CORE_SCRIPTS,
|
|
31
|
+
type: tokensRender.ResourceType.inlineScript,
|
|
32
|
+
payload,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
deps: {
|
|
36
|
+
payload: tokens.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN,
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
12
39
|
core.provide({
|
|
13
40
|
provide: tokens.MICRO_SENTRY_INSTANCE_TOKEN,
|
|
14
41
|
useFactory: () => {
|
|
15
42
|
if (process.env.NODE_ENV === 'development') {
|
|
43
|
+
// eslint-disable-next-line no-console
|
|
16
44
|
console.warn('micro-sentry will work only in browser environment, and will not work in server environment. If you need error logging both on server and client, take a look on @tramvai/module-sentry package');
|
|
17
45
|
}
|
|
18
46
|
return null;
|
|
@@ -21,6 +49,8 @@ const TramvaiMicroSentryModule = core.declareModule({
|
|
|
21
49
|
],
|
|
22
50
|
});
|
|
23
51
|
|
|
52
|
+
exports.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN = tokens.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN;
|
|
53
|
+
exports.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN = tokens.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN;
|
|
24
54
|
exports.MICRO_SENTRY_INSTANCE_TOKEN = tokens.MICRO_SENTRY_INSTANCE_TOKEN;
|
|
25
55
|
exports.MICRO_SENTRY_OPTIONS_TOKEN = tokens.MICRO_SENTRY_OPTIONS_TOKEN;
|
|
26
56
|
exports.TramvaiMicroSentryModule = TramvaiMicroSentryModule;
|
package/lib/tokens.browser.js
CHANGED
|
@@ -2,5 +2,7 @@ import { createToken } from '@tramvai/core';
|
|
|
2
2
|
|
|
3
3
|
const MICRO_SENTRY_INSTANCE_TOKEN = createToken('MICRO_SENTRY_INSTANCE_TOKEN');
|
|
4
4
|
const MICRO_SENTRY_OPTIONS_TOKEN = createToken('MICRO_SENTRY_OPTIONS_TOKEN');
|
|
5
|
+
const MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN = createToken('MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN');
|
|
6
|
+
const MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN = createToken('MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN');
|
|
5
7
|
|
|
6
|
-
export { MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN };
|
|
8
|
+
export { MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN, MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN, MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN };
|
package/lib/tokens.d.ts
CHANGED
|
@@ -5,4 +5,10 @@ export declare const MICRO_SENTRY_INSTANCE_TOKEN: (BrowserMicroSentryClient & {
|
|
|
5
5
|
export declare const MICRO_SENTRY_OPTIONS_TOKEN: BrowserSentryClientOptions & {
|
|
6
6
|
__type?: "base token" | undefined;
|
|
7
7
|
};
|
|
8
|
+
export declare const MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN: string & {
|
|
9
|
+
__type?: "base token" | undefined;
|
|
10
|
+
};
|
|
11
|
+
export declare const MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN: string & {
|
|
12
|
+
__type?: "base token" | undefined;
|
|
13
|
+
};
|
|
8
14
|
//# sourceMappingURL=tokens.d.ts.map
|
package/lib/tokens.es.js
CHANGED
|
@@ -2,5 +2,7 @@ import { createToken } from '@tramvai/core';
|
|
|
2
2
|
|
|
3
3
|
const MICRO_SENTRY_INSTANCE_TOKEN = createToken('MICRO_SENTRY_INSTANCE_TOKEN');
|
|
4
4
|
const MICRO_SENTRY_OPTIONS_TOKEN = createToken('MICRO_SENTRY_OPTIONS_TOKEN');
|
|
5
|
+
const MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN = createToken('MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN');
|
|
6
|
+
const MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN = createToken('MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN');
|
|
5
7
|
|
|
6
|
-
export { MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN };
|
|
8
|
+
export { MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN, MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN, MICRO_SENTRY_INSTANCE_TOKEN, MICRO_SENTRY_OPTIONS_TOKEN };
|
package/lib/tokens.js
CHANGED
|
@@ -6,6 +6,10 @@ var core = require('@tramvai/core');
|
|
|
6
6
|
|
|
7
7
|
const MICRO_SENTRY_INSTANCE_TOKEN = core.createToken('MICRO_SENTRY_INSTANCE_TOKEN');
|
|
8
8
|
const MICRO_SENTRY_OPTIONS_TOKEN = core.createToken('MICRO_SENTRY_OPTIONS_TOKEN');
|
|
9
|
+
const MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN = core.createToken('MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN');
|
|
10
|
+
const MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN = core.createToken('MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN');
|
|
9
11
|
|
|
12
|
+
exports.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN = MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_KEY_TOKEN;
|
|
13
|
+
exports.MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN = MICRO_SENTRY_INLINE_ERROR_INTERCEPTOR_TOKEN;
|
|
10
14
|
exports.MICRO_SENTRY_INSTANCE_TOKEN = MICRO_SENTRY_INSTANCE_TOKEN;
|
|
11
15
|
exports.MICRO_SENTRY_OPTIONS_TOKEN = MICRO_SENTRY_OPTIONS_TOKEN;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tramvai/module-micro-sentry",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.1",
|
|
4
4
|
"description": "Micro-sentry module",
|
|
5
5
|
"browser": "lib/browser.js",
|
|
6
6
|
"main": "lib/server.js",
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
"@micro-sentry/browser": "^7.0.1"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"@tramvai/
|
|
26
|
-
"@tramvai/
|
|
25
|
+
"@tramvai/tokens-render": "4.4.1",
|
|
26
|
+
"@tramvai/core": "4.4.1",
|
|
27
|
+
"@tramvai/module-common": "4.4.1"
|
|
27
28
|
},
|
|
28
29
|
"module": "lib/server.es.js"
|
|
29
30
|
}
|