@observa/sdk 2.4.0 → 2.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +140 -176
  2. package/dist/apis/ingestApi.d.ts +1 -15
  3. package/dist/apis/ingestApi.d.ts.map +1 -1
  4. package/dist/apis/ingestApi.js +2 -151
  5. package/dist/apis/ingestApi.js.map +1 -1
  6. package/dist/apis/uptimeApi.js +1 -1
  7. package/dist/apis/uptimeApi.js.map +1 -1
  8. package/dist/domain/ingest.d.ts +4 -33
  9. package/dist/domain/ingest.d.ts.map +1 -1
  10. package/dist/http/httpClient.d.ts +5 -2
  11. package/dist/http/httpClient.d.ts.map +1 -1
  12. package/dist/http/httpClient.js +44 -8
  13. package/dist/http/httpClient.js.map +1 -1
  14. package/dist/index.d.ts +18 -507
  15. package/dist/index.d.ts.map +1 -1
  16. package/dist/index.js +17 -582
  17. package/dist/index.js.map +1 -1
  18. package/dist/sdk.d.ts +4 -9
  19. package/dist/sdk.d.ts.map +1 -1
  20. package/dist/sdk.js +7 -19
  21. package/dist/sdk.js.map +1 -1
  22. package/package.json +9 -16
  23. package/dist/src/apis/ingestApi.d.ts +0 -22
  24. package/dist/src/apis/ingestApi.js +0 -167
  25. package/dist/src/apis/ingestApi.js.map +0 -1
  26. package/dist/src/apis/uptimeApi.d.ts +0 -11
  27. package/dist/src/apis/uptimeApi.js +0 -39
  28. package/dist/src/apis/uptimeApi.js.map +0 -1
  29. package/dist/src/domain/ingest.d.ts +0 -47
  30. package/dist/src/domain/ingest.js +0 -2
  31. package/dist/src/domain/ingest.js.map +0 -1
  32. package/dist/src/domain/uptime.d.ts +0 -23
  33. package/dist/src/domain/uptime.js +0 -2
  34. package/dist/src/domain/uptime.js.map +0 -1
  35. package/dist/src/http/errors.d.ts +0 -33
  36. package/dist/src/http/errors.js +0 -54
  37. package/dist/src/http/errors.js.map +0 -1
  38. package/dist/src/http/httpClient.d.ts +0 -45
  39. package/dist/src/http/httpClient.js +0 -165
  40. package/dist/src/http/httpClient.js.map +0 -1
  41. package/dist/src/index.d.ts +0 -12
  42. package/dist/src/index.js +0 -7
  43. package/dist/src/index.js.map +0 -1
  44. package/dist/src/sdk.d.ts +0 -23
  45. package/dist/src/sdk.js +0 -40
  46. package/dist/src/sdk.js.map +0 -1
  47. package/dist/src/utils/processContext.d.ts +0 -34
  48. package/dist/src/utils/processContext.js +0 -47
  49. package/dist/src/utils/processContext.js.map +0 -1
  50. package/dist/src/utils/validate.d.ts +0 -2
  51. package/dist/src/utils/validate.js +0 -12
  52. package/dist/src/utils/validate.js.map +0 -1
  53. package/dist/tests/httpClient.test.d.ts +0 -1
  54. package/dist/tests/httpClient.test.js +0 -47
  55. package/dist/tests/httpClient.test.js.map +0 -1
  56. package/dist/tests/ingestApi.test.d.ts +0 -1
  57. package/dist/tests/ingestApi.test.js +0 -65
  58. package/dist/tests/ingestApi.test.js.map +0 -1
  59. package/dist/tests/observaSdk.integration.test.d.ts +0 -1
  60. package/dist/tests/observaSdk.integration.test.js +0 -51
  61. package/dist/tests/observaSdk.integration.test.js.map +0 -1
  62. package/dist/tests/sdk.test.d.ts +0 -1
  63. package/dist/tests/sdk.test.js +0 -104
  64. package/dist/tests/sdk.test.js.map +0 -1
  65. package/dist/tsconfig.build.tsbuildinfo +0 -1
  66. package/dist/utils/processContext.d.ts +0 -35
  67. package/dist/utils/processContext.d.ts.map +0 -1
  68. package/dist/utils/processContext.js +0 -47
  69. package/dist/utils/processContext.js.map +0 -1
  70. package/src/apis/ingestApi.ts +0 -199
  71. package/src/apis/uptimeApi.ts +0 -58
  72. package/src/domain/ingest.ts +0 -93
  73. package/src/domain/uptime.ts +0 -86
  74. package/src/http/errors.ts +0 -88
  75. package/src/http/httpClient.ts +0 -284
  76. package/src/index.ts +0 -68
  77. package/src/sdk.ts +0 -107
  78. package/src/utils/processContext.ts +0 -84
  79. package/src/utils/validate.ts +0 -19
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/apis/ingestApi.ts","../src/http/errors.ts","../src/utils/processContext.ts","../src/utils/validate.ts","../src/apis/uptimeApi.ts","../src/http/httpClient.ts","../src/sdk.ts"],"sourcesContent":["import { randomUUID } from 'crypto'\nimport type { IngestEvent, IngestRequest, IngestResponse, StacktraceFrame } from '../domain/ingest'\nimport { ValidationError } from '../http/errors'\nimport { getProcessContextDynamic, getProcessContextStatic } from '../utils/processContext'\nimport { ensureDefined, ensureNonEmpty } from '../utils/validate'\nimport type { HttpClient } from '../http/httpClient'\n\nexport type IngestNormalizationOptions = {\n schemaVersion?: number\n includeContext?: boolean\n includeSystemContext?: boolean\n includeRuntimeContext?: boolean\n maxEventBytes?: number\n maxFrames?: number\n maxMessageLength?: number\n maxExceptionValueLength?: number\n}\n\nconst DEFAULT_NORMALIZATION: Required<IngestNormalizationOptions> = {\n schemaVersion: 1,\n includeContext: true,\n includeSystemContext: true,\n includeRuntimeContext: true,\n maxEventBytes: 64 * 1024,\n maxFrames: 60,\n maxMessageLength: 4000,\n maxExceptionValueLength: 4000,\n}\n\n/**\n * Event ingestion API.\n */\nexport class IngestApi {\n /**\n * Creates the ingestion client with an optional default DSN and PublicKey.\n */\n constructor(\n private readonly http: HttpClient,\n private readonly defaultDsnKey?: string,\n private readonly normalization?: IngestNormalizationOptions,\n private readonly defaultPublicKey?: string\n ) { }\n\n /**\n * Sends an event to the ingestion backend.\n */\n async event(input: IngestRequest): Promise<IngestResponse> {\n ensureDefined(input, 'input')\n const dsnKey = input.dsnKey ?? this.defaultDsnKey\n const publicKey = input.publicKey ?? this.defaultPublicKey\n\n ensureDefined(dsnKey, 'dsnKey')\n ensureNonEmpty(dsnKey, 'dsnKey')\n ensureDefined(input.event, 'event')\n\n if (!this.http.hasApiKey() && !publicKey) {\n throw new ValidationError('publicKey is required when apiKey is not provided')\n }\n\n if (input.idempotencyKey && input.idempotencyKey.length > 128) {\n throw new ValidationError('idempotencyKey must be at most 128 characters')\n }\n const headers: Record<string, string> = {}\n if (input.idempotencyKey) headers['x-idempotency-key'] = input.idempotencyKey\n if (input.sdkVersion) headers['x-sdk-version'] = input.sdkVersion\n const { idempotencyKey, sdkVersion, event, ...body } = input\n const normalizedEvent = normalizeEvent(event, this.normalization)\n \n const authMode = this.http.hasApiKey() ? 'apiKey' : 'none'\n return this.http.post<IngestResponse>('/ingest/events', { ...body, dsnKey, publicKey, event: normalizedEvent }, { auth: authMode, headers })\n }\n\n async health(dsnKey?: string, publicKey?: string): Promise<{ ok: boolean }> {\n const resolvedDsnKey = dsnKey ?? this.defaultDsnKey\n const resolvedPublicKey = publicKey ?? this.defaultPublicKey\n\n ensureDefined(resolvedDsnKey, 'dsnKey')\n ensureNonEmpty(resolvedDsnKey, 'dsnKey')\n \n const authMode = this.http.hasApiKey() ? 'apiKey' : 'none'\n return this.http.post<{ ok: boolean }>('/ingest/health', { dsnKey: resolvedDsnKey, publicKey: resolvedPublicKey }, { auth: authMode })\n }\n}\n\nfunction normalizeEvent(event: IngestEvent, options?: IngestNormalizationOptions): IngestEvent {\n const config = { ...DEFAULT_NORMALIZATION, ...options }\n const normalizedTimestamp = normalizeTimestamp(event.timestamp)\n const normalizedLevel = event.level ? event.level.toLowerCase() : undefined\n const normalizedMessage = event.message ? truncate(event.message, config.maxMessageLength) : undefined\n const normalizedException = normalizeException(event.exception, config)\n if (!normalizedMessage && !normalizedException) {\n throw new ValidationError('event message or exception is required')\n }\n const normalizedContext = normalizeContext(event.context, config)\n const normalizedEvent: IngestEvent = {\n ...event,\n event_id: event.event_id ?? randomUUID(),\n timestamp: normalizedTimestamp,\n schema_version: event.schema_version ?? config.schemaVersion,\n level: normalizedLevel as IngestEvent['level'],\n message: normalizedMessage,\n exception: normalizedException,\n context: normalizedContext,\n }\n return enforceSizeLimit(normalizedEvent, config)\n}\n\nfunction normalizeTimestamp(timestamp?: string) {\n if (!timestamp) return new Date().toISOString()\n const parsed = new Date(timestamp)\n if (Number.isNaN(parsed.getTime())) {\n throw new ValidationError('timestamp must be a valid ISO date')\n }\n return parsed.toISOString()\n}\n\nfunction normalizeException(exception: IngestEvent['exception'], config: Required<IngestNormalizationOptions>) {\n if (!exception) return undefined\n if (!exception.type || !exception.value) {\n throw new ValidationError('exception.type and exception.value are required')\n }\n return {\n ...exception,\n value: truncate(exception.value, config.maxExceptionValueLength),\n stacktrace: normalizeStacktrace(exception.stacktrace, config.maxFrames),\n }\n}\n\nfunction normalizeStacktrace(stacktrace: { frames?: StacktraceFrame[] } | undefined, maxFrames: number) {\n if (!stacktrace || !Array.isArray(stacktrace.frames)) return undefined\n const frames = stacktrace.frames\n const normalizedFrames = frames.slice(0, maxFrames).map((frame) => {\n const filename = typeof frame?.filename === 'string' ? frame.filename : undefined\n const functionName = typeof frame?.function === 'string' ? frame.function : undefined\n const lineno = typeof frame?.lineno === 'number' ? frame.lineno : undefined\n const colno = typeof frame?.colno === 'number' ? frame.colno : undefined\n const inferredInApp = filename ? !filename.includes('node_modules') : false\n return {\n filename,\n function: functionName,\n lineno,\n colno,\n in_app: typeof frame?.in_app === 'boolean' ? frame.in_app : inferredInApp,\n }\n })\n return { frames: normalizedFrames }\n}\n\nfunction normalizeContext(context: IngestEvent['context'] | undefined, config: Required<IngestNormalizationOptions>) {\n if (!config.includeContext) return context\n const systemContext = config.includeSystemContext ? getProcessContextDynamic() : undefined\n const runtimeContext = config.includeRuntimeContext ? getProcessContextStatic({ includeVersions: false }) : undefined\n const mergedContext = {\n ...context,\n system: context?.system ?? systemContext,\n runtime: context?.runtime ?? runtimeContext,\n }\n return mergedContext\n}\n\nfunction enforceSizeLimit(event: IngestEvent, config: Required<IngestNormalizationOptions>) {\n let normalized = event\n if (getSize(normalized) <= config.maxEventBytes) return normalized\n if (normalized.extra) {\n normalized = { ...normalized, extra: undefined }\n }\n if (getSize(normalized) <= config.maxEventBytes) return normalized\n if (normalized.tags) {\n normalized = { ...normalized, tags: undefined }\n }\n if (getSize(normalized) <= config.maxEventBytes) return normalized\n if (normalized.exception?.stacktrace) {\n normalized = {\n ...normalized,\n exception: { ...normalized.exception, stacktrace: undefined },\n }\n }\n if (getSize(normalized) <= config.maxEventBytes) return normalized\n if (normalized.message) {\n normalized = { ...normalized, message: truncate(normalized.message, config.maxMessageLength) }\n }\n if (normalized.exception?.value) {\n normalized = {\n ...normalized,\n exception: { ...normalized.exception, value: truncate(normalized.exception.value, config.maxExceptionValueLength) },\n }\n }\n if (getSize(normalized) <= config.maxEventBytes) return normalized\n throw new ValidationError('event payload exceeds size limit')\n}\n\nfunction getSize(value: unknown) {\n return Buffer.byteLength(JSON.stringify(value), 'utf8')\n}\n\nfunction truncate(value: string, maxLength: number) {\n if (value.length <= maxLength) return value\n return value.slice(0, maxLength)\n}\n","/**\r\n * Additional data to enrich SDK errors.\r\n */\r\nexport type ErrorDetails = {\r\n status?: number\r\n code?: string\r\n details?: unknown\r\n retryAfter?: number\r\n}\r\n\r\n/**\r\n * Base SDK error.\r\n */\r\nexport class SdkError extends Error {\r\n readonly status?: number\r\n readonly code?: string\r\n readonly details?: unknown\r\n\r\n /**\r\n * Creates an error with optional metadata.\r\n */\r\n constructor(message: string, details?: ErrorDetails) {\r\n super(message)\r\n this.name = new.target.name\r\n this.status = details?.status\r\n this.code = details?.code\r\n this.details = details?.details\r\n }\r\n}\r\n\r\n/**\r\n * Input validation error.\r\n */\r\nexport class ValidationError extends SdkError { }\r\n/**\r\n * Authentication error.\r\n */\r\nexport class AuthError extends SdkError { }\r\n/**\r\n * Error caused by insufficient permissions.\r\n */\r\nexport class ForbiddenError extends SdkError { }\r\n/**\r\n * Error when a resource does not exist.\r\n */\r\nexport class NotFoundError extends SdkError { }\r\n/**\r\n * Error caused by a state conflict.\r\n */\r\nexport class ConflictError extends SdkError { }\r\n/**\r\n * Error caused by rate limiting.\r\n */\r\nexport class RateLimitError extends SdkError {\r\n readonly retryAfter?: number\r\n\r\n constructor(message: string, details?: ErrorDetails) {\r\n super(message, details)\r\n this.retryAfter = details?.retryAfter\r\n }\r\n}\r\n/**\r\n * Server-side error.\r\n */\r\nexport class ServerError extends SdkError { }\r\n/**\r\n * Network error.\r\n */\r\nexport class NetworkError extends SdkError { }\r\n/**\r\n * Request timeout error.\r\n */\r\nexport class TimeoutError extends SdkError { }\r\n\r\n/**\r\n * Maps HTTP status codes to typed SDK errors.\r\n */\r\nexport function mapHttpError(status: number, details?: unknown, retryAfter?: number): SdkError {\r\n const info = { status, details, retryAfter }\r\n if (status === 400) return new ValidationError('Invalid request', info)\r\n if (status === 401) return new AuthError('Unauthorized', info)\r\n if (status === 403) return new ForbiddenError('Forbidden', info)\r\n if (status === 404) return new NotFoundError('Resource not found', info)\r\n if (status === 409) return new ConflictError('Conflict', info)\r\n if (status === 429) return new RateLimitError('Rate limit exceeded', info)\r\n if (status >= 500) return new ServerError('Server error', info)\r\n return new SdkError('HTTP error', info)\r\n}\r\n","export type ProcessContextStatic = {\r\n versions?: NodeJS.ProcessVersions\r\n node?: string\r\n platform?: NodeJS.Platform\r\n arch?: string\r\n releaseName?: string\r\n}\r\n\r\nexport type ProcessContextDynamic = {\r\n pid?: number\r\n uptimeSeconds?: number\r\n memory?: NodeJS.MemoryUsage\r\n}\r\n\r\nexport type ProcessContext = ProcessContextStatic & ProcessContextDynamic\r\n\r\nexport type ProcessContextOptions = {\r\n includeStatic?: boolean\r\n includeDynamic?: boolean\r\n includeVersions?: boolean\r\n includeRuntime?: boolean\r\n includePid?: boolean\r\n includeUptime?: boolean\r\n includeMemory?: boolean\r\n}\r\n\r\nexport type ProcessContextStaticOptions = {\r\n includeVersions?: boolean\r\n includeRuntime?: boolean\r\n}\r\n\r\nexport type ProcessContextDynamicOptions = {\r\n includePid?: boolean\r\n includeUptime?: boolean\r\n includeMemory?: boolean\r\n}\r\n\r\nexport function getProcessContext(options?: ProcessContextOptions): ProcessContext {\r\n const includeStatic = options?.includeStatic ?? true\r\n const includeDynamic = options?.includeDynamic ?? true\r\n const includeVersions = options?.includeVersions ?? true\r\n const includeRuntime = options?.includeRuntime ?? true\r\n const includePid = options?.includePid ?? true\r\n const includeUptime = options?.includeUptime ?? true\r\n const includeMemory = options?.includeMemory ?? true\r\n const context: ProcessContext = {}\r\n\r\n if (includeDynamic) {\r\n if (includePid) context.pid = process.pid\r\n if (includeUptime) context.uptimeSeconds = Math.round(process.uptime())\r\n if (includeMemory) context.memory = process.memoryUsage()\r\n }\r\n\r\n if (includeStatic) {\r\n if (includeVersions) context.versions = process.versions\r\n if (includeRuntime) {\r\n context.node = process.versions.node\r\n context.platform = process.platform\r\n context.arch = process.arch\r\n context.releaseName = process.release?.name\r\n }\r\n }\r\n\r\n return context\r\n}\r\n\r\nexport function getProcessContextStatic(options?: ProcessContextStaticOptions): ProcessContextStatic {\r\n return getProcessContext({\r\n includeDynamic: false,\r\n includeStatic: true,\r\n includeVersions: options?.includeVersions,\r\n includeRuntime: options?.includeRuntime,\r\n })\r\n}\r\n\r\nexport function getProcessContextDynamic(options?: ProcessContextDynamicOptions): ProcessContextDynamic {\r\n return getProcessContext({\r\n includeStatic: false,\r\n includeDynamic: true,\r\n includePid: options?.includePid,\r\n includeUptime: options?.includeUptime,\r\n includeMemory: options?.includeMemory,\r\n })\r\n}\r\n","import { ValidationError } from '../http/errors'\n\n/**\n * Ensures a string is present and non-empty.\n */\nexport function ensureNonEmpty(value: string, name: string) {\n if (!value || value.trim().length === 0) {\n throw new ValidationError(`${name} is required`)\n }\n}\n\n/**\n * Ensures a value is neither null nor undefined.\n */\nexport function ensureDefined<T>(value: T | null | undefined, name: string): asserts value is T {\n if (value === null || value === undefined) {\n throw new ValidationError(`${name} is required`)\n }\n}\n","import type { UptimeEvent, UptimeHeartbeatInput, UptimeSummary } from '../domain/uptime'\nimport { ensureDefined, ensureNonEmpty } from '../utils/validate'\nimport type { HttpClient } from '../http/httpClient'\n\n/**\n * Uptime API for heartbeats and public reads.\n */\nexport class UptimeApi {\n /**\n * Creates the uptime client with an optional default DSN.\n */\n constructor(private readonly http: HttpClient, private readonly defaultDsnKey?: string) { }\n\n /**\n * Records an uptime heartbeat.\n */\n async recordHeartbeat(input: UptimeHeartbeatInput): Promise<UptimeEvent> {\n ensureDefined(input, 'input')\n const dsnKey = input.dsnKey ?? this.defaultDsnKey\n ensureDefined(dsnKey, 'dsnKey')\n ensureNonEmpty(dsnKey, 'dsnKey')\n ensureNonEmpty(input.status, 'status')\n return this.http.post<UptimeEvent>('/uptime/heartbeats', { ...input, dsnKey }, { auth: 'apiKey' })\n }\n\n /**\n * Lists a project's daily uptime history.\n */\n async history(projectId: string, date: string): Promise<UptimeEvent[]> {\n ensureNonEmpty(projectId, 'projectId')\n ensureNonEmpty(date, 'date')\n return this.http.get<UptimeEvent[]>(`/projects/${encodeURIComponent(projectId)}/uptime/history`, {\n query: { date },\n auth: 'none',\n })\n }\n\n /**\n * Gets the latest uptime event for a project.\n */\n async latest(projectId: string): Promise<UptimeEvent | null> {\n ensureNonEmpty(projectId, 'projectId')\n return this.http.get<UptimeEvent | null>(`/projects/${encodeURIComponent(projectId)}/uptime/latest`, {\n auth: 'none',\n })\n }\n\n /**\n * Summarizes daily uptime.\n */\n async summary(projectId: string, days?: number, delayThresholdMinutes?: number): Promise<UptimeSummary[]> {\n ensureNonEmpty(projectId, 'projectId')\n return this.http.get<UptimeSummary[]>(`/projects/${encodeURIComponent(projectId)}/uptime/summary`, {\n query: { days, delayThresholdMinutes },\n auth: 'none',\n })\n }\n}\n","import { AuthError, NetworkError, TimeoutError, mapHttpError } from './errors'\n\n/**\n * Authentication mode per request.\n */\nexport type AuthMode = 'apiKey' | 'none'\n/**\n * Supported HTTP methods.\n */\nexport type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE'\n/**\n * Serializable query parameters.\n */\nexport type QueryParams = Record<string, string | number | boolean | undefined>\n\n/**\n * Retry policy for transient errors.\n */\nexport type RetryPolicy = {\n /**\n * Number of additional retries.\n */\n retries: number\n /**\n * Computes the delay between retries.\n */\n retryDelayMs?: (attempt: number, response?: Response, error?: unknown) => number\n /**\n * Determines whether a response or error should be retried.\n */\n retryOn?: (response?: Response, error?: unknown) => boolean\n}\n\n/**\n * Base HTTP client configuration.\n */\nexport type HttpClientOptions = {\n /**\n * Backend base URL.\n */\n baseUrl: string\n /**\n * API key used for SDK authentication.\n */\n apiKey?: string\n /**\n * Request timeout in milliseconds.\n */\n timeoutMs?: number\n /**\n * Global headers.\n */\n headers?: Record<string, string>\n /**\n * Retry policy.\n */\n retry?: RetryPolicy\n}\n\n/**\n * Per-request options.\n */\nexport type RequestOptions = {\n method: HttpMethod\n path: string\n query?: QueryParams\n body?: unknown\n headers?: Record<string, string>\n /**\n * Defines whether the request requires an apiKey or is public.\n */\n auth?: AuthMode\n}\n\n/**\n * Base HTTP client for the SDK.\n */\nexport class HttpClient {\n private apiKey?: string\n private readonly baseUrl: string\n private readonly timeoutMs: number\n private readonly headers: Record<string, string>\n private readonly retry?: RetryPolicy\n private healthCheckPromise?: Promise<unknown>\n\n /**\n * Creates an HTTP client with baseUrl and optional apiKey.\n */\n constructor(options: HttpClientOptions) {\n this.baseUrl = options.baseUrl.replace(/\\/+$/, '')\n this.apiKey = options.apiKey\n this.timeoutMs = options.timeoutMs ?? 5000\n this.headers = options.headers ?? {}\n this.retry = options.retry\n }\n\n /**\n * Updates the API key at runtime.\n */\n setApiKey(apiKey?: string) {\n this.apiKey = apiKey\n }\n\n /**\n * Checks if an API key is configured.\n */\n hasApiKey(): boolean {\n return !!this.apiKey\n }\n\n startHealthCheck(healthCheck: () => Promise<unknown>) {\n if (!this.healthCheckPromise) {\n const promise = healthCheck()\n this.healthCheckPromise = promise\n promise.catch(() => undefined)\n }\n }\n\n /**\n * GET request.\n */\n async get<T>(path: string, options?: Omit<RequestOptions, 'method' | 'path'>): Promise<T> {\n return this.request<T>({ method: 'GET', path, ...options })\n }\n\n /**\n * POST request.\n */\n async post<T>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method' | 'path' | 'body'>): Promise<T> {\n return this.request<T>({ method: 'POST', path, body, ...options })\n }\n\n /**\n * PUT request.\n */\n async put<T>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method' | 'path' | 'body'>): Promise<T> {\n return this.request<T>({ method: 'PUT', path, body, ...options })\n }\n\n /**\n * PATCH request.\n */\n async patch<T>(path: string, body?: unknown, options?: Omit<RequestOptions, 'method' | 'path' | 'body'>): Promise<T> {\n return this.request<T>({ method: 'PATCH', path, body, ...options })\n }\n\n /**\n * DELETE request.\n */\n async delete<T>(path: string, options?: Omit<RequestOptions, 'method' | 'path'>): Promise<T> {\n return this.request<T>({ method: 'DELETE', path, ...options })\n }\n\n /**\n * Executes a request with retry logic.\n */\n async request<T>(options: RequestOptions): Promise<T> {\n if (this.healthCheckPromise) {\n await this.healthCheckPromise\n }\n const retry = this.retry ?? { retries: 0 }\n const retryOn = retry.retryOn ?? ((response?: Response, error?: unknown) => {\n if (response) return response.status === 429 || response.status >= 500\n return error instanceof NetworkError || error instanceof TimeoutError || error instanceof TypeError\n })\n const retryDelayMs = retry.retryDelayMs ?? ((attempt: number) => Math.min(1000 * 2 ** (attempt - 1), 8000))\n let lastError: unknown\n\n for (let attempt = 0; attempt <= retry.retries; attempt += 1) {\n try {\n const { response, data } = await this.execute(options)\n if (!response.ok) {\n const retryAfter = this.parseRetryAfter(response.headers.get('retry-after'))\n const error = mapHttpError(response.status, data, retryAfter)\n if (retryOn(response, error) && attempt < retry.retries) {\n await this.delay(retryDelayMs(attempt + 1, response, error))\n continue\n }\n throw error\n }\n return data as T\n } catch (error) {\n lastError = error\n if (retryOn(undefined, error) && attempt < retry.retries) {\n await this.delay(retryDelayMs(attempt + 1, undefined, error))\n continue\n }\n throw error\n }\n }\n\n throw lastError\n }\n\n /**\n * Executes a request without retry and returns response + data.\n */\n private async execute(options: RequestOptions): Promise<{ response: Response; data: unknown }> {\n const url = this.buildUrl(options.path, options.query)\n const headers: Record<string, string> = { ...this.headers, ...options.headers }\n if (options.body !== undefined) headers['content-type'] = 'application/json'\n const authMode = options.auth ?? 'none'\n if (authMode === 'apiKey') {\n if (!this.apiKey) throw new AuthError('API key is required')\n headers['x-api-key'] = this.apiKey\n }\n\n const controller = new AbortController()\n const timer = setTimeout(() => controller.abort(), this.timeoutMs)\n\n try {\n const response = await fetch(url, {\n method: options.method,\n headers,\n body: options.body === undefined ? undefined : JSON.stringify(options.body),\n signal: controller.signal,\n })\n const data = await this.readBody(response)\n return { response, data }\n } catch (error: any) {\n if (error?.name === 'AbortError') {\n throw new TimeoutError('Request timeout')\n }\n if (error instanceof NetworkError || error instanceof TimeoutError) throw error\n if (error instanceof Error) {\n if (error instanceof AuthError) throw error\n }\n if (error instanceof Error && 'status' in error) throw error\n throw new NetworkError('Network error', { details: error })\n } finally {\n clearTimeout(timer)\n }\n }\n\n /**\n * Builds the final URL with query params.\n */\n private buildUrl(path: string, query?: QueryParams): string {\n const base = this.baseUrl\n const fullPath = path.startsWith('http') ? path : `${base}${path.startsWith('/') ? '' : '/'}${path}`\n if (!query) return fullPath\n const params = new URLSearchParams()\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue\n params.set(key, String(value))\n }\n const suffix = params.toString()\n return suffix ? `${fullPath}?${suffix}` : fullPath\n }\n\n /**\n * Parses the body as JSON when possible.\n */\n private async readBody(response: Response): Promise<unknown> {\n if (response.status === 204) return undefined\n const text = await response.text()\n if (!text) return undefined\n try {\n return JSON.parse(text)\n } catch {\n return text\n }\n }\n\n private parseRetryAfter(value: string | null): number | undefined {\n if (!value) return undefined\n const seconds = Number(value)\n if (!Number.isNaN(seconds) && Number.isFinite(seconds)) {\n return Math.max(0, seconds)\n }\n const parsedDate = Date.parse(value)\n if (Number.isNaN(parsedDate)) return undefined\n const diffMs = parsedDate - Date.now()\n if (diffMs <= 0) return 0\n return Math.ceil(diffMs / 1000)\n }\n\n /**\n * Simple delay for retries.\n */\n private async delay(ms: number): Promise<void> {\n await new Promise(resolve => setTimeout(resolve, ms))\n }\n}\n","import { IngestApi, type IngestNormalizationOptions } from './apis/ingestApi'\nimport { UptimeApi } from './apis/uptimeApi'\nimport { HttpClient, type RetryPolicy } from './http/httpClient'\nimport {\n getProcessContext,\n getProcessContextDynamic,\n getProcessContextStatic,\n type ProcessContext,\n type ProcessContextDynamic,\n type ProcessContextDynamicOptions,\n type ProcessContextOptions,\n type ProcessContextStatic,\n type ProcessContextStaticOptions,\n} from './utils/processContext'\n\n/**\n * SDK configuration options.\n */\nexport type ObservaSDKOptions = {\n /**\n * Organization API key used to authenticate SDK requests.\n */\n apiKey?: string\n /**\n * Project DSN used to identify the destination of events and heartbeats.\n */\n dsnKey: string\n /**\n * Public key for frontend/mobile projects.\n */\n publicKey?: string\n baseUrl?: string\n /**\n * HTTP request timeout in milliseconds.\n */\n timeoutMs?: number\n /**\n * Retry policy for transient errors.\n */\n retry?: RetryPolicy\n /**\n * Additional headers sent with every request.\n */\n headers?: Record<string, string>\n ingest?: IngestNormalizationOptions\n}\n\n/**\n * Fixed backend target for the SDK.\n */\nconst DEFAULT_BASE_URL = 'https://backend-observa-production.up.railway.app/v1'\n\n/**\n * Main SDK for error ingestion and uptime heartbeats.\n */\nexport class ObservaSDK {\n /**\n * Uptime API (heartbeats and public reads).\n */\n readonly uptime: UptimeApi\n /**\n * Event ingestion API.\n */\n readonly ingest: IngestApi\n\n private readonly http: HttpClient\n\n /**\n * Creates an SDK instance with required dsnKey and either apiKey or publicKey.\n */\n constructor(options: ObservaSDKOptions) {\n if (!options || (!options.apiKey && !options.publicKey) || !options.dsnKey) {\n throw new Error('ObservaSDK requires dsnKey and either apiKey or publicKey')\n }\n const baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\\/+$/, '')\n const normalizedBaseUrl = baseUrl.endsWith('/v1') ? baseUrl : `${baseUrl}/v1`\n this.http = new HttpClient({\n baseUrl: normalizedBaseUrl,\n apiKey: options.apiKey,\n timeoutMs: options.timeoutMs,\n retry: options.retry,\n headers: options.headers,\n })\n this.ingest = new IngestApi(this.http, options.dsnKey, options.ingest, options.publicKey)\n this.uptime = new UptimeApi(this.http, options.dsnKey)\n this.http.startHealthCheck(() => this.ingest.health(options.dsnKey, options.publicKey))\n }\n\n /**\n * Updates the API key used by the SDK at runtime.\n */\n setApiKey(apiKey: string) {\n this.http.setApiKey(apiKey)\n }\n\n getProcessContext(options?: ProcessContextOptions): ProcessContext {\n return getProcessContext(options)\n }\n\n getProcessContextStatic(options?: ProcessContextStaticOptions): ProcessContextStatic {\n return getProcessContextStatic(options)\n }\n\n getProcessContextDynamic(options?: ProcessContextDynamicOptions): ProcessContextDynamic {\n return getProcessContextDynamic(options)\n }\n}\n"],"mappings":";AAAA,SAAS,kBAAkB;;;ACapB,IAAM,WAAN,cAAuB,MAAM;AAAA,EACvB;AAAA,EACA;AAAA,EACA;AAAA;AAAA;AAAA;AAAA,EAKT,YAAY,SAAiB,SAAwB;AACjD,UAAM,OAAO;AACb,SAAK,OAAO,WAAW;AACvB,SAAK,SAAS,SAAS;AACvB,SAAK,OAAO,SAAS;AACrB,SAAK,UAAU,SAAS;AAAA,EAC5B;AACJ;AAKO,IAAM,kBAAN,cAA8B,SAAS;AAAE;AAIzC,IAAM,YAAN,cAAwB,SAAS;AAAE;AAInC,IAAM,iBAAN,cAA6B,SAAS;AAAE;AAIxC,IAAM,gBAAN,cAA4B,SAAS;AAAE;AAIvC,IAAM,gBAAN,cAA4B,SAAS;AAAE;AAIvC,IAAM,iBAAN,cAA6B,SAAS;AAAA,EAChC;AAAA,EAET,YAAY,SAAiB,SAAwB;AACjD,UAAM,SAAS,OAAO;AACtB,SAAK,aAAa,SAAS;AAAA,EAC/B;AACJ;AAIO,IAAM,cAAN,cAA0B,SAAS;AAAE;AAIrC,IAAM,eAAN,cAA2B,SAAS;AAAE;AAItC,IAAM,eAAN,cAA2B,SAAS;AAAE;AAKtC,SAAS,aAAa,QAAgB,SAAmB,YAA+B;AAC3F,QAAM,OAAO,EAAE,QAAQ,SAAS,WAAW;AAC3C,MAAI,WAAW,IAAK,QAAO,IAAI,gBAAgB,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,SAA6D;AACjF,WAAO,wBAAwB,OAAO;AAAA,EAC1C;AAAA,EAEA,yBAAyB,SAA+D;AACpF,WAAO,yBAAyB,OAAO;AAAA,EAC3C;AACJ;","names":[]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAA;AAMlC;;GAEG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAM9C;;GAEG;AACH,OAAO,EACL,QAAQ,EACR,eAAe,EACf,SAAS,EACT,cAAc,EACd,aAAa,EACb,aAAa,EACb,cAAc,EACd,WAAW,EACX,YAAY,EACZ,YAAY,GACb,MAAM,eAAe,CAAA;AAEtB;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA"}
package/dist/sdk.d.ts CHANGED
@@ -1,20 +1,19 @@
1
- import { IngestApi, type IngestNormalizationOptions } from './apis/ingestApi';
1
+ import { IngestApi } from './apis/ingestApi';
2
2
  import { UptimeApi } from './apis/uptimeApi';
