Unignored dist/ so yarn/npm can install from git URL without needing to build locally. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.BreadcrumbManager = void 0;
|
|
/**
|
|
* Manages breadcrumbs for an SDK instance
|
|
*/
|
|
class BreadcrumbManager {
|
|
constructor(maxBreadcrumbs = 100) {
|
|
this.breadcrumbs = [];
|
|
this.maxBreadcrumbs = maxBreadcrumbs;
|
|
}
|
|
/**
|
|
* Add a breadcrumb
|
|
*/
|
|
add(message, category = 'custom', level = 'info', data) {
|
|
const breadcrumb = {
|
|
timestamp: new Date(),
|
|
category,
|
|
message,
|
|
level,
|
|
data,
|
|
};
|
|
this.breadcrumbs.push(breadcrumb);
|
|
// Trim to max size
|
|
if (this.breadcrumbs.length > this.maxBreadcrumbs) {
|
|
this.breadcrumbs = this.breadcrumbs.slice(-this.maxBreadcrumbs);
|
|
}
|
|
}
|
|
/**
|
|
* Add a breadcrumb from a full Breadcrumb object
|
|
*/
|
|
addBreadcrumb(breadcrumb) {
|
|
const fullBreadcrumb = {
|
|
...breadcrumb,
|
|
timestamp: breadcrumb.timestamp ?? new Date(),
|
|
};
|
|
this.breadcrumbs.push(fullBreadcrumb);
|
|
if (this.breadcrumbs.length > this.maxBreadcrumbs) {
|
|
this.breadcrumbs = this.breadcrumbs.slice(-this.maxBreadcrumbs);
|
|
}
|
|
}
|
|
/**
|
|
* Get all breadcrumbs
|
|
*/
|
|
getAll() {
|
|
return [...this.breadcrumbs];
|
|
}
|
|
/**
|
|
* Clear all breadcrumbs
|
|
*/
|
|
clear() {
|
|
this.breadcrumbs = [];
|
|
}
|
|
/**
|
|
* Get the number of breadcrumbs
|
|
*/
|
|
get count() {
|
|
return this.breadcrumbs.length;
|
|
}
|
|
}
|
|
exports.BreadcrumbManager = BreadcrumbManager;
|
|
//# sourceMappingURL=breadcrumbs.js.map
|