@tramvai/module-application-monitoring 6.80.6
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 +278 -0
- package/lib/browser.d.ts +6 -0
- package/lib/browser.js +11 -0
- package/lib/constants.browser.js +3 -0
- package/lib/constants.d.ts +2 -0
- package/lib/constants.es.js +3 -0
- package/lib/constants.js +7 -0
- package/lib/inlineReporters/events/appCreationMonitoringScript.inline.d.ts +4 -0
- package/lib/inlineReporters/events/appCreationMonitoringScript.inline.es.js +10 -0
- package/lib/inlineReporters/events/appCreationMonitoringScript.inline.js +14 -0
- package/lib/inlineReporters/events/errorMonitoringScript.inline.d.ts +4 -0
- package/lib/inlineReporters/events/errorMonitoringScript.inline.es.js +29 -0
- package/lib/inlineReporters/events/errorMonitoringScript.inline.js +33 -0
- package/lib/inlineReporters/events/htmlOpenedMonitoringScript.inline.d.ts +4 -0
- package/lib/inlineReporters/events/htmlOpenedMonitoringScript.inline.es.js +5 -0
- package/lib/inlineReporters/events/htmlOpenedMonitoringScript.inline.js +9 -0
- package/lib/inlineReporters/events/index.d.ts +4 -0
- package/lib/server.d.ts +6 -0
- package/lib/server.es.js +76 -0
- package/lib/server.js +81 -0
- package/lib/sharedProviders.browser.js +77 -0
- package/lib/sharedProviders.d.ts +26 -0
- package/lib/sharedProviders.es.js +77 -0
- package/lib/sharedProviders.js +81 -0
- package/lib/tokens.browser.js +6 -0
- package/lib/tokens.d.ts +8 -0
- package/lib/tokens.es.js +6 -0
- package/lib/tokens.js +11 -0
- package/lib/types.d.ts +17 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# @tramvai/module-application-monitoring
|
|
2
|
+
|
|
3
|
+
Tramvai module for collecting and sending application health monitoring events throughout the application lifecycle.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
Tramvai application's health and performance monitoring. It monitors critical lifecycle events from HTML parsing through app initialization and rendering, capturing errors and performance metrics along the way.
|
|
8
|
+
|
|
9
|
+
### Monitored Events
|
|
10
|
+
|
|
11
|
+
| Event | Description | Trigger Point |
|
|
12
|
+
| --- | --- | --- |
|
|
13
|
+
| `html-opened` | HTML document parsed and ready | Document parse complete |
|
|
14
|
+
| `assets-loaded` | All critical assets loaded successfully | Window load event |
|
|
15
|
+
| `assets-load-failed` | One or more critical assets failed to load | Window load event (with errors) |
|
|
16
|
+
| `app:initialized` | Application initialization complete | After 'init' command line |
|
|
17
|
+
| `app:initialize-failed` | Application failed to initialize | App init error |
|
|
18
|
+
| `app:rendered` | Application rendered successfully | After successful app render |
|
|
19
|
+
| `app:render-failed` | Application rendering failed | Error boundary or renderer callback |
|
|
20
|
+
| `react:render` | React rendered successfully | After successful react render |
|
|
21
|
+
| `react:error` | React rendered with error | The error occure while react hydration, it can be uncaughtError,caughtError or recoverableError |
|
|
22
|
+
| `app:render-failed` | Application rendering failed | Error boundary or renderer callback |
|
|
23
|
+
|
|
24
|
+
| `unhandled-error` | Unhandled promise rejection | Global unhandledrejection event |
|
|
25
|
+
|
|
26
|
+
## Installation
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
npm install @tramvai/module-application-monitoring
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or with yarn:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
yarn add @tramvai/module-application-monitoring
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Basic Usage
|
|
39
|
+
|
|
40
|
+
### 1. Register the Module
|
|
41
|
+
|
|
42
|
+
Add the module to your Tramvai application:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { createApp } from '@tramvai/core';
|
|
46
|
+
import { ApplicationMonitoringModule } from '@tramvai/module-application-monitoring';
|
|
47
|
+
|
|
48
|
+
createApp({
|
|
49
|
+
name: 'my-app',
|
|
50
|
+
modules: [ApplicationMonitoringModule],
|
|
51
|
+
});
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### 2. Provide an Inline Reporter Factory
|
|
55
|
+
|
|
56
|
+
Inline reporter are used to capture lifecycle events and send them to a monitoring service (like an analytics tool or error logger). Inline reporters are injected into the HTML during server-side rendering. This allows to detect errors and performance issues early, even before the app is fully up and running.
|
|
57
|
+
|
|
58
|
+
Key Events Sent Through Inline Reporters:
|
|
59
|
+
|
|
60
|
+
- **HTML Opened** (`html-opened`): Tracks when the HTML is parsed and ready.
|
|
61
|
+
- **Assets Loaded** (`assets-loaded`) / Assets Load Failed (`**assets-load-failed**`): Tracks the success/failure of loading assets (JS, CSS, etc.).
|
|
62
|
+
- **App Start Failed** (`app-start-failed`): Tracks initialization errors.
|
|
63
|
+
- **Unhandled Errors** (`unhandled-error`): Tracks unhandled errors or promise rejections.
|
|
64
|
+
|
|
65
|
+
The module requires an inline reporter factory to send events to your monitoring service. To do this provide `INLINE_REPORTER_FACTORY_SCRIPT_TOKEN` using inline script or object
|
|
66
|
+
|
|
67
|
+
```typescript
|
|
68
|
+
import { provide } from '@tramvai/core';
|
|
69
|
+
import { INLINE_REPORTER_FACTORY_SCRIPT_TOKEN } from '@tramvai/module-application-monitoring';
|
|
70
|
+
|
|
71
|
+
const providers = [
|
|
72
|
+
provide({
|
|
73
|
+
provide: INLINE_REPORTER_FACTORY_SCRIPT_TOKEN,
|
|
74
|
+
useValue: (parameters) => {
|
|
75
|
+
return {
|
|
76
|
+
send(eventName, payload) {
|
|
77
|
+
fetch('/api/monitoring', {
|
|
78
|
+
method: 'POST',
|
|
79
|
+
headers: { 'Content-Type': 'application/json' },
|
|
80
|
+
body: JSON.stringify({
|
|
81
|
+
event: eventName,
|
|
82
|
+
...parameters,
|
|
83
|
+
...payload,
|
|
84
|
+
timestamp: Date.now(),
|
|
85
|
+
}),
|
|
86
|
+
});
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
}),
|
|
91
|
+
];
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
import { provide } from '@tramvai/core';
|
|
96
|
+
import { INLINE_REPORTER_FACTORY_SCRIPT_TOKEN } from '@tramvai/module-application-monitoring';
|
|
97
|
+
import { inlineReporterFactoryScript } from './inlineReporter.inline';
|
|
98
|
+
|
|
99
|
+
const providers = [
|
|
100
|
+
provide({
|
|
101
|
+
provide: INLINE_REPORTER_FACTORY_SCRIPT_TOKEN,
|
|
102
|
+
useFactory: () => {
|
|
103
|
+
return inlineReporterFactoryScript;
|
|
104
|
+
},
|
|
105
|
+
}),
|
|
106
|
+
];
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Configuration
|
|
110
|
+
|
|
111
|
+
### Tokens
|
|
112
|
+
|
|
113
|
+
#### INLINE_REPORTER_PARAMETERS_TOKEN
|
|
114
|
+
|
|
115
|
+
**Example: Adding Custom Parameters**
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { provide } from '@tramvai/core';
|
|
119
|
+
import { INLINE_REPORTER_PARAMETERS_TOKEN } from '@tramvai/module-application-monitoring';
|
|
120
|
+
|
|
121
|
+
provide({
|
|
122
|
+
provide: INLINE_REPORTER_PARAMETERS_TOKEN,
|
|
123
|
+
useFactory: ({ appInfo, envManager }) => {
|
|
124
|
+
return {
|
|
125
|
+
appName: appInfo.appName,
|
|
126
|
+
appRelease: envManager.get('APP_RELEASE'),
|
|
127
|
+
appVersion: envManager.get('APP_VERSION'),
|
|
128
|
+
environment: envManager.get('NODE_ENV'),
|
|
129
|
+
region: envManager.get('DEPLOY_REGION'),
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
deps: {
|
|
133
|
+
envManager: ENV_MANAGER_TOKEN,
|
|
134
|
+
appInfo: APP_INFO_TOKEN,
|
|
135
|
+
},
|
|
136
|
+
});
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### How to configure monitoring for main Tramvai events
|
|
140
|
+
|
|
141
|
+
There is a possibility to monitor the main events that occur while the Tramvai application is being initialized. Here is a list of these events:
|
|
142
|
+
|
|
143
|
+
- `app:initialized`
|
|
144
|
+
- `app:initialize-failed`
|
|
145
|
+
- `app:rendered`
|
|
146
|
+
- `app:render-failed`
|
|
147
|
+
- `react:render`
|
|
148
|
+
- `react:error`
|
|
149
|
+
|
|
150
|
+
When you are using ApplicationMonitoringModule, these events are sent to your remote logger by default. But in some cases, you will need custom metrics. Here is an example of how to do this:
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
import { provide } from '@tramvai/core';
|
|
154
|
+
import { TRAMVAI_HOOKS_TOKEN, commandLineListTokens } from '@tramvai/core';
|
|
155
|
+
|
|
156
|
+
const providers = [
|
|
157
|
+
provide({
|
|
158
|
+
provide: commandLineListTokens.init,
|
|
159
|
+
useFactory: ({ tramvaiHooks }) => {
|
|
160
|
+
hooks['app:initialized'].tap('app-init', () => {
|
|
161
|
+
fetch('/api/monitoring', {
|
|
162
|
+
method: 'POST',
|
|
163
|
+
headers: { 'Content-Type': 'application/json' },
|
|
164
|
+
body: JSON.stringify({
|
|
165
|
+
event: 'app-initialized',
|
|
166
|
+
...parameters,
|
|
167
|
+
...payload,
|
|
168
|
+
timestamp: Date.now(),
|
|
169
|
+
}),
|
|
170
|
+
});
|
|
171
|
+
});
|
|
172
|
+
hooks['app:initialize-failed'].tap('app-init-failed', (_, { error }) => {
|
|
173
|
+
fetch('/api/monitoring', {
|
|
174
|
+
method: 'POST',
|
|
175
|
+
headers: { 'Content-Type': 'application/json' },
|
|
176
|
+
body: JSON.stringify({
|
|
177
|
+
event: 'app-initialize-failed',
|
|
178
|
+
...error,
|
|
179
|
+
...parameters,
|
|
180
|
+
...payload,
|
|
181
|
+
timestamp: Date.now(),
|
|
182
|
+
}),
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
hooks['app:rendered'].tap('app-rendered', () => {
|
|
186
|
+
fetch('/api/monitoring', {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
headers: { 'Content-Type': 'application/json' },
|
|
189
|
+
body: JSON.stringify({
|
|
190
|
+
event: 'app-rendered',
|
|
191
|
+
...parameters,
|
|
192
|
+
...payload,
|
|
193
|
+
timestamp: Date.now(),
|
|
194
|
+
}),
|
|
195
|
+
});
|
|
196
|
+
s;
|
|
197
|
+
});
|
|
198
|
+
hooks['app:render-failed'].tap('app-render-failed', (_, { error }) => {
|
|
199
|
+
fetch('/api/monitoring', {
|
|
200
|
+
method: 'POST',
|
|
201
|
+
headers: { 'Content-Type': 'application/json' },
|
|
202
|
+
body: JSON.stringify({
|
|
203
|
+
event: 'app-render-failed',
|
|
204
|
+
error,
|
|
205
|
+
...parameters,
|
|
206
|
+
...payload,
|
|
207
|
+
timestamp: Date.now(),
|
|
208
|
+
}),
|
|
209
|
+
});
|
|
210
|
+
s;
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
hooks['react:render'].tap('react-render', () => {
|
|
214
|
+
fetch('/api/monitoring', {
|
|
215
|
+
method: 'POST',
|
|
216
|
+
headers: { 'Content-Type': 'application/json' },
|
|
217
|
+
body: JSON.stringify({
|
|
218
|
+
event: eventName,
|
|
219
|
+
...parameters,
|
|
220
|
+
...payload,
|
|
221
|
+
timestamp: Date.now(),
|
|
222
|
+
}),
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
hooks['react:error'].tap('react-error', (_, { error }) => {
|
|
227
|
+
fetch('/api/monitoring', {
|
|
228
|
+
method: 'POST',
|
|
229
|
+
headers: { 'Content-Type': 'application/json' },
|
|
230
|
+
body: JSON.stringify({
|
|
231
|
+
error,
|
|
232
|
+
event: 'react-error',
|
|
233
|
+
...parameters,
|
|
234
|
+
...payload,
|
|
235
|
+
timestamp: Date.now(),
|
|
236
|
+
}),
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
},
|
|
240
|
+
deps: {
|
|
241
|
+
tramvaiHooks: TRAMVAI_HOOKS_TOKEN,
|
|
242
|
+
},
|
|
243
|
+
}),
|
|
244
|
+
];
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
## How It Works
|
|
248
|
+
|
|
249
|
+
### Server-Side
|
|
250
|
+
|
|
251
|
+
1. **Inline Scripts Injection**: The module injects monitoring scripts into the HTML `<head>` during server-side rendering
|
|
252
|
+
2. **Early Monitoring**: Scripts execute immediately to catch early errors and events
|
|
253
|
+
3. **Reporter Initialization**: The inline reporter factory creates a global reporter instance
|
|
254
|
+
4. **Hook Registration**: Server-side hooks are registered to track initialization events
|
|
255
|
+
|
|
256
|
+
### Client-Side
|
|
257
|
+
|
|
258
|
+
1. **HTML Opened**: First script executes when HTML is parsed
|
|
259
|
+
2. **Asset Monitoring**: Error listeners track script/link loading failures
|
|
260
|
+
3. **App Creation**: Monitors unhandled errors during app bootstrap
|
|
261
|
+
4. **Initialization**: Tracks when app completes initialization
|
|
262
|
+
5. **Rendering**: Integrates with error boundaries and renderer callbacks
|
|
263
|
+
|
|
264
|
+
### Event Flow
|
|
265
|
+
|
|
266
|
+
```
|
|
267
|
+
HTML Parse → html-opened
|
|
268
|
+
↓
|
|
269
|
+
Asset Loading → assets-loaded / assets-load-failed
|
|
270
|
+
↓
|
|
271
|
+
App Bootstrap → app-start-failed (on error)
|
|
272
|
+
↓
|
|
273
|
+
App Init → app-initialized
|
|
274
|
+
↓
|
|
275
|
+
App Render → app-rendered / app-render-failed
|
|
276
|
+
↓
|
|
277
|
+
Runtime → unhandled-error (if occurs)
|
|
278
|
+
```
|
package/lib/browser.d.ts
ADDED
|
@@ -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 };
|
package/lib/constants.js
ADDED
|
@@ -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,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,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;
|
package/lib/server.d.ts
ADDED
|
@@ -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
|
package/lib/server.es.js
ADDED
|
@@ -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 };
|
package/lib/tokens.d.ts
ADDED
|
@@ -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
|
package/lib/tokens.es.js
ADDED
|
@@ -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": "6.80.6",
|
|
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": "6.80.6",
|
|
27
|
+
"@tramvai/tokens-render": "6.80.6"
|
|
28
|
+
},
|
|
29
|
+
"peerDependencies": {
|
|
30
|
+
"@tinkoff/dippy": "^1.0.0",
|
|
31
|
+
"@tramvai/core": "6.80.6",
|
|
32
|
+
"@tramvai/react": "6.80.6",
|
|
33
|
+
"tslib": "^2.4.0"
|
|
34
|
+
}
|
|
35
|
+
}
|