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>
71 lines
2.3 KiB
JavaScript
71 lines
2.3 KiB
JavaScript
"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
|