@abbacchio/browser-transport 0.1.3 → 0.2.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 +33 -3
- package/dist/auto.d.ts +4 -5
- package/dist/auto.d.ts.map +1 -1
- package/dist/auto.js +6 -9
- package/dist/auto.js.map +1 -1
- package/dist/client.d.ts +73 -35
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +294 -53
- package/dist/client.js.map +1 -1
- package/dist/console.d.ts +6 -17
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js +26 -74
- package/dist/console.js.map +1 -1
- package/dist/errors.d.ts +20 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +106 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/logger.d.ts +9 -48
- package/dist/logger.d.ts.map +1 -1
- package/dist/logger.js +27 -34
- package/dist/logger.js.map +1 -1
- package/dist/react/AbbacchioProvider.d.ts +5 -42
- package/dist/react/AbbacchioProvider.d.ts.map +1 -1
- package/dist/react/AbbacchioProvider.js +9 -48
- package/dist/react/AbbacchioProvider.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -48,7 +48,7 @@ import { interceptConsole, stopInterceptConsole } from '@abbacchio/browser-trans
|
|
|
48
48
|
interceptConsole({
|
|
49
49
|
url: 'http://localhost:4000/api/logs',
|
|
50
50
|
channel: 'my-frontend',
|
|
51
|
-
|
|
51
|
+
namespace: 'my-app',
|
|
52
52
|
secretKey: 'optional-encryption-key', // optional
|
|
53
53
|
})
|
|
54
54
|
|
|
@@ -69,7 +69,7 @@ import { createLogger } from '@abbacchio/browser-transport'
|
|
|
69
69
|
const log = createLogger({
|
|
70
70
|
url: 'http://localhost:4000/api/logs',
|
|
71
71
|
channel: 'my-app',
|
|
72
|
-
|
|
72
|
+
namespace: 'my-service',
|
|
73
73
|
})
|
|
74
74
|
|
|
75
75
|
log.info('User logged in', { userId: 123 })
|
|
@@ -121,7 +121,9 @@ Start intercepting console methods.
|
|
|
121
121
|
interface ConsoleInterceptorOptions {
|
|
122
122
|
url?: string // Server URL (default: 'http://localhost:4000/api/logs')
|
|
123
123
|
channel?: string // Channel name (default: 'default')
|
|
124
|
+
namespace?: string // Namespace for logs (takes precedence over appName)
|
|
124
125
|
appName?: string // Logger name (default: 'browser')
|
|
126
|
+
enabled?: boolean // Whether to send logs (default: true)
|
|
125
127
|
secretKey?: string // Encryption key (optional)
|
|
126
128
|
batchSize?: number // Logs per batch (default: 10)
|
|
127
129
|
flushInterval?: number // Ms between flushes (default: 1000)
|
|
@@ -138,7 +140,9 @@ Create a structured logger instance.
|
|
|
138
140
|
interface LoggerOptions {
|
|
139
141
|
url?: string
|
|
140
142
|
channel?: string
|
|
141
|
-
|
|
143
|
+
namespace?: string // Logger namespace (takes precedence over name)
|
|
144
|
+
name?: string // Logger name (deprecated, use namespace)
|
|
145
|
+
enabled?: boolean // Whether to send logs (default: true)
|
|
142
146
|
level?: number | 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal'
|
|
143
147
|
secretKey?: string
|
|
144
148
|
batchSize?: number
|
|
@@ -180,6 +184,32 @@ const log = useLogger() // Get logger instance
|
|
|
180
184
|
const { info, warn, error } = useAbbacchio() // Get logging methods
|
|
181
185
|
```
|
|
182
186
|
|
|
187
|
+
## Disabling in Production
|
|
188
|
+
|
|
189
|
+
Use `enabled: false` to prevent logs from being sent. Logs are silently dropped.
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
import { createLogger } from '@abbacchio/browser-transport'
|
|
193
|
+
|
|
194
|
+
const log = createLogger({
|
|
195
|
+
channel: 'my-app',
|
|
196
|
+
enabled: process.env.NODE_ENV !== 'production',
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
// Or toggle at runtime via the underlying client
|
|
200
|
+
import { createClient } from '@abbacchio/browser-transport'
|
|
201
|
+
|
|
202
|
+
const client = createClient({ enabled: false })
|
|
203
|
+
client.enable() // start sending
|
|
204
|
+
client.disable() // stop sending
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
You can also toggle via `configure()`:
|
|
208
|
+
|
|
209
|
+
```javascript
|
|
210
|
+
client.configure({ enabled: true })
|
|
211
|
+
```
|
|
212
|
+
|
|
183
213
|
## Encryption
|
|
184
214
|
|
|
185
215
|
All options support optional end-to-end encryption:
|
package/dist/auto.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Auto-initialize console interception
|
|
2
|
+
* Auto-initialize console interception (OTLP native)
|
|
3
3
|
*
|
|
4
4
|
* Simply import this module to start capturing console output:
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* ```typescript
|
|
8
8
|
* import '@abbacchio/browser-transport/auto'
|
|
9
9
|
*
|
|
10
|
-
* // All console.log calls now go to Abbacchio
|
|
10
|
+
* // All console.log calls now go to Abbacchio via OTLP
|
|
11
11
|
* console.log('This is captured!')
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
* ```html
|
|
18
18
|
* <script>
|
|
19
19
|
* window.__ABBACCHIO_CONFIG__ = {
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* endpoint: 'http://localhost:4002',
|
|
21
|
+
* serviceName: 'my-app',
|
|
22
22
|
* appName: 'my-web-app',
|
|
23
|
-
* secretKey: 'optional-encryption-key',
|
|
24
23
|
* }
|
|
25
24
|
* </script>
|
|
26
25
|
* <script type="module">
|
package/dist/auto.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.d.ts","sourceRoot":"","sources":["../src/auto.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auto.d.ts","sourceRoot":"","sources":["../src/auto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAoB,KAAK,yBAAyB,EAAE,MAAM,cAAc,CAAC;AAEhF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,oBAAoB,CAAC,EAAE,yBAAyB,CAAC;KAClD;CACF"}
|
package/dist/auto.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Auto-initialize console interception
|
|
2
|
+
* Auto-initialize console interception (OTLP native)
|
|
3
3
|
*
|
|
4
4
|
* Simply import this module to start capturing console output:
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* ```typescript
|
|
8
8
|
* import '@abbacchio/browser-transport/auto'
|
|
9
9
|
*
|
|
10
|
-
* // All console.log calls now go to Abbacchio
|
|
10
|
+
* // All console.log calls now go to Abbacchio via OTLP
|
|
11
11
|
* console.log('This is captured!')
|
|
12
12
|
* ```
|
|
13
13
|
*
|
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
* ```html
|
|
18
18
|
* <script>
|
|
19
19
|
* window.__ABBACCHIO_CONFIG__ = {
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* endpoint: 'http://localhost:4002',
|
|
21
|
+
* serviceName: 'my-app',
|
|
22
22
|
* appName: 'my-web-app',
|
|
23
|
-
* secretKey: 'optional-encryption-key',
|
|
24
23
|
* }
|
|
25
24
|
* </script>
|
|
26
25
|
* <script type="module">
|
|
@@ -29,12 +28,10 @@
|
|
|
29
28
|
* ```
|
|
30
29
|
*/
|
|
31
30
|
import { interceptConsole } from './console.js';
|
|
32
|
-
// Get configuration from global variable or use defaults
|
|
33
31
|
const config = (typeof window !== 'undefined' && window.__ABBACCHIO_CONFIG__) || {};
|
|
34
|
-
// Start intercepting with merged config
|
|
35
32
|
interceptConsole({
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
endpoint: 'http://localhost:4002',
|
|
34
|
+
serviceName: 'browser',
|
|
38
35
|
appName: 'auto',
|
|
39
36
|
...config,
|
|
40
37
|
});
|
package/dist/auto.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auto.js","sourceRoot":"","sources":["../src/auto.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"auto.js","sourceRoot":"","sources":["../src/auto.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,gBAAgB,EAAkC,MAAM,cAAc,CAAC;AAQhF,MAAM,MAAM,GACV,CAAC,OAAO,MAAM,KAAK,WAAW,IAAI,MAAM,CAAC,oBAAoB,CAAC,IAAI,EAAE,CAAC;AAEvE,gBAAgB,CAAC;IACf,QAAQ,EAAE,uBAAuB;IACjC,WAAW,EAAE,SAAS;IACtB,OAAO,EAAE,MAAM;IACf,GAAG,MAAM;CACV,CAAC,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Browser HTTP client for Abbacchio
|
|
3
|
-
*
|
|
2
|
+
* Browser HTTP client for Abbacchio (OTLP native)
|
|
3
|
+
* Sends logs to POST /v1/logs, metrics to POST /v1/metrics, traces to POST /v1/traces
|
|
4
4
|
*/
|
|
5
5
|
export interface AbbacchioClientOptions {
|
|
6
|
-
/**
|
|
6
|
+
/** Base URL of the OTLP server (e.g. "http://localhost:4002"). Logs go to {endpoint}/v1/logs */
|
|
7
|
+
endpoint?: string;
|
|
8
|
+
/** @deprecated Use `endpoint` instead */
|
|
7
9
|
url?: string;
|
|
8
|
-
/** Secret key for encryption. If provided,
|
|
10
|
+
/** Secret key for encryption. If provided, payloads will be encrypted before sending */
|
|
9
11
|
secretKey?: string;
|
|
10
|
-
/**
|
|
11
|
-
|
|
12
|
-
/**
|
|
12
|
+
/** Service name — maps to OTLP resource attribute `service.name`. Defaults to 'default' */
|
|
13
|
+
serviceName?: string;
|
|
14
|
+
/** Additional OTLP resource attributes */
|
|
15
|
+
resourceAttributes?: Record<string, string>;
|
|
16
|
+
/** Number of log records to batch before sending. Defaults to 10 */
|
|
13
17
|
batchSize?: number;
|
|
14
18
|
/** Interval in ms between flushes. Defaults to 1000 */
|
|
15
19
|
flushInterval?: number;
|
|
16
20
|
/** Additional headers to send with requests */
|
|
17
21
|
headers?: Record<string, string>;
|
|
22
|
+
/** Whether to send logs to the server. Defaults to true */
|
|
23
|
+
enabled?: boolean;
|
|
18
24
|
}
|
|
19
25
|
export interface LogEntry {
|
|
20
26
|
level: number;
|
|
@@ -24,51 +30,83 @@ export interface LogEntry {
|
|
|
24
30
|
[key: string]: unknown;
|
|
25
31
|
}
|
|
26
32
|
/**
|
|
27
|
-
*
|
|
28
|
-
|
|
33
|
+
* A metric data point to send via OTLP.
|
|
34
|
+
*/
|
|
35
|
+
export interface MetricRecord {
|
|
36
|
+
name: string;
|
|
37
|
+
description?: string;
|
|
38
|
+
unit?: string;
|
|
39
|
+
type: 'sum' | 'gauge';
|
|
40
|
+
value: number;
|
|
41
|
+
attributes?: Record<string, unknown>;
|
|
42
|
+
isMonotonic?: boolean;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* A trace span to send via OTLP.
|
|
46
|
+
*/
|
|
47
|
+
export interface SpanRecord {
|
|
48
|
+
traceId: string;
|
|
49
|
+
spanId: string;
|
|
50
|
+
parentSpanId?: string;
|
|
51
|
+
name: string;
|
|
52
|
+
kind?: number;
|
|
53
|
+
startTimeUnixNano: string;
|
|
54
|
+
endTimeUnixNano: string;
|
|
55
|
+
attributes?: Record<string, unknown>;
|
|
56
|
+
status?: {
|
|
57
|
+
code: number;
|
|
58
|
+
message?: string;
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Browser HTTP client for Abbacchio (OTLP native).
|
|
63
|
+
* Sends logs via POST /v1/logs in ExportLogsServiceRequest format.
|
|
29
64
|
*/
|
|
30
65
|
export declare class AbbacchioClient {
|
|
31
|
-
private
|
|
66
|
+
private endpoint;
|
|
32
67
|
private secretKey?;
|
|
33
|
-
private
|
|
68
|
+
private serviceName;
|
|
69
|
+
private resourceAttributes;
|
|
34
70
|
private batchSize;
|
|
35
71
|
private flushInterval;
|
|
36
72
|
private headers;
|
|
73
|
+
private enabled;
|
|
37
74
|
private buffer;
|
|
75
|
+
private metricBuffer;
|
|
76
|
+
private spanBuffer;
|
|
38
77
|
private timer;
|
|
78
|
+
private metricTimer;
|
|
79
|
+
private spanTimer;
|
|
39
80
|
private isClosed;
|
|
40
81
|
constructor(options?: AbbacchioClientOptions);
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Add a log to the buffer and trigger send if needed
|
|
47
|
-
*/
|
|
82
|
+
enable(): void;
|
|
83
|
+
disable(): void;
|
|
84
|
+
isEnabled(): boolean;
|
|
85
|
+
/** Add a log to the buffer and trigger send if needed */
|
|
48
86
|
add(log: LogEntry): void;
|
|
49
|
-
/**
|
|
50
|
-
* Schedule a send after the interval
|
|
51
|
-
*/
|
|
52
87
|
private scheduleSend;
|
|
53
|
-
/**
|
|
54
|
-
* Flush the buffer and send to server
|
|
55
|
-
*/
|
|
88
|
+
/** Flush all buffers (logs, metrics, traces) */
|
|
56
89
|
flush(): Promise<void>;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
90
|
+
flushLogs(): Promise<void>;
|
|
91
|
+
private sendLogs;
|
|
92
|
+
/** Add a metric data point to the buffer */
|
|
93
|
+
addMetric(metric: MetricRecord): void;
|
|
94
|
+
private scheduleMetricFlush;
|
|
95
|
+
flushMetrics(): Promise<void>;
|
|
96
|
+
private sendMetrics;
|
|
97
|
+
/** Add a trace span to the buffer */
|
|
98
|
+
addSpan(span: SpanRecord): void;
|
|
99
|
+
private scheduleSpanFlush;
|
|
100
|
+
flushSpans(): Promise<void>;
|
|
101
|
+
private sendSpans;
|
|
64
102
|
close(): Promise<void>;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
103
|
+
private buildResourceAttributes;
|
|
104
|
+
private post;
|
|
105
|
+
/** Update client configuration */
|
|
68
106
|
configure(options: Partial<AbbacchioClientOptions>): void;
|
|
69
107
|
}
|
|
70
108
|
/**
|
|
71
|
-
* Create a new Abbacchio client instance
|
|
109
|
+
* Create a new Abbacchio OTLP client instance
|
|
72
110
|
*/
|
|
73
111
|
export declare function createClient(options?: AbbacchioClientOptions): AbbacchioClient;
|
|
74
112
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAoDH,MAAM,WAAW,sBAAsB;IACrC,gGAAgG;IAChG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wFAAwF;IACxF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2FAA2F;IAC3F,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,0CAA0C;IAC1C,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5C,oEAAoE;IACpE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uDAAuD;IACvD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,+CAA+C;IAC/C,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,2DAA2D;IAC3D,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,QAAQ;IACvB,KAAK,EAAE,MAAM,CAAC;I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