import { AttributeValueType } from "../utils/otel"; import { AnyValue } from "./otlp"; import { Endpoint, Vars, PropagatorConfig } from "../vars"; export type InstrumentationName = | "@dash0/navigation" | "@dash0/web-vitals" | "@dash0/error" | "@dash0/fetch" | "@dash0/xhr" | "@dash0/session-recording" | "@dash0/frustration-signals"; /** * VCS (version control) context describing the build the SDK is running * inside. Used both as the public manual-override shape on `InitOptions.vcs` * and internally as the merged result of auto-detection. Each field maps to * a standard OpenTelemetry `vcs.*` resource attribute. */ export type VcsAttributes = { /** vcs.provider.name — e.g. "github", "gitlab", "bitbucket". */ providerName?: string; /** vcs.owner.name — repository owner / organization. */ ownerName?: string; /** vcs.repository.name — short repository name (no owner prefix). */ repositoryName?: string; /** vcs.repository.url.full — canonical repository URL. */ repositoryUrlFull?: string; /** vcs.ref.head.name — branch or tag name the build was made from. */ refHeadName?: string; /** vcs.ref.head.revision — commit SHA the build was made from. */ refHeadRevision?: string; /** vcs.change.id — pull/merge request identifier (preview deploys). */ changeId?: string; }; export type InitOptions = { serviceName: string; serviceNamespace?: string; serviceVersion?: string; environment?: string; deploymentName?: string; deploymentId?: string; /** * Additional attributes to include with transmitted signals */ additionalSignalAttributes?: Record; /** * When enabled (the default), reject `serviceName` values that contain * characters commonly associated with injection payloads (quotes, angle * brackets, braces, semicolons, control characters) and fall back to * `location.hostname`. This guards against automated security scanners or * untrusted callers influencing the value sent to `init()`. * * Set to `false` to opt out and pass the `serviceName` through unchanged. */ rejectSuspiciousServiceName?: boolean; /** * When `true`, disable auto-detection of VCS (version control) context * from the build environment. By default the SDK reads VCS context from * Vercel (`VERCEL_GIT_*`) and Netlify * (`REPOSITORY_URL`, `BRANCH`, * `COMMIT_REF`, `REVIEW_ID`) and applies the values * as resource attributes following the OTel `vcs.*` semantic conventions: * * - vcs.provider.name * - vcs.owner.name * - vcs.repository.name * - vcs.repository.url.full * - vcs.ref.head.name * - vcs.ref.head.revision * - vcs.change.id * * Pairing telemetry with the git commit + branch the build came from lets * Dash0 Agent answer questions like "which PR introduced this error?". * * Note: any fields supplied via `vcs` are still applied even when this flag * is `true` — manual overrides always win. Set this flag when you want to * prevent env-var reads entirely but still supply context explicitly. */ disableVcsDetection?: boolean; /** * Manually specify VCS (version control) context. Each provided field * overrides the value the SDK would otherwise auto-detect from the build * environment for that attribute. Use this for non-Vercel/Netlify * deployments, or when the auto-detected values are wrong. */ vcs?: VcsAttributes; /** * OTLP endpoints to which the generated telemetry should be sent to. */ endpoint: Endpoint | Endpoint[]; /** * Which instrumentations to enable. Defaults to undefined, which means all instrumentations. */ enabledInstrumentations?: InstrumentationName[]; /** * The percentage of sessions for which telemetry data is recorded and transmitted. * Must be a number between 0 and 100. * - 0: No sessions are recorded/transferred. * - 100: All sessions are recorded/transferred (default). * - Any other value: That percentage of sessions are recorded/transferred. * The sampling decision is deterministic per session ID. */ sessionSamplingRate?: number; /** * The session inactivity timeout. Session inactivity is the maximum * allowed time to pass between two page loads before the session is considered * to be expired. Also think of cache time-to-idle configuration options. */ sessionInactivityTimeoutMillis?: number; /** * The default session termination timeout. Session termination is the maximum * allowed time to pass since session start before the session is considered * to be expired. Also think of cache time-to-live configuration options. */ sessionTerminationTimeoutMillis?: number; /** * Configure trace context propagators for different URL patterns. * Each propagator defines which header type to send for matching URLs. */ propagators?: PropagatorConfig[]; } & Partial< Pick< Vars, | "ignoreUrls" | "ignoreErrorMessages" | "wrapEventHandlers" | "wrapTimers" | "propagateTraceHeadersCorsURLs" | "maxWaitForResourceTimingsMillis" | "maxToleranceForResourceTimingsMillis" | "headersToCapture" | "urlAttributeScrubber" | "pageViewInstrumentation" | "sessionRecording" | "frustrationSignals" | "enableTransportCompression" > >;