Skip to content
betterstack-alchemyUnofficial

Errors.Application

Kind ResourceType id BetterStack.Errors.ApplicationSource src/Errors/Application.tsLive test available A live lifecycle test exists: it runs against the offline mock by default and against the real API under bun run test:live. This records that the test exists, not a dated live run (see Compatibility). Test file: test/Errors/Application.test.ts.

A Better Stack error-tracking application: collects the exceptions, releases and web events of one service. Better Stack error tracking speaks the Sentry protocol, so a service reports to it with the official Sentry SDK for its platform, configured with the application’s DSN.

platform, dataRegion, correlateWithSourceId and teamId are set on create only: changing one replaces the application (a new DSN). Everything else updates in place; removing applicationGroupId, the code-mapping fields, the repository names or spikeProtectionBaselineMultiplier clears them. name defaults to a generated unique name; an existing application with the same explicit name is adopted with --adopt.

Destroying the application deletes it with all the data it received (the delete is sent with force=true). Retain it with RemovalPolicy.retain() where that data matters.

A Bun service’s error tracking

const errors = yield* BetterStack.Errors.Application("api-errors", {
name: "API",
platform: "bun_errors",
});

The SDK needs the DSN, https://<token>@<ingestingHost>/<id>, which the application exposes as dsn (a Redacted secret; token and ingestingHost are there too). Hand it to the service as environment: the same env record works for a Cloud.Service, a Cloudflare Worker or any host that sets environment variables.

The environment a Sentry SDK reads

const errors = yield* BetterStack.Errors.Application("api-errors", {
platform: "bun_errors",
});
const env = {
SENTRY_DSN: errors.dsn,
SENTRY_ENVIRONMENT: "production",
};

and in the service, as the Better Stack docs show for Node.js and Bun:

import * as Sentry from "@sentry/bun";
Sentry.init({ dsn: process.env.SENTRY_DSN, tracesSampleRate: 1.0 });

An application in an ApplicationGroup

const group = yield* BetterStack.Errors.ApplicationGroup("production", {
name: "Production apps",
});
yield* BetterStack.Errors.Application("web-errors", {
platform: "next_js_errors",
applicationGroupId: group.id,
});

A Release of the application

const errors = yield* BetterStack.Errors.Application("api-errors", {
platform: "bun_errors",
});
yield* BetterStack.Errors.Release("v1", {
applicationId: errors.id,
version: "v1.2.3",
environment: ["production"],
});

Find an application by id

const existing = BetterStack.Errors.Application.lookup({ id: "123456" });

Find an application by name (fails with AmbiguousLookup when several share it)

const byName = BetterStack.Errors.Application.lookup({ name: "Production API" });

platform "aiohttp_errors" | "android_errors" | "angular_errors" | "asgi_errors" | "asp_dot_net_core_errors" | "asp_dot_net_errors" | "astro_errors" | "aws_lambda_dot_ne… required

The SDK or framework the application reports errors from. Can't be changed after the application is created.

aiPromptTemplate string | null

The AI prompt used to fix this application's errors, or the default prompt when the application has none of its own. Send null to go back to the default prompt. A blank prompt is refused.

applicationGroupId string | null

The ID of the application group to put this application in, from List application groups.

codeMappingSourceRoot string | null

The path from your repository's root to the deployed source code, such as apps/backend/. A stack frame's path under code_mapping_stack_root is looked up under this path in the linked repository.

codeMappingStackRoot string | null

The absolute path to the root of the stack trace on your server, such as /usr/src/app/. Stack frames under it are mapped to files in the linked repository.

correlateWithSourceId string | null

The ID of the telemetry source whose logs and traces are linked to these errors. Get it via List sources. Set when the application is created and can't be changed. Sending it on update returns 422, even with the same value.

customBucket CreateApplicationRequestCustomBucket | null

Your own S3-compatible bucket to archive data in, or null when the application uses Better Stack storage. Changing only access_key_id and secret_access_key rotates the bucket's key pair.

dataRegion string

The data region, europe, us, singapore or a dedicated cluster's name from List data regions. An application created with correlate_with_source_id uses that source's region, and a different region here is refused. Omit it to use the organization's default. Set on create only. Sending it on update is refused.

errorsRetention number

Days to keep errors. Accepts one of the retention periods your plan offers, or the value already set. Defaults to your plan's default retention, or to a longer one your other applications already use.

githubRepositoryName string | null

The linked GitHub repository for source-code mapping, as owner/name, such as acme/web. Connect it to your team with the GitHub integration first. Send an empty string to disconnect it. Can't be set together with gitlab_repository_name.

gitlabRepositoryName string | null

The linked GitLab repository for source-code mapping, as group/name, such as acme/web, from your connected repositories. Send an empty string to disconnect it. Can't be set together with github_repository_name.

ingestingPaused boolean

Whether ingestion is paused for this application.

jsTagConfiguration CreateApplicationRequestJsTagConfiguration | null

Settings of the JavaScript tag, as on the application's Frontend page. null for an application without a JavaScript tag. An update changes only the keys you send, inside collect and sampling too. Only custom_config and own_domain accept null.

name string

Application name. Defaults to a unique name generated from the stack, stage and logical id.

replaysRetention number | null

Days to keep session replays. Accepts one of the retention periods your plan offers, or the value already set. A change applies to every application connected to the same source. Only an application that records session replays accepts it. null can't be sent.

spikeProtectionBaselineMultiplier number | null

The baseline multiplier of spike protection, from 0 to 100. Lower values start sampling sooner, and higher values allow bigger bursts before sampling starts. null while spike protection is off. Send null to turn spike protection off.

teamId string

