@bugspotter/sdk 0.2.4-alpha.5 → 0.3.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/CHANGELOG.md +7 -0
- package/dist/bugspotter.min.js +1 -1
- package/dist/capture/console.d.ts +11 -0
- package/dist/capture/console.js +28 -5
- package/dist/capture/network.d.ts +6 -0
- package/dist/capture/network.js +12 -2
- package/dist/core/capture-manager.d.ts +1 -0
- package/dist/core/capture-manager.js +9 -1
- package/dist/index.esm.js +1 -4
- package/dist/index.js +1 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/widget/components/style-manager.d.ts +17 -0
- package/dist/widget/components/style-manager.js +316 -107
- package/package.json +1 -1
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { BaseCapture, type CaptureOptions } from './base-capture';
|
|
2
2
|
type ConsoleLevel = 'log' | 'warn' | 'error' | 'info' | 'debug';
|
|
3
|
+
/**
|
|
4
|
+
* Prefix used for SDK internal log messages
|
|
5
|
+
* Exported for testing purposes
|
|
6
|
+
*/
|
|
7
|
+
export declare const SDK_LOG_PREFIX = "[BugSpotter]";
|
|
3
8
|
export interface ConsoleCaptureOptions extends CaptureOptions {
|
|
4
9
|
maxLogs?: number;
|
|
5
10
|
captureStackTrace?: boolean;
|
|
@@ -15,6 +20,12 @@ export declare class ConsoleCapture extends BaseCapture<LogEntry[], ConsoleCaptu
|
|
|
15
20
|
private createLogEntry;
|
|
16
21
|
private captureStack;
|
|
17
22
|
private addLog;
|
|
23
|
+
/**
|
|
24
|
+
* Check if log should be filtered (SDK internal logs)
|
|
25
|
+
* Filters out SDK debug logs (prefix [BugSpotter]) except errors
|
|
26
|
+
* Errors are always captured even if they contain SDK prefix
|
|
27
|
+
*/
|
|
28
|
+
private shouldFilterLog;
|
|
18
29
|
private interceptConsole;
|
|
19
30
|
getLogs(): LogEntry[];
|
|
20
31
|
clear(): void;
|
package/dist/capture/console.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConsoleCapture = void 0;
|
|
3
|
+
exports.ConsoleCapture = exports.SDK_LOG_PREFIX = void 0;
|
|
4
4
|
const base_capture_1 = require("./base-capture");
|
|
5
5
|
const circular_buffer_1 = require("../core/circular-buffer");
|
|
6
6
|
const CONSOLE_METHODS = ['log', 'warn', 'error', 'info', 'debug'];
|
|
7
|
+
/**
|
|
8
|
+
* Prefix used for SDK internal log messages
|
|
9
|
+
* Exported for testing purposes
|
|
10
|
+
*/
|
|
11
|
+
exports.SDK_LOG_PREFIX = '[BugSpotter]';
|
|
7
12
|
class ConsoleCapture extends base_capture_1.BaseCapture {
|
|
8
13
|
constructor(options = {}) {
|
|
9
14
|
var _a, _b, _c;
|
|
@@ -44,10 +49,10 @@ class ConsoleCapture extends base_capture_1.BaseCapture {
|
|
|
44
49
|
})
|
|
45
50
|
.join(' ');
|
|
46
51
|
}
|
|
47
|
-
createLogEntry(method, args) {
|
|
52
|
+
createLogEntry(method, args, message) {
|
|
48
53
|
const log = {
|
|
49
54
|
level: method,
|
|
50
|
-
message: this.formatMessage(args),
|
|
55
|
+
message: message !== null && message !== void 0 ? message : this.formatMessage(args),
|
|
51
56
|
timestamp: Date.now(),
|
|
52
57
|
};
|
|
53
58
|
if (this.captureStackTrace && method === 'error') {
|
|
@@ -64,6 +69,20 @@ class ConsoleCapture extends base_capture_1.BaseCapture {
|
|
|
64
69
|
addLog(log) {
|
|
65
70
|
this.buffer.add(log);
|
|
66
71
|
}
|
|
72
|
+
/**
|
|
73
|
+
* Check if log should be filtered (SDK internal logs)
|
|
74
|
+
* Filters out SDK debug logs (prefix [BugSpotter]) except errors
|
|
75
|
+
* Errors are always captured even if they contain SDK prefix
|
|
76
|
+
*/
|
|
77
|
+
shouldFilterLog(message, level) {
|
|
78
|
+
// Always keep SDK errors for debugging
|
|
79
|
+
if (level === 'error') {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
// Filter SDK internal logs (debug/info/warn/log only)
|
|
83
|
+
// Use startsWith to only match prefix, not substring anywhere in message
|
|
84
|
+
return message.startsWith(exports.SDK_LOG_PREFIX);
|
|
85
|
+
}
|
|
67
86
|
interceptConsole(levels = CONSOLE_METHODS) {
|
|
68
87
|
levels.forEach((method) => {
|
|
69
88
|
try {
|
|
@@ -71,8 +90,12 @@ class ConsoleCapture extends base_capture_1.BaseCapture {
|
|
|
71
90
|
this.originalMethods.set(method, original);
|
|
72
91
|
console[method] = (...args) => {
|
|
73
92
|
try {
|
|
74
|
-
const
|
|
75
|
-
|
|
93
|
+
const message = this.formatMessage(args);
|
|
94
|
+
// Filter SDK internal logs before creating log entry
|
|
95
|
+
if (!this.shouldFilterLog(message, method)) {
|
|
96
|
+
const log = this.createLogEntry(method, args, message);
|
|
97
|
+
this.addLog(log);
|
|
98
|
+
}
|
|
76
99
|
}
|
|
77
100
|
catch (error) {
|
|
78
101
|
this.handleError('creating log entry', error);
|
|
@@ -2,6 +2,12 @@ import { BaseCapture, type CaptureOptions } from './base-capture';
|
|
|
2
2
|
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
3
3
|
export interface NetworkCaptureOptions extends CaptureOptions {
|
|
4
4
|
maxRequests?: number;
|
|
5
|
+
/**
|
|
6
|
+
* Optional filter function to exclude URLs from capture
|
|
7
|
+
* Returns true to CAPTURE the URL, false to FILTER it out
|
|
8
|
+
* Note: Error responses (non-2xx status) are always captured regardless of filter result
|
|
9
|
+
* Example: (url) => !url.startsWith('https://api.bugspotter.com') captures all except SDK API
|
|
10
|
+
*/
|
|
5
11
|
filterUrls?: (url: string) => boolean;
|
|
6
12
|
}
|
|
7
13
|
export declare class NetworkCapture extends BaseCapture<NetworkRequest[], NetworkCaptureOptions> {
|
package/dist/capture/network.js
CHANGED
|
@@ -54,8 +54,18 @@ class NetworkCapture extends base_capture_1.BaseCapture {
|
|
|
54
54
|
return request;
|
|
55
55
|
}
|
|
56
56
|
addRequest(request) {
|
|
57
|
-
if
|
|
58
|
-
|
|
57
|
+
// Check if URL should be filtered
|
|
58
|
+
// filterUrls returns true to CAPTURE, false to FILTER OUT
|
|
59
|
+
// Exception: Always capture error responses (non-2xx) for debugging purposes
|
|
60
|
+
// Rationale: Error responses from SDK API calls (4xx, 5xx) are invaluable for diagnosing
|
|
61
|
+
// connectivity issues, authentication failures, rate limiting, or backend problems that
|
|
62
|
+
// could affect bug report submission. Users need this visibility to troubleshoot SDK issues.
|
|
63
|
+
if (this.filterUrls) {
|
|
64
|
+
const shouldCapture = this.filterUrls(request.url);
|
|
65
|
+
const isError = request.status < 200 || request.status >= 300;
|
|
66
|
+
if (!shouldCapture && !isError) {
|
|
67
|
+
return; // Filter out successful requests from filtered URLs
|
|
68
|
+
}
|
|
59
69
|
}
|
|
60
70
|
this.buffer.add(request);
|
|
61
71
|
}
|
|
@@ -21,7 +21,15 @@ class CaptureManager {
|
|
|
21
21
|
// Initialize core capture modules
|
|
22
22
|
this.screenshot = new screenshot_1.ScreenshotCapture();
|
|
23
23
|
this.console = new console_1.ConsoleCapture({ sanitizer: config.sanitizer });
|
|
24
|
-
|
|
24
|
+
// Configure network capture to filter SDK API calls
|
|
25
|
+
const networkOptions = {
|
|
26
|
+
sanitizer: config.sanitizer,
|
|
27
|
+
};
|
|
28
|
+
if (config.apiEndpoint) {
|
|
29
|
+
const endpoint = config.apiEndpoint;
|
|
30
|
+
networkOptions.filterUrls = (url) => !url.startsWith(endpoint);
|
|
31
|
+
}
|
|
32
|
+
this.network = new network_1.NetworkCapture(networkOptions);
|
|
25
33
|
this.metadata = new metadata_1.MetadataCapture({ sanitizer: config.sanitizer });
|
|
26
34
|
// Initialize optional replay/DOM collector
|
|
27
35
|
const replayEnabled = (_b = (_a = config.replay) === null || _a === void 0 ? void 0 : _a.enabled) !== null && _b !== void 0 ? _b : true;
|
package/dist/index.esm.js
CHANGED
|
@@ -104,10 +104,7 @@ export class BugSpotter {
|
|
|
104
104
|
});
|
|
105
105
|
}
|
|
106
106
|
// Initialize capture manager
|
|
107
|
-
this.captureManager = new CaptureManager({
|
|
108
|
-
sanitizer: this.sanitizer,
|
|
109
|
-
replay: config.replay,
|
|
110
|
-
});
|
|
107
|
+
this.captureManager = new CaptureManager(Object.assign(Object.assign({ sanitizer: this.sanitizer }, (config.endpoint && { apiEndpoint: getApiBaseUrl(config.endpoint) })), { replay: config.replay }));
|
|
111
108
|
// Initialize bug reporter
|
|
112
109
|
this.bugReporter = new BugReporter(config);
|
|
113
110
|
// Initialize widget (enabled by default)
|
package/dist/index.js
CHANGED
|
@@ -107,10 +107,7 @@ class BugSpotter {
|
|
|
107
107
|
});
|
|
108
108
|
}
|
|
109
109
|
// Initialize capture manager
|
|
110
|
-
this.captureManager = new capture_manager_1.CaptureManager({
|
|
111
|
-
sanitizer: this.sanitizer,
|
|
112
|
-
replay: config.replay,
|
|
113
|
-
});
|
|
110
|
+
this.captureManager = new capture_manager_1.CaptureManager(Object.assign(Object.assign({ sanitizer: this.sanitizer }, (config.endpoint && { apiEndpoint: (0, url_helpers_1.getApiBaseUrl)(config.endpoint) })), { replay: config.replay }));
|
|
114
111
|
// Initialize bug reporter
|
|
115
112
|
this.bugReporter = new bug_reporter_1.BugReporter(config);
|
|
116
113
|
// Initialize widget (enabled by default)
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED
|
@@ -13,11 +13,28 @@ export interface StyleConfig {
|
|
|
13
13
|
}
|
|
14
14
|
export declare class StyleManager {
|
|
15
15
|
private config;
|
|
16
|
+
private readonly SPACING;
|
|
17
|
+
private readonly BREAKPOINTS;
|
|
18
|
+
private readonly MODAL_SIZES;
|
|
19
|
+
private readonly FONT_SIZES;
|
|
20
|
+
private readonly BORDER_STYLES;
|
|
21
|
+
private readonly SHADOW_STYLES;
|
|
16
22
|
constructor(config?: StyleConfig);
|
|
17
23
|
/**
|
|
18
24
|
* Generate complete CSS stylesheet for the modal
|
|
19
25
|
*/
|
|
20
26
|
generateStyles(): string;
|
|
27
|
+
private generateOverlayStyles;
|
|
28
|
+
private generateModalStyles;
|
|
29
|
+
private generateHeaderStyles;
|
|
30
|
+
private generateBodyStyles;
|
|
31
|
+
private generateFormStyles;
|
|
32
|
+
private generateButtonStyles;
|
|
33
|
+
private generatePIIStyles;
|
|
34
|
+
private generateLoadingStyles;
|
|
35
|
+
private generateAccessibilityStyles;
|
|
36
|
+
private generateTabletResponsiveStyles;
|
|
37
|
+
private generateMobileResponsiveStyles;
|
|
21
38
|
/**
|
|
22
39
|
* Inject styles into document head
|
|
23
40
|
*/
|