3
3
  import { type RetryPolicy } from './http/httpClient';
4
- import { type ProcessContext, type ProcessContextDynamic, type ProcessContextDynamicOptions, type ProcessContextOptions, type ProcessContextStatic, type ProcessContextStaticOptions } from './utils/processContext';
5
4
  /**
6
5
  * SDK configuration options.
7
6
  */
8
7
  export type ObservaSDKOptions = {
9
8
  /**
10
9
  * Organization API key used to authenticate SDK requests.
10
+ * Optional — when omitted, write endpoints authenticate via dsnKey only (browser-safe mode).
11
11
  */
12
- apiKey: string;
12
+ apiKey?: string;
13
13
  /**
14
14
  * Project DSN used to identify the destination of events and heartbeats.
15
15
  */
16
16
  dsnKey: string;
17
- baseUrl?: string;
18
17
  /**
19
18
  * HTTP request timeout in milliseconds.
20
19
  */
@@ -27,7 +26,6 @@ export type ObservaSDKOptions = {
27
26
  * Additional headers sent with every request.
28
27
  */
29
28
  headers?: Record<string, string>;
30
- ingest?: IngestNormalizationOptions;
31
29
  };
32
30
  /**
33
31
  * Main SDK for error ingestion and uptime heartbeats.
@@ -43,15 +41,12 @@ export declare class ObservaSDK {
43
41
  readonly ingest: IngestApi;
44
42
  private readonly http;
45
43
  /**
46
- * Creates an SDK instance with required apiKey and dsnKey.
44
+ * Creates an SDK instance. dsnKey is required; apiKey is optional (DSN-only mode).
47
45
  */
48
46
  constructor(options: ObservaSDKOptions);
49
47
  /**
50
48
  * Updates the API key used by the SDK at runtime.
51
49
  */
52
50
  setApiKey(apiKey: string): void;
53
- getProcessContext(options?: ProcessContextOptions): ProcessContext;
54
- getProcessContextStatic(options?: ProcessContextStaticOptions): ProcessContextStatic;
55
- getProcessContextDynamic(options?: ProcessContextDynamicOptions): ProcessContextDynamic;
56
51
  }
