@syncular/observability-sentry 0.0.1-89 → 0.0.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/dist/browser.d.ts +1 -20
- package/dist/browser.d.ts.map +1 -1
- package/dist/browser.js +1 -68
- package/dist/browser.js.map +1 -1
- package/dist/cloudflare.d.ts +1 -20
- package/dist/cloudflare.d.ts.map +1 -1
- package/dist/cloudflare.js +0 -50
- package/dist/cloudflare.js.map +1 -1
- package/dist/shared.d.ts +1 -1
- package/dist/shared.d.ts.map +1 -1
- package/dist/shared.js +3 -47
- package/dist/shared.js.map +1 -1
- package/package.json +1 -1
- package/src/browser.ts +1 -85
- package/src/cloudflare.ts +0 -62
- package/src/shared.test.ts +0 -41
- package/src/shared.ts +3 -50
package/dist/browser.d.ts
CHANGED
|
@@ -1,16 +1,6 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/react';
|
|
2
|
-
import { type SyncTelemetry
|
|
2
|
+
import { type SyncTelemetry } from '@syncular/core';
|
|
3
3
|
export type BrowserSentryInitOptions = Parameters<typeof Sentry.init>[0];
|
|
4
|
-
export type BrowserSentryCaptureMessageLevel = Parameters<typeof Sentry.captureMessage>[1];
|
|
5
|
-
interface BrowserSentryCaptureMessageOptions {
|
|
6
|
-
level?: BrowserSentryCaptureMessageLevel;
|
|
7
|
-
tags?: Record<string, string>;
|
|
8
|
-
}
|
|
9
|
-
type BrowserSentryLogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
10
|
-
interface BrowserSentryLogOptions {
|
|
11
|
-
level?: BrowserSentryLogLevel;
|
|
12
|
-
attributes?: Record<string, SyncTelemetryAttributeValue>;
|
|
13
|
-
}
|
|
14
4
|
/**
|
|
15
5
|
* Create a Syncular telemetry backend wired to `@sentry/react`.
|
|
16
6
|
*/
|
|
@@ -23,13 +13,4 @@ export declare function configureBrowserSentryTelemetry(): SyncTelemetry;
|
|
|
23
13
|
* Initialize browser Sentry and configure Syncular telemetry.
|
|
24
14
|
*/
|
|
25
15
|
export declare function initAndConfigureBrowserSentry(options: BrowserSentryInitOptions): SyncTelemetry;
|
|
26
|
-
/**
|
|
27
|
-
* Capture a browser message in Sentry with optional tags.
|
|
28
|
-
*/
|
|
29
|
-
export declare function captureBrowserSentryMessage(message: string, options?: BrowserSentryCaptureMessageOptions): void;
|
|
30
|
-
/**
|
|
31
|
-
* Emit a browser Sentry log entry.
|
|
32
|
-
*/
|
|
33
|
-
export declare function logBrowserSentryMessage(message: string, options?: BrowserSentryLogOptions): void;
|
|
34
|
-
export {};
|
|
35
16
|
//# sourceMappingURL=browser.d.ts.map
|
package/dist/browser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAGL,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,MAAM,wBAAwB,GAAG,UAAU,CAAC,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAsBzE;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,aAAa,CAkD5D;AAED;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,aAAa,CAI/D;AAED;;GAEG;AACH,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,wBAAwB,GAChC,aAAa,CAGf"}
|
package/dist/browser.js
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/react';
|
|
2
2
|
import { configureSyncTelemetry, } from '@syncular/core';
|
|
3
3
|
import { createSentrySyncTelemetry } from './shared.js';
|
|
4
|
-
function resolveBrowserLogMethod(level) {
|
|
5
|
-
switch (level) {
|
|
6
|
-
case 'trace':
|
|
7
|
-
return Sentry.logger.trace ?? Sentry.logger.debug ?? Sentry.logger.info;
|
|
8
|
-
case 'debug':
|
|
9
|
-
return Sentry.logger.debug ?? Sentry.logger.info;
|
|
10
|
-
case 'info':
|
|
11
|
-
return Sentry.logger.info;
|
|
12
|
-
case 'warn':
|
|
13
|
-
return Sentry.logger.warn ?? Sentry.logger.info;
|
|
14
|
-
case 'error':
|
|
15
|
-
return Sentry.logger.error ?? Sentry.logger.warn ?? Sentry.logger.info;
|
|
16
|
-
case 'fatal':
|
|
17
|
-
return (Sentry.logger.fatal ??
|
|
18
|
-
Sentry.logger.error ??
|
|
19
|
-
Sentry.logger.warn ??
|
|
20
|
-
Sentry.logger.info);
|
|
21
|
-
default:
|
|
22
|
-
return Sentry.logger.info;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
4
|
function toCountMetricOptions(options) {
|
|
26
5
|
if (!options?.attributes)
|
|
27
6
|
return undefined;
|
|
@@ -103,53 +82,7 @@ export function configureBrowserSentryTelemetry() {
|
|
|
103
82
|
* Initialize browser Sentry and configure Syncular telemetry.
|
|
104
83
|
*/
|
|
105
84
|
export function initAndConfigureBrowserSentry(options) {
|
|
106
|
-
|
|
107
|
-
Sentry.init(configuredOptions);
|
|
85
|
+
Sentry.init(options);
|
|
108
86
|
return configureBrowserSentryTelemetry();
|
|
109
87
|
}
|
|
110
|
-
function ensureBrowserTracingIntegration(options) {
|
|
111
|
-
const integrations = options.integrations;
|
|
112
|
-
if (typeof integrations === 'function')
|
|
113
|
-
return options;
|
|
114
|
-
const configuredIntegrations = integrations ?? [];
|
|
115
|
-
const hasBrowserTracing = configuredIntegrations.some((integration) => integration.name === 'BrowserTracing');
|
|
116
|
-
if (hasBrowserTracing)
|
|
117
|
-
return options;
|
|
118
|
-
return {
|
|
119
|
-
...options,
|
|
120
|
-
integrations: [
|
|
121
|
-
Sentry.browserTracingIntegration(),
|
|
122
|
-
...configuredIntegrations,
|
|
123
|
-
],
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Capture a browser message in Sentry with optional tags.
|
|
128
|
-
*/
|
|
129
|
-
export function captureBrowserSentryMessage(message, options) {
|
|
130
|
-
if (!options?.tags || Object.keys(options.tags).length === 0) {
|
|
131
|
-
Sentry.captureMessage(message, options?.level);
|
|
132
|
-
return;
|
|
133
|
-
}
|
|
134
|
-
Sentry.withScope((scope) => {
|
|
135
|
-
for (const [name, value] of Object.entries(options.tags ?? {})) {
|
|
136
|
-
scope.setTag(name, value);
|
|
137
|
-
}
|
|
138
|
-
Sentry.captureMessage(message, options?.level);
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Emit a browser Sentry log entry.
|
|
143
|
-
*/
|
|
144
|
-
export function logBrowserSentryMessage(message, options) {
|
|
145
|
-
const level = options?.level ?? 'info';
|
|
146
|
-
const logMethod = resolveBrowserLogMethod(level);
|
|
147
|
-
if (!logMethod)
|
|
148
|
-
return;
|
|
149
|
-
if (!options?.attributes || Object.keys(options.attributes).length === 0) {
|
|
150
|
-
logMethod(message);
|
|
151
|
-
return;
|
|
152
|
-
}
|
|
153
|
-
logMethod(message, options.attributes);
|
|
154
|
-
}
|
|
155
88
|
//# sourceMappingURL=browser.js.map
|
package/dist/browser.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,sBAAsB,
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,sBAAsB,GAGvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE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AC/D,MAAM,SAAS,GAAG,4BAA4B,EAAE,CAAC;IACjD,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,SAAS,CAAC;AAAA,CAClB;AAED;;GAEG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAAiC,EAClB;IACf,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,OAAO,+BAA+B,EAAE,CAAC;AAAA,CAC1C"}
|
package/dist/cloudflare.d.ts
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import * as Sentry from '@sentry/cloudflare';
|
|
2
|
-
import { type SyncTelemetry
|
|
3
|
-
export type CloudflareSentryCaptureMessageLevel = Parameters<typeof Sentry.captureMessage>[1];
|
|
4
|
-
interface CloudflareSentryCaptureMessageOptions {
|
|
5
|
-
level?: CloudflareSentryCaptureMessageLevel;
|
|
6
|
-
tags?: Record<string, string>;
|
|
7
|
-
}
|
|
8
|
-
type CloudflareSentryLogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
9
|
-
interface CloudflareSentryLogOptions {
|
|
10
|
-
level?: CloudflareSentryLogLevel;
|
|
11
|
-
attributes?: Record<string, SyncTelemetryAttributeValue>;
|
|
12
|
-
}
|
|
2
|
+
import { type SyncTelemetry } from '@syncular/core';
|
|
13
3
|
/**
|
|
14
4
|
* Re-export Cloudflare Sentry worker wrapper.
|
|
15
5
|
*/
|
|
@@ -22,13 +12,4 @@ export declare function createCloudflareSentryTelemetry(): SyncTelemetry;
|
|
|
22
12
|
* Configure Syncular core telemetry to use the Cloudflare Sentry adapter.
|
|
23
13
|
*/
|
|
24
14
|
export declare function configureCloudflareSentryTelemetry(): SyncTelemetry;
|
|
25
|
-
/**
|
|
26
|
-
* Capture a worker message in Sentry with optional tags.
|
|
27
|
-
*/
|
|
28
|
-
export declare function captureCloudflareSentryMessage(message: string, options?: CloudflareSentryCaptureMessageOptions): void;
|
|
29
|
-
/**
|
|
30
|
-
* Emit a Cloudflare Sentry log entry.
|
|
31
|
-
*/
|
|
32
|
-
export declare function logCloudflareSentryMessage(message: string, options?: CloudflareSentryLogOptions): void;
|
|
33
|
-
export {};
|
|
34
15
|
//# sourceMappingURL=cloudflare.d.ts.map
|
package/dist/cloudflare.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAGL,KAAK,aAAa,
|
|
1
|
+
{"version":3,"file":"cloudflare.d.ts","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,gBAAgB,CAAC;AAuBxB;;GAEG;AACH,eAAO,MAAM,oBAAoB,0BAAoB,CAAC;AAEtD;;GAEG;AACH,wBAAgB,+BAA+B,IAAI,aAAa,CAkD/D;AAED;;GAEG;AACH,wBAAgB,kCAAkC,IAAI,aAAa,CAIlE"}
|
package/dist/cloudflare.js
CHANGED
|
@@ -18,27 +18,6 @@ function toValueMetricOptions(options) {
|
|
|
18
18
|
unit: options.unit,
|
|
19
19
|
};
|
|
20
20
|
}
|
|
21
|
-
function resolveCloudflareLogMethod(level) {
|
|
22
|
-
switch (level) {
|
|
23
|
-
case 'trace':
|
|
24
|
-
return Sentry.logger.trace ?? Sentry.logger.debug ?? Sentry.logger.info;
|
|
25
|
-
case 'debug':
|
|
26
|
-
return Sentry.logger.debug ?? Sentry.logger.info;
|
|
27
|
-
case 'info':
|
|
28
|
-
return Sentry.logger.info;
|
|
29
|
-
case 'warn':
|
|
30
|
-
return Sentry.logger.warn ?? Sentry.logger.info;
|
|
31
|
-
case 'error':
|
|
32
|
-
return Sentry.logger.error ?? Sentry.logger.warn ?? Sentry.logger.info;
|
|
33
|
-
case 'fatal':
|
|
34
|
-
return (Sentry.logger.fatal ??
|
|
35
|
-
Sentry.logger.error ??
|
|
36
|
-
Sentry.logger.warn ??
|
|
37
|
-
Sentry.logger.info);
|
|
38
|
-
default:
|
|
39
|
-
return Sentry.logger.info;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
21
|
/**
|
|
43
22
|
* Re-export Cloudflare Sentry worker wrapper.
|
|
44
23
|
*/
|
|
@@ -103,33 +82,4 @@ export function configureCloudflareSentryTelemetry() {
|
|
|
103
82
|
configureSyncTelemetry(telemetry);
|
|
104
83
|
return telemetry;
|
|
105
84
|
}
|
|
106
|
-
/**
|
|
107
|
-
* Capture a worker message in Sentry with optional tags.
|
|
108
|
-
*/
|
|
109
|
-
export function captureCloudflareSentryMessage(message, options) {
|
|
110
|
-
if (!options?.tags || Object.keys(options.tags).length === 0) {
|
|
111
|
-
Sentry.captureMessage(message, options?.level);
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
Sentry.withScope((scope) => {
|
|
115
|
-
for (const [name, value] of Object.entries(options.tags ?? {})) {
|
|
116
|
-
scope.setTag(name, value);
|
|
117
|
-
}
|
|
118
|
-
Sentry.captureMessage(message, options?.level);
|
|
119
|
-
});
|
|
120
|
-
}
|
|
121
|
-
/**
|
|
122
|
-
* Emit a Cloudflare Sentry log entry.
|
|
123
|
-
*/
|
|
124
|
-
export function logCloudflareSentryMessage(message, options) {
|
|
125
|
-
const level = options?.level ?? 'info';
|
|
126
|
-
const logMethod = resolveCloudflareLogMethod(level);
|
|
127
|
-
if (!logMethod)
|
|
128
|
-
return;
|
|
129
|
-
if (!options?.attributes || Object.keys(options.attributes).length === 0) {
|
|
130
|
-
logMethod(message);
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
logMethod(message, options.attributes);
|
|
134
|
-
}
|
|
135
85
|
//# sourceMappingURL=cloudflare.js.map
|
package/dist/cloudflare.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACL,sBAAsB,
|
|
1
|
+
{"version":3,"file":"cloudflare.js","sourceRoot":"","sources":["../src/cloudflare.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EACL,sBAAsB,GAGvB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAC;AAErD,SAAS,oBAAoB,CAC3B,OAA2B,EAC6B;IACxD,IAAI,CAAC,OAAO,EAAE,UAAU;QAAE,OAAO,SAAS,CAAC;IAC3C,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;AAAA,CAC3C;AAED,SAAS,oBAAoB,CAC3B,OAA2B,EAC6B;IACxD,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IAC/B,MAAM,aAAa,GAAG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,CAAC,aAAa,IAAI,CAAC,OAAO;QAAE,OAAO,SAAS,CAAC;IACjD,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,IAAI,EAAE,OAAO,CAAC,IAAI;KACnB,CAAC;AAAA,CACH;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,CAAC,UAAU,CAAC;AAEtD;;GAEG;AACH,MAAM,UAAU,+BAA+B,GAAkB;IAC/D,OAAO,yBAAyB,CAAC;QAC/B,MAAM,EAAE,MAAM,CAAC,MAAM;QACrB,SAAS,CAAC,OAAO,EAAE,QAAQ,EAAE;YAC3B,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE,CACxC,QAA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C;gBACpD,IAAI,aAAa,EAAE,CAAC;oBAClB,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,aAAa,CAAC,CAAC;oBACxD,OAAO;gBACT,CAAC;gBACD,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAAA,CAC1C;SACF;QACD,gBAAgB,CAAC,KAAK,EAAE;YACtB,MAAM,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;QAAA,CAChC;KACF,CAAC,CAAC;AAAA,CACJ;AAED;;GAEG;AACH,MAAM,UAAU,kCAAkC,GAAkB;IAClE,MAAM,SAAS,GAAG,+BAA+B,EAAE,CAAC;IACpD,sBAAsB,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,SAAS,CAAC;AAAA,CAClB"}
|
package/dist/shared.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { SyncMetricOptions, SyncSpanOptions, SyncTelemetry,
|
|
1
|
+
import type { SyncMetricOptions, SyncSpanOptions, SyncTelemetry, SyncTelemetryAttributeValue, SyncTelemetryAttributes } from '@syncular/core';
|
|
2
2
|
interface SentryLoggerAdapter {
|
|
3
3
|
trace?(message: string, attributes?: Record<string, unknown>): void;
|
|
4
4
|
debug?(message: string, attributes?: Record<string, unknown>): void;
|
package/dist/shared.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAGjB,eAAe,EACf,aAAa,EACb,
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EAGjB,eAAe,EACf,aAAa,EACb,2BAA2B,EAC3B,uBAAuB,EAIxB,MAAM,gBAAgB,CAAC;AAExB,UAAU,mBAAmB;IAC3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CAAC;IACvE,YAAY,CAAC,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,IAAI,CAAC;CAC/E;AAED,MAAM,WAAW,sBAAsB;IACrC,MAAM,CAAC,EAAE,mBAAmB,CAAC;IAC7B,SAAS,CAAC,CAAC,CAAC,EACV,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,CAAC,IAAI,EAAE,iBAAiB,KAAK,CAAC,GACvC,CAAC,CAAC;IACL,OAAO,CAAC,EAAE,oBAAoB,CAAC;IAC/B,gBAAgB,CAAC,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CACzC;AAgFD;;GAEG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,sBAAsB,GAC9B,aAAa,CAyBf"}
|
package/dist/shared.js
CHANGED
|
@@ -47,44 +47,6 @@ function toSpan(span) {
|
|
|
47
47
|
},
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
|
-
function toLogAttributeValue(value) {
|
|
51
|
-
if (typeof value === 'string')
|
|
52
|
-
return value;
|
|
53
|
-
if (typeof value === 'number') {
|
|
54
|
-
return Number.isFinite(value) ? value : undefined;
|
|
55
|
-
}
|
|
56
|
-
if (typeof value === 'boolean')
|
|
57
|
-
return value;
|
|
58
|
-
if (typeof value === 'bigint') {
|
|
59
|
-
const asNumber = Number(value);
|
|
60
|
-
if (Number.isFinite(asNumber))
|
|
61
|
-
return asNumber;
|
|
62
|
-
return value.toString();
|
|
63
|
-
}
|
|
64
|
-
if (value instanceof Date)
|
|
65
|
-
return value.toISOString();
|
|
66
|
-
if (value === null || value === undefined)
|
|
67
|
-
return undefined;
|
|
68
|
-
if (Array.isArray(value) || typeof value === 'object') {
|
|
69
|
-
try {
|
|
70
|
-
return JSON.stringify(value);
|
|
71
|
-
}
|
|
72
|
-
catch {
|
|
73
|
-
return String(value);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return String(value);
|
|
77
|
-
}
|
|
78
|
-
function sanitizeLogAttributes(attributes) {
|
|
79
|
-
const sanitized = {};
|
|
80
|
-
for (const [name, value] of Object.entries(attributes)) {
|
|
81
|
-
const normalized = toLogAttributeValue(value);
|
|
82
|
-
if (normalized !== undefined) {
|
|
83
|
-
sanitized[name] = normalized;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
return Object.keys(sanitized).length > 0 ? sanitized : null;
|
|
87
|
-
}
|
|
88
50
|
function createTracer(adapter) {
|
|
89
51
|
return {
|
|
90
52
|
startSpan(options, callback) {
|
|
@@ -118,12 +80,11 @@ export function createSentrySyncTelemetry(adapter) {
|
|
|
118
80
|
const logMethod = resolveLogMethod(adapter.logger, level);
|
|
119
81
|
if (!logMethod)
|
|
120
82
|
return;
|
|
121
|
-
|
|
122
|
-
if (!sanitizedAttributes) {
|
|
83
|
+
if (Object.keys(attributes).length === 0) {
|
|
123
84
|
logMethod(message);
|
|
124
85
|
return;
|
|
125
86
|
}
|
|
126
|
-
logMethod(message,
|
|
87
|
+
logMethod(message, attributes);
|
|
127
88
|
},
|
|
128
89
|
tracer: createTracer(adapter),
|
|
129
90
|
metrics: createMetrics(adapter),
|
|
@@ -135,12 +96,7 @@ export function createSentrySyncTelemetry(adapter) {
|
|
|
135
96
|
resolveLogMethod(adapter.logger, 'info');
|
|
136
97
|
if (!logMethod)
|
|
137
98
|
return;
|
|
138
|
-
|
|
139
|
-
if (!sanitizedContext) {
|
|
140
|
-
logMethod('sync.exception.context');
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
logMethod('sync.exception.context', sanitizedContext);
|
|
99
|
+
logMethod('sync.exception.context', context);
|
|
144
100
|
},
|
|
145
101
|
};
|
|
146
102
|
}
|
package/dist/shared.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AA4CA,MAAM,QAAQ,GAAa;IACzB,YAAY,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,OAAO,CAAC,CAAC;gBACnB,OAAO;YACT,CAAC;YACD,SAAS,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAAA,CAChC;QACD,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC;QAC7B,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC;QAC/B,gBAAgB,CAAC,KAAK,EAAE,OAAO,EAAE;YAC/B,OAAO,CAAC,gBAAgB,EAAE,CAAC,KAAK,CAAC,CAAC;YAClC,IAAI,CAAC,OAAO;gBAAE,OAAO;YACrB,MAAM,SAAS,GACb,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC;gBACzC,gBAAgB,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YAC3C,IAAI,CAAC,SAAS;gBAAE,OAAO;YACvB,SAAS,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;QAAA,CAC9C;KACF,CAAC;AAAA,CACH"}
|
package/package.json
CHANGED
package/src/browser.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
configureSyncTelemetry,
|
|
4
4
|
type SyncMetricOptions,
|
|
5
5
|
type SyncTelemetry,
|
|
6
|
-
type SyncTelemetryAttributeValue,
|
|
7
6
|
} from '@syncular/core';
|
|
8
7
|
import { createSentrySyncTelemetry } from './shared';
|
|
9
8
|
|
|
@@ -17,50 +16,6 @@ interface BrowserSentryCaptureMessageOptions {
|
|
|
17
16
|
tags?: Record<string, string>;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
type BrowserSentryLogLevel =
|
|
21
|
-
| 'trace'
|
|
22
|
-
| 'debug'
|
|
23
|
-
| 'info'
|
|
24
|
-
| 'warn'
|
|
25
|
-
| 'error'
|
|
26
|
-
| 'fatal';
|
|
27
|
-
|
|
28
|
-
interface BrowserSentryLogOptions {
|
|
29
|
-
level?: BrowserSentryLogLevel;
|
|
30
|
-
attributes?: Record<string, SyncTelemetryAttributeValue>;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function resolveBrowserLogMethod(
|
|
34
|
-
level: BrowserSentryLogLevel
|
|
35
|
-
):
|
|
36
|
-
| ((
|
|
37
|
-
message: string,
|
|
38
|
-
attributes?: Record<string, SyncTelemetryAttributeValue>
|
|
39
|
-
) => void)
|
|
40
|
-
| null {
|
|
41
|
-
switch (level) {
|
|
42
|
-
case 'trace':
|
|
43
|
-
return Sentry.logger.trace ?? Sentry.logger.debug ?? Sentry.logger.info;
|
|
44
|
-
case 'debug':
|
|
45
|
-
return Sentry.logger.debug ?? Sentry.logger.info;
|
|
46
|
-
case 'info':
|
|
47
|
-
return Sentry.logger.info;
|
|
48
|
-
case 'warn':
|
|
49
|
-
return Sentry.logger.warn ?? Sentry.logger.info;
|
|
50
|
-
case 'error':
|
|
51
|
-
return Sentry.logger.error ?? Sentry.logger.warn ?? Sentry.logger.info;
|
|
52
|
-
case 'fatal':
|
|
53
|
-
return (
|
|
54
|
-
Sentry.logger.fatal ??
|
|
55
|
-
Sentry.logger.error ??
|
|
56
|
-
Sentry.logger.warn ??
|
|
57
|
-
Sentry.logger.info
|
|
58
|
-
);
|
|
59
|
-
default:
|
|
60
|
-
return Sentry.logger.info;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
19
|
function toCountMetricOptions(
|
|
65
20
|
options?: SyncMetricOptions
|
|
66
21
|
): Parameters<typeof Sentry.metrics.count>[2] | undefined {
|
|
@@ -151,32 +106,10 @@ export function configureBrowserSentryTelemetry(): SyncTelemetry {
|
|
|
151
106
|
export function initAndConfigureBrowserSentry(
|
|
152
107
|
options: BrowserSentryInitOptions
|
|
153
108
|
): SyncTelemetry {
|
|
154
|
-
|
|
155
|
-
Sentry.init(configuredOptions);
|
|
109
|
+
Sentry.init(options);
|
|
156
110
|
return configureBrowserSentryTelemetry();
|
|
157
111
|
}
|
|
158
112
|
|
|
159
|
-
function ensureBrowserTracingIntegration(
|
|
160
|
-
options: BrowserSentryInitOptions
|
|
161
|
-
): BrowserSentryInitOptions {
|
|
162
|
-
const integrations = options.integrations;
|
|
163
|
-
if (typeof integrations === 'function') return options;
|
|
164
|
-
|
|
165
|
-
const configuredIntegrations = integrations ?? [];
|
|
166
|
-
const hasBrowserTracing = configuredIntegrations.some(
|
|
167
|
-
(integration) => integration.name === 'BrowserTracing'
|
|
168
|
-
);
|
|
169
|
-
if (hasBrowserTracing) return options;
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
...options,
|
|
173
|
-
integrations: [
|
|
174
|
-
Sentry.browserTracingIntegration(),
|
|
175
|
-
...configuredIntegrations,
|
|
176
|
-
],
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
113
|
/**
|
|
181
114
|
* Capture a browser message in Sentry with optional tags.
|
|
182
115
|
*/
|
|
@@ -196,20 +129,3 @@ export function captureBrowserSentryMessage(
|
|
|
196
129
|
Sentry.captureMessage(message, options?.level);
|
|
197
130
|
});
|
|
198
131
|
}
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Emit a browser Sentry log entry.
|
|
202
|
-
*/
|
|
203
|
-
export function logBrowserSentryMessage(
|
|
204
|
-
message: string,
|
|
205
|
-
options?: BrowserSentryLogOptions
|
|
206
|
-
): void {
|
|
207
|
-
const level = options?.level ?? 'info';
|
|
208
|
-
const logMethod = resolveBrowserLogMethod(level);
|
|
209
|
-
if (!logMethod) return;
|
|
210
|
-
if (!options?.attributes || Object.keys(options.attributes).length === 0) {
|
|
211
|
-
logMethod(message);
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
logMethod(message, options.attributes);
|
|
215
|
-
}
|
package/src/cloudflare.ts
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
configureSyncTelemetry,
|
|
4
4
|
type SyncMetricOptions,
|
|
5
5
|
type SyncTelemetry,
|
|
6
|
-
type SyncTelemetryAttributeValue,
|
|
7
6
|
} from '@syncular/core';
|
|
8
7
|
import { createSentrySyncTelemetry } from './shared';
|
|
9
8
|
|
|
@@ -36,50 +35,6 @@ interface CloudflareSentryCaptureMessageOptions {
|
|
|
36
35
|
tags?: Record<string, string>;
|
|
37
36
|
}
|
|
38
37
|
|
|
39
|
-
type CloudflareSentryLogLevel =
|
|
40
|
-
| 'trace'
|
|
41
|
-
| 'debug'
|
|
42
|
-
| 'info'
|
|
43
|
-
| 'warn'
|
|
44
|
-
| 'error'
|
|
45
|
-
| 'fatal';
|
|
46
|
-
|
|
47
|
-
interface CloudflareSentryLogOptions {
|
|
48
|
-
level?: CloudflareSentryLogLevel;
|
|
49
|
-
attributes?: Record<string, SyncTelemetryAttributeValue>;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function resolveCloudflareLogMethod(
|
|
53
|
-
level: CloudflareSentryLogLevel
|
|
54
|
-
):
|
|
55
|
-
| ((
|
|
56
|
-
message: string,
|
|
57
|
-
attributes?: Record<string, SyncTelemetryAttributeValue>
|
|
58
|
-
) => void)
|
|
59
|
-
| null {
|
|
60
|
-
switch (level) {
|
|
61
|
-
case 'trace':
|
|
62
|
-
return Sentry.logger.trace ?? Sentry.logger.debug ?? Sentry.logger.info;
|
|
63
|
-
case 'debug':
|
|
64
|
-
return Sentry.logger.debug ?? Sentry.logger.info;
|
|
65
|
-
case 'info':
|
|
66
|
-
return Sentry.logger.info;
|
|
67
|
-
case 'warn':
|
|
68
|
-
return Sentry.logger.warn ?? Sentry.logger.info;
|
|
69
|
-
case 'error':
|
|
70
|
-
return Sentry.logger.error ?? Sentry.logger.warn ?? Sentry.logger.info;
|
|
71
|
-
case 'fatal':
|
|
72
|
-
return (
|
|
73
|
-
Sentry.logger.fatal ??
|
|
74
|
-
Sentry.logger.error ??
|
|
75
|
-
Sentry.logger.warn ??
|
|
76
|
-
Sentry.logger.info
|
|
77
|
-
);
|
|
78
|
-
default:
|
|
79
|
-
return Sentry.logger.info;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
38
|
/**
|
|
84
39
|
* Re-export Cloudflare Sentry worker wrapper.
|
|
85
40
|
*/
|
|
@@ -168,20 +123,3 @@ export function captureCloudflareSentryMessage(
|
|
|
168
123
|
Sentry.captureMessage(message, options?.level);
|
|
169
124
|
});
|
|
170
125
|
}
|
|
171
|
-
|
|
172
|
-
/**
|
|
173
|
-
* Emit a Cloudflare Sentry log entry.
|
|
174
|
-
*/
|
|
175
|
-
export function logCloudflareSentryMessage(
|
|
176
|
-
message: string,
|
|
177
|
-
options?: CloudflareSentryLogOptions
|
|
178
|
-
): void {
|
|
179
|
-
const level = options?.level ?? 'info';
|
|
180
|
-
const logMethod = resolveCloudflareLogMethod(level);
|
|
181
|
-
if (!logMethod) return;
|
|
182
|
-
if (!options?.attributes || Object.keys(options.attributes).length === 0) {
|
|
183
|
-
logMethod(message);
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
logMethod(message, options.attributes);
|
|
187
|
-
}
|
package/src/shared.test.ts
CHANGED
|
@@ -101,45 +101,4 @@ describe('createSentrySyncTelemetry', () => {
|
|
|
101
101
|
attributes: { requestId: 'r1' },
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
|
-
|
|
105
|
-
test('sanitizes non-primitive log attributes', () => {
|
|
106
|
-
const logs: Array<{
|
|
107
|
-
level: string;
|
|
108
|
-
message: string;
|
|
109
|
-
attributes?: Record<string, unknown>;
|
|
110
|
-
}> = [];
|
|
111
|
-
|
|
112
|
-
const telemetry = createSentrySyncTelemetry({
|
|
113
|
-
logger: {
|
|
114
|
-
info(message, attributes) {
|
|
115
|
-
logs.push({ level: 'info', message, attributes });
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
telemetry.log({
|
|
121
|
-
event: 'sync.attributes',
|
|
122
|
-
id: 'abc',
|
|
123
|
-
nested: { ok: true },
|
|
124
|
-
values: [1, 2, 3],
|
|
125
|
-
enabled: true,
|
|
126
|
-
count: 3,
|
|
127
|
-
ignored: undefined,
|
|
128
|
-
nonFinite: Number.POSITIVE_INFINITY,
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
expect(logs).toEqual([
|
|
132
|
-
{
|
|
133
|
-
level: 'info',
|
|
134
|
-
message: 'sync.attributes',
|
|
135
|
-
attributes: {
|
|
136
|
-
id: 'abc',
|
|
137
|
-
nested: '{"ok":true}',
|
|
138
|
-
values: '[1,2,3]',
|
|
139
|
-
enabled: true,
|
|
140
|
-
count: 3,
|
|
141
|
-
},
|
|
142
|
-
},
|
|
143
|
-
]);
|
|
144
|
-
});
|
|
145
104
|
});
|
package/src/shared.ts
CHANGED
|
@@ -97,47 +97,6 @@ function toSpan(span: SentrySpanAdapter): SyncSpan {
|
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
function toLogAttributeValue(
|
|
101
|
-
value: unknown
|
|
102
|
-
): SyncTelemetryAttributeValue | undefined {
|
|
103
|
-
if (typeof value === 'string') return value;
|
|
104
|
-
if (typeof value === 'number') {
|
|
105
|
-
return Number.isFinite(value) ? value : undefined;
|
|
106
|
-
}
|
|
107
|
-
if (typeof value === 'boolean') return value;
|
|
108
|
-
if (typeof value === 'bigint') {
|
|
109
|
-
const asNumber = Number(value);
|
|
110
|
-
if (Number.isFinite(asNumber)) return asNumber;
|
|
111
|
-
return value.toString();
|
|
112
|
-
}
|
|
113
|
-
if (value instanceof Date) return value.toISOString();
|
|
114
|
-
if (value === null || value === undefined) return undefined;
|
|
115
|
-
|
|
116
|
-
if (Array.isArray(value) || typeof value === 'object') {
|
|
117
|
-
try {
|
|
118
|
-
return JSON.stringify(value);
|
|
119
|
-
} catch {
|
|
120
|
-
return String(value);
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
return String(value);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
function sanitizeLogAttributes(
|
|
128
|
-
attributes: Record<string, unknown>
|
|
129
|
-
): Record<string, SyncTelemetryAttributeValue> | null {
|
|
130
|
-
const sanitized: Record<string, SyncTelemetryAttributeValue> = {};
|
|
131
|
-
for (const [name, value] of Object.entries(attributes)) {
|
|
132
|
-
const normalized = toLogAttributeValue(value);
|
|
133
|
-
if (normalized !== undefined) {
|
|
134
|
-
sanitized[name] = normalized;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return Object.keys(sanitized).length > 0 ? sanitized : null;
|
|
139
|
-
}
|
|
140
|
-
|
|
141
100
|
function createTracer(adapter: SentryTelemetryAdapter): SyncTracer {
|
|
142
101
|
return {
|
|
143
102
|
startSpan<T>(options: SyncSpanOptions, callback: (span: SyncSpan) => T): T {
|
|
@@ -173,12 +132,11 @@ export function createSentrySyncTelemetry(
|
|
|
173
132
|
const { event: message, ...attributes } = event;
|
|
174
133
|
const logMethod = resolveLogMethod(adapter.logger, level);
|
|
175
134
|
if (!logMethod) return;
|
|
176
|
-
|
|
177
|
-
if (!sanitizedAttributes) {
|
|
135
|
+
if (Object.keys(attributes).length === 0) {
|
|
178
136
|
logMethod(message);
|
|
179
137
|
return;
|
|
180
138
|
}
|
|
181
|
-
logMethod(message,
|
|
139
|
+
logMethod(message, attributes);
|
|
182
140
|
},
|
|
183
141
|
tracer: createTracer(adapter),
|
|
184
142
|
metrics: createMetrics(adapter),
|
|
@@ -189,12 +147,7 @@ export function createSentrySyncTelemetry(
|
|
|
189
147
|
resolveLogMethod(adapter.logger, 'error') ??
|
|
190
148
|
resolveLogMethod(adapter.logger, 'info');
|
|
191
149
|
if (!logMethod) return;
|
|
192
|
-
|
|
193
|
-
if (!sanitizedContext) {
|
|
194
|
-
logMethod('sync.exception.context');
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
logMethod('sync.exception.context', sanitizedContext);
|
|
150
|
+
logMethod('sync.exception.context', context);
|
|
198
151
|
},
|
|
199
152
|
};
|
|
200
153
|
}
|