@tramvai/module-application-monitoring 7.16.0

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 ADDED
@@ -0,0 +1,3 @@
1
+ # @tramvai/module-application-monitoring
2
+
3
+ [Actual documentation](03-features/014-monitoring/04-application-health.md)
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+ export * from './tokens';
3
+ export declare const ApplicationMonitoringModule: import("@tinkoff/dippy/lib/modules/module.h").ModuleClass & Partial<import("@tinkoff/dippy/lib/modules/module.h").ModuleSecretParameters> & {
4
+ [x: string]: (...args: any[]) => import("@tramvai/core").ModuleType;
5
+ };
6
+ //# sourceMappingURL=browser.d.ts.map
package/lib/browser.js ADDED
@@ -0,0 +1,11 @@
1
+ import { declareModule } from '@tramvai/core';
2
+ import { sharedProviders } from './sharedProviders.browser.js';
3
+ export { INLINE_REPORTER_FACTORY_SCRIPT_TOKEN, INLINE_REPORTER_PARAMETERS_TOKEN } from './tokens.browser.js';
4
+
5
+ const ApplicationMonitoringModule = declareModule({
6
+ name: 'ApplicationMonitoringModule',
7
+ imports: [],
8
+ providers: [...sharedProviders],
9
+ });
10
+
11
+ export { ApplicationMonitoringModule };
@@ -0,0 +1,3 @@
1
+ const LOGGER_NAME = 'application-health';
2
+
3
+ export { LOGGER_NAME };
@@ -0,0 +1,2 @@
1
+ export declare const LOGGER_NAME = "application-health";
2
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1,3 @@
1
+ const LOGGER_NAME = 'application-health';
2
+
3
+ export { LOGGER_NAME };
@@ -0,0 +1,7 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const LOGGER_NAME = 'application-health';
6
+
7
+ exports.LOGGER_NAME = LOGGER_NAME;
@@ -0,0 +1,4 @@
1
+ export declare const appCreationMonitoringScript: (payload: {
2
+ [x: string]: any;
3
+ }) => void;
4
+ //# sourceMappingURL=appCreationMonitoringScript.inline.d.ts.map
@@ -0,0 +1,10 @@
1
+ const appCreationMonitoringScript = (payload) => {
2
+ window.addEventListener('unhandledrejection',
3
+ //@ts-expect-error
4
+ (event) => {
5
+ const eventName = 'unhandled-error';
6
+ window.__TRAMVAI_INLINE_REPORTER?.send?.(eventName, { ...event, ...payload });
7
+ }, true);
8
+ };
9
+
10
+ export { appCreationMonitoringScript };
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const appCreationMonitoringScript = (payload) => {
6
+ window.addEventListener('unhandledrejection',
7
+ //@ts-expect-error
8
+ (event) => {
9
+ const eventName = 'unhandled-error';
10
+ window.__TRAMVAI_INLINE_REPORTER?.send?.(eventName, { ...event, ...payload });
11
+ }, true);
12
+ };
13
+
14
+ exports.appCreationMonitoringScript = appCreationMonitoringScript;
@@ -0,0 +1,4 @@
1
+ export declare const errorMonitoringScript: (payload: {
2
+ [x: string]: any;
3
+ }) => void;
4
+ //# sourceMappingURL=errorMonitoringScript.inline.d.ts.map
@@ -0,0 +1,29 @@
1
+ const errorMonitoringScript = (payload) => {
2
+ const errors = [];
3
+ window.addEventListener('error', (event) => {
4
+ const tag = event && event.target;
5
+ const tagName = tag && tag.tagName && tag.tagName.toLowerCase();
6
+ if (!tag || (tagName !== 'link' && tagName !== 'script')) {
7
+ return;
8
+ }
9
+ if (event?.error?.retry === 'success') {
10
+ return;
11
+ }
12
+ if (!tag.dataset.critical && !tag.dataset.webpack) {
13
+ return;
14
+ }
15
+ errors.push(event);
16
+ }, true);
17
+ window.addEventListener('load', () => {
18
+ let eventName = null;
19
+ if (errors.length > 0) {
20
+ eventName = 'assets-load-failed';
21
+ }
22
+ else {
23
+ eventName = 'assets-loaded';
24
+ }
25
+ window.__TRAMVAI_INLINE_REPORTER?.send?.(eventName, { ...payload });
26
+ });
27
+ };
28
+
29
+ export { errorMonitoringScript };
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const errorMonitoringScript = (payload) => {
6
+ const errors = [];
7
+ window.addEventListener('error', (event) => {
8
+ const tag = event && event.target;
9
+ const tagName = tag && tag.tagName && tag.tagName.toLowerCase();
10
+ if (!tag || (tagName !== 'link' && tagName !== 'script')) {
11
+ return;
12
+ }
13
+ if (event?.error?.retry === 'success') {
14
+ return;
15
+ }
16
+ if (!tag.dataset.critical && !tag.dataset.webpack) {
17
+ return;
18
+ }
19
+ errors.push(event);
20
+ }, true);
21
+ window.addEventListener('load', () => {
22
+ let eventName = null;
23
+ if (errors.length > 0) {
24
+ eventName = 'assets-load-failed';
25
+ }
26
+ else {
27
+ eventName = 'assets-loaded';
28
+ }
29
+ window.__TRAMVAI_INLINE_REPORTER?.send?.(eventName, { ...payload });
30
+ });
31
+ };
32
+
33
+ exports.errorMonitoringScript = errorMonitoringScript;
@@ -0,0 +1,4 @@
1
+ export declare const htmlOpenedMonitoringScript: (payload: {
2
+ [x: string]: any;
3
+ }) => void;
4
+ //# sourceMappingURL=htmlOpenedMonitoringScript.inline.d.ts.map
@@ -0,0 +1,5 @@
1
+ const htmlOpenedMonitoringScript = (payload) => {
2
+ window.__TRAMVAI_INLINE_REPORTER?.send?.('html-opened', { ...payload });
3
+ };
4
+
5
+ export { htmlOpenedMonitoringScript };
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const htmlOpenedMonitoringScript = (payload) => {
6
+ window.__TRAMVAI_INLINE_REPORTER?.send?.('html-opened', { ...payload });
7
+ };
8
+
9
+ exports.htmlOpenedMonitoringScript = htmlOpenedMonitoringScript;
@@ -0,0 +1,4 @@
1
+ export * from './appCreationMonitoringScript.inline';
2
+ export * from './errorMonitoringScript.inline';
3
+ export * from './htmlOpenedMonitoringScript.inline';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,6 @@
1
+ export * from './types';
2
+ export * from './tokens';
3
+ export declare const ApplicationMonitoringModule: import("@tinkoff/dippy/lib/modules/module.h").ModuleClass & Partial<import("@tinkoff/dippy/lib/modules/module.h").ModuleSecretParameters> & {
4
+ [x: string]: (...args: any[]) => import("@tramvai/core").ModuleType;
5
+ };
6
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,76 @@
1
+ import { declareModule, provide } from '@tramvai/core';
2
+ import { RENDER_SLOTS, ResourceSlot, ResourceType } from '@tramvai/tokens-render';
3
+ import { LOGGER_TOKEN } from '@tramvai/module-common';
4
+ import { INLINE_REPORTER_PARAMETERS_TOKEN, INLINE_REPORTER_FACTORY_SCRIPT_TOKEN } from './tokens.es.js';
5
+ export { INLINE_REPORTER_FACTORY_SCRIPT_TOKEN, INLINE_REPORTER_PARAMETERS_TOKEN } from './tokens.es.js';
6
+ import { appCreationMonitoringScript } from './inlineReporters/events/appCreationMonitoringScript.inline.es.js';
7
+ import { errorMonitoringScript } from './inlineReporters/events/errorMonitoringScript.inline.es.js';
8
+ import { htmlOpenedMonitoringScript } from './inlineReporters/events/htmlOpenedMonitoringScript.inline.es.js';
9
+ import { sharedProviders } from './sharedProviders.es.js';
10
+
11
+ const ApplicationMonitoringModule = declareModule({
12
+ name: 'ApplicationMonitoringModule',
13
+ imports: [],
14
+ providers: [
15
+ ...sharedProviders,
16
+ provide({
17
+ provide: RENDER_SLOTS,
18
+ multi: true,
19
+ useFactory: ({ inlineReporterFactory, inlineReporterParameters, logger }) => {
20
+ const log = logger('application-monitoring');
21
+ if (!inlineReporterFactory) {
22
+ log.debug('@tramvai/module-application-monitoring is on use but INLINE_REPORTER_FACTORY_SCRIPT_TOKEN token is not provided');
23
+ return [];
24
+ }
25
+ return {
26
+ slot: ResourceSlot.HEAD_PERFORMANCE,
27
+ type: ResourceType.inlineScript,
28
+ payload: `window.__TRAMVAI_INLINE_REPORTER = (${inlineReporterFactory})(${JSON.stringify(inlineReporterParameters)})`,
29
+ };
30
+ },
31
+ deps: {
32
+ logger: LOGGER_TOKEN,
33
+ inlineReporterParameters: INLINE_REPORTER_PARAMETERS_TOKEN,
34
+ inlineReporterFactory: {
35
+ token: INLINE_REPORTER_FACTORY_SCRIPT_TOKEN,
36
+ optional: true,
37
+ },
38
+ },
39
+ }),
40
+ provide({
41
+ provide: RENDER_SLOTS,
42
+ multi: true,
43
+ useFactory: () => {
44
+ return {
45
+ slot: ResourceSlot.HEAD_PERFORMANCE,
46
+ type: ResourceType.inlineScript,
47
+ payload: `(${htmlOpenedMonitoringScript})()`,
48
+ };
49
+ },
50
+ }),
51
+ provide({
52
+ provide: RENDER_SLOTS,
53
+ multi: true,
54
+ useFactory: () => {
55
+ return {
56
+ slot: ResourceSlot.HEAD_PERFORMANCE,
57
+ type: ResourceType.inlineScript,
58
+ payload: `(${errorMonitoringScript})()`,
59
+ };
60
+ },
61
+ }),
62
+ provide({
63
+ provide: RENDER_SLOTS,
64
+ multi: true,
65
+ useFactory: () => {
66
+ return {
67
+ slot: ResourceSlot.HEAD_PERFORMANCE,
68
+ type: ResourceType.inlineScript,
69
+ payload: `(${appCreationMonitoringScript})()`,
70
+ };
71
+ },
72
+ }),
73
+ ],
74
+ });
75
+
76
+ export { ApplicationMonitoringModule };
package/lib/server.js ADDED
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@tramvai/core');
6
+ var tokensRender = require('@tramvai/tokens-render');
7
+ var moduleCommon = require('@tramvai/module-common');
8
+ var tokens = require('./tokens.js');
9
+ var appCreationMonitoringScript_inline = require('./inlineReporters/events/appCreationMonitoringScript.inline.js');
10
+ var errorMonitoringScript_inline = require('./inlineReporters/events/errorMonitoringScript.inline.js');
11
+ var htmlOpenedMonitoringScript_inline = require('./inlineReporters/events/htmlOpenedMonitoringScript.inline.js');
12
+ var sharedProviders = require('./sharedProviders.js');
13
+
14
+ const ApplicationMonitoringModule = core.declareModule({
15
+ name: 'ApplicationMonitoringModule',
16
+ imports: [],
17
+ providers: [
18
+ ...sharedProviders.sharedProviders,
19
+ core.provide({
20
+ provide: tokensRender.RENDER_SLOTS,
21
+ multi: true,
22
+ useFactory: ({ inlineReporterFactory, inlineReporterParameters, logger }) => {
23
+ const log = logger('application-monitoring');
24
+ if (!inlineReporterFactory) {
25
+ log.debug('@tramvai/module-application-monitoring is on use but INLINE_REPORTER_FACTORY_SCRIPT_TOKEN token is not provided');
26
+ return [];
27
+ }
28
+ return {
29
+ slot: tokensRender.ResourceSlot.HEAD_PERFORMANCE,
30
+ type: tokensRender.ResourceType.inlineScript,
31
+ payload: `window.__TRAMVAI_INLINE_REPORTER = (${inlineReporterFactory})(${JSON.stringify(inlineReporterParameters)})`,
32
+ };
33
+ },
34
+ deps: {
35
+ logger: moduleCommon.LOGGER_TOKEN,
36
+ inlineReporterParameters: tokens.INLINE_REPORTER_PARAMETERS_TOKEN,
37
+ inlineReporterFactory: {
38
+ token: tokens.INLINE_REPORTER_FACTORY_SCRIPT_TOKEN,
39
+ optional: true,
40
+ },
41
+ },
42
+ }),
43
+ core.provide({
44
+ provide: tokensRender.RENDER_SLOTS,
45
+ multi: true,
46
+ useFactory: () => {
47
+ return {
48
+ slot: tokensRender.ResourceSlot.HEAD_PERFORMANCE,
49
+ type: tokensRender.ResourceType.inlineScript,
50
+ payload: `(${htmlOpenedMonitoringScript_inline.htmlOpenedMonitoringScript})()`,
51
+ };
52
+ },
53
+ }),
54
+ core.provide({
55
+ provide: tokensRender.RENDER_SLOTS,
56
+ multi: true,
57
+ useFactory: () => {
58
+ return {
59
+ slot: tokensRender.ResourceSlot.HEAD_PERFORMANCE,
60
+ type: tokensRender.ResourceType.inlineScript,
61
+ payload: `(${errorMonitoringScript_inline.errorMonitoringScript})()`,
62
+ };
63
+ },
64
+ }),
65
+ core.provide({
66
+ provide: tokensRender.RENDER_SLOTS,
67
+ multi: true,
68
+ useFactory: () => {
69
+ return {
70
+ slot: tokensRender.ResourceSlot.HEAD_PERFORMANCE,
71
+ type: tokensRender.ResourceType.inlineScript,
72
+ payload: `(${appCreationMonitoringScript_inline.appCreationMonitoringScript})()`,
73
+ };
74
+ },
75
+ }),
76
+ ],
77
+ });
78
+
79
+ exports.INLINE_REPORTER_FACTORY_SCRIPT_TOKEN = tokens.INLINE_REPORTER_FACTORY_SCRIPT_TOKEN;
80
+ exports.INLINE_REPORTER_PARAMETERS_TOKEN = tokens.INLINE_REPORTER_PARAMETERS_TOKEN;
81
+ exports.ApplicationMonitoringModule = ApplicationMonitoringModule;
@@ -0,0 +1,77 @@
1
+ import { LOGGER_TOKEN, ENV_MANAGER_TOKEN } from '@tramvai/module-common';
2
+ import { provide, commandLineListTokens, TRAMVAI_HOOKS_TOKEN, APP_INFO_TOKEN } from '@tramvai/core';
3
+ import { INLINE_REPORTER_PARAMETERS_TOKEN } from './tokens.browser.js';
4
+ import { LOGGER_NAME } from './constants.browser.js';
5
+
6
+ const sharedProviders = [
7
+ provide({
8
+ provide: commandLineListTokens.init,
9
+ useFactory: ({ logger, tramvaiHooks }) => {
10
+ const log = logger({
11
+ name: LOGGER_NAME,
12
+ defaults: {
13
+ remote: true,
14
+ },
15
+ });
16
+ return function applicationHealthSubscribe() {
17
+ let applicationRenderFinished = false;
18
+ tramvaiHooks['app:initialized'].tap('application-health', () => {
19
+ log.info({ event: 'app:initialized' });
20
+ });
21
+ tramvaiHooks['app:initialize-failed'].tap('application-health', () => {
22
+ log.info({ event: 'app:initialized-failed' });
23
+ });
24
+ tramvaiHooks['app:rendered'].tap('application-health', () => {
25
+ log.info({ event: 'app:rendered' });
26
+ if (!applicationRenderFinished) {
27
+ applicationRenderFinished = true;
28
+ }
29
+ });
30
+ tramvaiHooks['react:render'].tap('application-health', () => {
31
+ log.info({ event: 'react:render' });
32
+ if (!applicationRenderFinished) {
33
+ applicationRenderFinished = true;
34
+ tramvaiHooks['app:rendered'].call({});
35
+ }
36
+ });
37
+ tramvaiHooks['app:render-failed'].tap('application-health', (_, { error }) => {
38
+ log.error({ event: 'app:initialized', error });
39
+ });
40
+ tramvaiHooks['react:error'].tap('application-health', (_, { event, error, errorInfo, otherErrors }) => {
41
+ log.error({ event: 'react:error', error, errorInfo, otherErrors });
42
+ switch (event) {
43
+ case 'page-error-boundary':
44
+ case 'hydrate:on-uncaught-error':
45
+ case 'hydrate:failed': {
46
+ if (!applicationRenderFinished) {
47
+ applicationRenderFinished = true;
48
+ tramvaiHooks['app:render-failed'].call({ error });
49
+ }
50
+ break;
51
+ }
52
+ }
53
+ });
54
+ };
55
+ },
56
+ deps: {
57
+ logger: LOGGER_TOKEN,
58
+ tramvaiHooks: TRAMVAI_HOOKS_TOKEN,
59
+ },
60
+ }),
61
+ provide({
62
+ provide: INLINE_REPORTER_PARAMETERS_TOKEN,
63
+ useFactory: ({ appInfo, envManager }) => {
64
+ return {
65
+ appName: appInfo.appName,
66
+ appRelease: envManager.get('APP_RELEASE'),
67
+ appVersion: envManager.get('APP_VERSION'),
68
+ };
69
+ },
70
+ deps: {
71
+ envManager: ENV_MANAGER_TOKEN,
72
+ appInfo: APP_INFO_TOKEN,
73
+ },
74
+ }),
75
+ ];
76
+
77
+ export { sharedProviders };
@@ -0,0 +1,26 @@
1
+ export declare const sharedProviders: (import("@tramvai/core").Provider<{
2
+ logger: import("@tramvai/module-common").Logger & ((configOrName: string | {
3
+ [key: string]: any;
4
+ name: string;
5
+ }) => import("@tramvai/module-common").Logger) & {
6
+ __type?: "base token" | undefined;
7
+ };
8
+ tramvaiHooks: import("@tramvai/core").TramvaiHooks & {
9
+ __type?: "base token" | undefined;
10
+ };
11
+ }, import("@tramvai/core").Command & {
12
+ __type?: "multi token" | undefined;
13
+ }> | import("@tramvai/core").Provider<{
14
+ envManager: import("@tramvai/module-common").EnvironmentManager & {
15
+ __type?: "base token" | undefined;
16
+ };
17
+ appInfo: {
18
+ [key: string]: string;
19
+ appName: string;
20
+ } & {
21
+ __type?: "base token" | undefined;
22
+ };
23
+ }, import("./types").InlineReporterParameters & {
24
+ __type?: "base token" | undefined;
25
+ }>)[];
26
+ //# sourceMappingURL=sharedProviders.d.ts.map
@@ -0,0 +1,77 @@
1
+ import { LOGGER_TOKEN, ENV_MANAGER_TOKEN } from '@tramvai/module-common';
2
+ import { provide, commandLineListTokens, TRAMVAI_HOOKS_TOKEN, APP_INFO_TOKEN } from '@tramvai/core';
3
+ import { INLINE_REPORTER_PARAMETERS_TOKEN } from './tokens.es.js';
4
+ import { LOGGER_NAME } from './constants.es.js';
5
+
6
+ const sharedProviders = [
7
+ provide({
8
+ provide: commandLineListTokens.init,
9
+ useFactory: ({ logger, tramvaiHooks }) => {
10
+ const log = logger({
11
+ name: LOGGER_NAME,
12
+ defaults: {
13
+ remote: true,
14
+ },
15
+ });
16
+ return function applicationHealthSubscribe() {
17
+ let applicationRenderFinished = false;
18
+ tramvaiHooks['app:initialized'].tap('application-health', () => {
19
+ log.info({ event: 'app:initialized' });
20
+ });
21
+ tramvaiHooks['app:initialize-failed'].tap('application-health', () => {
22
+ log.info({ event: 'app:initialized-failed' });
23
+ });
24
+ tramvaiHooks['app:rendered'].tap('application-health', () => {
25
+ log.info({ event: 'app:rendered' });
26
+ if (!applicationRenderFinished) {
27
+ applicationRenderFinished = true;
28
+ }
29
+ });
30
+ tramvaiHooks['react:render'].tap('application-health', () => {
31
+ log.info({ event: 'react:render' });
32
+ if (!applicationRenderFinished) {
33
+ applicationRenderFinished = true;
34
+ tramvaiHooks['app:rendered'].call({});
35
+ }
36
+ });
37
+ tramvaiHooks['app:render-failed'].tap('application-health', (_, { error }) => {
38
+ log.error({ event: 'app:initialized', error });
39
+ });
40
+ tramvaiHooks['react:error'].tap('application-health', (_, { event, error, errorInfo, otherErrors }) => {
41
+ log.error({ event: 'react:error', error, errorInfo, otherErrors });
42
+ switch (event) {
43
+ case 'page-error-boundary':
44
+ case 'hydrate:on-uncaught-error':
45
+ case 'hydrate:failed': {
46
+ if (!applicationRenderFinished) {
47
+ applicationRenderFinished = true;
48
+ tramvaiHooks['app:render-failed'].call({ error });
49
+ }
50
+ break;
51
+ }
52
+ }
53
+ });
54
+ };
55
+ },
56
+ deps: {
57
+ logger: LOGGER_TOKEN,
58
+ tramvaiHooks: TRAMVAI_HOOKS_TOKEN,
59
+ },
60
+ }),
61
+ provide({
62
+ provide: INLINE_REPORTER_PARAMETERS_TOKEN,
63
+ useFactory: ({ appInfo, envManager }) => {
64
+ return {
65
+ appName: appInfo.appName,
66
+ appRelease: envManager.get('APP_RELEASE'),
67
+ appVersion: envManager.get('APP_VERSION'),
68
+ };
69
+ },
70
+ deps: {
71
+ envManager: ENV_MANAGER_TOKEN,
72
+ appInfo: APP_INFO_TOKEN,
73
+ },
74
+ }),
75
+ ];
76
+
77
+ export { sharedProviders };
@@ -0,0 +1,81 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var moduleCommon = require('@tramvai/module-common');
6
+ var core = require('@tramvai/core');
7
+ var tokens = require('./tokens.js');
8
+ var constants = require('./constants.js');
9
+
10
+ const sharedProviders = [
11
+ core.provide({
12
+ provide: core.commandLineListTokens.init,
13
+ useFactory: ({ logger, tramvaiHooks }) => {
14
+ const log = logger({
15
+ name: constants.LOGGER_NAME,
16
+ defaults: {
17
+ remote: true,
18
+ },
19
+ });
20
+ return function applicationHealthSubscribe() {
21
+ let applicationRenderFinished = false;
22
+ tramvaiHooks['app:initialized'].tap('application-health', () => {
23
+ log.info({ event: 'app:initialized' });
24
+ });
25
+ tramvaiHooks['app:initialize-failed'].tap('application-health', () => {
26
+ log.info({ event: 'app:initialized-failed' });
27
+ });
28
+ tramvaiHooks['app:rendered'].tap('application-health', () => {
29
+ log.info({ event: 'app:rendered' });
30
+ if (!applicationRenderFinished) {
31
+ applicationRenderFinished = true;
32
+ }
33
+ });
34
+ tramvaiHooks['react:render'].tap('application-health', () => {
35
+ log.info({ event: 'react:render' });
36
+ if (!applicationRenderFinished) {
37
+ applicationRenderFinished = true;
38
+ tramvaiHooks['app:rendered'].call({});
39
+ }
40
+ });
41
+ tramvaiHooks['app:render-failed'].tap('application-health', (_, { error }) => {
42
+ log.error({ event: 'app:initialized', error });
43
+ });
44
+ tramvaiHooks['react:error'].tap('application-health', (_, { event, error, errorInfo, otherErrors }) => {
45
+ log.error({ event: 'react:error', error, errorInfo, otherErrors });
46
+ switch (event) {
47
+ case 'page-error-boundary':
48
+ case 'hydrate:on-uncaught-error':
49
+ case 'hydrate:failed': {
50
+ if (!applicationRenderFinished) {
51
+ applicationRenderFinished = true;
52
+ tramvaiHooks['app:render-failed'].call({ error });
53
+ }
54
+ break;
55
+ }
56
+ }
57
+ });
58
+ };
59
+ },
60
+ deps: {
61
+ logger: moduleCommon.LOGGER_TOKEN,
62
+ tramvaiHooks: core.TRAMVAI_HOOKS_TOKEN,
63
+ },
64
+ }),
65
+ core.provide({
66
+ provide: tokens.INLINE_REPORTER_PARAMETERS_TOKEN,
67
+ useFactory: ({ appInfo, envManager }) => {
68
+ return {
69
+ appName: appInfo.appName,
70
+ appRelease: envManager.get('APP_RELEASE'),
71
+ appVersion: envManager.get('APP_VERSION'),
72
+ };
73
+ },
74
+ deps: {
75
+ envManager: moduleCommon.ENV_MANAGER_TOKEN,
76
+ appInfo: core.APP_INFO_TOKEN,
77
+ },
78
+ }),
79
+ ];
80
+
81
+ exports.sharedProviders = sharedProviders;
@@ -0,0 +1,6 @@
1
+ import { createToken } from '@tinkoff/dippy';
2
+
3
+ const INLINE_REPORTER_PARAMETERS_TOKEN = createToken('INLINE_REPORTER_PARAMETERS_TOKEN');
4
+ const INLINE_REPORTER_FACTORY_SCRIPT_TOKEN = createToken('INLINE_REPORTER_FACTORY_SCRIPT');
5
+
6
+ export { INLINE_REPORTER_FACTORY_SCRIPT_TOKEN, INLINE_REPORTER_PARAMETERS_TOKEN };
@@ -0,0 +1,8 @@
1
+ import type { InlineReporterParameters, TramvaiInlineReporter } from './types';
2
+ export declare const INLINE_REPORTER_PARAMETERS_TOKEN: InlineReporterParameters & {
3
+ __type?: "base token" | undefined;
4
+ };
5
+ export declare const INLINE_REPORTER_FACTORY_SCRIPT_TOKEN: ((inlineReporterParameters: InlineReporterParameters) => TramvaiInlineReporter) & {
6
+ __type?: "base token" | undefined;
7
+ };
8
+ //# sourceMappingURL=tokens.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { createToken } from '@tinkoff/dippy';
2
+
3
+ const INLINE_REPORTER_PARAMETERS_TOKEN = createToken('INLINE_REPORTER_PARAMETERS_TOKEN');
4
+ const INLINE_REPORTER_FACTORY_SCRIPT_TOKEN = createToken('INLINE_REPORTER_FACTORY_SCRIPT');
5
+
6
+ export { INLINE_REPORTER_FACTORY_SCRIPT_TOKEN, INLINE_REPORTER_PARAMETERS_TOKEN };
package/lib/tokens.js ADDED
@@ -0,0 +1,11 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var dippy = require('@tinkoff/dippy');
6
+
7
+ const INLINE_REPORTER_PARAMETERS_TOKEN = dippy.createToken('INLINE_REPORTER_PARAMETERS_TOKEN');
8
+ const INLINE_REPORTER_FACTORY_SCRIPT_TOKEN = dippy.createToken('INLINE_REPORTER_FACTORY_SCRIPT');
9
+
10
+ exports.INLINE_REPORTER_FACTORY_SCRIPT_TOKEN = INLINE_REPORTER_FACTORY_SCRIPT_TOKEN;
11
+ exports.INLINE_REPORTER_PARAMETERS_TOKEN = INLINE_REPORTER_PARAMETERS_TOKEN;
package/lib/types.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ declare global {
2
+ interface Window {
3
+ __TRAMVAI_INLINE_REPORTER: TramvaiInlineReporter;
4
+ }
5
+ }
6
+ export interface TramvaiInlineReporter {
7
+ send(eventName: string, payload?: {
8
+ [key: string]: any;
9
+ }): void;
10
+ }
11
+ export interface InlineReporterParameters {
12
+ appName: string;
13
+ appVersion: string | undefined;
14
+ appRelease: string | undefined;
15
+ [x: string]: any;
16
+ }
17
+ //# sourceMappingURL=types.d.ts.map
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@tramvai/module-application-monitoring",
3
+ "version": "7.16.0",
4
+ "description": "Модуль сбора и отправки событий мониторинга состояния приложения",
5
+ "browser": "lib/browser.js",
6
+ "main": "lib/server.js",
7
+ "module": "lib/server.es.js",
8
+ "typings": "lib/server.d.ts",
9
+ "files": [
10
+ "lib"
11
+ ],
12
+ "sideEffects": false,
13
+ "license": "Apache-2.0",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+ssh://git@github.com/tramvaijs/tramvai.git"
17
+ },
18
+ "scripts": {
19
+ "build": "tramvai-build --forPublish --preserveModules",
20
+ "watch": "tsc -w"
21
+ },
22
+ "publishConfig": {
23
+ "registry": "https://registry.npmjs.org/"
24
+ },
25
+ "dependencies": {
26
+ "@tramvai/module-common": "7.16.0",
27
+ "@tramvai/tokens-render": "7.16.0"
28
+ },
29
+ "peerDependencies": {
30
+ "@tinkoff/dippy": "^1.0.0",
31
+ "@tramvai/core": "7.16.0",
32
+ "@tramvai/react": "7.16.0",
33
+ "tslib": "^2.4.0"
34
+ }
35
+ }