Include dist folder for git-based installs
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>
This commit is contained in:
parent
935022bd54
commit
8c300c1f8d
4
.gitignore
vendored
4
.gitignore
vendored
@ -1,8 +1,8 @@
|
|||||||
# Dependencies
|
# Dependencies
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
# Build output
|
# Build output - NOT ignored so git installs work
|
||||||
dist/
|
# dist/
|
||||||
|
|
||||||
# IDE
|
# IDE
|
||||||
.idea/
|
.idea/
|
||||||
|
|||||||
62
dist/cjs/breadcrumbs.js
vendored
Normal file
62
dist/cjs/breadcrumbs.js
vendored
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
"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
|
||||||
1
dist/cjs/breadcrumbs.js.map
vendored
Normal file
1
dist/cjs/breadcrumbs.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../src/breadcrumbs.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,iBAAiB;IAI5B,YAAY,iBAAyB,GAAG;QAFhC,gBAAW,GAAiB,EAAE,CAAC;QAGrC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,GAAG,CACD,OAAe,EACf,WAA+B,QAAQ,EACvC,QAAuB,MAAM,EAC7B,IAA8B;QAE9B,MAAM,UAAU,GAAe;YAC7B,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,QAAQ;YACR,OAAO;YACP,KAAK;YACL,IAAI;SACL,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAElC,mBAAmB;QACnB,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,UAAgE;QAC5E,MAAM,cAAc,GAAe;YACjC,GAAG,UAAU;YACb,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE;SAC9C,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAEtC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACjC,CAAC;CACF;AArED,8CAqEC"}
|
||||||
306
dist/cjs/client.js
vendored
Normal file
306
dist/cjs/client.js
vendored
Normal file
@ -0,0 +1,306 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.TelemetryClient = exports.enableDebugLogging = void 0;
|
||||||
|
exports.setDebugLogging = setDebugLogging;
|
||||||
|
const config_1 = require("./config");
|
||||||
|
const transport_1 = require("./transport");
|
||||||
|
const queue_1 = require("./queue");
|
||||||
|
const breadcrumbs_1 = require("./breadcrumbs");
|
||||||
|
const journey_1 = require("./journey");
|
||||||
|
/**
|
||||||
|
* Global debug logging flag. When enabled, all IronTelemetry clients
|
||||||
|
* will output debug information to the console.
|
||||||
|
*/
|
||||||
|
exports.enableDebugLogging = false;
|
||||||
|
/**
|
||||||
|
* Enable or disable global debug logging for all TelemetryClient instances.
|
||||||
|
* @param enabled Whether to enable debug logging
|
||||||
|
*/
|
||||||
|
function setDebugLogging(enabled) {
|
||||||
|
exports.enableDebugLogging = enabled;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Main IronTelemetry client class
|
||||||
|
*/
|
||||||
|
class TelemetryClient {
|
||||||
|
constructor(options) {
|
||||||
|
this.tags = {};
|
||||||
|
this.extra = {};
|
||||||
|
this.isInitialized = false;
|
||||||
|
this.options = (0, config_1.resolveOptions)(options);
|
||||||
|
this.transport = new transport_1.Transport(this.options.parsedDsn, this.options.apiBaseUrl, this.options.debug);
|
||||||
|
this.queue = this.options.enableOfflineQueue
|
||||||
|
? new queue_1.OfflineQueue(this.options.maxOfflineQueueSize, this.options.debug)
|
||||||
|
: null;
|
||||||
|
this.breadcrumbs = new breadcrumbs_1.BreadcrumbManager(this.options.maxBreadcrumbs);
|
||||||
|
this.isInitialized = true;
|
||||||
|
// Start flush interval for offline queue
|
||||||
|
if (this.queue) {
|
||||||
|
this.flushInterval = setInterval(() => this.processQueue(), 30000);
|
||||||
|
}
|
||||||
|
if (this.options.debug || exports.enableDebugLogging) {
|
||||||
|
console.log('[IronTelemetry] Initialized with DSN:', this.options.dsn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Capture an exception
|
||||||
|
*/
|
||||||
|
async captureException(error, extra) {
|
||||||
|
const exception = this.parseException(error);
|
||||||
|
const event = this.createEvent('error', exception.message, exception);
|
||||||
|
if (extra) {
|
||||||
|
event.extra = { ...event.extra, ...extra };
|
||||||
|
}
|
||||||
|
return this.sendEvent(event);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Capture a message
|
||||||
|
*/
|
||||||
|
async captureMessage(message, level = 'info') {
|
||||||
|
const event = this.createEvent(level, message);
|
||||||
|
return this.sendEvent(event);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Log a structured message with title, message, and optional data.
|
||||||
|
* Useful for structured logging that differentiates the log title from its details.
|
||||||
|
* @param level The severity level of the log
|
||||||
|
* @param title A short, descriptive title for the log entry
|
||||||
|
* @param message Optional detailed message
|
||||||
|
* @param data Optional additional data to attach to the log
|
||||||
|
*/
|
||||||
|
async logMessage(level, title, message, data) {
|
||||||
|
const fullMessage = message ? `${title}: ${message}` : title;
|
||||||
|
const event = this.createEvent(level, fullMessage);
|
||||||
|
if (data) {
|
||||||
|
event.extra = { ...event.extra, logTitle: title, logData: data };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.extra = { ...event.extra, logTitle: title };
|
||||||
|
}
|
||||||
|
return this.sendEvent(event);
|
||||||
|
}
|
||||||
|
addBreadcrumb(messageOrBreadcrumb, category, level, data) {
|
||||||
|
if (typeof messageOrBreadcrumb === 'string') {
|
||||||
|
this.breadcrumbs.add(messageOrBreadcrumb, category, level, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.breadcrumbs.addBreadcrumb(messageOrBreadcrumb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get a copy of the current breadcrumbs list.
|
||||||
|
* @returns A read-only array of breadcrumbs
|
||||||
|
*/
|
||||||
|
getBreadcrumbs() {
|
||||||
|
return this.breadcrumbs.getAll();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Clear all breadcrumbs.
|
||||||
|
*/
|
||||||
|
clearBreadcrumbs() {
|
||||||
|
this.breadcrumbs.clear();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set user context
|
||||||
|
*/
|
||||||
|
setUser(id, email, data) {
|
||||||
|
this.user = { id, email, data };
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Clear user context
|
||||||
|
*/
|
||||||
|
clearUser() {
|
||||||
|
this.user = undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set a tag
|
||||||
|
*/
|
||||||
|
setTag(key, value) {
|
||||||
|
this.tags[key] = value;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set extra context
|
||||||
|
*/
|
||||||
|
setExtra(key, value) {
|
||||||
|
this.extra[key] = value;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a new journey
|
||||||
|
*/
|
||||||
|
startJourney(name) {
|
||||||
|
this.currentJourney = new journey_1.Journey(name);
|
||||||
|
// Copy user context to journey
|
||||||
|
if (this.user) {
|
||||||
|
this.currentJourney.setUser(this.user.id, this.user.email, this.user.data);
|
||||||
|
}
|
||||||
|
return new journey_1.JourneyScope(this.currentJourney, () => {
|
||||||
|
this.currentJourney = undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a step in the current journey
|
||||||
|
*/
|
||||||
|
startStep(name, category) {
|
||||||
|
if (!this.currentJourney) {
|
||||||
|
throw new Error('No active journey. Call startJourney() first.');
|
||||||
|
}
|
||||||
|
const step = this.currentJourney.startStep(name, category);
|
||||||
|
return new journey_1.StepScope(step);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Flush pending events
|
||||||
|
*/
|
||||||
|
async flush() {
|
||||||
|
await this.processQueue();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Close the client
|
||||||
|
*/
|
||||||
|
close() {
|
||||||
|
if (this.flushInterval) {
|
||||||
|
clearInterval(this.flushInterval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Create a telemetry event
|
||||||
|
*/
|
||||||
|
createEvent(level, message, exception) {
|
||||||
|
const event = {
|
||||||
|
eventId: (0, config_1.generateEventId)(),
|
||||||
|
timestamp: new Date(),
|
||||||
|
level,
|
||||||
|
message,
|
||||||
|
exception,
|
||||||
|
user: this.currentJourney?.getUser() ?? this.user,
|
||||||
|
tags: { ...this.tags },
|
||||||
|
extra: { ...this.extra },
|
||||||
|
breadcrumbs: this.breadcrumbs.getAll(),
|
||||||
|
journey: this.currentJourney?.getContext(),
|
||||||
|
environment: this.options.environment,
|
||||||
|
appVersion: this.options.appVersion,
|
||||||
|
platform: this.getPlatformInfo(),
|
||||||
|
};
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Send an event
|
||||||
|
*/
|
||||||
|
async sendEvent(event) {
|
||||||
|
// Check sample rate
|
||||||
|
if (Math.random() > this.options.sampleRate) {
|
||||||
|
if (this.options.debug || exports.enableDebugLogging) {
|
||||||
|
console.log('[IronTelemetry] Event dropped due to sample rate');
|
||||||
|
}
|
||||||
|
return { success: true, eventId: event.eventId };
|
||||||
|
}
|
||||||
|
// Apply beforeSend hook
|
||||||
|
const beforeSendResult = this.options.beforeSend(event);
|
||||||
|
if (beforeSendResult === false || beforeSendResult === null) {
|
||||||
|
if (this.options.debug || exports.enableDebugLogging) {
|
||||||
|
console.log('[IronTelemetry] Event dropped by beforeSend hook');
|
||||||
|
}
|
||||||
|
return { success: true, eventId: event.eventId };
|
||||||
|
}
|
||||||
|
const eventToSend = beforeSendResult === true ? event : beforeSendResult;
|
||||||
|
// Try to send
|
||||||
|
const result = await this.transport.send(eventToSend);
|
||||||
|
if (!result.success && this.queue) {
|
||||||
|
this.queue.enqueue(eventToSend);
|
||||||
|
return { ...result, queued: true };
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Process offline queue
|
||||||
|
*/
|
||||||
|
async processQueue() {
|
||||||
|
if (!this.queue || this.queue.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const isOnline = await this.transport.isOnline();
|
||||||
|
if (!isOnline) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const events = this.queue.getAll();
|
||||||
|
for (const event of events) {
|
||||||
|
const result = await this.transport.send(event);
|
||||||
|
if (result.success) {
|
||||||
|
this.queue.remove(event.eventId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Parse an error into exception info
|
||||||
|
*/
|
||||||
|
parseException(error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return {
|
||||||
|
type: error.name || 'Error',
|
||||||
|
message: error.message,
|
||||||
|
stacktrace: this.parseStackTrace(error.stack),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: 'Error',
|
||||||
|
message: String(error),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Parse a stack trace string into frames
|
||||||
|
*/
|
||||||
|
parseStackTrace(stack) {
|
||||||
|
if (!stack)
|
||||||
|
return undefined;
|
||||||
|
const frames = [];
|
||||||
|
const lines = stack.split('\n');
|
||||||
|
for (const line of lines) {
|
||||||
|
// Chrome/Node format: " at functionName (filename:line:column)"
|
||||||
|
const chromeMatch = line.match(/^\s*at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);
|
||||||
|
if (chromeMatch) {
|
||||||
|
frames.push({
|
||||||
|
function: chromeMatch[1] || '<anonymous>',
|
||||||
|
filename: chromeMatch[2],
|
||||||
|
lineno: parseInt(chromeMatch[3], 10),
|
||||||
|
colno: parseInt(chromeMatch[4], 10),
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Firefox format: "functionName@filename:line:column"
|
||||||
|
const firefoxMatch = line.match(/^(.*)@(.+?):(\d+):(\d+)$/);
|
||||||
|
if (firefoxMatch) {
|
||||||
|
frames.push({
|
||||||
|
function: firefoxMatch[1] || '<anonymous>',
|
||||||
|
filename: firefoxMatch[2],
|
||||||
|
lineno: parseInt(firefoxMatch[3], 10),
|
||||||
|
colno: parseInt(firefoxMatch[4], 10),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return frames.length > 0 ? frames : undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get platform information
|
||||||
|
*/
|
||||||
|
getPlatformInfo() {
|
||||||
|
// Check for browser environment
|
||||||
|
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
|
||||||
|
return {
|
||||||
|
name: 'browser',
|
||||||
|
userAgent: navigator.userAgent,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Check for Node.js environment
|
||||||
|
if (typeof process !== 'undefined' && process.versions?.node) {
|
||||||
|
return {
|
||||||
|
name: 'node',
|
||||||
|
version: process.versions.node,
|
||||||
|
os: process.platform,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
name: 'unknown',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.TelemetryClient = TelemetryClient;
|
||||||
|
//# sourceMappingURL=client.js.map
|
||||||
1
dist/cjs/client.js.map
vendored
Normal file
1
dist/cjs/client.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
71
dist/cjs/config.js
vendored
Normal file
71
dist/cjs/config.js
vendored
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.DEFAULT_OPTIONS = void 0;
|
||||||
|
exports.parseDsn = parseDsn;
|
||||||
|
exports.resolveOptions = resolveOptions;
|
||||||
|
exports.generateEventId = generateEventId;
|
||||||
|
/**
|
||||||
|
* Default configuration values
|
||||||
|
*/
|
||||||
|
exports.DEFAULT_OPTIONS = {
|
||||||
|
sampleRate: 1.0,
|
||||||
|
maxBreadcrumbs: 100,
|
||||||
|
debug: false,
|
||||||
|
enableOfflineQueue: true,
|
||||||
|
maxOfflineQueueSize: 500,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Parse a DSN string into its components
|
||||||
|
* Format: https://pk_live_xxx@irontelemetry.com
|
||||||
|
*/
|
||||||
|
function parseDsn(dsn) {
|
||||||
|
try {
|
||||||
|
const url = new URL(dsn);
|
||||||
|
const publicKey = url.username;
|
||||||
|
if (!publicKey || !publicKey.startsWith('pk_')) {
|
||||||
|
throw new Error('DSN must contain a valid public key starting with pk_');
|
||||||
|
}
|
||||||
|
const protocol = url.protocol.replace(':', '');
|
||||||
|
const host = url.host;
|
||||||
|
return {
|
||||||
|
publicKey,
|
||||||
|
host,
|
||||||
|
protocol,
|
||||||
|
apiBaseUrl: `${protocol}://${host}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (error instanceof Error && error.message.includes('pk_')) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
throw new Error(`Invalid DSN format: ${dsn}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Validate and merge options with defaults
|
||||||
|
*/
|
||||||
|
function resolveOptions(options) {
|
||||||
|
const parsedDsn = parseDsn(options.dsn);
|
||||||
|
return {
|
||||||
|
dsn: options.dsn,
|
||||||
|
environment: options.environment ?? 'production',
|
||||||
|
appVersion: options.appVersion ?? '0.0.0',
|
||||||
|
sampleRate: Math.max(0, Math.min(1, options.sampleRate ?? exports.DEFAULT_OPTIONS.sampleRate)),
|
||||||
|
maxBreadcrumbs: options.maxBreadcrumbs ?? exports.DEFAULT_OPTIONS.maxBreadcrumbs,
|
||||||
|
debug: options.debug ?? exports.DEFAULT_OPTIONS.debug,
|
||||||
|
beforeSend: options.beforeSend ?? (() => true),
|
||||||
|
enableOfflineQueue: options.enableOfflineQueue ?? exports.DEFAULT_OPTIONS.enableOfflineQueue,
|
||||||
|
maxOfflineQueueSize: options.maxOfflineQueueSize ?? exports.DEFAULT_OPTIONS.maxOfflineQueueSize,
|
||||||
|
apiBaseUrl: options.apiBaseUrl ?? parsedDsn.apiBaseUrl,
|
||||||
|
parsedDsn,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Generate a unique event ID
|
||||||
|
*/
|
||||||
|
function generateEventId() {
|
||||||
|
const timestamp = Date.now().toString(36);
|
||||||
|
const random = Math.random().toString(36).substring(2, 15);
|
||||||
|
return `${timestamp}-${random}`;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=config.js.map
|
||||||
1
dist/cjs/config.js.map
vendored
Normal file
1
dist/cjs/config.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":";;;AAiBA,4BAwBC;AAKD,wCAgBC;AAKD,0CAIC;AArED;;GAEG;AACU,QAAA,eAAe,GAA8B;IACxD,UAAU,EAAE,GAAG;IACf,cAAc,EAAE,GAAG;IACnB,KAAK,EAAE,KAAK;IACZ,kBAAkB,EAAE,IAAI;IACxB,mBAAmB,EAAE,GAAG;CACzB,CAAC;AAEF;;;GAGG;AACH,SAAgB,QAAQ,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC;QAE/B,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,KAAK,CAAC,uDAAuD,CAAC,CAAC;QAC3E,CAAC;QAED,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC/C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QAEtB,OAAO;YACL,SAAS;YACT,IAAI;YACJ,QAAQ;YACR,UAAU,EAAE,GAAG,QAAQ,MAAM,IAAI,EAAE;SACpC,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5D,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,EAAE,CAAC,CAAC;IAChD,CAAC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@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.StepScope = exports.Step = exports.JourneyScope = exports.Journey = exports.TelemetryClient = void 0;
|
||||||
|
exports.init = init;
|
||||||
|
exports.getClient = getClient;
|
||||||
|
exports.captureException = captureException;
|
||||||
|
exports.captureMessage = captureMessage;
|
||||||
|
exports.addBreadcrumb = addBreadcrumb;
|
||||||
|
exports.setUser = setUser;
|
||||||
|
exports.clearUser = clearUser;
|
||||||
|
exports.setTag = setTag;
|
||||||
|
exports.setExtra = setExtra;
|
||||||
|
exports.startJourney = startJourney;
|
||||||
|
exports.startStep = startStep;
|
||||||
|
exports.flush = flush;
|
||||||
|
exports.close = close;
|
||||||
|
exports.enableErrorCapture = enableErrorCapture;
|
||||||
|
exports.useUnhandledExceptionHandler = useUnhandledExceptionHandler;
|
||||||
|
exports.trackStep = trackStep;
|
||||||
|
exports.trackStepAsync = trackStepAsync;
|
||||||
|
const client_1 = require("./client");
|
||||||
|
// Export classes
|
||||||
|
var client_2 = require("./client");
|
||||||
|
Object.defineProperty(exports, "TelemetryClient", { enumerable: true, get: function () { return client_2.TelemetryClient; } });
|
||||||
|
var journey_1 = require("./journey");
|
||||||
|
Object.defineProperty(exports, "Journey", { enumerable: true, get: function () { return journey_1.Journey; } });
|
||||||
|
Object.defineProperty(exports, "JourneyScope", { enumerable: true, get: function () { return journey_1.JourneyScope; } });
|
||||||
|
Object.defineProperty(exports, "Step", { enumerable: true, get: function () { return journey_1.Step; } });
|
||||||
|
Object.defineProperty(exports, "StepScope", { enumerable: true, get: function () { return journey_1.StepScope; } });
|
||||||
|
// Global client instance
|
||||||
|
let globalClient = null;
|
||||||
|
/**
|
||||||
|
* Initialize the global IronTelemetry client
|
||||||
|
*/
|
||||||
|
function init(optionsOrDsn) {
|
||||||
|
const options = typeof optionsOrDsn === 'string' ? { dsn: optionsOrDsn } : optionsOrDsn;
|
||||||
|
globalClient = new client_1.TelemetryClient(options);
|
||||||
|
return globalClient;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the global client instance
|
||||||
|
*/
|
||||||
|
function getClient() {
|
||||||
|
return globalClient;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Capture an exception using the global client
|
||||||
|
*/
|
||||||
|
async function captureException(error, extra) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return { success: false, error: 'Client not initialized' };
|
||||||
|
}
|
||||||
|
return globalClient.captureException(error, extra);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Capture a message using the global client
|
||||||
|
*/
|
||||||
|
async function captureMessage(message, level = 'info') {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return { success: false, error: 'Client not initialized' };
|
||||||
|
}
|
||||||
|
return globalClient.captureMessage(message, level);
|
||||||
|
}
|
||||||
|
function addBreadcrumb(messageOrBreadcrumb, category, level, data) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof messageOrBreadcrumb === 'string') {
|
||||||
|
globalClient.addBreadcrumb(messageOrBreadcrumb, category, level, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
globalClient.addBreadcrumb(messageOrBreadcrumb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set user context using the global client
|
||||||
|
*/
|
||||||
|
function setUser(id, email, data) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalClient.setUser(id, email, data);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Clear user context using the global client
|
||||||
|
*/
|
||||||
|
function clearUser() {
|
||||||
|
if (!globalClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalClient.clearUser();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set a tag using the global client
|
||||||
|
*/
|
||||||
|
function setTag(key, value) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalClient.setTag(key, value);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set extra context using the global client
|
||||||
|
*/
|
||||||
|
function setExtra(key, value) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalClient.setExtra(key, value);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a journey using the global client
|
||||||
|
*/
|
||||||
|
function startJourney(name) {
|
||||||
|
if (!globalClient) {
|
||||||
|
throw new Error('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
}
|
||||||
|
return globalClient.startJourney(name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a step in the current journey using the global client
|
||||||
|
*/
|
||||||
|
function startStep(name, category) {
|
||||||
|
if (!globalClient) {
|
||||||
|
throw new Error('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
}
|
||||||
|
return globalClient.startStep(name, category);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Flush pending events using the global client
|
||||||
|
*/
|
||||||
|
async function flush() {
|
||||||
|
if (!globalClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await globalClient.flush();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Close the global client
|
||||||
|
*/
|
||||||
|
function close() {
|
||||||
|
if (globalClient) {
|
||||||
|
globalClient.close();
|
||||||
|
globalClient = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Default export for convenience
|
||||||
|
const IronTelemetry = {
|
||||||
|
init,
|
||||||
|
getClient,
|
||||||
|
captureException,
|
||||||
|
captureMessage,
|
||||||
|
addBreadcrumb,
|
||||||
|
setUser,
|
||||||
|
clearUser,
|
||||||
|
setTag,
|
||||||
|
setExtra,
|
||||||
|
startJourney,
|
||||||
|
startStep,
|
||||||
|
flush,
|
||||||
|
close,
|
||||||
|
};
|
||||||
|
exports.default = IronTelemetry;
|
||||||
|
/**
|
||||||
|
* Enable the Error.prototype.capture() extension.
|
||||||
|
* This is opt-in to avoid TypeScript conflicts in projects that create
|
||||||
|
* Error-like objects without the capture method.
|
||||||
|
*
|
||||||
|
* After calling this, you can use: throw new Error('msg').capture()
|
||||||
|
*/
|
||||||
|
function enableErrorCapture() {
|
||||||
|
if (typeof Error.prototype.capture === 'function') {
|
||||||
|
return; // Already enabled
|
||||||
|
}
|
||||||
|
Error.prototype.capture = function () {
|
||||||
|
captureException(this);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Type augmentation for projects that call enableErrorCapture()
|
||||||
|
// Users can add this to their project if they want type support:
|
||||||
|
// declare global { interface Error { capture(): Error; } }
|
||||||
|
/**
|
||||||
|
* Set up global unhandled exception handler
|
||||||
|
*/
|
||||||
|
function useUnhandledExceptionHandler() {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
// Browser
|
||||||
|
window.addEventListener('error', (event) => {
|
||||||
|
captureException(event.error ?? new Error(event.message));
|
||||||
|
});
|
||||||
|
window.addEventListener('unhandledrejection', (event) => {
|
||||||
|
captureException(event.reason ?? new Error('Unhandled Promise rejection'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (typeof process !== 'undefined') {
|
||||||
|
// Node.js
|
||||||
|
process.on('uncaughtException', (error) => {
|
||||||
|
captureException(error);
|
||||||
|
});
|
||||||
|
process.on('unhandledRejection', (reason) => {
|
||||||
|
captureException(reason ?? new Error('Unhandled Promise rejection'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Track a step with automatic error handling
|
||||||
|
*/
|
||||||
|
function trackStep(name, fn, category) {
|
||||||
|
if (!globalClient) {
|
||||||
|
return fn();
|
||||||
|
}
|
||||||
|
const step = startStep(name, category);
|
||||||
|
try {
|
||||||
|
const result = fn();
|
||||||
|
step[Symbol.dispose]();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
step.getStep().fail();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Track an async step with automatic error handling
|
||||||
|
*/
|
||||||
|
async function trackStepAsync(name, fn, category) {
|
||||||
|
if (!globalClient) {
|
||||||
|
return fn();
|
||||||
|
}
|
||||||
|
const step = startStep(name, category);
|
||||||
|
try {
|
||||||
|
const result = await fn();
|
||||||
|
step[Symbol.dispose]();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
step.getStep().fail();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
1
dist/cjs/index.js.map
vendored
Normal file
1
dist/cjs/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
202
dist/cjs/journey.js
vendored
Normal file
202
dist/cjs/journey.js
vendored
Normal file
@ -0,0 +1,202 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.StepScope = exports.JourneyScope = exports.Step = exports.Journey = void 0;
|
||||||
|
const config_1 = require("./config");
|
||||||
|
/**
|
||||||
|
* Represents an active journey tracking session
|
||||||
|
*/
|
||||||
|
class Journey {
|
||||||
|
constructor(name) {
|
||||||
|
this.metadata = {};
|
||||||
|
this.steps = [];
|
||||||
|
this._completed = false;
|
||||||
|
this._failed = false;
|
||||||
|
this.id = (0, config_1.generateEventId)();
|
||||||
|
this.name = name;
|
||||||
|
this.startedAt = new Date();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set user context for this journey
|
||||||
|
*/
|
||||||
|
setUser(id, email, data) {
|
||||||
|
this.user = { id, email, data };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set metadata for this journey
|
||||||
|
*/
|
||||||
|
setMetadata(key, value) {
|
||||||
|
this.metadata[key] = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a new step in this journey
|
||||||
|
*/
|
||||||
|
startStep(name, category) {
|
||||||
|
// Complete any existing step
|
||||||
|
if (this.currentStep && this.currentStep.status === 'in_progress') {
|
||||||
|
this.currentStep.status = 'completed';
|
||||||
|
this.currentStep.endedAt = new Date();
|
||||||
|
}
|
||||||
|
const step = {
|
||||||
|
name,
|
||||||
|
category,
|
||||||
|
startedAt: new Date(),
|
||||||
|
status: 'in_progress',
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
this.steps.push(step);
|
||||||
|
this.currentStep = step;
|
||||||
|
return new Step(step, this);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark the journey as completed
|
||||||
|
*/
|
||||||
|
complete() {
|
||||||
|
if (this.currentStep && this.currentStep.status === 'in_progress') {
|
||||||
|
this.currentStep.status = 'completed';
|
||||||
|
this.currentStep.endedAt = new Date();
|
||||||
|
}
|
||||||
|
this._completed = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark the journey as failed
|
||||||
|
*/
|
||||||
|
fail() {
|
||||||
|
if (this.currentStep && this.currentStep.status === 'in_progress') {
|
||||||
|
this.currentStep.status = 'failed';
|
||||||
|
this.currentStep.endedAt = new Date();
|
||||||
|
}
|
||||||
|
this._failed = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the journey context for an event
|
||||||
|
*/
|
||||||
|
getContext() {
|
||||||
|
return {
|
||||||
|
journeyId: this.id,
|
||||||
|
name: this.name,
|
||||||
|
currentStep: this.currentStep?.name,
|
||||||
|
startedAt: this.startedAt,
|
||||||
|
metadata: this.metadata,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the user context for this journey
|
||||||
|
*/
|
||||||
|
getUser() {
|
||||||
|
return this.user;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if the journey is complete
|
||||||
|
*/
|
||||||
|
get isComplete() {
|
||||||
|
return this._completed || this._failed;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get journey ID
|
||||||
|
*/
|
||||||
|
get journeyId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Journey = Journey;
|
||||||
|
/**
|
||||||
|
* Represents a step within a journey
|
||||||
|
*/
|
||||||
|
class Step {
|
||||||
|
constructor(step, journey) {
|
||||||
|
this.step = step;
|
||||||
|
this.journey = journey;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set data for this step
|
||||||
|
*/
|
||||||
|
setData(key, value) {
|
||||||
|
this.step.data[key] = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark the step as completed
|
||||||
|
*/
|
||||||
|
complete() {
|
||||||
|
this.step.status = 'completed';
|
||||||
|
this.step.endedAt = new Date();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark the step as failed
|
||||||
|
*/
|
||||||
|
fail() {
|
||||||
|
this.step.status = 'failed';
|
||||||
|
this.step.endedAt = new Date();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the step name
|
||||||
|
*/
|
||||||
|
get name() {
|
||||||
|
return this.step.name;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the parent journey
|
||||||
|
*/
|
||||||
|
getJourney() {
|
||||||
|
return this.journey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Step = Step;
|
||||||
|
/**
|
||||||
|
* Journey scope that auto-completes on disposal
|
||||||
|
*/
|
||||||
|
class JourneyScope {
|
||||||
|
constructor(journey, onComplete) {
|
||||||
|
this.journey = journey;
|
||||||
|
this.onComplete = onComplete;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the underlying journey
|
||||||
|
*/
|
||||||
|
getJourney() {
|
||||||
|
return this.journey;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Dispose of the journey scope
|
||||||
|
*/
|
||||||
|
[Symbol.dispose]() {
|
||||||
|
if (!this.journey.isComplete) {
|
||||||
|
this.journey.complete();
|
||||||
|
}
|
||||||
|
this.onComplete?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.JourneyScope = JourneyScope;
|
||||||
|
/**
|
||||||
|
* Step scope that auto-completes on disposal
|
||||||
|
*/
|
||||||
|
class StepScope {
|
||||||
|
constructor(step) {
|
||||||
|
this.step = step;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the underlying step
|
||||||
|
*/
|
||||||
|
getStep() {
|
||||||
|
return this.step;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set data on the step
|
||||||
|
*/
|
||||||
|
setData(key, value) {
|
||||||
|
this.step.setData(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Dispose of the step scope
|
||||||
|
*/
|
||||||
|
[Symbol.dispose]() {
|
||||||
|
if (this.step['step'].status === 'in_progress') {
|
||||||
|
this.step.complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.StepScope = StepScope;
|
||||||
|
//# sourceMappingURL=journey.js.map
|
||||||
1
dist/cjs/journey.js.map
vendored
Normal file
1
dist/cjs/journey.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"journey.js","sourceRoot":"","sources":["../../src/journey.ts"],"names":[],"mappings":";;;AACA,qCAA2C;AAE3C;;GAEG;AACH,MAAa,OAAO;IAWlB,YAAY,IAAY;QAPhB,aAAQ,GAA4B,EAAE,CAAC;QAEvC,UAAK,GAAkB,EAAE,CAAC;QAE1B,eAAU,GAAY,KAAK,CAAC;QAC5B,YAAO,GAAY,KAAK,CAAC;QAG/B,IAAI,CAAC,EAAE,GAAG,IAAA,wBAAe,GAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAC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IACd,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;YAC/C,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CACF;AA9BD,8BA8BC"}
|
||||||
119
dist/cjs/queue.js
vendored
Normal file
119
dist/cjs/queue.js
vendored
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.OfflineQueue = void 0;
|
||||||
|
const STORAGE_KEY = 'irontelemetry_queue';
|
||||||
|
/**
|
||||||
|
* Offline queue for storing events when the network is unavailable
|
||||||
|
*/
|
||||||
|
class OfflineQueue {
|
||||||
|
constructor(maxSize = 500, debug = false) {
|
||||||
|
this.queue = [];
|
||||||
|
this.maxSize = maxSize;
|
||||||
|
this.debug = debug;
|
||||||
|
this.load();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Add an event to the queue
|
||||||
|
*/
|
||||||
|
enqueue(event) {
|
||||||
|
if (this.queue.length >= this.maxSize) {
|
||||||
|
// Remove oldest events to make room
|
||||||
|
this.queue.shift();
|
||||||
|
if (this.debug) {
|
||||||
|
console.log('[IronTelemetry] Queue full, dropping oldest event');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.queue.push(event);
|
||||||
|
this.save();
|
||||||
|
if (this.debug) {
|
||||||
|
console.log('[IronTelemetry] Event queued, queue size:', this.queue.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get all queued events
|
||||||
|
*/
|
||||||
|
getAll() {
|
||||||
|
return [...this.queue];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Remove an event from the queue
|
||||||
|
*/
|
||||||
|
remove(eventId) {
|
||||||
|
this.queue = this.queue.filter((e) => e.eventId !== eventId);
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Clear all queued events
|
||||||
|
*/
|
||||||
|
clear() {
|
||||||
|
this.queue = [];
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the number of queued events
|
||||||
|
*/
|
||||||
|
get size() {
|
||||||
|
return this.queue.length;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if the queue is empty
|
||||||
|
*/
|
||||||
|
get isEmpty() {
|
||||||
|
return this.queue.length === 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Load queue from persistent storage
|
||||||
|
*/
|
||||||
|
load() {
|
||||||
|
try {
|
||||||
|
if (typeof localStorage !== 'undefined') {
|
||||||
|
const data = localStorage.getItem(STORAGE_KEY);
|
||||||
|
if (data) {
|
||||||
|
const parsed = JSON.parse(data);
|
||||||
|
this.queue = parsed.map((e) => this.deserializeEvent(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (this.debug) {
|
||||||
|
console.error('[IronTelemetry] Failed to load queue from storage:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Save queue to persistent storage
|
||||||
|
*/
|
||||||
|
save() {
|
||||||
|
try {
|
||||||
|
if (typeof localStorage !== 'undefined') {
|
||||||
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.queue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (this.debug) {
|
||||||
|
console.error('[IronTelemetry] Failed to save queue to storage:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Deserialize an event from storage
|
||||||
|
*/
|
||||||
|
deserializeEvent(data) {
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
timestamp: new Date(data.timestamp),
|
||||||
|
breadcrumbs: (data.breadcrumbs ?? []).map((b) => ({
|
||||||
|
...b,
|
||||||
|
timestamp: new Date(b.timestamp),
|
||||||
|
})),
|
||||||
|
journey: data.journey
|
||||||
|
? {
|
||||||
|
...data.journey,
|
||||||
|
startedAt: new Date(data.journey.startedAt),
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.OfflineQueue = OfflineQueue;
|
||||||
|
//# sourceMappingURL=queue.js.map
|
||||||
1
dist/cjs/queue.js.map
vendored
Normal file
1
dist/cjs/queue.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":";;;AAEA,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C;;GAEG;AACH,MAAa,YAAY;IAKvB,YAAY,UAAkB,GAAG,EAAE,QAAiB,KAAK;QAFjD,UAAK,GAAqB,EAAE,CAAC;QAGnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,IAAI,EAAE,CAAC;IACd,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,KAAqB;QAC3B,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACtC,oCAAoC;YACpC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,GAAG,CAAC,mDAAmD,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC;QAEZ,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,2CAA2C,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAA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,OAAO,YAAY,KAAK,WAAW,EAAE,CAAC;gBACxC,YAAY,CAAC,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAChE,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;gBACf,OAAO,CAAC,KAAK,CAAC,kDAAkD,EAAE,KAAK,CAAC,CAAC;YAC3E,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACK,gBAAgB,CAAC,IAA6B;QACpD,OAAO;YACL,GAAG,IAAI;YACP,SAAS,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,SAAmB,CAAC;YAC7C,WAAW,EAAE,CAAE,IAAI,CAAC,WAAyC,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBAC/E,GAAG,CAAC;gBACJ,SAAS,EAAE,IAAI,IAAI,CAAC,CAAC,CAAC,SAAmB,CAAC;aAC3C,CAAC,CAAC;YACH,OAAO,EAAE,IAAI,CAAC,OAAO;gBACnB,CAAC,CAAC;oBACE,GAAI,IAAI,CAAC,OAAmC;oBAC5C,SAAS,EAAE,IAAI,IAAI,CAAE,IAAI,CAAC,OAAmC,CAAC,SAAmB,CAAC;iBACnF;gBACH,CAAC,CAAC,SAAS;SACI,CAAC;IACtB,CAAC;CACF;AAzHD,oCAyHC"}
|
||||||
104
dist/cjs/transport.js
vendored
Normal file
104
dist/cjs/transport.js
vendored
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.Transport = void 0;
|
||||||
|
/**
|
||||||
|
* HTTP transport for sending events to the server
|
||||||
|
*/
|
||||||
|
class Transport {
|
||||||
|
constructor(parsedDsn, apiBaseUrl, debug = false) {
|
||||||
|
this.apiBaseUrl = apiBaseUrl;
|
||||||
|
this.publicKey = parsedDsn.publicKey;
|
||||||
|
this.debug = debug;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Send an event to the server
|
||||||
|
*/
|
||||||
|
async send(event) {
|
||||||
|
const url = `${this.apiBaseUrl}/api/v1/events`;
|
||||||
|
try {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-Public-Key': this.publicKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(this.serializeEvent(event)),
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
if (this.debug) {
|
||||||
|
console.error('[IronTelemetry] Failed to send event:', response.status, errorText);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: `HTTP ${response.status}: ${errorText}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const result = await response.json();
|
||||||
|
if (this.debug) {
|
||||||
|
console.log('[IronTelemetry] Event sent successfully:', event.eventId);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
eventId: result.eventId ?? event.eventId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
if (this.debug) {
|
||||||
|
console.error('[IronTelemetry] Failed to send event:', errorMessage);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: errorMessage,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if the server is reachable
|
||||||
|
*/
|
||||||
|
async isOnline() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${this.apiBaseUrl}/api/v1/health`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'X-Public-Key': this.publicKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return response.ok;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Serialize an event for sending
|
||||||
|
*/
|
||||||
|
serializeEvent(event) {
|
||||||
|
return {
|
||||||
|
eventId: event.eventId,
|
||||||
|
timestamp: event.timestamp.toISOString(),
|
||||||
|
level: event.level,
|
||||||
|
message: event.message,
|
||||||
|
exception: event.exception,
|
||||||
|
user: event.user,
|
||||||
|
tags: event.tags,
|
||||||
|
extra: event.extra,
|
||||||
|
breadcrumbs: event.breadcrumbs.map((b) => ({
|
||||||
|
...b,
|
||||||
|
timestamp: b.timestamp.toISOString(),
|
||||||
|
})),
|
||||||
|
journey: event.journey
|
||||||
|
? {
|
||||||
|
...event.journey,
|
||||||
|
startedAt: event.journey.startedAt.toISOString(),
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
environment: event.environment,
|
||||||
|
appVersion: event.appVersion,
|
||||||
|
platform: event.platform,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.Transport = Transport;
|
||||||
|
//# sourceMappingURL=transport.js.map
|
||||||
1
dist/cjs/transport.js.map
vendored
Normal file
1
dist/cjs/transport.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":";;;AAEA;;GAEG;AACH,MAAa,SAAS;IAKpB,YAAY,SAAoB,EAAE,UAAkB,EAAE,QAAiB,KAAK;QAC1E,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,SAAS,CAAC;QACrC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI,CAAC,KAAqB;QAC9B,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,gBAAgB,CAAC;QAE/C,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,K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SACzB,CAAC;IACJ,CAAC;CACF;AAzGD,8BAyGC"}
|
||||||
3
dist/cjs/types.js
vendored
Normal file
3
dist/cjs/types.js
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
//# sourceMappingURL=types.js.map
|
||||||
1
dist/cjs/types.js.map
vendored
Normal file
1
dist/cjs/types.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
||||||
58
dist/esm/breadcrumbs.js
vendored
Normal file
58
dist/esm/breadcrumbs.js
vendored
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
/**
|
||||||
|
* Manages breadcrumbs for an SDK instance
|
||||||
|
*/
|
||||||
|
export 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=breadcrumbs.js.map
|
||||||
1
dist/esm/breadcrumbs.js.map
vendored
Normal file
1
dist/esm/breadcrumbs.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"breadcrumbs.js","sourceRoot":"","sources":["../../src/breadcrumbs.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAI5B,YAAY,iBAAyB,GAAG;QAFhC,gBAAW,GAAiB,EAAE,CAAC;QAGrC,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,GAAG,CACD,OAAe,EACf,WAA+B,QAAQ,EACvC,QAAuB,MAAM,EAC7B,IAA8B;QAE9B,MAAM,UAAU,GAAe;YAC7B,SAAS,EAAE,IAAI,IAAI,EAAE;YACrB,QAAQ;YACR,OAAO;YACP,KAAK;YACL,IAAI;SACL,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAElC,mBAAmB;QACnB,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,UAAgE;QAC5E,MAAM,cAAc,GAAe;YACjC,GAAG,UAAU;YACb,SAAS,EAAE,UAAU,CAAC,SAAS,IAAI,IAAI,IAAI,EAAE;SAC9C,CAAC;QAEF,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAEtC,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;YAClD,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO,CAAC,GAAG,IAAI,CAAC,WAAW,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,KAAK;QACH,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED;;OAEG;IACH,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACjC,CAAC;CACF"}
|
||||||
301
dist/esm/client.js
vendored
Normal file
301
dist/esm/client.js
vendored
Normal file
@ -0,0 +1,301 @@
|
|||||||
|
import { resolveOptions, generateEventId } from './config';
|
||||||
|
import { Transport } from './transport';
|
||||||
|
import { OfflineQueue } from './queue';
|
||||||
|
import { BreadcrumbManager } from './breadcrumbs';
|
||||||
|
import { Journey, JourneyScope, StepScope } from './journey';
|
||||||
|
/**
|
||||||
|
* Global debug logging flag. When enabled, all IronTelemetry clients
|
||||||
|
* will output debug information to the console.
|
||||||
|
*/
|
||||||
|
export let enableDebugLogging = false;
|
||||||
|
/**
|
||||||
|
* Enable or disable global debug logging for all TelemetryClient instances.
|
||||||
|
* @param enabled Whether to enable debug logging
|
||||||
|
*/
|
||||||
|
export function setDebugLogging(enabled) {
|
||||||
|
enableDebugLogging = enabled;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Main IronTelemetry client class
|
||||||
|
*/
|
||||||
|
export class TelemetryClient {
|
||||||
|
constructor(options) {
|
||||||
|
this.tags = {};
|
||||||
|
this.extra = {};
|
||||||
|
this.isInitialized = false;
|
||||||
|
this.options = resolveOptions(options);
|
||||||
|
this.transport = new Transport(this.options.parsedDsn, this.options.apiBaseUrl, this.options.debug);
|
||||||
|
this.queue = this.options.enableOfflineQueue
|
||||||
|
? new OfflineQueue(this.options.maxOfflineQueueSize, this.options.debug)
|
||||||
|
: null;
|
||||||
|
this.breadcrumbs = new BreadcrumbManager(this.options.maxBreadcrumbs);
|
||||||
|
this.isInitialized = true;
|
||||||
|
// Start flush interval for offline queue
|
||||||
|
if (this.queue) {
|
||||||
|
this.flushInterval = setInterval(() => this.processQueue(), 30000);
|
||||||
|
}
|
||||||
|
if (this.options.debug || enableDebugLogging) {
|
||||||
|
console.log('[IronTelemetry] Initialized with DSN:', this.options.dsn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Capture an exception
|
||||||
|
*/
|
||||||
|
async captureException(error, extra) {
|
||||||
|
const exception = this.parseException(error);
|
||||||
|
const event = this.createEvent('error', exception.message, exception);
|
||||||
|
if (extra) {
|
||||||
|
event.extra = { ...event.extra, ...extra };
|
||||||
|
}
|
||||||
|
return this.sendEvent(event);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Capture a message
|
||||||
|
*/
|
||||||
|
async captureMessage(message, level = 'info') {
|
||||||
|
const event = this.createEvent(level, message);
|
||||||
|
return this.sendEvent(event);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Log a structured message with title, message, and optional data.
|
||||||
|
* Useful for structured logging that differentiates the log title from its details.
|
||||||
|
* @param level The severity level of the log
|
||||||
|
* @param title A short, descriptive title for the log entry
|
||||||
|
* @param message Optional detailed message
|
||||||
|
* @param data Optional additional data to attach to the log
|
||||||
|
*/
|
||||||
|
async logMessage(level, title, message, data) {
|
||||||
|
const fullMessage = message ? `${title}: ${message}` : title;
|
||||||
|
const event = this.createEvent(level, fullMessage);
|
||||||
|
if (data) {
|
||||||
|
event.extra = { ...event.extra, logTitle: title, logData: data };
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
event.extra = { ...event.extra, logTitle: title };
|
||||||
|
}
|
||||||
|
return this.sendEvent(event);
|
||||||
|
}
|
||||||
|
addBreadcrumb(messageOrBreadcrumb, category, level, data) {
|
||||||
|
if (typeof messageOrBreadcrumb === 'string') {
|
||||||
|
this.breadcrumbs.add(messageOrBreadcrumb, category, level, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.breadcrumbs.addBreadcrumb(messageOrBreadcrumb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get a copy of the current breadcrumbs list.
|
||||||
|
* @returns A read-only array of breadcrumbs
|
||||||
|
*/
|
||||||
|
getBreadcrumbs() {
|
||||||
|
return this.breadcrumbs.getAll();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Clear all breadcrumbs.
|
||||||
|
*/
|
||||||
|
clearBreadcrumbs() {
|
||||||
|
this.breadcrumbs.clear();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set user context
|
||||||
|
*/
|
||||||
|
setUser(id, email, data) {
|
||||||
|
this.user = { id, email, data };
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Clear user context
|
||||||
|
*/
|
||||||
|
clearUser() {
|
||||||
|
this.user = undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set a tag
|
||||||
|
*/
|
||||||
|
setTag(key, value) {
|
||||||
|
this.tags[key] = value;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set extra context
|
||||||
|
*/
|
||||||
|
setExtra(key, value) {
|
||||||
|
this.extra[key] = value;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a new journey
|
||||||
|
*/
|
||||||
|
startJourney(name) {
|
||||||
|
this.currentJourney = new Journey(name);
|
||||||
|
// Copy user context to journey
|
||||||
|
if (this.user) {
|
||||||
|
this.currentJourney.setUser(this.user.id, this.user.email, this.user.data);
|
||||||
|
}
|
||||||
|
return new JourneyScope(this.currentJourney, () => {
|
||||||
|
this.currentJourney = undefined;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a step in the current journey
|
||||||
|
*/
|
||||||
|
startStep(name, category) {
|
||||||
|
if (!this.currentJourney) {
|
||||||
|
throw new Error('No active journey. Call startJourney() first.');
|
||||||
|
}
|
||||||
|
const step = this.currentJourney.startStep(name, category);
|
||||||
|
return new StepScope(step);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Flush pending events
|
||||||
|
*/
|
||||||
|
async flush() {
|
||||||
|
await this.processQueue();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Close the client
|
||||||
|
*/
|
||||||
|
close() {
|
||||||
|
if (this.flushInterval) {
|
||||||
|
clearInterval(this.flushInterval);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Create a telemetry event
|
||||||
|
*/
|
||||||
|
createEvent(level, message, exception) {
|
||||||
|
const event = {
|
||||||
|
eventId: generateEventId(),
|
||||||
|
timestamp: new Date(),
|
||||||
|
level,
|
||||||
|
message,
|
||||||
|
exception,
|
||||||
|
user: this.currentJourney?.getUser() ?? this.user,
|
||||||
|
tags: { ...this.tags },
|
||||||
|
extra: { ...this.extra },
|
||||||
|
breadcrumbs: this.breadcrumbs.getAll(),
|
||||||
|
journey: this.currentJourney?.getContext(),
|
||||||
|
environment: this.options.environment,
|
||||||
|
appVersion: this.options.appVersion,
|
||||||
|
platform: this.getPlatformInfo(),
|
||||||
|
};
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Send an event
|
||||||
|
*/
|
||||||
|
async sendEvent(event) {
|
||||||
|
// Check sample rate
|
||||||
|
if (Math.random() > this.options.sampleRate) {
|
||||||
|
if (this.options.debug || enableDebugLogging) {
|
||||||
|
console.log('[IronTelemetry] Event dropped due to sample rate');
|
||||||
|
}
|
||||||
|
return { success: true, eventId: event.eventId };
|
||||||
|
}
|
||||||
|
// Apply beforeSend hook
|
||||||
|
const beforeSendResult = this.options.beforeSend(event);
|
||||||
|
if (beforeSendResult === false || beforeSendResult === null) {
|
||||||
|
if (this.options.debug || enableDebugLogging) {
|
||||||
|
console.log('[IronTelemetry] Event dropped by beforeSend hook');
|
||||||
|
}
|
||||||
|
return { success: true, eventId: event.eventId };
|
||||||
|
}
|
||||||
|
const eventToSend = beforeSendResult === true ? event : beforeSendResult;
|
||||||
|
// Try to send
|
||||||
|
const result = await this.transport.send(eventToSend);
|
||||||
|
if (!result.success && this.queue) {
|
||||||
|
this.queue.enqueue(eventToSend);
|
||||||
|
return { ...result, queued: true };
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Process offline queue
|
||||||
|
*/
|
||||||
|
async processQueue() {
|
||||||
|
if (!this.queue || this.queue.isEmpty) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const isOnline = await this.transport.isOnline();
|
||||||
|
if (!isOnline) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const events = this.queue.getAll();
|
||||||
|
for (const event of events) {
|
||||||
|
const result = await this.transport.send(event);
|
||||||
|
if (result.success) {
|
||||||
|
this.queue.remove(event.eventId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Parse an error into exception info
|
||||||
|
*/
|
||||||
|
parseException(error) {
|
||||||
|
if (error instanceof Error) {
|
||||||
|
return {
|
||||||
|
type: error.name || 'Error',
|
||||||
|
message: error.message,
|
||||||
|
stacktrace: this.parseStackTrace(error.stack),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
type: 'Error',
|
||||||
|
message: String(error),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Parse a stack trace string into frames
|
||||||
|
*/
|
||||||
|
parseStackTrace(stack) {
|
||||||
|
if (!stack)
|
||||||
|
return undefined;
|
||||||
|
const frames = [];
|
||||||
|
const lines = stack.split('\n');
|
||||||
|
for (const line of lines) {
|
||||||
|
// Chrome/Node format: " at functionName (filename:line:column)"
|
||||||
|
const chromeMatch = line.match(/^\s*at\s+(?:(.+?)\s+\()?(.+?):(\d+):(\d+)\)?$/);
|
||||||
|
if (chromeMatch) {
|
||||||
|
frames.push({
|
||||||
|
function: chromeMatch[1] || '<anonymous>',
|
||||||
|
filename: chromeMatch[2],
|
||||||
|
lineno: parseInt(chromeMatch[3], 10),
|
||||||
|
colno: parseInt(chromeMatch[4], 10),
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// Firefox format: "functionName@filename:line:column"
|
||||||
|
const firefoxMatch = line.match(/^(.*)@(.+?):(\d+):(\d+)$/);
|
||||||
|
if (firefoxMatch) {
|
||||||
|
frames.push({
|
||||||
|
function: firefoxMatch[1] || '<anonymous>',
|
||||||
|
filename: firefoxMatch[2],
|
||||||
|
lineno: parseInt(firefoxMatch[3], 10),
|
||||||
|
colno: parseInt(firefoxMatch[4], 10),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return frames.length > 0 ? frames : undefined;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get platform information
|
||||||
|
*/
|
||||||
|
getPlatformInfo() {
|
||||||
|
// Check for browser environment
|
||||||
|
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
|
||||||
|
return {
|
||||||
|
name: 'browser',
|
||||||
|
userAgent: navigator.userAgent,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Check for Node.js environment
|
||||||
|
if (typeof process !== 'undefined' && process.versions?.node) {
|
||||||
|
return {
|
||||||
|
name: 'node',
|
||||||
|
version: process.versions.node,
|
||||||
|
os: process.platform,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
name: 'unknown',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=client.js.map
|
||||||
1
dist/esm/client.js.map
vendored
Normal file
1
dist/esm/client.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
65
dist/esm/config.js
vendored
Normal file
65
dist/esm/config.js
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Default configuration values
|
||||||
|
*/
|
||||||
|
export const DEFAULT_OPTIONS = {
|
||||||
|
sampleRate: 1.0,
|
||||||
|
maxBreadcrumbs: 100,
|
||||||
|
debug: false,
|
||||||
|
enableOfflineQueue: true,
|
||||||
|
maxOfflineQueueSize: 500,
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Parse a DSN string into its components
|
||||||
|
* Format: https://pk_live_xxx@irontelemetry.com
|
||||||
|
*/
|
||||||
|
export function parseDsn(dsn) {
|
||||||
|
try {
|
||||||
|
const url = new URL(dsn);
|
||||||
|
const publicKey = url.username;
|
||||||
|
if (!publicKey || !publicKey.startsWith('pk_')) {
|
||||||
|
throw new Error('DSN must contain a valid public key starting with pk_');
|
||||||
|
}
|
||||||
|
const protocol = url.protocol.replace(':', '');
|
||||||
|
const host = url.host;
|
||||||
|
return {
|
||||||
|
publicKey,
|
||||||
|
host,
|
||||||
|
protocol,
|
||||||
|
apiBaseUrl: `${protocol}://${host}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (error instanceof Error && error.message.includes('pk_')) {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
throw new Error(`Invalid DSN format: ${dsn}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Validate and merge options with defaults
|
||||||
|
*/
|
||||||
|
export function resolveOptions(options) {
|
||||||
|
const parsedDsn = parseDsn(options.dsn);
|
||||||
|
return {
|
||||||
|
dsn: options.dsn,
|
||||||
|
environment: options.environment ?? 'production',
|
||||||
|
appVersion: options.appVersion ?? '0.0.0',
|
||||||
|
sampleRate: Math.max(0, Math.min(1, options.sampleRate ?? DEFAULT_OPTIONS.sampleRate)),
|
||||||
|
maxBreadcrumbs: options.maxBreadcrumbs ?? DEFAULT_OPTIONS.maxBreadcrumbs,
|
||||||
|
debug: options.debug ?? DEFAULT_OPTIONS.debug,
|
||||||
|
beforeSend: options.beforeSend ?? (() => true),
|
||||||
|
enableOfflineQueue: options.enableOfflineQueue ?? DEFAULT_OPTIONS.enableOfflineQueue,
|
||||||
|
maxOfflineQueueSize: options.maxOfflineQueueSize ?? DEFAULT_OPTIONS.maxOfflineQueueSize,
|
||||||
|
apiBaseUrl: options.apiBaseUrl ?? parsedDsn.apiBaseUrl,
|
||||||
|
parsedDsn,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Generate a unique event ID
|
||||||
|
*/
|
||||||
|
export function generateEventId() {
|
||||||
|
const timestamp = Date.now().toString(36);
|
||||||
|
const random = Math.random().toString(36).substring(2, 15);
|
||||||
|
return `${timestamp}-${random}`;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=config.js.map
|
||||||
1
dist/esm/config.js.map
vendored
Normal file
1
dist/esm/config.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAA8B;IACxD,UAAU,EAAE,GAAG;IACf,cAAc,EAAE,GAAG;IACnB,KAAK,EAAE,KAAK;IACZ,kBAAkB,EAAE,IAAI;IACxB,mBAAmB,EAAE,GAAG;CACzB,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,MAAM,SAAS,GAAG,GAAG,CAAC,QAAQ,CAAC;QAE/B,IAAI,CAAC,SAAS,IAA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QAC9C,kBAAkB,EAAE,OAAO,CAAC,kBAAkB,IAAI,eAAe,CAAC,kBAAmB;QACrF,mBAAmB,EAAE,OAAO,CAAC,mBAAmB,IAAI,eAAe,CAAC,mBAAoB;QACxF,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,SAAS,CAAC,UAAU;QACtD,SAAS;KACV,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe;IAC7B,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC3D,OAAO,GAAG,SAAS,IAAI,MAAM,EAAE,CAAC;AAClC,CAAC"}
|
||||||
223
dist/esm/index.js
vendored
Normal file
223
dist/esm/index.js
vendored
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
import { TelemetryClient } from './client';
|
||||||
|
// Export classes
|
||||||
|
export { TelemetryClient } from './client';
|
||||||
|
export { Journey, JourneyScope, Step, StepScope } from './journey';
|
||||||
|
// Global client instance
|
||||||
|
let globalClient = null;
|
||||||
|
/**
|
||||||
|
* Initialize the global IronTelemetry client
|
||||||
|
*/
|
||||||
|
export function init(optionsOrDsn) {
|
||||||
|
const options = typeof optionsOrDsn === 'string' ? { dsn: optionsOrDsn } : optionsOrDsn;
|
||||||
|
globalClient = new TelemetryClient(options);
|
||||||
|
return globalClient;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the global client instance
|
||||||
|
*/
|
||||||
|
export function getClient() {
|
||||||
|
return globalClient;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Capture an exception using the global client
|
||||||
|
*/
|
||||||
|
export async function captureException(error, extra) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return { success: false, error: 'Client not initialized' };
|
||||||
|
}
|
||||||
|
return globalClient.captureException(error, extra);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Capture a message using the global client
|
||||||
|
*/
|
||||||
|
export async function captureMessage(message, level = 'info') {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return { success: false, error: 'Client not initialized' };
|
||||||
|
}
|
||||||
|
return globalClient.captureMessage(message, level);
|
||||||
|
}
|
||||||
|
export function addBreadcrumb(messageOrBreadcrumb, category, level, data) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (typeof messageOrBreadcrumb === 'string') {
|
||||||
|
globalClient.addBreadcrumb(messageOrBreadcrumb, category, level, data);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
globalClient.addBreadcrumb(messageOrBreadcrumb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set user context using the global client
|
||||||
|
*/
|
||||||
|
export function setUser(id, email, data) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalClient.setUser(id, email, data);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Clear user context using the global client
|
||||||
|
*/
|
||||||
|
export function clearUser() {
|
||||||
|
if (!globalClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalClient.clearUser();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set a tag using the global client
|
||||||
|
*/
|
||||||
|
export function setTag(key, value) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalClient.setTag(key, value);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set extra context using the global client
|
||||||
|
*/
|
||||||
|
export function setExtra(key, value) {
|
||||||
|
if (!globalClient) {
|
||||||
|
console.warn('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
globalClient.setExtra(key, value);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a journey using the global client
|
||||||
|
*/
|
||||||
|
export function startJourney(name) {
|
||||||
|
if (!globalClient) {
|
||||||
|
throw new Error('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
}
|
||||||
|
return globalClient.startJourney(name);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a step in the current journey using the global client
|
||||||
|
*/
|
||||||
|
export function startStep(name, category) {
|
||||||
|
if (!globalClient) {
|
||||||
|
throw new Error('[IronTelemetry] Client not initialized. Call init() first.');
|
||||||
|
}
|
||||||
|
return globalClient.startStep(name, category);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Flush pending events using the global client
|
||||||
|
*/
|
||||||
|
export async function flush() {
|
||||||
|
if (!globalClient) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await globalClient.flush();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Close the global client
|
||||||
|
*/
|
||||||
|
export function close() {
|
||||||
|
if (globalClient) {
|
||||||
|
globalClient.close();
|
||||||
|
globalClient = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Default export for convenience
|
||||||
|
const IronTelemetry = {
|
||||||
|
init,
|
||||||
|
getClient,
|
||||||
|
captureException,
|
||||||
|
captureMessage,
|
||||||
|
addBreadcrumb,
|
||||||
|
setUser,
|
||||||
|
clearUser,
|
||||||
|
setTag,
|
||||||
|
setExtra,
|
||||||
|
startJourney,
|
||||||
|
startStep,
|
||||||
|
flush,
|
||||||
|
close,
|
||||||
|
};
|
||||||
|
export default IronTelemetry;
|
||||||
|
/**
|
||||||
|
* Enable the Error.prototype.capture() extension.
|
||||||
|
* This is opt-in to avoid TypeScript conflicts in projects that create
|
||||||
|
* Error-like objects without the capture method.
|
||||||
|
*
|
||||||
|
* After calling this, you can use: throw new Error('msg').capture()
|
||||||
|
*/
|
||||||
|
export function enableErrorCapture() {
|
||||||
|
if (typeof Error.prototype.capture === 'function') {
|
||||||
|
return; // Already enabled
|
||||||
|
}
|
||||||
|
Error.prototype.capture = function () {
|
||||||
|
captureException(this);
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// Type augmentation for projects that call enableErrorCapture()
|
||||||
|
// Users can add this to their project if they want type support:
|
||||||
|
// declare global { interface Error { capture(): Error; } }
|
||||||
|
/**
|
||||||
|
* Set up global unhandled exception handler
|
||||||
|
*/
|
||||||
|
export function useUnhandledExceptionHandler() {
|
||||||
|
if (typeof window !== 'undefined') {
|
||||||
|
// Browser
|
||||||
|
window.addEventListener('error', (event) => {
|
||||||
|
captureException(event.error ?? new Error(event.message));
|
||||||
|
});
|
||||||
|
window.addEventListener('unhandledrejection', (event) => {
|
||||||
|
captureException(event.reason ?? new Error('Unhandled Promise rejection'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if (typeof process !== 'undefined') {
|
||||||
|
// Node.js
|
||||||
|
process.on('uncaughtException', (error) => {
|
||||||
|
captureException(error);
|
||||||
|
});
|
||||||
|
process.on('unhandledRejection', (reason) => {
|
||||||
|
captureException(reason ?? new Error('Unhandled Promise rejection'));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Track a step with automatic error handling
|
||||||
|
*/
|
||||||
|
export function trackStep(name, fn, category) {
|
||||||
|
if (!globalClient) {
|
||||||
|
return fn();
|
||||||
|
}
|
||||||
|
const step = startStep(name, category);
|
||||||
|
try {
|
||||||
|
const result = fn();
|
||||||
|
step[Symbol.dispose]();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
step.getStep().fail();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Track an async step with automatic error handling
|
||||||
|
*/
|
||||||
|
export async function trackStepAsync(name, fn, category) {
|
||||||
|
if (!globalClient) {
|
||||||
|
return fn();
|
||||||
|
}
|
||||||
|
const step = startStep(name, category);
|
||||||
|
try {
|
||||||
|
const result = await fn();
|
||||||
|
step[Symbol.dispose]();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
step.getStep().fail();
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=index.js.map
|
||||||
1
dist/esm/index.js.map
vendored
Normal file
1
dist/esm/index.js.map
vendored
Normal file
File diff suppressed because one or more lines are too long
195
dist/esm/journey.js
vendored
Normal file
195
dist/esm/journey.js
vendored
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
import { generateEventId } from './config';
|
||||||
|
/**
|
||||||
|
* Represents an active journey tracking session
|
||||||
|
*/
|
||||||
|
export class Journey {
|
||||||
|
constructor(name) {
|
||||||
|
this.metadata = {};
|
||||||
|
this.steps = [];
|
||||||
|
this._completed = false;
|
||||||
|
this._failed = false;
|
||||||
|
this.id = generateEventId();
|
||||||
|
this.name = name;
|
||||||
|
this.startedAt = new Date();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set user context for this journey
|
||||||
|
*/
|
||||||
|
setUser(id, email, data) {
|
||||||
|
this.user = { id, email, data };
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set metadata for this journey
|
||||||
|
*/
|
||||||
|
setMetadata(key, value) {
|
||||||
|
this.metadata[key] = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Start a new step in this journey
|
||||||
|
*/
|
||||||
|
startStep(name, category) {
|
||||||
|
// Complete any existing step
|
||||||
|
if (this.currentStep && this.currentStep.status === 'in_progress') {
|
||||||
|
this.currentStep.status = 'completed';
|
||||||
|
this.currentStep.endedAt = new Date();
|
||||||
|
}
|
||||||
|
const step = {
|
||||||
|
name,
|
||||||
|
category,
|
||||||
|
startedAt: new Date(),
|
||||||
|
status: 'in_progress',
|
||||||
|
data: {},
|
||||||
|
};
|
||||||
|
this.steps.push(step);
|
||||||
|
this.currentStep = step;
|
||||||
|
return new Step(step, this);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark the journey as completed
|
||||||
|
*/
|
||||||
|
complete() {
|
||||||
|
if (this.currentStep && this.currentStep.status === 'in_progress') {
|
||||||
|
this.currentStep.status = 'completed';
|
||||||
|
this.currentStep.endedAt = new Date();
|
||||||
|
}
|
||||||
|
this._completed = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark the journey as failed
|
||||||
|
*/
|
||||||
|
fail() {
|
||||||
|
if (this.currentStep && this.currentStep.status === 'in_progress') {
|
||||||
|
this.currentStep.status = 'failed';
|
||||||
|
this.currentStep.endedAt = new Date();
|
||||||
|
}
|
||||||
|
this._failed = true;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the journey context for an event
|
||||||
|
*/
|
||||||
|
getContext() {
|
||||||
|
return {
|
||||||
|
journeyId: this.id,
|
||||||
|
name: this.name,
|
||||||
|
currentStep: this.currentStep?.name,
|
||||||
|
startedAt: this.startedAt,
|
||||||
|
metadata: this.metadata,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the user context for this journey
|
||||||
|
*/
|
||||||
|
getUser() {
|
||||||
|
return this.user;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if the journey is complete
|
||||||
|
*/
|
||||||
|
get isComplete() {
|
||||||
|
return this._completed || this._failed;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get journey ID
|
||||||
|
*/
|
||||||
|
get journeyId() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents a step within a journey
|
||||||
|
*/
|
||||||
|
export class Step {
|
||||||
|
constructor(step, journey) {
|
||||||
|
this.step = step;
|
||||||
|
this.journey = journey;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set data for this step
|
||||||
|
*/
|
||||||
|
setData(key, value) {
|
||||||
|
this.step.data[key] = value;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark the step as completed
|
||||||
|
*/
|
||||||
|
complete() {
|
||||||
|
this.step.status = 'completed';
|
||||||
|
this.step.endedAt = new Date();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Mark the step as failed
|
||||||
|
*/
|
||||||
|
fail() {
|
||||||
|
this.step.status = 'failed';
|
||||||
|
this.step.endedAt = new Date();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the step name
|
||||||
|
*/
|
||||||
|
get name() {
|
||||||
|
return this.step.name;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the parent journey
|
||||||
|
*/
|
||||||
|
getJourney() {
|
||||||
|
return this.journey;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Journey scope that auto-completes on disposal
|
||||||
|
*/
|
||||||
|
export class JourneyScope {
|
||||||
|
constructor(journey, onComplete) {
|
||||||
|
this.journey = journey;
|
||||||
|
this.onComplete = onComplete;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the underlying journey
|
||||||
|
*/
|
||||||
|
getJourney() {
|
||||||
|
return this.journey;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Dispose of the journey scope
|
||||||
|
*/
|
||||||
|
[Symbol.dispose]() {
|
||||||
|
if (!this.journey.isComplete) {
|
||||||
|
this.journey.complete();
|
||||||
|
}
|
||||||
|
this.onComplete?.();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Step scope that auto-completes on disposal
|
||||||
|
*/
|
||||||
|
export class StepScope {
|
||||||
|
constructor(step) {
|
||||||
|
this.step = step;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the underlying step
|
||||||
|
*/
|
||||||
|
getStep() {
|
||||||
|
return this.step;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Set data on the step
|
||||||
|
*/
|
||||||
|
setData(key, value) {
|
||||||
|
this.step.setData(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Dispose of the step scope
|
||||||
|
*/
|
||||||
|
[Symbol.dispose]() {
|
||||||
|
if (this.step['step'].status === 'in_progress') {
|
||||||
|
this.step.complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=journey.js.map
|
||||||
1
dist/esm/journey.js.map
vendored
Normal file
1
dist/esm/journey.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"journey.js","sourceRoot":"","sources":["../../src/journey.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C;;GAEG;AACH,MAAM,OAAO,OAAO;IAWlB,YAAY,IAAY;QAPhB,aAAQ,GAA4B,EAAE,CAAC;QAEvC,UAAK,GAAkB,EAAE,CAAC;QAE1B,eAAU,GAAY,KAAK,CAAC;QAC5B,YAAO,GAAY,KAAK,CAAC;QAG/B,IAAI,CAAC,EAAE,GAAG,eAAe,EAAE,CAAC;QAC5B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,SAAS,GAAG,IAAI,IAAI,EAAE,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,EAAU,EAAE,KAAc,EAAE,IAA8B;QAChE,IAAI,CAAC,IAAI,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,GAAW,EAAE,KAAc;QACrC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QAC3B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,IAAY,EAAE,QAAiB;QACvC,6BAA6B;QAC7B,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IAIvB,YAAY,OAAgB,EAAE,UAAuB;QACnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC;YAC7B,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC1B,CAAC;QACD,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC;IACtB,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,SAAS;IAGpB,YAAY,IAAU;QACpB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAW,EAAE,KAAc;QACjC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,KAAK,aAAa,EAAE,CAAC;YAC/C,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvB,CAAC;IACH,CAAC;CACF"}
|
||||||
115
dist/esm/queue.js
vendored
Normal file
115
dist/esm/queue.js
vendored
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
const STORAGE_KEY = 'irontelemetry_queue';
|
||||||
|
/**
|
||||||
|
* Offline queue for storing events when the network is unavailable
|
||||||
|
*/
|
||||||
|
export class OfflineQueue {
|
||||||
|
constructor(maxSize = 500, debug = false) {
|
||||||
|
this.queue = [];
|
||||||
|
this.maxSize = maxSize;
|
||||||
|
this.debug = debug;
|
||||||
|
this.load();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Add an event to the queue
|
||||||
|
*/
|
||||||
|
enqueue(event) {
|
||||||
|
if (this.queue.length >= this.maxSize) {
|
||||||
|
// Remove oldest events to make room
|
||||||
|
this.queue.shift();
|
||||||
|
if (this.debug) {
|
||||||
|
console.log('[IronTelemetry] Queue full, dropping oldest event');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.queue.push(event);
|
||||||
|
this.save();
|
||||||
|
if (this.debug) {
|
||||||
|
console.log('[IronTelemetry] Event queued, queue size:', this.queue.length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get all queued events
|
||||||
|
*/
|
||||||
|
getAll() {
|
||||||
|
return [...this.queue];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Remove an event from the queue
|
||||||
|
*/
|
||||||
|
remove(eventId) {
|
||||||
|
this.queue = this.queue.filter((e) => e.eventId !== eventId);
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Clear all queued events
|
||||||
|
*/
|
||||||
|
clear() {
|
||||||
|
this.queue = [];
|
||||||
|
this.save();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Get the number of queued events
|
||||||
|
*/
|
||||||
|
get size() {
|
||||||
|
return this.queue.length;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if the queue is empty
|
||||||
|
*/
|
||||||
|
get isEmpty() {
|
||||||
|
return this.queue.length === 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Load queue from persistent storage
|
||||||
|
*/
|
||||||
|
load() {
|
||||||
|
try {
|
||||||
|
if (typeof localStorage !== 'undefined') {
|
||||||
|
const data = localStorage.getItem(STORAGE_KEY);
|
||||||
|
if (data) {
|
||||||
|
const parsed = JSON.parse(data);
|
||||||
|
this.queue = parsed.map((e) => this.deserializeEvent(e));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (this.debug) {
|
||||||
|
console.error('[IronTelemetry] Failed to load queue from storage:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Save queue to persistent storage
|
||||||
|
*/
|
||||||
|
save() {
|
||||||
|
try {
|
||||||
|
if (typeof localStorage !== 'undefined') {
|
||||||
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(this.queue));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
if (this.debug) {
|
||||||
|
console.error('[IronTelemetry] Failed to save queue to storage:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Deserialize an event from storage
|
||||||
|
*/
|
||||||
|
deserializeEvent(data) {
|
||||||
|
return {
|
||||||
|
...data,
|
||||||
|
timestamp: new Date(data.timestamp),
|
||||||
|
breadcrumbs: (data.breadcrumbs ?? []).map((b) => ({
|
||||||
|
...b,
|
||||||
|
timestamp: new Date(b.timestamp),
|
||||||
|
})),
|
||||||
|
journey: data.journey
|
||||||
|
? {
|
||||||
|
...data.journey,
|
||||||
|
startedAt: new Date(data.journey.startedAt),
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=queue.js.map
|
||||||
1
dist/esm/queue.js.map
vendored
Normal file
1
dist/esm/queue.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C;;GAEG;AACH,MAAM,OAAO,YAAY;IAKvB,YAAY,UAAkB,GAAG,EAAE,QAAiB,KAAK;QAFjD,UAAK,GAAqB,EAAE,CAAC;QAGnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAA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,IAAI,IAAI,CAAC,CAAC,CAAC,SAAmB,CAAC;aAC3C,CAAC,CAAC;YACH,OAAO,EAAE,IAAI,CAAC,OAAO;gBACnB,CAAC,CAAC;oBACE,GAAI,IAAI,CAAC,OAAmC;oBAC5C,SAAS,EAAE,IAAI,IAAI,CAAE,IAAI,CAAC,OAAmC,CAAC,SAAmB,CAAC;iBACnF;gBACH,CAAC,CAAC,SAAS;SACI,CAAC;IACtB,CAAC;CACF"}
|
||||||
100
dist/esm/transport.js
vendored
Normal file
100
dist/esm/transport.js
vendored
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* HTTP transport for sending events to the server
|
||||||
|
*/
|
||||||
|
export class Transport {
|
||||||
|
constructor(parsedDsn, apiBaseUrl, debug = false) {
|
||||||
|
this.apiBaseUrl = apiBaseUrl;
|
||||||
|
this.publicKey = parsedDsn.publicKey;
|
||||||
|
this.debug = debug;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Send an event to the server
|
||||||
|
*/
|
||||||
|
async send(event) {
|
||||||
|
const url = `${this.apiBaseUrl}/api/v1/events`;
|
||||||
|
try {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'X-Public-Key': this.publicKey,
|
||||||
|
},
|
||||||
|
body: JSON.stringify(this.serializeEvent(event)),
|
||||||
|
});
|
||||||
|
if (!response.ok) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
if (this.debug) {
|
||||||
|
console.error('[IronTelemetry] Failed to send event:', response.status, errorText);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: `HTTP ${response.status}: ${errorText}`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const result = await response.json();
|
||||||
|
if (this.debug) {
|
||||||
|
console.log('[IronTelemetry] Event sent successfully:', event.eventId);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: true,
|
||||||
|
eventId: result.eventId ?? event.eventId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
||||||
|
if (this.debug) {
|
||||||
|
console.error('[IronTelemetry] Failed to send event:', errorMessage);
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
success: false,
|
||||||
|
error: errorMessage,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Check if the server is reachable
|
||||||
|
*/
|
||||||
|
async isOnline() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${this.apiBaseUrl}/api/v1/health`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'X-Public-Key': this.publicKey,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
return response.ok;
|
||||||
|
}
|
||||||
|
catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Serialize an event for sending
|
||||||
|
*/
|
||||||
|
serializeEvent(event) {
|
||||||
|
return {
|
||||||
|
eventId: event.eventId,
|
||||||
|
timestamp: event.timestamp.toISOString(),
|
||||||
|
level: event.level,
|
||||||
|
message: event.message,
|
||||||
|
exception: event.exception,
|
||||||
|
user: event.user,
|
||||||
|
tags: event.tags,
|
||||||
|
extra: event.extra,
|
||||||
|
breadcrumbs: event.breadcrumbs.map((b) => ({
|
||||||
|
...b,
|
||||||
|
timestamp: b.timestamp.toISOString(),
|
||||||
|
})),
|
||||||
|
journey: event.journey
|
||||||
|
? {
|
||||||
|
...event.journey,
|
||||||
|
startedAt: event.journey.startedAt.toISOString(),
|
||||||
|
}
|
||||||
|
: undefined,
|
||||||
|
environment: event.environment,
|
||||||
|
appVersion: event.appVersion,
|
||||||
|
platform: event.platform,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=transport.js.map
|
||||||
1
dist/esm/transport.js.map
vendored
Normal file
1
dist/esm/transport.js.map
vendored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E,KAAK,CAAC,KAAK;YAClB,WAAW,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;gBACzC,GAAG,CAAC;gBACJ,SAAS,EAAE,CAAC,CAAC,SAAS,CAAC,WAAW,EAAE;aACrC,CAAC,CAAC;YACH,OAAO,EAAE,KAAK,CAAC,OAAO;gBACpB,CAAC,CAAC;oBACE,GAAG,KAAK,CAAC,OAAO;oBAChB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE;iBACjD;gBACH,CAAC,CAAC,SAAS;YACb,WAAW,EAAE,KAAK,CAAC,WAAW;YAC9B,UAAU,EAAE,KAAK,CAAC,UAAU;YAC5B,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC;IACJ,CAAC;CACF"}
|
||||||
2
dist/esm/types.js
vendored
Normal file
2
dist/esm/types.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
export {};
|
||||||
|
//# sourceMappingURL=types.js.map
|
||||||
1
dist/esm/types.js.map
vendored
Normal file
1
dist/esm/types.js.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
||||||
32
dist/types/breadcrumbs.d.ts
vendored
Normal file
32
dist/types/breadcrumbs.d.ts
vendored
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
import type { Breadcrumb, BreadcrumbCategory, SeverityLevel } from './types';
|
||||||
|
/**
|
||||||
|
* Manages breadcrumbs for an SDK instance
|
||||||
|
*/
|
||||||
|
export declare class BreadcrumbManager {
|
||||||
|
private readonly maxBreadcrumbs;
|
||||||
|
private breadcrumbs;
|
||||||
|
constructor(maxBreadcrumbs?: number);
|
||||||
|
/**
|
||||||
|
* Add a breadcrumb
|
||||||
|
*/
|
||||||
|
add(message: string, category?: BreadcrumbCategory, level?: SeverityLevel, data?: Record<string, unknown>): void;
|
||||||
|
/**
|
||||||
|
* Add a breadcrumb from a full Breadcrumb object
|
||||||
|
*/
|
||||||
|
addBreadcrumb(breadcrumb: Omit<Breadcrumb, 'timestamp'> & {
|
||||||
|
timestamp?: Date;
|
||||||
|
}): void;
|
||||||
|
/**
|
||||||
|
* Get all breadcrumbs
|
||||||
|
*/
|
||||||
|
getAll(): Breadcrumb[];
|
||||||
|
/**
|
||||||
|
* Clear all breadcrumbs
|
||||||
|
*/
|
||||||
|
clear(): void;
|
||||||
|
/**
|
||||||
|
* Get the number of breadcrumbs
|
||||||
|
*/
|
||||||
|
get count(): number;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=breadcrumbs.d.ts.map
|
||||||
1
dist/types/breadcrumbs.d.ts.map
vendored
Normal file
1
dist/types/breadcrumbs.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"breadcrumbs.d.ts","sourceRoot":"","sources":["../../src/breadcrumbs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE7E;;GAEG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAS;IACxC,OAAO,CAAC,WAAW,CAAoB;gBAE3B,cAAc,GAAE,MAAY;IAIxC;;OAEG;IACH,GAAG,CACD,OAAO,EAAE,MAAM,EACf,QAAQ,GAAE,kBAA6B,EACvC,KAAK,GAAE,aAAsB,EAC7B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC7B,IAAI;IAiBP;;OAEG;IACH,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,GAAG;QAAE,SAAS,CAAC,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI;IAarF;;OAEG;IACH,MAAM,IAAI,UAAU,EAAE;IAItB;;OAEG;IACH,KAAK,IAAI,IAAI;IAIb;;OAEG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;CACF"}
|
||||||
116
dist/types/client.d.ts
vendored
Normal file
116
dist/types/client.d.ts
vendored
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import type { TelemetryOptions, SeverityLevel, Breadcrumb, BreadcrumbCategory, SendResult } from './types';
|
||||||
|
import { JourneyScope, StepScope } from './journey';
|
||||||
|
/**
|
||||||
|
* Global debug logging flag. When enabled, all IronTelemetry clients
|
||||||
|
* will output debug information to the console.
|
||||||
|
*/
|
||||||
|
export declare let enableDebugLogging: boolean;
|
||||||
|
/**
|
||||||
|
* Enable or disable global debug logging for all TelemetryClient instances.
|
||||||
|
* @param enabled Whether to enable debug logging
|
||||||
|
*/
|
||||||
|
export declare function setDebugLogging(enabled: boolean): void;
|
||||||
|
/**
|
||||||
|
* Main IronTelemetry client class
|
||||||
|
*/
|
||||||
|
export declare class TelemetryClient {
|
||||||
|
private readonly options;
|
||||||
|
private readonly transport;
|
||||||
|
private readonly queue;
|
||||||
|
private readonly breadcrumbs;
|
||||||
|
private tags;
|
||||||
|
private extra;
|
||||||
|
private user?;
|
||||||
|
private currentJourney?;
|
||||||
|
private flushInterval?;
|
||||||
|
private isInitialized;
|
||||||
|
constructor(options: TelemetryOptions);
|
||||||
|
/**
|
||||||
|
* Capture an exception
|
||||||
|
*/
|
||||||
|
captureException(error: Error | unknown, extra?: Record<string, unknown>): Promise<SendResult>;
|
||||||
|
/**
|
||||||
|
* Capture a message
|
||||||
|
*/
|
||||||
|
captureMessage(message: string, level?: SeverityLevel): Promise<SendResult>;
|
||||||
|
/**
|
||||||
|
* Log a structured message with title, message, and optional data.
|
||||||
|
* Useful for structured logging that differentiates the log title from its details.
|
||||||
|
* @param level The severity level of the log
|
||||||
|
* @param title A short, descriptive title for the log entry
|
||||||
|
* @param message Optional detailed message
|
||||||
|
* @param data Optional additional data to attach to the log
|
||||||
|
*/
|
||||||
|
logMessage(level: SeverityLevel, title: string, message?: string, data?: Record<string, unknown>): Promise<SendResult>;
|
||||||
|
/**
|
||||||
|
* Add a breadcrumb
|
||||||
|
*/
|
||||||
|
addBreadcrumb(message: string, category?: BreadcrumbCategory, level?: SeverityLevel, data?: Record<string, unknown>): void;
|
||||||
|
addBreadcrumb(breadcrumb: Omit<Breadcrumb, 'timestamp'>): void;
|
||||||
|
/**
|
||||||
|
* Get a copy of the current breadcrumbs list.
|
||||||
|
* @returns A read-only array of breadcrumbs
|
||||||
|
*/
|
||||||
|
getBreadcrumbs(): ReadonlyArray<Breadcrumb>;
|
||||||
|
/**
|
||||||
|
* Clear all breadcrumbs.
|
||||||
|
*/
|
||||||
|
clearBreadcrumbs(): void;
|
||||||
|
/**
|
||||||
|
* Set user context
|
||||||
|
*/
|
||||||
|
setUser(id: string, email?: string, data?: Record<string, unknown>): void;
|
||||||
|
/**
|
||||||
|
* Clear user context
|
||||||
|
*/
|
||||||
|
clearUser(): void;
|
||||||
|
/**
|
||||||
|
* Set a tag
|
||||||
|
*/
|
||||||
|
setTag(key: string, value: string): void;
|
||||||
|
/**
|
||||||
|
* Set extra context
|
||||||
|
*/
|
||||||
|
setExtra(key: string, value: unknown): void;
|
||||||
|
/**
|
||||||
|
* Start a new journey
|
||||||
|
*/
|
||||||
|
startJourney(name: string): JourneyScope;
|
||||||
|
/**
|
||||||
|
* Start a step in the current journey
|
||||||
|
*/
|
||||||
|
startStep(name: string, category?: string): StepScope;
|
||||||
|
/**
|
||||||
|
* Flush pending events
|
||||||
|
*/
|
||||||
|
flush(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Close the client
|
||||||
|
*/
|
||||||
|
close(): void;
|
||||||
|
/**
|
||||||
|
* Create a telemetry event
|
||||||
|
*/
|
||||||
|
private createEvent;
|
||||||
|
/**
|
||||||
|
* Send an event
|
||||||
|
*/
|
||||||
|
private sendEvent;
|
||||||
|
/**
|
||||||
|
* Process offline queue
|
||||||
|
*/
|
||||||
|
private processQueue;
|
||||||
|
/**
|
||||||
|
* Parse an error into exception info
|
||||||
|
*/
|
||||||
|
private parseException;
|
||||||
|
/**
|
||||||
|
* Parse a stack trace string into frames
|
||||||
|
*/
|
||||||
|
private parseStackTrace;
|
||||||
|
/**
|
||||||
|
* Get platform information
|
||||||
|
*/
|
||||||
|
private getPlatformInfo;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=client.d.ts.map
|
||||||
1
dist/types/client.d.ts.map
vendored
Normal file
1
dist/types/client.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAEhB,aAAa,EACb,UAAU,EACV,kBAAkB,EAKlB,UAAU,EACX,MAAM,SAAS,CAAC;AAKjB,OAAO,EAAW,YAAY,EAAQ,SAAS,EAAE,MAAM,WAAW,CAAC;AAEnE;;;GAGG;AACH,eAAO,IAAI,kBAAkB,SAAQ,CAAC;AAEtC;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAEtD;AAED;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAoC;IAC5D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAsB;IAC5C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAoB;IAEhD,OAAO,CAAC,IAAI,CAA8B;IAC1C,OAAO,CAAC,KAAK,CAA+B;IAC5C,OAAO,CAAC,IAAI,CAAC,CAAO;IACpB,OAAO,CAAC,cAAc,CAAC,CAAU;IACjC,OAAO,CAAC,aAAa,CAAC,CAAiC;IACvD,OAAO,CAAC,aAAa,CAAkB;gBAE3B,OAAO,EAAE,gBAAgB;IAmBrC;;OAEG;IACG,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAA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KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAI5B;;OAEG;IACH,KAAK,IAAI,IAAI;IAMb;;OAEG;IACH,OAAO,CAAC,WAAW;IAwBnB;;OAEG;YACW,SAAS;IA+BvB;;OAEG;YACW,YAAY;IAoB1B;;OAEG;IACH,OAAO,CAAC,cAAc;IAetB;;OAEG;IACH,OAAO,CAAC,eAAe;IAkCvB;;OAEG;IACH,OAAO,CAAC,eAAe;CAsBxB"}
|
||||||
21
dist/types/config.d.ts
vendored
Normal file
21
dist/types/config.d.ts
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
import type { TelemetryOptions, ParsedDsn } from './types';
|
||||||
|
/**
|
||||||
|
* Default configuration values
|
||||||
|
*/
|
||||||
|
export declare const DEFAULT_OPTIONS: Partial<TelemetryOptions>;
|
||||||
|
/**
|
||||||
|
* Parse a DSN string into its components
|
||||||
|
* Format: https://pk_live_xxx@irontelemetry.com
|
||||||
|
*/
|
||||||
|
export declare function parseDsn(dsn: string): ParsedDsn;
|
||||||
|
/**
|
||||||
|
* Validate and merge options with defaults
|
||||||
|
*/
|
||||||
|
export declare function resolveOptions(options: TelemetryOptions): Required<TelemetryOptions> & {
|
||||||
|
parsedDsn: ParsedDsn;
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* Generate a unique event ID
|
||||||
|
*/
|
||||||
|
export declare function generateEventId(): string;
|
||||||
|
//# sourceMappingURL=config.d.ts.map
|
||||||
1
dist/types/config.d.ts.map
vendored
Normal file
1
dist/types/config.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,OAAO,CAAC,gBAAgB,CAMrD,CAAC;AAEF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAwB/C;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,gBAAgB,GAAG,QAAQ,CAAC,gBAAgB,CAAC,GAAG;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,CAgB/G;AAED;;GAEG;AACH,wBAAgB,eAAe,IAAI,MAAM,CAIxC"}
|
||||||
96
dist/types/index.d.ts
vendored
Normal file
96
dist/types/index.d.ts
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
import { TelemetryClient } from './client';
|
||||||
|
import type { TelemetryOptions, SeverityLevel, Breadcrumb, BreadcrumbCategory, SendResult } from './types';
|
||||||
|
import { JourneyScope, StepScope } from './journey';
|
||||||
|
export type { TelemetryOptions, TelemetryEvent, SeverityLevel, Breadcrumb, BreadcrumbCategory, User, SendResult, ExceptionInfo, StackFrame, PlatformInfo, JourneyContext, JourneyStep, ParsedDsn, } from './types';
|
||||||
|
export { TelemetryClient } from './client';
|
||||||
|
export { Journey, JourneyScope, Step, StepScope } from './journey';
|
||||||
|
/**
|
||||||
|
* Initialize the global IronTelemetry client
|
||||||
|
*/
|
||||||
|
export declare function init(optionsOrDsn: TelemetryOptions | string): TelemetryClient;
|
||||||
|
/**
|
||||||
|
* Get the global client instance
|
||||||
|
*/
|
||||||
|
export declare function getClient(): TelemetryClient | null;
|
||||||
|
/**
|
||||||
|
* Capture an exception using the global client
|
||||||
|
*/
|
||||||
|
export declare function captureException(error: Error | unknown, extra?: Record<string, unknown>): Promise<SendResult>;
|
||||||
|
/**
|
||||||
|
* Capture a message using the global client
|
||||||
|
*/
|
||||||
|
export declare function captureMessage(message: string, level?: SeverityLevel): Promise<SendResult>;
|
||||||
|
/**
|
||||||
|
* Add a breadcrumb using the global client
|
||||||
|
*/
|
||||||
|
export declare function addBreadcrumb(message: string, category?: BreadcrumbCategory, level?: SeverityLevel, data?: Record<string, unknown>): void;
|
||||||
|
export declare function addBreadcrumb(breadcrumb: Omit<Breadcrumb, 'timestamp'>): void;
|
||||||
|
/**
|
||||||
|
* Set user context using the global client
|
||||||
|
*/
|
||||||
|
export declare function setUser(id: string, email?: string, data?: Record<string, unknown>): void;
|
||||||
|
/**
|
||||||
|
* Clear user context using the global client
|
||||||
|
*/
|
||||||
|
export declare function clearUser(): void;
|
||||||
|
/**
|
||||||
|
* Set a tag using the global client
|
||||||
|
*/
|
||||||
|
export declare function setTag(key: string, value: string): void;
|
||||||
|
/**
|
||||||
|
* Set extra context using the global client
|
||||||
|
*/
|
||||||
|
export declare function setExtra(key: string, value: unknown): void;
|
||||||
|
/**
|
||||||
|
* Start a journey using the global client
|
||||||
|
*/
|
||||||
|
export declare function startJourney(name: string): JourneyScope;
|
||||||
|
/**
|
||||||
|
* Start a step in the current journey using the global client
|
||||||
|
*/
|
||||||
|
export declare function startStep(name: string, category?: string): StepScope;
|
||||||
|
/**
|
||||||
|
* Flush pending events using the global client
|
||||||
|
*/
|
||||||
|
export declare function flush(): Promise<void>;
|
||||||
|
/**
|
||||||
|
* Close the global client
|
||||||
|
*/
|
||||||
|
export declare function close(): void;
|
||||||
|
declare const IronTelemetry: {
|
||||||
|
init: typeof init;
|
||||||
|
getClient: typeof getClient;
|
||||||
|
captureException: typeof captureException;
|
||||||
|
captureMessage: typeof captureMessage;
|
||||||
|
addBreadcrumb: typeof addBreadcrumb;
|
||||||
|
setUser: typeof setUser;
|
||||||
|
clearUser: typeof clearUser;
|
||||||
|
setTag: typeof setTag;
|
||||||
|
setExtra: typeof setExtra;
|
||||||
|
startJourney: typeof startJourney;
|
||||||
|
startStep: typeof startStep;
|
||||||
|
flush: typeof flush;
|
||||||
|
close: typeof close;
|
||||||
|
};
|
||||||
|
export default IronTelemetry;
|
||||||
|
/**
|
||||||
|
* Enable the Error.prototype.capture() extension.
|
||||||
|
* This is opt-in to avoid TypeScript conflicts in projects that create
|
||||||
|
* Error-like objects without the capture method.
|
||||||
|
*
|
||||||
|
* After calling this, you can use: throw new Error('msg').capture()
|
||||||
|
*/
|
||||||
|
export declare function enableErrorCapture(): void;
|
||||||
|
/**
|
||||||
|
* Set up global unhandled exception handler
|
||||||
|
*/
|
||||||
|
export declare function useUnhandledExceptionHandler(): void;
|
||||||
|
/**
|
||||||
|
* Track a step with automatic error handling
|
||||||
|
*/
|
||||||
|
export declare function trackStep<T>(name: string, fn: () => T, category?: string): T;
|
||||||
|
/**
|
||||||
|
* Track an async step with automatic error handling
|
||||||
|
*/
|
||||||
|
export declare function trackStepAsync<T>(name: string, fn: () => Promise<T>, category?: string): Promise<T>;
|
||||||
|
//# sourceMappingURL=index.d.ts.map
|
||||||
1
dist/types/index.d.ts.map
vendored
Normal file
1
dist/types/index.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,KAAK,EACV,gBAAgB,EAEhB,aAAa,EACb,UAAU,EACV,kBAAkB,EAElB,UAAU,EACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAGpD,YAAY,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,UAAU,EACV,aAAa,EACb,UAAU,EACV,YAAY,EACZ,cAAc,EACd,WAAW,EACX,SAAS,GACV,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAKnE;;GAEG;AACH,wBAAgB,IAAI,CAAC,YAAY,EAAE,gBAAgB,GAAG,MAAM,GAAG,eAAe,CAI7E;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,eAAe,GAAG,IAAI,CAElD;AAED;;GAEG;AACH,w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GAEG;AACH,wBAAgB,KAAK,IAAI,IAAI,CAK5B;AAGD,QAAA,MAAM,aAAa;;;;;;;;;;;;;;CAclB,CAAC;AAEF,eAAe,aAAa,CAAC;AAE7B;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CASzC;AAMD;;GAEG;AACH,wBAAgB,4BAA4B,IAAI,IAAI,CAoBnD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,CAAC,CAe5E;AAED;;GAEG;AACH,wBAAsB,cAAc,CAAC,CAAC,EACpC,IAAI,EAAE,MAAM,EACZ,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,CAAC,CAAC,CAeZ"}
|
||||||
116
dist/types/journey.d.ts
vendored
Normal file
116
dist/types/journey.d.ts
vendored
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
import type { JourneyContext, JourneyStep, User } from './types';
|
||||||
|
/**
|
||||||
|
* Represents an active journey tracking session
|
||||||
|
*/
|
||||||
|
export declare class Journey {
|
||||||
|
private readonly id;
|
||||||
|
private readonly name;
|
||||||
|
private readonly startedAt;
|
||||||
|
private metadata;
|
||||||
|
private user?;
|
||||||
|
private steps;
|
||||||
|
private currentStep?;
|
||||||
|
private _completed;
|
||||||
|
private _failed;
|
||||||
|
constructor(name: string);
|
||||||
|
/**
|
||||||
|
* Set user context for this journey
|
||||||
|
*/
|
||||||
|
setUser(id: string, email?: string, data?: Record<string, unknown>): this;
|
||||||
|
/**
|
||||||
|
* Set metadata for this journey
|
||||||
|
*/
|
||||||
|
setMetadata(key: string, value: unknown): this;
|
||||||
|
/**
|
||||||
|
* Start a new step in this journey
|
||||||
|
*/
|
||||||
|
startStep(name: string, category?: string): Step;
|
||||||
|
/**
|
||||||
|
* Mark the journey as completed
|
||||||
|
*/
|
||||||
|
complete(): void;
|
||||||
|
/**
|
||||||
|
* Mark the journey as failed
|
||||||
|
*/
|
||||||
|
fail(): void;
|
||||||
|
/**
|
||||||
|
* Get the journey context for an event
|
||||||
|
*/
|
||||||
|
getContext(): JourneyContext;
|
||||||
|
/**
|
||||||
|
* Get the user context for this journey
|
||||||
|
*/
|
||||||
|
getUser(): User | undefined;
|
||||||
|
/**
|
||||||
|
* Check if the journey is complete
|
||||||
|
*/
|
||||||
|
get isComplete(): boolean;
|
||||||
|
/**
|
||||||
|
* Get journey ID
|
||||||
|
*/
|
||||||
|
get journeyId(): string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Represents a step within a journey
|
||||||
|
*/
|
||||||
|
export declare class Step {
|
||||||
|
private readonly step;
|
||||||
|
private readonly journey;
|
||||||
|
constructor(step: JourneyStep, journey: Journey);
|
||||||
|
/**
|
||||||
|
* Set data for this step
|
||||||
|
*/
|
||||||
|
setData(key: string, value: unknown): this;
|
||||||
|
/**
|
||||||
|
* Mark the step as completed
|
||||||
|
*/
|
||||||
|
complete(): void;
|
||||||
|
/**
|
||||||
|
* Mark the step as failed
|
||||||
|
*/
|
||||||
|
fail(): void;
|
||||||
|
/**
|
||||||
|
* Get the step name
|
||||||
|
*/
|
||||||
|
get name(): string;
|
||||||
|
/**
|
||||||
|
* Get the parent journey
|
||||||
|
*/
|
||||||
|
getJourney(): Journey;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Journey scope that auto-completes on disposal
|
||||||
|
*/
|
||||||
|
export declare class JourneyScope {
|
||||||
|
private readonly journey;
|
||||||
|
private readonly onComplete?;
|
||||||
|
constructor(journey: Journey, onComplete?: () => void);
|
||||||
|
/**
|
||||||
|
* Get the underlying journey
|
||||||
|
*/
|
||||||
|
getJourney(): Journey;
|
||||||
|
/**
|
||||||
|
* Dispose of the journey scope
|
||||||
|
*/
|
||||||
|
[Symbol.dispose](): void;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Step scope that auto-completes on disposal
|
||||||
|
*/
|
||||||
|
export declare class StepScope {
|
||||||
|
private readonly step;
|
||||||
|
constructor(step: Step);
|
||||||
|
/**
|
||||||
|
* Get the underlying step
|
||||||
|
*/
|
||||||
|
getStep(): Step;
|
||||||
|
/**
|
||||||
|
* Set data on the step
|
||||||
|
*/
|
||||||
|
setData(key: string, value: unknown): this;
|
||||||
|
/**
|
||||||
|
* Dispose of the step scope
|
||||||
|
*/
|
||||||
|
[Symbol.dispose](): void;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=journey.d.ts.map
|
||||||
1
dist/types/journey.d.ts.map
vendored
Normal file
1
dist/types/journey.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"journey.d.ts","sourceRoot":"","sources":["../../src/journey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAGjE;;GAEG;AACH,qBAAa,OAAO;IAClB,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAS;IAC5B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAO;IACjC,OAAO,CAAC,QAAQ,CAA+B;IAC/C,OAAO,CAAC,IAAI,CAAC,CAAO;IACpB,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,WAAW,CAAC,CAAc;IAClC,OAAO,CAAC,UAAU,CAAkB;IACpC,OAAO,CAAC,OAAO,CAAkB;gBAErB,IAAI,EAAE,MAAM;IAMxB;;OAEG;IACH,OAAO,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI;IAKzE;;OAEG;IACH,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAK9C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AG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI;IAK1C;;OAEG;IACH,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;CAKzB"}
|
||||||
47
dist/types/queue.d.ts
vendored
Normal file
47
dist/types/queue.d.ts
vendored
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
import type { TelemetryEvent } from './types';
|
||||||
|
/**
|
||||||
|
* Offline queue for storing events when the network is unavailable
|
||||||
|
*/
|
||||||
|
export declare class OfflineQueue {
|
||||||
|
private readonly maxSize;
|
||||||
|
private readonly debug;
|
||||||
|
private queue;
|
||||||
|
constructor(maxSize?: number, debug?: boolean);
|
||||||
|
/**
|
||||||
|
* Add an event to the queue
|
||||||
|
*/
|
||||||
|
enqueue(event: TelemetryEvent): void;
|
||||||
|
/**
|
||||||
|
* Get all queued events
|
||||||
|
*/
|
||||||
|
getAll(): TelemetryEvent[];
|
||||||
|
/**
|
||||||
|
* Remove an event from the queue
|
||||||
|
*/
|
||||||
|
remove(eventId: string): void;
|
||||||
|
/**
|
||||||
|
* Clear all queued events
|
||||||
|
*/
|
||||||
|
clear(): void;
|
||||||
|
/**
|
||||||
|
* Get the number of queued events
|
||||||
|
*/
|
||||||
|
get size(): number;
|
||||||
|
/**
|
||||||
|
* Check if the queue is empty
|
||||||
|
*/
|
||||||
|
get isEmpty(): boolean;
|
||||||
|
/**
|
||||||
|
* Load queue from persistent storage
|
||||||
|
*/
|
||||||
|
private load;
|
||||||
|
/**
|
||||||
|
* Save queue to persistent storage
|
||||||
|
*/
|
||||||
|
private save;
|
||||||
|
/**
|
||||||
|
* Deserialize an event from storage
|
||||||
|
*/
|
||||||
|
private deserializeEvent;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=queue.d.ts.map
|
||||||
1
dist/types/queue.d.ts.map
vendored
Normal file
1
dist/types/queue.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAI9C;;GAEG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;IAChC,OAAO,CAAC,KAAK,CAAwB;gBAEzB,OAAO,GAAE,MAAY,EAAE,KAAK,GAAE,OAAe;IAMzD;;OAEG;IACH,OAAO,CAAC,KAAK,EAAE,cAAc,GAAG,IAAI;IAiBpC;;OAEG;IACH,MAAM,IAAI,cAAc,EAAE;IAI1B;;OAEG;IACH,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAK7B;;OAEG;IACH,KAAK,IAAI,IAAI;IAKb;;OAEG;IACH,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED;;OAEG;IACH,IAAI,OAAO,IAAI,OAAO,CAErB;IAED;;OAEG;IACH,OAAO,CAAC,IAAI;IAgBZ;;OAEG;IACH,OAAO,CAAC,IAAI;IAYZ;;OAEG;IACH,OAAO,CAAC,gBAAgB;CAgBzB"}
|
||||||
23
dist/types/transport.d.ts
vendored
Normal file
23
dist/types/transport.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import type { TelemetryEvent, SendResult, ParsedDsn } from './types';
|
||||||
|
/**
|
||||||
|
* HTTP transport for sending events to the server
|
||||||
|
*/
|
||||||
|
export declare class Transport {
|
||||||
|
private readonly apiBaseUrl;
|
||||||
|
private readonly publicKey;
|
||||||
|
private readonly debug;
|
||||||
|
constructor(parsedDsn: ParsedDsn, apiBaseUrl: string, debug?: boolean);
|
||||||
|
/**
|
||||||
|
* Send an event to the server
|
||||||
|
*/
|
||||||
|
send(event: TelemetryEvent): Promise<SendResult>;
|
||||||
|
/**
|
||||||
|
* Check if the server is reachable
|
||||||
|
*/
|
||||||
|
isOnline(): Promise<boolean>;
|
||||||
|
/**
|
||||||
|
* Serialize an event for sending
|
||||||
|
*/
|
||||||
|
private serializeEvent;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=transport.d.ts.map
|
||||||
1
dist/types/transport.d.ts.map
vendored
Normal file
1
dist/types/transport.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAErE;;GAEG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAU;gBAEpB,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe;IAM5E;;OAEG;IACG,IAAI,CAAC,KAAK,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;IA8CtD;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC;IAclC;;OAEG;IACH,OAAO,CAAC,cAAc;CAyBvB"}
|
||||||
196
dist/types/types.d.ts
vendored
Normal file
196
dist/types/types.d.ts
vendored
Normal file
@ -0,0 +1,196 @@
|
|||||||
|
/**
|
||||||
|
* Severity levels for events
|
||||||
|
*/
|
||||||
|
export type SeverityLevel = 'debug' | 'info' | 'warning' | 'error' | 'fatal';
|
||||||
|
/**
|
||||||
|
* Breadcrumb categories
|
||||||
|
*/
|
||||||
|
export type BreadcrumbCategory = 'ui' | 'user' | 'http' | 'navigation' | 'console' | 'auth' | 'business' | 'notification' | 'custom';
|
||||||
|
/**
|
||||||
|
* A breadcrumb representing an event leading up to an error
|
||||||
|
*/
|
||||||
|
export interface Breadcrumb {
|
||||||
|
/** Timestamp when the breadcrumb was created */
|
||||||
|
timestamp: Date;
|
||||||
|
/** Category of the breadcrumb */
|
||||||
|
category: BreadcrumbCategory;
|
||||||
|
/** Human-readable message */
|
||||||
|
message: string;
|
||||||
|
/** Severity level */
|
||||||
|
level?: SeverityLevel;
|
||||||
|
/** Additional data */
|
||||||
|
data?: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* User information for context
|
||||||
|
*/
|
||||||
|
export interface User {
|
||||||
|
/** Unique identifier for the user */
|
||||||
|
id: string;
|
||||||
|
/** Email address */
|
||||||
|
email?: string;
|
||||||
|
/** Display name */
|
||||||
|
name?: string;
|
||||||
|
/** Additional user data */
|
||||||
|
data?: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Exception/error information
|
||||||
|
*/
|
||||||
|
export interface ExceptionInfo {
|
||||||
|
/** Exception type/class name */
|
||||||
|
type: string;
|
||||||
|
/** Error message */
|
||||||
|
message: string;
|
||||||
|
/** Stack trace */
|
||||||
|
stacktrace?: StackFrame[];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Stack frame information
|
||||||
|
*/
|
||||||
|
export interface StackFrame {
|
||||||
|
/** Function name */
|
||||||
|
function?: string;
|
||||||
|
/** File name */
|
||||||
|
filename?: string;
|
||||||
|
/** Line number */
|
||||||
|
lineno?: number;
|
||||||
|
/** Column number */
|
||||||
|
colno?: number;
|
||||||
|
/** Source context around the line */
|
||||||
|
context?: string[];
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Event payload sent to the server
|
||||||
|
*/
|
||||||
|
export interface TelemetryEvent {
|
||||||
|
/** Unique event ID */
|
||||||
|
eventId: string;
|
||||||
|
/** Event timestamp */
|
||||||
|
timestamp: Date;
|
||||||
|
/** Severity level */
|
||||||
|
level: SeverityLevel;
|
||||||
|
/** Message */
|
||||||
|
message?: string;
|
||||||
|
/** Exception information */
|
||||||
|
exception?: ExceptionInfo;
|
||||||
|
/** User context */
|
||||||
|
user?: User;
|
||||||
|
/** Tags for categorization */
|
||||||
|
tags: Record<string, string>;
|
||||||
|
/** Extra contextual data */
|
||||||
|
extra: Record<string, unknown>;
|
||||||
|
/** Breadcrumbs leading up to this event */
|
||||||
|
breadcrumbs: Breadcrumb[];
|
||||||
|
/** Journey context if in a journey */
|
||||||
|
journey?: JourneyContext;
|
||||||
|
/** Environment name */
|
||||||
|
environment?: string;
|
||||||
|
/** Application version */
|
||||||
|
appVersion?: string;
|
||||||
|
/** Platform information */
|
||||||
|
platform: PlatformInfo;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Platform/runtime information
|
||||||
|
*/
|
||||||
|
export interface PlatformInfo {
|
||||||
|
/** Platform name (browser, node, etc.) */
|
||||||
|
name: string;
|
||||||
|
/** Platform version */
|
||||||
|
version?: string;
|
||||||
|
/** Operating system */
|
||||||
|
os?: string;
|
||||||
|
/** Browser/runtime user agent */
|
||||||
|
userAgent?: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Journey context for tracking user flows
|
||||||
|
*/
|
||||||
|
export interface JourneyContext {
|
||||||
|
/** Journey ID */
|
||||||
|
journeyId: string;
|
||||||
|
/** Journey name */
|
||||||
|
name: string;
|
||||||
|
/** Current step name */
|
||||||
|
currentStep?: string;
|
||||||
|
/** Journey start time */
|
||||||
|
startedAt: Date;
|
||||||
|
/** Journey metadata */
|
||||||
|
metadata: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Step within a journey
|
||||||
|
*/
|
||||||
|
export interface JourneyStep {
|
||||||
|
/** Step name */
|
||||||
|
name: string;
|
||||||
|
/** Step category */
|
||||||
|
category?: string;
|
||||||
|
/** Step start time */
|
||||||
|
startedAt: Date;
|
||||||
|
/** Step end time */
|
||||||
|
endedAt?: Date;
|
||||||
|
/** Step status */
|
||||||
|
status: 'in_progress' | 'completed' | 'failed';
|
||||||
|
/** Step data */
|
||||||
|
data: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Options for initializing the SDK
|
||||||
|
*/
|
||||||
|
export interface TelemetryOptions {
|
||||||
|
/**
|
||||||
|
* Data Source Name (DSN) containing the public key
|
||||||
|
* Format: https://pk_live_xxx@irontelemetry.com
|
||||||
|
*/
|
||||||
|
dsn: string;
|
||||||
|
/** Environment name (e.g., 'production', 'staging') */
|
||||||
|
environment?: string;
|
||||||
|
/** Application version */
|
||||||
|
appVersion?: string;
|
||||||
|
/** Sample rate for events (0.0 to 1.0) */
|
||||||
|
sampleRate?: number;
|
||||||
|
/** Maximum number of breadcrumbs to keep */
|
||||||
|
maxBreadcrumbs?: number;
|
||||||
|
/** Enable debug logging */
|
||||||
|
debug?: boolean;
|
||||||
|
/**
|
||||||
|
* Hook called before sending an event
|
||||||
|
* Return false or null to drop the event, or return the (modified) event to send
|
||||||
|
*/
|
||||||
|
beforeSend?: (event: TelemetryEvent) => boolean | TelemetryEvent | null;
|
||||||
|
/** Enable offline queue for failed events */
|
||||||
|
enableOfflineQueue?: boolean;
|
||||||
|
/** Maximum size of the offline queue */
|
||||||
|
maxOfflineQueueSize?: number;
|
||||||
|
/** API base URL (defaults to parsed from DSN) */
|
||||||
|
apiBaseUrl?: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Parsed DSN components
|
||||||
|
*/
|
||||||
|
export interface ParsedDsn {
|
||||||
|
/** Public key */
|
||||||
|
publicKey: string;
|
||||||
|
/** Host */
|
||||||
|
host: string;
|
||||||
|
/** Protocol (http or https) */
|
||||||
|
protocol: string;
|
||||||
|
/** Full API base URL */
|
||||||
|
apiBaseUrl: string;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Result of sending an event
|
||||||
|
*/
|
||||||
|
export interface SendResult {
|
||||||
|
/** Whether the send was successful */
|
||||||
|
success: boolean;
|
||||||
|
/** Event ID if successful */
|
||||||
|
eventId?: string;
|
||||||
|
/** Error message if failed */
|
||||||
|
error?: string;
|
||||||
|
/** Whether the event was queued for retry */
|
||||||
|
queued?: boolean;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=types.d.ts.map
|
||||||
1
dist/types/types.d.ts.map
vendored
Normal file
1
dist/types/types.d.ts.map
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,OAAO,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAC1B,IAAI,GACJ,MAAM,GACN,MAAM,GACN,YAAY,GACZ,SAAS,GACT,MAAM,GACN,UAAU,GACV,cAAc,GACd,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,gDAAgD;IAChD,SAAS,EAAE,IAAI,CAAC;IAChB,iCAAiC;IACjC,QAAQ,EAAE,kBAAkB,CAAC;IAC7B,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,qBAAqB;IACrB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,sBAAsB;IACtB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,IAAI;IACnB,qCAAqC;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,oBAAoB;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,mBAAmB;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,2BAA2B;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,oBAAoB;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,kBAAkB;IAClB,UAAU,CAAC,EAAE,UAAU,EAAE,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,oBAAoB;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IA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