Team that owns the resource, such as t123. Defaults to the credentials' team (BETTERSTACK_TEAM_ID, or the profile's team). Changing it replaces the resource.

vrlTransformationExceptions string

The VRL program that groups incoming exceptions into errors. A new application starts with its platform's default grouping, which groups exceptions by error name and call stack on most platforms. Read more about exception grouping. Send an empty string to remove it. Send null to go back to the default grouping.

vrlTransformationLogs string

The VRL program applied to logs collected alongside errors, during ingestion. Read more about VRL transformations. Send an empty string to remove it.

vrlTransformationReplays string

The VRL program applied to session replays during ingestion. Send an empty string to remove it.

vrlTransformationSpans string

The VRL program applied to spans collected alongside errors, during ingestion. Send an empty string to remove it.

vrlTransformationWebEvents string

The VRL program applied to web events, such as page views and web vitals, during ingestion. A new application starts with the default web events program. Send an empty string to remove it. Send null to go back to the default web events program.

webEventsRetention number

Days to keep web events. Accepts one of the retention periods your plan offers, or the value already set. A connected application's web events retention is set on its connected source.

id string always set

The application's id.

aiPromptTemplate string | null

The AI prompt used to fix this application's errors, or the default prompt when the application has none of its own.

applicationGroupId string | null

The ID of the application group to put this application in, from List application groups.

codeMappingSourceRoot string | null

The path from your repository's root to the deployed source code, such as apps/backend/. A stack frame's path under code_mapping_stack_root is looked up under this path in the linked repository.

codeMappingStackRoot string | null

The absolute path to the root of the stack trace on your server, such as /usr/src/app/. Stack frames under it are mapped to files in the linked repository.

correlateWithSourceId string | null

The ID of the telemetry source whose logs and traces are linked to these errors. Get it via List sources.

createdAt string

When the application was created.

customBucket ApplicationsApplicationGroupResponseDataItemCustomBucket | null

Your own S3-compatible bucket to archive data in, or null when the application uses Better Stack storage. Changing only access_key_id and secret_access_key rotates the bucket's key pair.

dataRegion string

The data region, europe, us, singapore or a dedicated cluster's name from List data regions. An application created with correlate_with_source_id uses that source's region, and a different region here is refused.

dsn Redacted<string>

The DSN to configure a Sentry SDK with: https://<token>@<ingestingHost>/<id>, as the Better Stack docs build it. undefined until the API answers both token and ingestingHost.

errorsRetention number

Days to keep errors. Accepts one of the retention periods your plan offers, or the value already set.

githubRepositoryName string | null

The linked GitHub repository for source-code mapping, as owner/name, such as acme/web. Connect it to your team with the GitHub integration first.

gitlabRepositoryName string | null

The linked GitLab repository for source-code mapping, as group/name, such as acme/web, from your connected repositories.

ingestingHost string

Host to send data to.

ingestingPaused boolean

Whether ingestion is paused for this application.

jsTagConfiguration ApplicationJsTagConfiguration | null

Settings of the JavaScript tag, as on the application's Frontend page. null for an application without a JavaScript tag.

jsTagOwnDomainStatus "checking" | "missing" | "invalid" | "valid" | null

Whether the CNAME record of your own subdomain points to proxy.betterstack.net. null when js_tag_configuration has no own_domain.

jsTagToken Redacted<string> | null

The token of the browser tag, separate from token. Pass it as the ?t= value when you load the /b.js browser tag. null for a platform without a browser tag.

name string

Application name.

parentSourceId string | null

The ID of the telemetry source this application is connected to. query_collections names that source's collections. null when the application isn't connected to a source.

platform "aiohttp_errors" | "android_errors" | "angular_errors" | "asgi_errors" | "asp_dot_net_core_errors" | "asp_dot_net_errors" | "astro_errors" | "aws_lambda_dot_ne…

The SDK or framework the application reports errors from.

queryCollections ApplicationQueryCollections

The ClickHouse database, table and collections to use when you query the application's data.

replaysRetention number | null

Days to keep session replays. Accepts one of the retention periods your plan offers, or the value already set. A change applies to every application connected to the same source. Only an application that records session replays accepts it.

sourceTypes string[]

The kinds of data the application holds, such as exceptions, logs, metrics, replays, spans or web_events, sorted by name.

spikeProtectionBaselineMultiplier number | null

The baseline multiplier of spike protection, from 0 to 100. Lower values start sampling sooner, and higher values allow bigger bursts before sampling starts. null while spike protection is off.

tableName string

The application's table name, which identifies its data in SQL queries.

teamId string

The team that owns the application, such as t123.

teamName string

Name of the team that owns the application.

token Redacted<string>

Ingestion token: the secret part of [ApplicationAttributes.dsn](/reference/errors/application/).

updatedAt string

When the application was last updated.

vrlTransformationExceptions string

The VRL program that groups incoming exceptions into errors. A new application starts with its platform's default grouping, which groups exceptions by error name and call stack on most platforms. Read more about exception grouping.

vrlTransformationLogs string

The VRL program applied to logs collected alongside errors, during ingestion. Read more about VRL transformations.

vrlTransformationReplays string

The VRL program applied to session replays during ingestion.

vrlTransformationSpans string

The VRL program applied to spans collected alongside errors, during ingestion.

vrlTransformationWebEvents string

The VRL program applied to web events, such as page views and web vitals, during ingestion. A new application starts with the default web events program.

webEventsRetention number

Days to keep web events. Accepts one of the retention periods your plan offers, or the value already set. A connected application's web events retention is set on its connected source.

Application.lookup(props) reads an object this stack does not manage. It is never created, updated or deleted.

teamId string

Team that owns it, such as t123. Defaults to the credentials' team.