@kubesense/kubesense-browser-logs 0.0.0-stage → 2.0.0-beta.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/LICENSE +201 -0
- package/README.md +90 -2
- package/bundle/kubesense-logs.js +1 -0
- package/cjs/boot/logsPublicApi.d.ts +231 -0
- package/cjs/boot/logsPublicApi.js +75 -0
- package/cjs/boot/logsPublicApi.js.map +1 -0
- package/cjs/boot/preStartLogs.d.ts +8 -0
- package/cjs/boot/preStartLogs.js +105 -0
- package/cjs/boot/preStartLogs.js.map +1 -0
- package/cjs/boot/startLogs.d.ts +35 -0
- package/cjs/boot/startLogs.js +54 -0
- package/cjs/boot/startLogs.js.map +1 -0
- package/cjs/domain/assembly.d.ts +5 -0
- package/cjs/domain/assembly.js +35 -0
- package/cjs/domain/assembly.js.map +1 -0
- package/cjs/domain/configuration.d.ts +306 -0
- package/cjs/domain/configuration.js +86 -0
- package/cjs/domain/configuration.js.map +1 -0
- package/cjs/domain/console/consoleCollection.d.ts +20 -0
- package/cjs/domain/console/consoleCollection.js +37 -0
- package/cjs/domain/console/consoleCollection.js.map +1 -0
- package/cjs/domain/contexts/commonContext.d.ts +2 -0
- package/cjs/domain/contexts/commonContext.js +13 -0
- package/cjs/domain/contexts/commonContext.js.map +1 -0
- package/cjs/domain/contexts/internalContext.d.ts +7 -0
- package/cjs/domain/contexts/internalContext.js +11 -0
- package/cjs/domain/contexts/internalContext.js.map +1 -0
- package/cjs/domain/contexts/rumInternalContext.d.ts +2 -0
- package/cjs/domain/contexts/rumInternalContext.js +32 -0
- package/cjs/domain/contexts/rumInternalContext.js.map +1 -0
- package/cjs/domain/contexts/sessionContext.d.ts +4 -0
- package/cjs/domain/contexts/sessionContext.js +20 -0
- package/cjs/domain/contexts/sessionContext.js.map +1 -0
- package/cjs/domain/contexts/trackingConsentContext.d.ts +3 -0
- package/cjs/domain/contexts/trackingConsentContext.js +14 -0
- package/cjs/domain/contexts/trackingConsentContext.js.map +1 -0
- package/cjs/domain/createErrorFieldFromRawError.d.ts +10 -0
- package/cjs/domain/createErrorFieldFromRawError.js +15 -0
- package/cjs/domain/createErrorFieldFromRawError.js.map +1 -0
- package/cjs/domain/hooks.d.ts +28 -0
- package/cjs/domain/hooks.js +13 -0
- package/cjs/domain/hooks.js.map +1 -0
- package/cjs/domain/lifeCycle.d.ts +24 -0
- package/cjs/domain/lifeCycle.js +6 -0
- package/cjs/domain/lifeCycle.js.map +1 -0
- package/cjs/domain/logger/isAuthorized.d.ts +17 -0
- package/cjs/domain/logger/isAuthorized.js +34 -0
- package/cjs/domain/logger/isAuthorized.js.map +1 -0
- package/cjs/domain/logger/loggerCollection.d.ts +7 -0
- package/cjs/domain/logger/loggerCollection.js +47 -0
- package/cjs/domain/logger/loggerCollection.js.map +1 -0
- package/cjs/domain/logger.d.ts +48 -0
- package/cjs/domain/logger.js +112 -0
- package/cjs/domain/logger.js.map +1 -0
- package/cjs/domain/networkError/networkErrorCollection.d.ts +9 -0
- package/cjs/domain/networkError/networkErrorCollection.js +57 -0
- package/cjs/domain/networkError/networkErrorCollection.js.map +1 -0
- package/cjs/domain/plugins.d.ts +49 -0
- package/cjs/domain/plugins.js +12 -0
- package/cjs/domain/plugins.js.map +1 -0
- package/cjs/domain/remoteSdkConfiguration.d.ts +26 -0
- package/cjs/domain/remoteSdkConfiguration.js +67 -0
- package/cjs/domain/remoteSdkConfiguration.js.map +1 -0
- package/cjs/domain/report/reportCollection.d.ts +13 -0
- package/cjs/domain/report/reportCollection.js +30 -0
- package/cjs/domain/report/reportCollection.js.map +1 -0
- package/cjs/domain/reportError.d.ts +2 -0
- package/cjs/domain/reportError.js +20 -0
- package/cjs/domain/reportError.js.map +1 -0
- package/cjs/domain/runtimeError/runtimeErrorCollection.d.ts +14 -0
- package/cjs/domain/runtimeError/runtimeErrorCollection.js +29 -0
- package/cjs/domain/runtimeError/runtimeErrorCollection.js.map +1 -0
- package/cjs/domainContext.types.d.ts +11 -0
- package/cjs/entries/main.d.ts +33 -0
- package/cjs/entries/main.js +31 -0
- package/cjs/entries/main.js.map +1 -0
- package/cjs/logsEvent.types.d.ts +192 -0
- package/cjs/rawLogsEvent.types.d.ts +59 -0
- package/cjs/transport/startLogsBatch.d.ts +4 -0
- package/cjs/transport/startLogsBatch.js +22 -0
- package/cjs/transport/startLogsBatch.js.map +1 -0
- package/cjs/transport/startLogsBridge.d.ts +2 -0
- package/cjs/transport/startLogsBridge.js +13 -0
- package/cjs/transport/startLogsBridge.js.map +1 -0
- package/esm/boot/logsPublicApi.mjs +75 -0
- package/esm/boot/logsPublicApi.mjs.map +1 -0
- package/esm/boot/preStartLogs.mjs +105 -0
- package/esm/boot/preStartLogs.mjs.map +1 -0
- package/esm/boot/startLogs.mjs +54 -0
- package/esm/boot/startLogs.mjs.map +1 -0
- package/esm/domain/assembly.mjs +35 -0
- package/esm/domain/assembly.mjs.map +1 -0
- package/esm/domain/configuration.mjs +84 -0
- package/esm/domain/configuration.mjs.map +1 -0
- package/esm/domain/console/consoleCollection.mjs +36 -0
- package/esm/domain/console/consoleCollection.mjs.map +1 -0
- package/esm/domain/contexts/commonContext.mjs +13 -0
- package/esm/domain/contexts/commonContext.mjs.map +1 -0
- package/esm/domain/contexts/internalContext.mjs +11 -0
- package/esm/domain/contexts/internalContext.mjs.map +1 -0
- package/esm/domain/contexts/rumInternalContext.mjs +32 -0
- package/esm/domain/contexts/rumInternalContext.mjs.map +1 -0
- package/esm/domain/contexts/sessionContext.mjs +20 -0
- package/esm/domain/contexts/sessionContext.mjs.map +1 -0
- package/esm/domain/contexts/trackingConsentContext.mjs +14 -0
- package/esm/domain/contexts/trackingConsentContext.mjs.map +1 -0
- package/esm/domain/createErrorFieldFromRawError.mjs +15 -0
- package/esm/domain/createErrorFieldFromRawError.mjs.map +1 -0
- package/esm/domain/hooks.mjs +13 -0
- package/esm/domain/hooks.mjs.map +1 -0
- package/esm/domain/lifeCycle.mjs +7 -0
- package/esm/domain/lifeCycle.mjs.map +1 -0
- package/esm/domain/logger/isAuthorized.mjs +32 -0
- package/esm/domain/logger/isAuthorized.mjs.map +1 -0
- package/esm/domain/logger/loggerCollection.mjs +47 -0
- package/esm/domain/logger/loggerCollection.mjs.map +1 -0
- package/esm/domain/logger.mjs +110 -0
- package/esm/domain/logger.mjs.map +1 -0
- package/esm/domain/networkError/networkErrorCollection.mjs +56 -0
- package/esm/domain/networkError/networkErrorCollection.mjs.map +1 -0
- package/esm/domain/plugins.mjs +12 -0
- package/esm/domain/plugins.mjs.map +1 -0
- package/esm/domain/remoteSdkConfiguration.mjs +65 -0
- package/esm/domain/remoteSdkConfiguration.mjs.map +1 -0
- package/esm/domain/report/reportCollection.mjs +30 -0
- package/esm/domain/report/reportCollection.mjs.map +1 -0
- package/esm/domain/reportError.mjs +20 -0
- package/esm/domain/reportError.mjs.map +1 -0
- package/esm/domain/runtimeError/runtimeErrorCollection.mjs +29 -0
- package/esm/domain/runtimeError/runtimeErrorCollection.mjs.map +1 -0
- package/esm/entries/main.mjs +27 -0
- package/esm/entries/main.mjs.map +1 -0
- package/esm/transport/startLogsBatch.mjs +22 -0
- package/esm/transport/startLogsBatch.mjs.map +1 -0
- package/esm/transport/startLogsBridge.mjs +13 -0
- package/esm/transport/startLogsBridge.mjs.map +1 -0
- package/package.json +53 -3
- package/src/boot/logsPublicApi.ts +427 -0
- package/src/boot/preStartLogs.ts +192 -0
- package/src/boot/startLogs.ts +83 -0
- package/src/domain/assembly.ts +73 -0
- package/src/domain/configuration.ts +176 -0
- package/src/domain/console/consoleCollection.ts +58 -0
- package/src/domain/contexts/commonContext.ts +15 -0
- package/src/domain/contexts/internalContext.ts +19 -0
- package/src/domain/contexts/rumInternalContext.ts +60 -0
- package/src/domain/contexts/sessionContext.ts +34 -0
- package/src/domain/contexts/trackingConsentContext.ts +18 -0
- package/src/domain/createErrorFieldFromRawError.ts +22 -0
- package/src/domain/hooks.ts +40 -0
- package/src/domain/lifeCycle.ts +25 -0
- package/src/domain/logger/isAuthorized.ts +33 -0
- package/src/domain/logger/loggerCollection.ts +69 -0
- package/src/domain/logger.ts +202 -0
- package/src/domain/networkError/networkErrorCollection.ts +104 -0
- package/src/domain/plugins.ts +72 -0
- package/src/domain/remoteSdkConfiguration.ts +105 -0
- package/src/domain/report/reportCollection.ts +47 -0
- package/src/domain/reportError.ts +20 -0
- package/src/domain/runtimeError/runtimeErrorCollection.ts +51 -0
- package/src/domainContext.types.ts +21 -0
- package/src/entries/main.ts +65 -0
- package/src/logsEvent.types.ts +198 -0
- package/src/rawLogsEvent.types.ts +74 -0
- package/src/transport/startLogsBatch.ts +29 -0
- package/src/transport/startLogsBridge.ts +13 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* KubeSense Browser Logs SDK for collecting and forwarding browser logs to KubeSense.
|
|
4
|
+
* Provides comprehensive logging capabilities with automatic error tracking and custom log collection.
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
* @see [Browser Log Collection](https://docs.kubesense.ai/logs/log_collection/javascript/)
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { globalObject } from '@kubesense/kubesense-js-core/util'
|
|
11
|
+
import { defineGlobal } from '@kubesense/kubesense-browser-core'
|
|
12
|
+
import type { LogsPublicApi } from '../boot/logsPublicApi'
|
|
13
|
+
import { makeLogsPublicApi } from '../boot/logsPublicApi'
|
|
14
|
+
|
|
15
|
+
export type { InternalContext } from '../domain/contexts/internalContext'
|
|
16
|
+
export type { LogsMessage } from '../domain/logger'
|
|
17
|
+
export { Logger, HandlerType } from '../domain/logger'
|
|
18
|
+
export { StatusType } from '../domain/logger/isAuthorized'
|
|
19
|
+
export type { LoggerConfiguration, LogsPublicApi as KubesenseLogs } from '../boot/logsPublicApi'
|
|
20
|
+
export type { LogsInitConfiguration, LogsBeforeSend } from '../domain/configuration'
|
|
21
|
+
export type { LogsEvent } from '../logsEvent.types'
|
|
22
|
+
export type { LogsPlugin, OnLogsStartOptions, OnInitOptions } from '../domain/plugins'
|
|
23
|
+
export type {
|
|
24
|
+
LogsEventDomainContext,
|
|
25
|
+
NetworkLogsEventDomainContext,
|
|
26
|
+
ConsoleLogsEventDomainContext,
|
|
27
|
+
LoggerLogsEventDomainContext,
|
|
28
|
+
} from '../domainContext.types'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use {@link KubesenseLogs} instead
|
|
32
|
+
*/
|
|
33
|
+
export type LogsGlobal = LogsPublicApi
|
|
34
|
+
|
|
35
|
+
export type {
|
|
36
|
+
InitConfiguration,
|
|
37
|
+
PublicApi,
|
|
38
|
+
Context,
|
|
39
|
+
ContextValue,
|
|
40
|
+
ContextArray,
|
|
41
|
+
User,
|
|
42
|
+
Account,
|
|
43
|
+
TraceContextInjection,
|
|
44
|
+
SessionPersistence,
|
|
45
|
+
TrackingConsent,
|
|
46
|
+
MatchOption,
|
|
47
|
+
RawReportType,
|
|
48
|
+
ErrorSource,
|
|
49
|
+
} from '@kubesense/kubesense-browser-core'
|
|
50
|
+
export type { ProxyFn, Site } from '@kubesense/kubesense-js-core/transport'
|
|
51
|
+
export type { ConsoleApiName } from '@kubesense/kubesense-js-core/util'
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The global Logs instance. Use this to call Logs methods.
|
|
55
|
+
*
|
|
56
|
+
* @category Main
|
|
57
|
+
* @see {@link KubesenseLogs}
|
|
58
|
+
* @see [Browser Log Collection](https://docs.kubesense.ai/logs/log_collection/javascript/)
|
|
59
|
+
*/
|
|
60
|
+
export const kubesenseLogs = makeLogsPublicApi({ sdkName: 'logs' })
|
|
61
|
+
|
|
62
|
+
interface BrowserWindow {
|
|
63
|
+
KUBESENSE_LOGS?: LogsPublicApi
|
|
64
|
+
}
|
|
65
|
+
defineGlobal(globalObject as BrowserWindow, 'KUBESENSE_LOGS', kubesenseLogs)
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export interface LogsEvent {
|
|
2
|
+
/**
|
|
3
|
+
* Start of the log in ms from epoch
|
|
4
|
+
*/
|
|
5
|
+
date: number
|
|
6
|
+
/**
|
|
7
|
+
* The log message
|
|
8
|
+
*/
|
|
9
|
+
message: string
|
|
10
|
+
/**
|
|
11
|
+
* The log status
|
|
12
|
+
*/
|
|
13
|
+
status: 'ok' | 'debug' | 'info' | 'notice' | 'warn' | 'error' | 'critical' | 'alert' | 'emerg'
|
|
14
|
+
/**
|
|
15
|
+
* Origin of the log
|
|
16
|
+
*/
|
|
17
|
+
origin: 'network' | 'source' | 'console' | 'logger' | 'agent' | 'report'
|
|
18
|
+
/**
|
|
19
|
+
* UUID of the application
|
|
20
|
+
*/
|
|
21
|
+
application_id?: string
|
|
22
|
+
/**
|
|
23
|
+
* The service name
|
|
24
|
+
*/
|
|
25
|
+
service?: string
|
|
26
|
+
/**
|
|
27
|
+
* Tags of the log
|
|
28
|
+
*/
|
|
29
|
+
ktags?: string
|
|
30
|
+
/**
|
|
31
|
+
* UUID of the session (deprecated in favor of session.id)
|
|
32
|
+
*/
|
|
33
|
+
session_id?: string
|
|
34
|
+
/**
|
|
35
|
+
* Session properties
|
|
36
|
+
*/
|
|
37
|
+
session?: {
|
|
38
|
+
/**
|
|
39
|
+
* UUID of the session
|
|
40
|
+
*/
|
|
41
|
+
id?: string
|
|
42
|
+
|
|
43
|
+
[k: string]: unknown
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* View properties
|
|
47
|
+
*/
|
|
48
|
+
view: {
|
|
49
|
+
/**
|
|
50
|
+
* URL that linked to the initial view of the page
|
|
51
|
+
*/
|
|
52
|
+
referrer?: string
|
|
53
|
+
/**
|
|
54
|
+
* URL of the view
|
|
55
|
+
*/
|
|
56
|
+
url: string
|
|
57
|
+
/**
|
|
58
|
+
* UUID of the view
|
|
59
|
+
*/
|
|
60
|
+
id?: string
|
|
61
|
+
/**
|
|
62
|
+
* User defined name of the view
|
|
63
|
+
*/
|
|
64
|
+
name?: string
|
|
65
|
+
|
|
66
|
+
[k: string]: unknown
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Logger properties
|
|
70
|
+
*/
|
|
71
|
+
logger?: {
|
|
72
|
+
/**
|
|
73
|
+
* Name of the logger
|
|
74
|
+
*/
|
|
75
|
+
name: string
|
|
76
|
+
|
|
77
|
+
[k: string]: unknown
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Error properties
|
|
81
|
+
*/
|
|
82
|
+
error?: {
|
|
83
|
+
/**
|
|
84
|
+
* Kind of the error
|
|
85
|
+
*/
|
|
86
|
+
kind?: string
|
|
87
|
+
/**
|
|
88
|
+
* Stacktrace of the error
|
|
89
|
+
*/
|
|
90
|
+
stack?: string
|
|
91
|
+
/**
|
|
92
|
+
* Fingerprint of the error
|
|
93
|
+
*/
|
|
94
|
+
fingerprint?: string
|
|
95
|
+
/**
|
|
96
|
+
* Message of the error
|
|
97
|
+
*/
|
|
98
|
+
message?: string
|
|
99
|
+
/**
|
|
100
|
+
* Flattened causes of the error
|
|
101
|
+
*/
|
|
102
|
+
causes?: Array<{
|
|
103
|
+
message: string
|
|
104
|
+
source: string
|
|
105
|
+
type?: string
|
|
106
|
+
stack?: string
|
|
107
|
+
}>
|
|
108
|
+
/**
|
|
109
|
+
* The language or platform impacting the error stack trace format
|
|
110
|
+
*/
|
|
111
|
+
source_type?: 'browser' | 'browser+wasm'
|
|
112
|
+
/**
|
|
113
|
+
* WebAssembly modules available for stack trace symbolication
|
|
114
|
+
*/
|
|
115
|
+
wasm_modules?: Array<{
|
|
116
|
+
url: string
|
|
117
|
+
build_id: string
|
|
118
|
+
}>
|
|
119
|
+
|
|
120
|
+
[k: string]: unknown
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Resource properties of the error
|
|
124
|
+
*/
|
|
125
|
+
http?: {
|
|
126
|
+
/**
|
|
127
|
+
* HTTP method of the resource
|
|
128
|
+
*/
|
|
129
|
+
method: 'POST' | 'GET' | 'HEAD' | 'PUT' | 'DELETE' | 'PATCH'
|
|
130
|
+
/**
|
|
131
|
+
* HTTP Status code of the resource
|
|
132
|
+
*/
|
|
133
|
+
status_code: number
|
|
134
|
+
/**
|
|
135
|
+
* URL of the resource
|
|
136
|
+
*/
|
|
137
|
+
url: string
|
|
138
|
+
|
|
139
|
+
[k: string]: unknown
|
|
140
|
+
}
|
|
141
|
+
user_action?: {
|
|
142
|
+
id: string | string[]
|
|
143
|
+
}
|
|
144
|
+
usr?: {
|
|
145
|
+
/**
|
|
146
|
+
* Identifier of the user
|
|
147
|
+
*/
|
|
148
|
+
id?: string
|
|
149
|
+
/**
|
|
150
|
+
* Name of the user
|
|
151
|
+
*/
|
|
152
|
+
name?: string
|
|
153
|
+
/**
|
|
154
|
+
* Email of the user
|
|
155
|
+
*/
|
|
156
|
+
email?: string
|
|
157
|
+
/**
|
|
158
|
+
* Mobile phone number of the user
|
|
159
|
+
*/
|
|
160
|
+
mobile?: string
|
|
161
|
+
/**
|
|
162
|
+
* Identifier of the user across sessions
|
|
163
|
+
*/
|
|
164
|
+
anonymous_id?: string
|
|
165
|
+
[k: string]: unknown
|
|
166
|
+
}
|
|
167
|
+
account?: {
|
|
168
|
+
/**
|
|
169
|
+
* Identifier of the account
|
|
170
|
+
*/
|
|
171
|
+
id: string
|
|
172
|
+
/**
|
|
173
|
+
* Name of the account
|
|
174
|
+
*/
|
|
175
|
+
name?: string
|
|
176
|
+
[k: string]: unknown
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Internal properties
|
|
180
|
+
*/
|
|
181
|
+
_kubesense?: {
|
|
182
|
+
/**
|
|
183
|
+
* Mapping of source file URLs to their debug IDs for source map deobfuscation
|
|
184
|
+
*/
|
|
185
|
+
debug_ids?: Array<{
|
|
186
|
+
/**
|
|
187
|
+
* URL of the source file
|
|
188
|
+
*/
|
|
189
|
+
url: string
|
|
190
|
+
/**
|
|
191
|
+
* Debug ID (UUID) for the source file
|
|
192
|
+
*/
|
|
193
|
+
id: string
|
|
194
|
+
}>
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
[k: string]: unknown
|
|
198
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ErrorSource, RawErrorCause, ErrorHandling, DebugIdEntry } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import type { TimeStamp } from '@kubesense/kubesense-js-core/time'
|
|
3
|
+
import type { StatusType } from './domain/logger/isAuthorized'
|
|
4
|
+
|
|
5
|
+
export type RawLogsEvent =
|
|
6
|
+
| RawConsoleLogsEvent
|
|
7
|
+
| RawNetworkLogsEvent
|
|
8
|
+
| RawLoggerLogsEvent
|
|
9
|
+
| RawAgentLogsEvent
|
|
10
|
+
| RawReportLogsEvent
|
|
11
|
+
| RawRuntimeLogsEvent
|
|
12
|
+
|
|
13
|
+
interface Error {
|
|
14
|
+
message?: string
|
|
15
|
+
kind?: string
|
|
16
|
+
stack?: string
|
|
17
|
+
fingerprint?: string
|
|
18
|
+
causes?: RawErrorCause[]
|
|
19
|
+
handling: ErrorHandling | undefined
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface CommonRawLogsEvent {
|
|
23
|
+
date: TimeStamp
|
|
24
|
+
message: string
|
|
25
|
+
status: StatusType
|
|
26
|
+
error?: Error
|
|
27
|
+
origin: ErrorSource
|
|
28
|
+
_kubesense?: {
|
|
29
|
+
debug_ids?: DebugIdEntry[]
|
|
30
|
+
}
|
|
31
|
+
[key: string]: unknown
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface RawConsoleLogsEvent extends CommonRawLogsEvent {
|
|
35
|
+
origin: typeof ErrorSource.CONSOLE
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface RawLoggerLogsEvent extends CommonRawLogsEvent {
|
|
39
|
+
origin: typeof ErrorSource.LOGGER
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface RawNetworkLogsEvent extends CommonRawLogsEvent {
|
|
43
|
+
origin: typeof ErrorSource.NETWORK
|
|
44
|
+
status: typeof StatusType.error
|
|
45
|
+
error: Error
|
|
46
|
+
http: {
|
|
47
|
+
method: 'POST' | 'GET' | 'HEAD' | 'PUT' | 'DELETE' | 'PATCH'
|
|
48
|
+
status_code: number
|
|
49
|
+
url: string
|
|
50
|
+
[k: string]: unknown
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface RawReportLogsEvent extends CommonRawLogsEvent {
|
|
55
|
+
origin: typeof ErrorSource.REPORT
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface RawRuntimeLogsEvent extends CommonRawLogsEvent {
|
|
59
|
+
origin: typeof ErrorSource.SOURCE
|
|
60
|
+
status: typeof StatusType.error
|
|
61
|
+
error: Error
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface RawAgentLogsEvent extends CommonRawLogsEvent {
|
|
65
|
+
origin: typeof ErrorSource.AGENT
|
|
66
|
+
status: typeof StatusType.error
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface CommonContext {
|
|
70
|
+
view?: {
|
|
71
|
+
referrer: string
|
|
72
|
+
url: string
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Context, SessionManager } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { createBatch } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import { createEndpointBuilder, createReplicaEndpointBuilder } from '@kubesense/kubesense-js-core/transport'
|
|
4
|
+
import type { LogsConfiguration } from '../domain/configuration'
|
|
5
|
+
import type { LifeCycle } from '../domain/lifeCycle'
|
|
6
|
+
import { LifeCycleEventType } from '../domain/lifeCycle'
|
|
7
|
+
import type { LogsEvent } from '../logsEvent.types'
|
|
8
|
+
|
|
9
|
+
export function startLogsBatch(
|
|
10
|
+
configuration: LogsConfiguration,
|
|
11
|
+
lifeCycle: LifeCycle,
|
|
12
|
+
reportError: (message: string) => void,
|
|
13
|
+
sessionManager: SessionManager
|
|
14
|
+
) {
|
|
15
|
+
const endpoints = [createEndpointBuilder(configuration, 'logs')]
|
|
16
|
+
const replicaEndpoint = createReplicaEndpointBuilder(configuration, 'logs')
|
|
17
|
+
if (replicaEndpoint) {
|
|
18
|
+
endpoints.push(replicaEndpoint)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const batch = createBatch({ endpoints, reportError })
|
|
22
|
+
sessionManager.expireObservable.subscribe(() => batch.forceFlush('session_expire'))
|
|
23
|
+
|
|
24
|
+
lifeCycle.subscribe(LifeCycleEventType.LOG_COLLECTED, (serverLogsEvent: LogsEvent & Context) => {
|
|
25
|
+
batch.add(serverLogsEvent)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
return batch
|
|
29
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Context } from '@kubesense/kubesense-browser-core'
|
|
2
|
+
import { getEventBridge } from '@kubesense/kubesense-browser-core'
|
|
3
|
+
import type { LifeCycle } from '../domain/lifeCycle'
|
|
4
|
+
import { LifeCycleEventType } from '../domain/lifeCycle'
|
|
5
|
+
import type { LogsEvent } from '../logsEvent.types'
|
|
6
|
+
|
|
7
|
+
export function startLogsBridge(lifeCycle: LifeCycle) {
|
|
8
|
+
const bridge = getEventBridge<'log', LogsEvent>()!
|
|
9
|
+
|
|
10
|
+
lifeCycle.subscribe(LifeCycleEventType.LOG_COLLECTED, (serverLogsEvent: LogsEvent & Context) => {
|
|
11
|
+
bridge.send('log', serverLogsEvent)
|
|
12
|
+
})
|
|
13
|
+
}
|