57
52
  //# sourceMappingURL=sdk.d.ts.map
package/dist/sdk.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAc,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAChE,OAAO,EAIH,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,4BAA4B,EACjC,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,EACzB,KAAK,2BAA2B,EACnC,MAAM,wBAAwB,CAAA;AAE/B;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC5B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAA;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U;IACnB;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAC1B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;IAE1B,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAY;IAEjC;;OAEG;gBACS,OAAO,EAAE,iBAAiB;IAgBtC;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM;CAG3B"}
package/dist/sdk.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import { IngestApi } from './apis/ingestApi';
2
2
  import { UptimeApi } from './apis/uptimeApi';
3
3
  import { HttpClient } from './http/httpClient';
4
- import { getProcessContext, getProcessContextDynamic, getProcessContextStatic, } from './utils/processContext';
5
4
  /**
6
5
  * Fixed backend target for the SDK.
7
6
  */
8
- const DEFAULT_BASE_URL = 'https://backend-observa-production.up.railway.app/v1';
7
+ const DEFAULT_BASE_URL = 'https://backend-observa-production.up.railway.app';
9
8
  /**
10
9
  * Main SDK for error ingestion and uptime heartbeats.
11
10
  */
@@ -20,24 +19,22 @@ export class ObservaSDK {
20
19
  ingest;
21
20
  http;
22
21
  /**
23
- * Creates an SDK instance with required apiKey and dsnKey.
22
+ * Creates an SDK instance. dsnKey is required; apiKey is optional (DSN-only mode).
24
23
  */
25
24
  constructor(options) {
26
- if (!options || !options.apiKey || !options.dsnKey) {
27
- throw new Error('ObservaSDK requires both apiKey and dsnKey');
25
+ if (!options?.dsnKey) {
26
+ throw new Error('dsnKey is required');
28
27
  }
29
- const baseUrl = (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, '');
30
- const normalizedBaseUrl = baseUrl.endsWith('/v1') ? baseUrl : `${baseUrl}/v1`;
31
28
  this.http = new HttpClient({
32
- baseUrl: normalizedBaseUrl,
29
+ baseUrl: DEFAULT_BASE_URL,
33
30
  apiKey: options.apiKey,
34
31
  timeoutMs: options.timeoutMs,
35
32
  retry: options.retry,
36
33
  headers: options.headers,
37
34
  });
38
- this.ingest = new IngestApi(this.http, options.dsnKey, options.ingest);
35
+ this.http.startHealthCheck();
39
36
  this.uptime = new UptimeApi(this.http, options.dsnKey);
40
- this.http.startHealthCheck(() => this.ingest.health(options.dsnKey));
37
+ this.ingest = new IngestApi(this.http, options.dsnKey);
41
38
  }
42
39
  /**
43
40
  * Updates the API key used by the SDK at runtime.
@@ -45,14 +42,5 @@ export class ObservaSDK {
45
42
  setApiKey(apiKey) {
46
43
  this.http.setApiKey(apiKey);
47
44
  }
48
- getProcessContext(options) {
49
- return getProcessContext(options);
50
- }
51
- getProcessContextStatic(options) {
52
- return getProcessContextStatic(options);
53
- }
54
- getProcessContextDynamic(options) {
55
- return getProcessContextDynamic(options);
56
- }
57
45
  }
58
46
  //# sourceMappingURL=sdk.js.map
package/dist/sdk.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"sdk.js","sourceRoot":"","sources":["../src/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmC,MAAM,kBAAkB,CAAA;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAoB,MAAM,mBAAmB,CAAA;AAChE,OAAO,EACH,iBAAiB,EACjB,wBAAwB,EACxB,uBAAuB,GAO1B,MAAM,wBAAwB,CAAA;AA8B/B;;GAEG;AACH,MAAM,gBAAgB,GAAG,sDAAsD,CAAA;AAE/E;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;OAEG;IACM,MAAM,CAAW;IAC1B;;OAEG;IACM,MAAM,CAAW;IAET,IAAI,CAAY;IAEjC;;OAEG;IACH,YAAY,OAA0B;QAClC,IAAI,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACjD,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAA;QACjE,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,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AAA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,EAAE,UAAU,EAAoB,MAAM,mBAAmB,CAAA;AA6BhE;;GAEG;AACH,MAAM,gBAAgB,GAAG,mDAAmD,CAAA;AAE5E;;GAEG;AACH,MAAM,OAAO,UAAU;IACnB;;OAEG;IACM,MAAM,CAAW;IAC1B;;OAEG;IACM,MAAM,CAAW;IAET,IAAI,CAAY;IAEjC;;OAEG;IACH,YAAY,OAA0B;QAClC,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;QACzC,CAAC;QACD,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC;YACvB,OAAO,EAAE,gBAAgB;YACzB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,OAAO,EAAE,OAAO,CAAC,OAAO;SAC3B,CAAC,CAAA;QACF,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;QACtD,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IAC1D,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,MAAc;QACpB,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;CACJ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@observa/sdk",
3
- "version": "2.4.0",
3
+ "version": "2.4.5",
4
4
  "description": "Observa SDK for Node.js",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,32 +21,25 @@
21
21
  }
22
22
  },
23
23
  "files": [
24
- "src/",
25
- "dist/"
24
+ "dist"
26
25
  ],
27
26
  "sideEffects": false,
28
27
  "engines": {
29
28
  "node": ">=18"
30
29
  },
31
30
  "devDependencies": {
31
+ "@swc/core": "^1.15.18",
32
+ "@swc/jest": "^0.2.39",
32
33
  "@types/bun": "latest",
33
34
  "@types/jest": "^29.5.12",
34
- "jest": "^29.7.0",
35
- "standard-version": "^9.5.0",
36
- "ts-jest": "^29.1.2",
37
- "tsup": "^8.0.1",
35
+ "jest": "^30.3.0",
38
36
  "typescript": "^5.6.3"
39
37
  },
40
38
  "scripts": {
41
- "build": "tsup src/index.ts --format esm --dts --sourcemap --outDir dist",
42
- "changelog": "standard-version --skip.bump --skip.commit --skip.tag",
43
- "release": "standard-version",
44
- "release:major": "standard-version --release-as major",
45
- "release:minor": "standard-version --release-as minor",
46
- "release:patch": "standard-version --release-as patch",
39
+ "build": "tsc -p tsconfig.build.json",
47
40
  "typecheck": "tsc -p tsconfig.json --noEmit",
48
- "test": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --config ./jest.config.mjs",
49
- "test:watch": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --watch --config ./jest.config.mjs",
50
- "test:list": "node --experimental-vm-modules ./node_modules/jest/bin/jest.js --listTests --config ./jest.config.mjs"
41
+ "test": "node ./node_modules/jest/bin/jest.js --config ./jest.config.mjs",
42
+ "test:watch": "node ./node_modules/jest/bin/jest.js --watch --config ./jest.config.mjs",
43
+ "test:list": "node ./node_modules/jest/bin/jest.js --listTests --config ./jest.config.mjs"
51
44
  }
52
45
  }
@@ -1,22 +0,0 @@
1
- import type { IngestRequest, IngestResponse } from '../domain/ingest';
2
- import type { HttpClient } from '../http/httpClient';
3
- export type IngestNormalizationOptions = {
4
- schemaVersion?: number;
5
- includeContext?: boolean;
6
- includeSystemContext?: boolean;
7
- includeRuntimeContext?: boolean;
8
- maxEventBytes?: number;
9
- maxFrames?: number;
10
- maxMessageLength?: number;
11
- maxExceptionValueLength?: number;
12
- };
13
- export declare class IngestApi {
14
- private readonly http;
15
- private readonly defaultDsnKey?;
16
- private readonly normalization?;
17
- constructor(http: HttpClient, defaultDsnKey?: string | undefined, normalization?: IngestNormalizationOptions | undefined);
18
- event(input: IngestRequest): Promise<IngestResponse>;
19
- health(dsnKey?: string): Promise<{
20
- ok: boolean;
21
- }>;
22
- }
@@ -1,167 +0,0 @@
1
- import { randomUUID } from 'crypto';
2
- import { ValidationError } from '../http/errors.js';
3
- import { getProcessContextDynamic, getProcessContextStatic } from '../utils/processContext.js';
4
- import { ensureDefined, ensureNonEmpty } from '../utils/validate.js';
5
- const DEFAULT_NORMALIZATION = {
6
- schemaVersion: 1,
7
- includeContext: true,
8
- includeSystemContext: true,
9
- includeRuntimeContext: true,
10
- maxEventBytes: 64 * 1024,
11
- maxFrames: 60,
12
- maxMessageLength: 4000,
13
- maxExceptionValueLength: 4000,
14
- };
15
- export class IngestApi {
16
- http;
17
- defaultDsnKey;
18
- normalization;
19
- constructor(http, defaultDsnKey, normalization) {
20
- this.http = http;
21
- this.defaultDsnKey = defaultDsnKey;
22
- this.normalization = normalization;
23
- }
24
- async event(input) {
25
- ensureDefined(input, 'input');
26
- const dsnKey = input.dsnKey ?? this.defaultDsnKey;
27
- ensureDefined(dsnKey, 'dsnKey');
28
- ensureNonEmpty(dsnKey, 'dsnKey');
29
- ensureDefined(input.event, 'event');
30
- if (input.idempotencyKey && input.idempotencyKey.length > 128) {
31
- throw new ValidationError('idempotencyKey must be at most 128 characters');
32
- }
33
- const headers = {};
34
- if (input.idempotencyKey)
35
- headers['x-idempotency-key'] = input.idempotencyKey;
36
- if (input.sdkVersion)
37
- headers['x-sdk-version'] = input.sdkVersion;
38
- const { idempotencyKey, sdkVersion, event, ...body } = input;
39
- const normalizedEvent = normalizeEvent(event, this.normalization);
40
- return this.http.post('/ingest/events', { ...body, dsnKey, event: normalizedEvent }, { auth: 'apiKey', headers });
41
- }
42
- async health(dsnKey) {
43
- const resolvedDsnKey = dsnKey ?? this.defaultDsnKey;
44
- ensureDefined(resolvedDsnKey, 'dsnKey');
45
- ensureNonEmpty(resolvedDsnKey, 'dsnKey');
46
- return this.http.post('/ingest/health', { dsnKey: resolvedDsnKey }, { auth: 'apiKey' });
47
- }
48
- }
49
- function normalizeEvent(event, options) {
50
- const config = { ...DEFAULT_NORMALIZATION, ...options };
51
- const normalizedTimestamp = normalizeTimestamp(event.timestamp);
52
- const normalizedLevel = event.level ? event.level.toLowerCase() : undefined;
53
- const normalizedMessage = event.message ? truncate(event.message, config.maxMessageLength) : undefined;
54
- const normalizedException = normalizeException(event.exception, config);
55
- if (!normalizedMessage && !normalizedException) {
56
- throw new ValidationError('event message or exception is required');
57
- }
58
- const normalizedContext = normalizeContext(event.context, config);
59
- const normalizedEvent = {
60
- ...event,
61
- event_id: event.event_id ?? randomUUID(),
62
- timestamp: normalizedTimestamp,
63
- schema_version: event.schema_version ?? config.schemaVersion,
64
- level: normalizedLevel,
65
- message: normalizedMessage,
66
- exception: normalizedException,
67
- context: normalizedContext,
68
- };
69
- return enforceSizeLimit(normalizedEvent, config);
70
- }
71
- function normalizeTimestamp(timestamp) {
72
- if (!timestamp)
73
- return new Date().toISOString();
74
- const parsed = new Date(timestamp);
75
- if (Number.isNaN(parsed.getTime())) {
76
- throw new ValidationError('timestamp must be a valid ISO date');
77
- }
78
- return parsed.toISOString();
79
- }
80
- function normalizeException(exception, config) {
81
- if (!exception)
82
- return undefined;
83
- if (!exception.type || !exception.value) {
84
- throw new ValidationError('exception.type and exception.value are required');
85
- }
86
- return {
87
- ...exception,
88
- value: truncate(exception.value, config.maxExceptionValueLength),
89
- stacktrace: normalizeStacktrace(exception.stacktrace, config.maxFrames),
90
- };
91
- }
92
- function normalizeStacktrace(stacktrace, maxFrames) {
93
- if (!stacktrace || !Array.isArray(stacktrace.frames))
94
- return undefined;
95
- const frames = stacktrace.frames;
96
- const normalizedFrames = frames.slice(0, maxFrames).map((frame) => {
97
- const filename = typeof frame?.filename === 'string' ? frame.filename : undefined;
98
- const functionName = typeof frame?.function === 'string' ? frame.function : undefined;
99
- const lineno = typeof frame?.lineno === 'number' ? frame.lineno : undefined;
100
- const colno = typeof frame?.colno === 'number' ? frame.colno : undefined;
101
- const inferredInApp = filename ? !filename.includes('node_modules') : false;
102
- return {
103
- filename,
104
- function: functionName,
105
- lineno,
106
- colno,
107
- in_app: typeof frame?.in_app === 'boolean' ? frame.in_app : inferredInApp,
108
- };
109
- });
110
- return { frames: normalizedFrames };
111
- }
112
- function normalizeContext(context, config) {
113
- if (!config.includeContext)
114
- return context;
115
- const systemContext = config.includeSystemContext ? getProcessContextDynamic() : undefined;
116
- const runtimeContext = config.includeRuntimeContext ? getProcessContextStatic({ includeVersions: false }) : undefined;
117
- const mergedContext = {
118
- ...context,
119
- system: context?.system ?? systemContext,
120
- runtime: context?.runtime ?? runtimeContext,
121
- };
122
- return mergedContext;
123
- }
124
- function enforceSizeLimit(event, config) {
125
- let normalized = event;
126
- if (getSize(normalized) <= config.maxEventBytes)
127
- return normalized;
128
- if (normalized.extra) {
129
- normalized = { ...normalized, extra: undefined };
130
- }
131
- if (getSize(normalized) <= config.maxEventBytes)
132
- return normalized;
133
- if (normalized.tags) {
134
- normalized = { ...normalized, tags: undefined };
135
- }
136
- if (getSize(normalized) <= config.maxEventBytes)
137
- return normalized;
138
- if (normalized.exception?.stacktrace) {
139
- normalized = {
140
- ...normalized,
141
- exception: { ...normalized.exception, stacktrace: undefined },
142
- };
143
- }
144
- if (getSize(normalized) <= config.maxEventBytes)
145
- return normalized;
146
- if (normalized.message) {
147
- normalized = { ...normalized, message: truncate(normalized.message, config.maxMessageLength) };
148
- }
149
- if (normalized.exception?.value) {
150
- normalized = {
151
- ...normalized,
152
- exception: { ...normalized.exception, value: truncate(normalized.exception.value, config.maxExceptionValueLength) },
153
- };
154
- }
155
- if (getSize(normalized) <= config.maxEventBytes)
156
- return normalized;
157
- throw new ValidationError('event payload exceeds size limit');
158
- }
159
- function getSize(value) {
160
- return Buffer.byteLength(JSON.stringify(value), 'utf8');
161
- }
162
- function truncate(value, maxLength) {
163
- if (value.length <= maxLength)
164
- return value;
165
- return value.slice(0, maxLength);
166
- }
167
- //# sourceMappingURL=ingestApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ingestApi.js","sourceRoot":"","sources":["../../../src/apis/ingestApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AAEnC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAChD,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAC3F,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAcjE,MAAM,qBAAqB,GAAyC;IAChE,aAAa,EAAE,CAAC;IAChB,cAAc,EAAE,IAAI;IACpB,oBAAoB,EAAE,IAAI;IAC1B,qBAAqB,EAAE,IAAI;IAC3B,aAAa,EAAE,EAAE,GAAG,IAAI;IACxB,SAAS,EAAE,EAAE;IACb,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,IAAI;CAChC,CAAA;AAKD,MAAM,OAAO,SAAS;IAKG;IACA;IACA;IAHrB,YACqB,IAAgB,EAChB,aAAsB,EACtB,aAA0C;QAF1C,SAAI,GAAJ,IAAI,CAAY;QAChB,kBAAa,GAAb,aAAa,CAAS;QACtB,kBAAa,GAAb,aAAa,CAA6B;IAC3D,CAAC;IAKL,KAAK,CAAC,KAAK,CAAC,KAAoB;QAC5B,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC7B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,aAAa,CAAA;QACjD,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAC/B,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,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,CAAC,uBAAuB,CAAC,EAAE;SACtH,CAAA;IACL,CAAC;IACD,IAAI,OAAO,CAAC,UAAU,CAAC,IAAI,MAAM,CAAC,aAAa;QAAE,OAAO,UAAU,CAAA;IAClE,MAAM,IAAI,eAAe,CAAC,kCAAkC,CAAC,CAAA;AACjE,CAAC;AAED,SAAS,OAAO,CAAC,KAAc;IAC3B,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAA;AAC3D,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,SAAiB;IAC9C,IAAI,KAAK,CAAC,MAAM,IAAI,SAAS;QAAE,OAAO,KAAK,CAAA;IAC3C,OAAO,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAA;AACpC,CAAC"}
@@ -1,11 +0,0 @@
1
- import type { UptimeEvent, UptimeHeartbeatInput, UptimeSummary } from '../domain/uptime';
2
- import type { HttpClient } from '../http/httpClient';
3
- export declare class UptimeApi {
4
- private readonly http;
5
- private readonly defaultDsnKey?;
6
- constructor(http: HttpClient, defaultDsnKey?: string | undefined);
7
- recordHeartbeat(input: UptimeHeartbeatInput): Promise<UptimeEvent>;
8
- history(projectId: string, date: string): Promise<UptimeEvent[]>;
9
- latest(projectId: string): Promise<UptimeEvent | null>;
10
- summary(projectId: string, days?: number, delayThresholdMinutes?: number): Promise<UptimeSummary[]>;
11
- }
@@ -1,39 +0,0 @@
1
- import { ensureDefined, ensureNonEmpty } from '../utils/validate.js';
2
- export class UptimeApi {
3
- http;
4
- defaultDsnKey;
5
- constructor(http, defaultDsnKey) {
6
- this.http = http;
7
- this.defaultDsnKey = defaultDsnKey;
8
- }
9
- async recordHeartbeat(input) {
10
- ensureDefined(input, 'input');
11
- const dsnKey = input.dsnKey ?? this.defaultDsnKey;
12
- ensureDefined(dsnKey, 'dsnKey');
13
- ensureNonEmpty(dsnKey, 'dsnKey');
14
- ensureNonEmpty(input.status, 'status');
15
- return this.http.post('/uptime/heartbeats', { ...input, dsnKey }, { auth: 'apiKey' });
16
- }
17
- async history(projectId, date) {
18
- ensureNonEmpty(projectId, 'projectId');
19
- ensureNonEmpty(date, 'date');
20
- return this.http.get(`/projects/${encodeURIComponent(projectId)}/uptime/history`, {
21
- query: { date },
22
- auth: 'none',
23
- });
24
- }
25
- async latest(projectId) {
26
- ensureNonEmpty(projectId, 'projectId');
27
- return this.http.get(`/projects/${encodeURIComponent(projectId)}/uptime/latest`, {
28
- auth: 'none',
29
- });
30
- }
31
- async summary(projectId, days, delayThresholdMinutes) {
32
- ensureNonEmpty(projectId, 'projectId');
33
- return this.http.get(`/projects/${encodeURIComponent(projectId)}/uptime/summary`, {
34
- query: { days, delayThresholdMinutes },
35
- auth: 'none',
36
- });
37
- }
38
- }
39
- //# sourceMappingURL=uptimeApi.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uptimeApi.js","sourceRoot":"","sources":["../../../src/apis/uptimeApi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAMjE,MAAM,OAAO,SAAS;IAIW;IAAmC;IAAhE,YAA6B,IAAgB,EAAmB,aAAsB;QAAzD,SAAI,GAAJ,IAAI,CAAY;QAAmB,kBAAa,GAAb,aAAa,CAAS;IAAI,CAAC;IAK3F,KAAK,CAAC,eAAe,CAAC,KAA2B;QAC7C,aAAa,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;QAC7B,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,aAAa,CAAA;QACjD,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAC/B,cAAc,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QAChC,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAc,oBAAoB,EAAE,EAAE,GAAG,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IACtG,CAAC;IAKD,KAAK,CAAC,OAAO,CAAC,SAAiB,EAAE,IAAY;QACzC,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QACtC,cAAc,CAAC,IAAI,EAAE,MAAM,CAAC,CAAA;QAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAgB,aAAa,kBAAkB,CAAC,SAAS,CAAC,iBAAiB,EAAE;YAC7F,KAAK,EAAE,EAAE,IAAI,EAAE;YACf,IAAI,EAAE,MAAM;SACf,CAAC,CAAA;IACN,CAAC;IAKD,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC1B,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAqB,aAAa,kBAAkB,CAAC,SAAS,CAAC,gBAAgB,EAAE;YACjG,IAAI,EAAE,MAAM;SACf,CAAC,CAAA;IACN,CAAC;IAKD,KAAK,CAAC,OAAO,CAAC,SAAiB,EAAE,IAAa,EAAE,qBAA8B;QAC1E,cAAc,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QACtC,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAkB,aAAa,kBAAkB,CAAC,SAAS,CAAC,iBAAiB,EAAE;YAC/F,KAAK,EAAE,EAAE,IAAI,EAAE,qBAAqB,EAAE;YACtC,IAAI,EAAE,MAAM;SACf,CAAC,CAAA;IACN,CAAC;CACJ"}
@@ -1,47 +0,0 @@
1
- import type { ProcessContextDynamic, ProcessContextStatic } from '../utils/processContext';
2
- export type IngestLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
3
- export type StacktraceFrame = {
4
- filename?: string;
5
- function?: string;
6
- lineno?: number;
7
- colno?: number;
8
- in_app?: boolean;
9
- };
10
- export type Stacktrace = {
11
- frames: StacktraceFrame[];
12
- };
13
- export type IngestException = {
14
- type: string;
15
- value: string;
16
- stacktrace?: Stacktrace;
17
- };
18
- export type RequestContext = {
19
- requestId?: string;
20
- userId?: string;
21
- [key: string]: unknown;
22
- };
23
- export type IngestEventContext = {
24
- system?: ProcessContextDynamic;
25
- runtime?: ProcessContextStatic;
26
- request?: RequestContext;
27
- };
28
- export type IngestEvent = {
29
- event_id?: string;
30
- timestamp?: string;
31
- schema_version?: number;
32
- level?: IngestLevel;
33
- message?: string;
34
- exception?: IngestException;
35
- context?: IngestEventContext;
36
- tags?: Record<string, string>;
37
- extra?: Record<string, unknown>;
38
- };
39
- export type IngestRequest = {
40
- dsnKey?: string;
41
- event: IngestEvent;
42
- idempotencyKey?: string;
43
- sdkVersion?: string;
44
- };
45
- export type IngestResponse = {
46
- event_id: string;
47
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ingest.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ingest.js","sourceRoot":"","sources":["../../../src/domain/ingest.ts"],"names":[],"mappings":""}
@@ -1,23 +0,0 @@
1
- export type UptimeStatus = 'up' | 'down' | 'degraded';
2
- export type UptimeEvent = {
3
- id: string;
4
- projectId: string;
5
- status: UptimeStatus;
6
- message?: string;
7
- responseTimeMs?: number;
8
- checkedAt?: string;
9
- createdAt?: string;
10
- };
11
- export type UptimeHeartbeatInput = {
12
- dsnKey?: string;
13
- status: UptimeStatus;
14
- responseTimeMs?: number;
15
- checkedAt?: string;
16
- message?: string;
17
- };
18
- export type UptimeSummary = {
19
- date: string;
20
- missingHours?: number;
21
- delayMinutes?: number;
22
- delayedCount?: number;
23
- };
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=uptime.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uptime.js","sourceRoot":"","sources":["../../../src/domain/uptime.ts"],"names":[],"mappings":""}