Reference
JavaScript SDK API
Functions, classes, options, parameters, and return values for the Anectico JavaScript and TypeScript SDK.
This is the application-developer API for @anectico/sdk 0.1.x. Import optional capabilities from
their documented subpaths so replay, React, and provider-specific code stays out of the base bundle.
Use a key with ingest:write for traces, metrics, logs, and errors. Add analytics:write for
identity, groups, diagnostic events, and flag exposure events; flags:read for decisions; and
replay:write for replay.
Initialize the core client
import { init, AnecticoClient } from '@anectico/sdk';
const anectico = await init({
apiKey: process.env.ANECTICO_API_KEY,
serviceName: 'orders-api',
});
// Equivalent lifecycle with explicit construction:
const second = await new AnecticoClient(options).start();
await second.stop();
| API | Parameters | Returns | Behavior |
|---|---|---|---|
init(options?) |
AnecticoOptions |
Promise<AnecticoClient> |
Creates, validates, starts, and returns one client. Recommended entry point. |
new AnecticoClient(options?) |
AnecticoOptions |
AnecticoClient |
Creates an unstarted client. Call start() before recording. |
start() |
— | Promise<AnecticoClient> |
Validates configuration and starts OTLP transports. Repeated calls return the same client. |
flush() |
— | Promise<void> |
Waits for in-flight identity posts and force-flushes trace, metric, and log providers without stopping them. Concurrent calls share one flush. Use at serverless invocation boundaries. |
stop() |
— | Promise<void> |
Waits for bounded in-flight identify/group posts, flushes transports, removes installed hooks, and releases resources. Concurrent and repeated calls share the same shutdown. |
registerShutdownHook(hook) |
cleanup function | void |
Registers a cleanup that stop() invokes once. Framework integrations use this to remove installed handlers. |
isRunning() |
— | boolean |
Reports whether the client currently accepts telemetry. |
getConfig() |
— | ResolvedConfig |
Returns a defensive copy of the resolved configuration for diagnostics. It includes sensitive headers; do not log it. |
health() |
— | HealthStatus |
Returns healthy, degraded, or stopped, recent internal errors, uptime, and signal counters. |
stats() |
— | ClientStats |
Returns processed, dropped, and failed-export counters plus timing data. |
Keep one client per application process or browser page. Always await stop() during graceful
server shutdown so identity posts and buffered telemetry finish before the process exits. A rejected
identity endpoint response is reported through SDK debug logging instead of being treated as an
accepted delivery. In managed mode, allow application-drain time plus up to twice
shutdownTimeout: one deadline for identity/group delivery and one for concurrent trace, metric,
and log provider shutdown.
Node cannot intercept SIGKILL, kill -9, a forced zero-grace pod deletion, or host loss, so these
paths produce no terminal capture and run no final flush. The unexported tail can include active
spans, in-flight identity/group requests, up to maxQueueSize ended spans and logs per batched
signal (2,048 each by default), and metric observations since the last
metricExportInterval. Prefer SIGTERM with a non-zero termination grace period.
For AWS Lambda-style runtimes, memoize one initNode() promise at module scope and await flush()
in the handler’s finally block. This exports the completed invocation before the runtime can freeze
without disabling warm reuse. Keep end-user attribution request-scoped with
contextWithDistinctId; reserve stop() for final process teardown.
Browser performance budget
For production browser applications, keep the core SDK’s incremental compressed transfer at or
below 250 KiB and load the optional replay subpath only when recording is enabled; its incremental
compressed transfer budget is 200 KiB. Against an otherwise identical control build, target no more
than a 20% matched-workload regression, no more than 200 ms total blocking time, no task above
100 ms, and no SDK request amplification above 5% of application requests. These are acceptance
ceilings, not expected steady-state values. Measure cold and warm builds on representative long
pages and interaction bursts, and call stop() when instrumentation is disabled so hooks, timers,
and observers are released.
Replay uses ordinary fetches for size- and timer-triggered chunks so large initial snapshots and
short activity bursts are not rejected by the browser’s shared keepalive-body quota. The final
pagehide tail alone uses a keepalive request because it may need to outlive the document.
AnecticoOptions
Explicit options override environment values. Required values have no usable default.
| Option | Type | Default/environment | Purpose |
|---|---|---|---|
apiKey |
string |
ANECTICO_API_KEY; required |
Project-scoped Anectico API key. |
serviceName |
string |
OTEL_SERVICE_NAME; required |
Logical application or service name. |
serviceVersion |
string |
OTEL_SERVICE_VERSION; 0.0.0 |
Deployed version. |
environment |
string |
ANECTICO_ENVIRONMENT; runtime-derived |
Deployment environment such as production. |
release |
string |
ANECTICO_RELEASE, then real serviceVersion |
Release used for regression detection and source maps. |
dist |
string |
ANECTICO_DIST; empty |
Artifact/build discriminator within a release. |
endpoint |
string |
ANECTICO_ENDPOINT; https://api.anectico.com |
Base API and OTLP URL. |
protocol |
'http' |
http |
JavaScript supports OTLP over HTTP only. |
openTelemetryMode |
'managed' | 'existing' |
ANECTICO_OTEL_MODE; managed |
Use existing when the application already owns global providers, exporters, instrumentation, and their lifecycle. |
enableTraces |
boolean |
ANECTICO_ENABLE_TRACES; true |
Enable trace export. |
enableMetrics |
boolean |
ANECTICO_ENABLE_METRICS; true |
Enable metric export. |
enableLogs |
boolean |
ANECTICO_ENABLE_LOGS; true |
Enable log export. |
enableErrorCapture |
boolean |
ANECTICO_ENABLE_ERROR_CAPTURE; true |
Enable captureError and captureMessage. |
enableFetchTracing |
boolean |
true |
Browser only: instrument fetch/XHR and inject trace headers. Disabling it does both. |
propagateTraceHeaderCorsUrls |
(string | RegExp)[] |
empty | Browser cross-origin destinations allowed to receive trace and identity headers. |
propagateTraceHeaderUrls |
(string | RegExp)[] |
ANECTICO_PROPAGATE_TRACE_HEADER_URLS; empty |
Node HTTP(S) destinations allowed to receive trace and identity headers. |
ignoreIncomingRequestPaths |
string[] |
ANECTICO_IGNORE_INCOMING_REQUEST_PATHS; empty |
Node managed mode: exact or trailing-* paths excluded from generic incoming HTTP spans, such as health and internal control routes. |
traceSampleRate |
number |
OTEL_TRACES_SAMPLER_ARG; 0.1 production, 1 development |
Trace sampling in the inclusive range 0–1. |
errorSampleRate |
number |
ANECTICO_ERROR_SAMPLE_RATE; 1 |
Non-fatal captured-error sampling in the inclusive range 0–1. |
attachStackTrace |
boolean |
ANECTICO_ATTACH_STACK_TRACE; true |
Parse and attach error stack frames. |
maxStackTraceFrames |
number |
ANECTICO_MAX_STACK_TRACE_FRAMES; 50 |
Maximum captured frames. |
batchSize |
number |
OTEL_BSP_MAX_EXPORT_BATCH_SIZE; 512 |
Maximum items per export batch. |
batchTimeout |
number |
OTEL_BSP_SCHEDULE_DELAY; 5000 ms |
Maximum delay before a trace/log batch flushes. |
maxQueueSize |
number |
OTEL_BSP_MAX_QUEUE_SIZE; 2048 |
Queue capacity before signals are dropped. Must be at least batchSize. |
exportTimeout |
number |
OTEL_BSP_EXPORT_TIMEOUT; 30000 ms |
Per-export deadline. |
metricExportInterval |
number |
OTEL_METRIC_EXPORT_INTERVAL; 60000 ms |
Metric push interval; raised to at least exportTimeout. |
shutdownTimeout |
number |
OTEL_BSP_SHUTDOWN_TIMEOUT; 5000 ms |
Per-phase graceful deadline: bounds one-shot identity/group delivery and the concurrent provider-shutdown phase. |
resourceAttributes |
Record<string,string> |
empty | Extra OpenTelemetry resource attributes. |
headers |
Record<string,string> |
empty | Extra headers on exports. Do not expose secrets in browser builds. |
debug |
boolean |
ANECTICO_DEBUG; false |
Enable SDK diagnostic logs. |
In existing mode, Anectico creates no provider, exporter, propagator, or auto-instrumentation and does
not flush or shut down application-owned providers. Start the application’s OpenTelemetry SDK
first. Anectico’s manual APIs use its registered globals; the application remains responsible for
provider flush/shutdown and for installing both W3C Trace Context and W3C Baggage propagation.
Add the exported BaggageSpanProcessor and BaggageLogRecordProcessor to application-owned
providers before startup when request-scoped identity should be materialized on spans and logs.
Traces, metrics, logs, and AI operations
| Method | Parameters | Returns | Behavior |
|---|---|---|---|
tracer |
property | OpenTelemetry Tracer |
Access the underlying tracer for advanced instrumentation. |
startSpan(name, options?) |
name; OTel SpanOptions |
OTel Span |
Starts a span. The caller must call span.end(). Returns a no-op span before startup. |
recordMetric(name, value, labels?) |
metric name; number; string labels | void |
Records one histogram observation. Invalid calls increment dropped-metric stats rather than throwing. |
logEvent(level, message, attrs?) |
debug | info | warn | error | silent; message; attributes |
void |
Emits one structured OTel log. Complex attribute values are JSON-stringified. |
recordLLMCall(options) |
LLMCallOptions |
void |
Records one completed model call as a gen_ai client span. |
recordToolCall(options) |
ToolCallOptions |
void |
Records one completed agent tool/function call. |
startAgentRun(options) |
AgentRunOptions |
{ span, context, end } |
Starts an invoke_agent span. Run child work in the returned OTel context, then call run.end(status, reasonCode); the first valid outcome wins. |
Agent-run status is completed, failed, timed_out, cancelled, or max_steps. The reason is a
lowercase code matching [a-z][a-z0-9_]{0,63}; free text is rejected. Calling run.span.end()
directly bypasses the terminal contract and produces only the legacy inferred status.
LLMCallOptions.model is required. Optional fields are responseModel, provider, operation,
token counts (inputTokens, outputTokens, reasoningTokens, cacheReadTokens,
cacheWriteTokens), costUsd, finishReason, startTime, endTime, and isError. messages and
output opt into prompt/completion content capture.
ToolCallOptions.name is required. Optional fields are type, callId, conversationId,
agentName, isError, arguments, and result. Arguments and results can contain sensitive data;
omit them unless content capture is approved.
Errors, messages, users, and breadcrumbs
| Method | Parameters | Returns | Behavior |
|---|---|---|---|
captureError(error, options?) |
Error; CaptureOptions |
string |
Sends an error span and returns its generated ID. Returns '' when capture is unavailable or sampled out. |
captureMessage(message, level?, options?) |
message; ErrorLevel; CaptureOptions |
string |
Captures a diagnostic message. Only error and fatal produce error status. |
addBreadcrumb(category, message, options?) |
strings; BreadcrumbOptions |
void |
Buffers context for the next captured error, then clears the buffer. Capacity is 100. |
setUser(user) |
AnecticoUser |
void |
Sets global error user context. Prefer identify for the cross-signal identity spine. |
clearUser() |
— | void |
Removes global error user context. |
CaptureOptions accepts tags: Record<string,string>, extra: Record<string,unknown>, user,
stackTrace, level, and fingerprint. A fingerprint is a string or string array; commas are the
component delimiter, and {{default}} includes automatic grouping. Tag keys are encoded as indexed
anectico.tag.* telemetry attributes automatically; the capture level is indexed as
error.level for Issue filtering and context.
AnecticoUser accepts id, email, username, ipAddress, segment, and data. Breadcrumb options
accept level and data.
Identity and accounts
| Method | Parameters | Returns | Behavior |
|---|---|---|---|
identify(distinctId, properties?) |
stable ID; person properties | void |
Switches shared identity and starts a best-effort identify request that stop() waits for. Empty IDs are ignored. |
group(groupType, groupKey, properties?) |
group type; stable key; group properties | void |
Associates the current person with an account and starts a $groupidentify request that stop() waits for. |
reset() |
— | void |
Logout: stops active replay recorders and flushes their prior-user tail before rotating anonymous identity/session; also clears groups, global error-user context, and uncaptured breadcrumbs. Other already-captured telemetry remains queued with its original attribution. |
getSessionId() |
— | string |
Returns the current browser tab’s cross-signal session ID, rotating it after its idle/max duration. |
For concurrent Node requests, use contextWithDistinctId(ctx, id) and
distinctIdFromContext(ctx) instead of changing process-wide identity. adoptDistinctIdFromBaggage
must be used only after an authenticated gateway has replaced untrusted inbound baggage.
Browser session state is tab-scoped. A reload keeps the same session, while a separate, duplicated,
or opener-created tab receives its own session and replay boundary. Call identify after
authentication in every tab. Calling reset on logout rotates only that tab’s identity/session and
does not move another live tab’s telemetry into the new customer’s session. Replay’s next chunk
index is stored beside this tab-scoped state so a reload appends to the recording instead of
replacing its first chunks.
Diagnostic events: @anectico/sdk/analytics
import { AnalyticsClient } from '@anectico/sdk/analytics';
const events = new AnalyticsClient({
endpoint: 'https://api.anectico.com',
apiKey: process.env.ANECTICO_API_KEY!,
});
| API | Parameters | Returns | Behavior |
|---|---|---|---|
new AnalyticsClient(options) |
endpoint, API key, optional flushAt, flushInterval, fetchImpl, identity |
AnalyticsClient |
Creates a batching event client. Defaults: flush at 20 events or 5 seconds. |
getDistinctId() |
— | string |
Current shared known or anonymous ID. |
capture(event, properties?) |
name; properties | void |
Queues one diagnostic event with identity, groups, session, timestamp, and dedup ID. |
identify(distinctId, personProps?) |
ID; person properties | void |
Queues identity merge, switches identity, and starts a flush. |
group(type, key, properties?) |
group type/key; properties | void |
Records membership and a group identify event. |
reset() |
— | void |
Rotates anonymous identity and session. |
flush({ keepalive? }?) |
optional browser keepalive | Promise<void> |
Sends queued events in server-safe chunks and requeues transient failures. |
stop({ keepalive? }?) |
optional browser keepalive | Promise<void> |
Stops timers/listeners and flushes remaining events. Further capture calls fail. |
The diagnostic-event queue is bounded and in memory. A transient network failure is requeued
with the same message ID and the timer retries while the page remains alive, so reconnecting without
navigation preserves order and backend deduplication. A reload, navigation, browser termination, or
OS process kill replaces that memory and can discard events that have not reached Anectico. Call
await events.flush({ keepalive: true }) before controlled navigation when delivery matters; do not
describe browser diagnostic events as durable offline storage.
Feature flags: @anectico/sdk/analytics
FlagsClient needs flags:read. Its default exposure sender also needs analytics:write.
| API | Parameters | Returns | Behavior |
|---|---|---|---|
new FlagsClient(options, capture?) |
endpoint, API key, optional fetch/bootstrap; optional exposure callback | FlagsClient |
Creates an in-memory decision client. Bootstrap avoids the first network call. |
reload(distinctId, personProperties?, groups?) |
person ID; properties; group map | Promise<void> |
Calls /api/v1/decide, replaces cached flags/payloads, and resets exposure dedup when identity changes. |
getFeatureFlag(key) |
flag key | boolean | string | undefined |
Returns a decision and emits one deduplicated exposure for that key/value. |
isFeatureEnabled(key) |
flag key | boolean |
True for true or a non-empty string variant. |
getFeatureFlagPayload(key) |
flag key | unknown |
Returns the payload from the latest decision. |
allFlags() |
— | Record<string, boolean | string> |
Returns a copy of every cached decision. |
hadEvaluationErrors() |
— | boolean |
Reports whether the server used a fallback during the latest evaluation. |
reset() |
— | void |
Clears only the per-key/value exposure dedup set. Cached decisions and payloads remain available until the next reload. |
Browser decisions reveal flag configuration to the client. Never store secrets in flag rules or payloads.
For Node/server local evaluation, import LocalFlagsClient from @anectico/sdk/flags-local and pass
{endpoint, apiKey, projectId} plus an optional capture callback in the same shape accepted by
FlagsClient. refresh() validates a project-bound snapshot with ETag/If-None-Match; repeated
refreshes are serialized. evaluate(key, distinctId, personProperties?) returns
{value?,payload?,snapshot_version?,reason,error?} and never returns a value from a stale snapshot
or an unsupported cohort/group target. Successful matched/default reads emit
$feature_flag_called once per identity/key/value when a callback is configured; call
reset() after an explicit identity reset. A network-backed callback also needs analytics:write.
| Local API | Parameters | Returns | Behavior |
|---|---|---|---|
new LocalFlagsClient(options, capture?) |
options: endpoint, API key, canonical project ID, optional fetch/clock; capture(event, properties, distinctId) |
LocalFlagsClient |
Creates one exact-project cache. Snapshot reads need flags:read; an Anectico-backed capture callback needs analytics:write. |
refresh() |
— | Promise<"updated" | "not_modified"> |
Fetches or conditionally revalidates the strict, bounded snapshot without replacing a last-known-good cache on failure. |
evaluate(key, distinctId, personProperties?) |
flag key, exact identity, person properties | LocalEvaluationResult |
Evaluates only a fresh snapshot and emits a successful exposure through the optional callback. |
reset() |
— | void |
Clears local (identity,key,value) exposure deduplication; preserves the snapshot. |
Replay: @anectico/sdk/replay
startReplay(options) starts rrweb recording and returns a synchronous stop function. The stop
function removes hooks and flushes the buffered tail. It is idempotent.
AnecticoClient.reset() also stops every active recorder synchronously and flushes its buffered tail
before changing the shared identity/session. This prevents a recorder started for user A from
capturing user B’s UI after logout. Start a new recorder after identifying user B if replay should
resume.
Replay chunks are best-effort and buffered only in page memory. A failed chunk upload is dropped rather than retried, and an offline reload can lose the buffered tail. Replay must never be used as a durable audit log.
| Option | Type/default | Purpose |
|---|---|---|
endpoint, apiKey |
required strings | Replay endpoint and key with replay:write. |
sessionId, distinctId |
optional strings | Override shared session/person linkage. |
maxEvents |
number; 50 |
Flush threshold. |
flushMs |
number; 5000 |
Time-based flush interval. |
maskAllInputs |
boolean; true |
Mask input values in the DOM recording. |
slimDOM |
true | 'all'; unset |
Remove non-visual scripts, comments, and head metadata from DOM snapshots. Use 'all' for the smallest initial snapshot. |
inlineStylesheet |
boolean; rrweb default true |
Inline linked stylesheets into snapshots. Set false when the replay viewer can load the original stylesheets and snapshot size matters. |
captureConsole |
boolean; true |
Record console events. Disable unless required. |
captureNetwork |
boolean; true |
Record fetch/XHR metadata and bodies. Disable unless required. |
maxBodyBytes |
number; 10240 |
Per-body truncation limit. |
maxNetworkEvents, maxConsoleEvents |
number; 1000 |
Per-session event caps. |
fetchImpl |
typeof fetch |
Test/SSR transport override. |
shouldFlush(...) and buildChunkBody(...) are exported pure helpers for custom/testing use; most
applications should call only startReplay.
Initialize replay before mounting a very large DOM so the first visible state is recorded, then
hydrate long feeds or tables progressively. For pages with hundreds of nodes, combine progressive
rendering with slimDOM: 'all' and, where the viewer can load the original CSS,
inlineStylesheet: false. This keeps recorder parse work and the initial snapshot off the longest
main-thread task without reducing the recorded user journey.
Node, browser, Express, Fastify, NestJS/GraphQL/Prisma, Next.js, and React
| Import/API | Parameters | Returns | Behavior |
|---|---|---|---|
@anectico/sdk/node initNode(options?) |
AnecticoOptions |
Promise<AnecticoClient> |
Starts the client and installs Node HTTP/process handlers. |
registerProcessHandlers(client) |
client | cleanup function | Installs uncaught exception, rejection, and shutdown handlers. Fatal exceptions and rejections are printed to stderr before the best-effort telemetry flush. The first terminal event owns one capture/flush/exit sequence; capture failure or secondary terminal events cannot bypass or duplicate it. Anectico owns SIGTERM/SIGINT only when no application listener is present; an application listener must close work and spans before awaiting client.stop(). |
setupNodePropagation(trustedUrls?) |
string/regular-expression destination allowlist | void |
Idempotently installs W3C trace/baggage propagation and Node HTTP instrumentation, including synchronized CommonJS and ESM node:http/node:https exports. Preload @anectico/sdk/node/register before application imports. An application propagator registered first is preserved and should include both W3C Trace Context and W3C Baggage. |
setupNodeFrameworkInstrumentation() |
— | void |
Idempotently registers privacy-safe GraphQL execution/resolver and Prisma operation/query instrumentation. The Node preload calls this before application imports. |
anecticoExpressMiddleware(client, options?) |
client; ExpressMiddlewareOptions |
Express handler | Creates request spans and extracts trace context. Identity baggage is ignored unless explicitly trusted. |
anecticoExpressErrorHandler(client) |
client | Express error handler | Captures route errors and must be registered after routes. |
anecticoFastifyPlugin(instance, options) |
Fastify instance; AnecticoFastifyPluginOptions |
Promise<void> |
Registers global lifecycle hooks for request spans, async request identity, errors, timeouts, body aborts, and response disconnects. |
@anectico/sdk/browser initBrowser(options?) |
AnecticoOptions |
Promise<AnecticoClient> |
Starts browser transport, global handlers, and low-overhead fetch/XHR tracing with W3C propagation. It does not clone response bodies or allocate a Resource Timing observer per request. |
registerBrowserHandlers(client) |
client | cleanup function | Installs global error/rejection and lifecycle flush handlers. |
AnecticoProvider |
client, children |
React node | Exposes the client through React context. |
useAnectico() |
— | AnecticoClient |
Reads the provider client; throws outside AnecticoProvider. |
useSpan(name) |
span name | { span, endSpan } |
Creates a component-lifetime span and ends it on unmount. |
AnecticoErrorBoundary |
client, children, optional fallback/hooks | React component | Captures render errors while preserving custom fallback behavior. |
ExpressMiddlewareOptions supports ignorePaths, safe recordHeaders, trustIncomingIdentity,
requestIdentityHook, and spanNameHook. The identity hook resolves a server-authenticated
customer for the current request, overrides untrusted inbound identity baggage, propagates the
identity downstream, and rebinds the matching preload HTTP root. Exact and trailing-* ignored
paths also suppress the generic incoming HTTP span installed by the Node preload. Sensitive
headers are redacted even when requested.
For a managed raw Node HTTP server without the Express or Fastify integration,
set ignoreIncomingRequestPaths on initNode() (or the comma-separated
ANECTICO_IGNORE_INCOMING_REQUEST_PATHS) to suppress health, readiness, and
internal control traffic. Matching supports exact paths and a trailing *;
query strings do not affect matching.
AnecticoFastifyPluginOptions requires client and supports the same ignore/header/trust/span-name
controls plus requestIdentityHook. The identity hook resolves the authenticated customer for the
current request without mutating process-global SDK identity, and rebinds the matching preload HTTP
root so every span in the server trace has the same customer. Its ignored paths likewise apply to
both Fastify and preload HTTP spans.
For NestJS Apollo and Prisma, preload @anectico/sdk/node/register before the
application entry point. Named GraphQL operations and bounded resolver spans are
recorded automatically; literal values are replaced with *, variables are not
recorded, repeated list paths are merged, and trivial property resolvers are
omitted. GraphQL execution errors promote the named operation span to error status,
record the original resolver exception, and add graphql.error.count even when
Apollo returns HTTP 200. Prisma operations and parameterized database queries
appear as child spans, making repeated N+1 work visible.
For Next.js App Router, preload @anectico/sdk/node/register with NODE_OPTIONS before
next start, then memoize one initNode() client from the root
instrumentation.ts register hook. An async onRequestError hook may await
captureError, but it must not attach request headers, cookies, query values, or
action payloads. Add only trusted same-application or downstream origins to
propagateTraceHeaderUrls; internal Route Handler calls are not trusted
implicitly. Next’s OpenTelemetry spans then preserve browser → Server Action →
fetch → Route Handler causality and identity. Name business Actions and attach
bounded safe attributes through the active OpenTelemetry span; never record
FormData, payment tokens, or other server-action secrets.
LLM wrappers and source maps
| API | Parameters | Returns | Behavior |
|---|---|---|---|
wrapOpenAI(client, anectico, options?) |
OpenAI client; Anectico client; { captureContent? } |
same OpenAI client | Instruments non-streaming chat.completions.create calls in place. Idempotent. |
wrapAnthropic(client, anectico, options?) |
Anthropic client; Anectico client; { captureContent? } |
same Anthropic client | Instruments non-streaming messages.create calls in place. Idempotent. |
uploadSourceMap(options) |
release, dist, filename, content, endpoint, API key, optional fetch | Promise<void> |
Uploads one source map. CI should normally use anectico symbols upload-sourcemap. |
collectSourceMaps(directory, fs) |
directory; required filesystem facade | CollectedSourceMap[] |
Finds .map files for a custom uploader. The packaged CLI supplies the Node filesystem adapter. |
Both LLM wrappers pass streaming calls through without automatic spans. captureContent defaults to
false and can record sensitive prompts and completions.
Validation and utility exports
These root exports support framework authors and custom integrations. Normal applications should
prefer init, AnecticoClient, and the documented subpath clients.
| API | Parameters | Returns/behavior |
|---|---|---|
resolveConfig(options?) |
partial AnecticoOptions |
Resolves environment values, defaults, and explicit options into ResolvedConfig. It does not validate required values. |
validateConfig(config) |
resolved config | void; throws for missing credentials/service identity, invalid URL/protocol/rates, or inconsistent batching/timeouts. |
validateAPIKey(key) |
string | void; throws when the key does not match the supported API-key shape. |
isAPIKeyFormat(value) |
string | Boolean shape check without throwing. |
maskAPIKey(key) |
string | Log-safe prefix plus last four characters. Never use the result for authentication. |
generateErrorId() |
— | Hyphenless random error/message ID. |
parseStackTrace(error, maxFrames=50) |
Error; limit |
StackFrame[] parsed from V8, Firefox, or Safari stacks. |
formatStackTrace(frames) |
StackFrame[] |
OpenTelemetry stacktrace string. |
framesToSerializable(frames) |
camel-case frames | Backend wire frames with in_app. |
resolveCaptureOptions(options?, defaultLevel='error') |
capture options/default level | Capture defaults used by custom capture implementations. |
new UserManager() |
— | Mutable global error-user holder with setUser, getUser, and clearUser; values are copied. |
userToAttributes(user) |
AnecticoUser |
Flat OpenTelemetry enduser.* and user.data.* string attributes. |
new IdentityManager(storage?) |
optional Web Storage-like adapter | Identity holder with getDistinctId, getAnonId, identify, group, getGroups, and reset. |
sharedIdentity() |
— | Process/page-wide IdentityManager shared by core signals and analytics. |
contextWithDistinctId(ctx, id) |
OTel context and ID | New context carrying request-local identity and W3C baggage. |
distinctIdFromContext(ctx) |
OTel context | Request-local ID or undefined. |
adoptDistinctIdFromBaggage(ctx) |
trusted OTel context | New context that promotes baggage identity; authenticate first. |
new BreadcrumbBuffer(capacity=100) |
positive capacity | Ring buffer with size, isEmpty, add, serialize, and clear. |
createTransport(config) |
validated ResolvedConfig |
TransportComponents containing enabled OTel providers and signal handles. |
flushTransport(components, timeoutMs) |
components/deadline | Promise<void>; force-flushes all providers without stopping them and reports aggregated failures. |
shutdownTransport(components, timeoutMs) |
components/deadline | Promise<void>; shuts down all providers and reports aggregated failures. |
The Node subpath additionally exports removeDistinctIdFromBaggage(ctx) for stripping an inbound
Anectico identity member while retaining trace context, plus the request-context helpers listed above.