# Options | Sentry for Kotlin Multiplatform

```kotlin
import io.sentry.kotlin.multiplatform.Sentry

Sentry.init { options ->
  options.dsn = "https://examplePublicKey@o0.ingest.sentry.io/0"
  options.release = "io.sentry.samples@3.0.0+1"
}
```

## [Core Options](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#core-options)

Options that can be read from an environment variable (`SENTRY_DSN`, `SENTRY_ENVIRONMENT`, `SENTRY_RELEASE`) are read automatically.

### [`dsn`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#dsn)

The DSN tells the SDK where to send the events. If this value is not provided, the SDK will try to read it from the `SENTRY_DSN` environment variable. If that variable also does not exist, the SDK will just not send any events.

In runtimes without a process environment (such as the browser) that fallback does not apply.

Learn more about [DSN utilization](https://docs.sentry.io/product/sentry-basics/dsn-explainer.md#dsn-utilization).

### [`sendDefaultPii`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#send-default-pii)

If this flag is enabled, certain personally identifiable information [(PII)](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/data-management/data-collected.md) is added by active integrations. By default, no such data is sent.

If you are using Sentry in your mobile app, read our [frequently asked questions about mobile data privacy](https://docs.sentry.io/security-legal-pii/security/mobile-privacy.md) to assist with Apple App Store and Google Play app privacy details.

This options is available since SDK version `0.13.0`

This option is turned off by default.

If you enable this option, be sure to manually remove what you don't want to send using our features for managing [*Sensitive Data*](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/data-management/sensitive-data.md).

### [`debug`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#debug)

Turns debug mode on or off. If debug is enabled SDK will attempt to print out useful debugging information if something goes wrong with sending the event. The default is always `false`. It's generally not recommended to turn it on in production, though turning `debug` mode on will not cause any safety concerns.

### [`diagnosticLevel`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#diagnostic-level)

Enabling `debug` mode makes the SDK generate as much diagnostic data as possible. However, if you'd prefer to lower the verbosity of the Sentry SDK diagnostics logs, configure this option to set the appropriate level:

* `debug`: **default** The most verbose mode
* `info`: Informational messages
* `warning`: Warning that something might not be right
* `error`: Only SDK internal errors are printed
* `fatal`: Only critical errors are printed

### [`dist`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#dist)

Sets the distribution of the application. Distributions are used to disambiguate build or deployment variants of the same release of an application. For example, the dist can be the build number of an Xcode build or the version code of an Android build. The dist has a max length of 64 characters.

### [`release`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#release)

Sets the release. Some SDKs will try to automatically configure a release out of the box but it's a better idea to manually set it to guarantee that the release is in sync with your deploy integrations or source map uploads. Release names are strings, but some formats are detected by Sentry and might be rendered differently. Learn more about how to send release data so Sentry can tell you about regressions between releases and identify the potential source in [the releases documentation](https://docs.sentry.io/product/releases.md) or the [sandbox](https://sandbox.sentry.io/?scenario=releases\&source=docs).

By default the SDK will try to read this value from the `SENTRY_RELEASE` environment variable (in the browser SDK, this will be read off of the `window.SENTRY_RELEASE.id` if available).

### [`environment`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#environment)

Sets the environment. This string is freeform and not set by default. A release can be associated with more than one environment to separate them in the UI (think `staging` vs `prod` or similar).

By default the SDK will try to read this value from the `SENTRY_ENVIRONMENT` environment variable (except for the browser SDK where this is not applicable).

### [`sampleRate`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#sample-rate)

Configures the sample rate for error events, in the range of `0.0` to `1.0`. The default is `1.0`, which means that 100% of error events will be sent. If set to `0.1`, only 10% of error events will be sent. Events are picked randomly.

### [`maxBreadcrumbs`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#max-breadcrumbs)

This variable controls the total amount of breadcrumbs that should be captured. This defaults to `100`, but you can set this to any number. However, you should be aware that Sentry has a [maximum payload size](https://develop.sentry.dev/sdk/data-model/envelopes/#size-limits) and any events exceeding that payload size will be dropped.

### [`attachStacktrace`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#attach-stacktrace)

When enabled, stack traces are automatically attached to all messages logged. Stack traces are always attached to exceptions; however, when this option is set, stack traces are also sent with messages. This option, for instance, means that stack traces appear next to all log messages.

This option is turned on by default.

Grouping in Sentry is different for events with stack traces and without. As a result, you will get new groups as you enable or disable this flag for certain events.

## [Hooks](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#hooks)

These options can be used to hook the SDK in various ways to customize the reporting of events.

### [`beforeSend`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#before-send)

This function is called with an SDK-specific message or error event object, and can return a modified event object, or `null` to skip reporting the event. This can be used, for instance, for manual PII stripping before sending.

By the time `beforeSend` is executed, all scope data has already been applied to the event. Further modification of the scope won't have any effect.

### [`beforeSendTransaction`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#before-send-transaction)

This function is called with an SDK-specific transaction event object, and can return a modified transaction event object, or `null` to skip reporting the event. One way this might be used is for manual PII stripping before sending.

### [`beforeBreadcrumb`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#before-breadcrumb)

This function is called with an SDK-specific breadcrumb object before the breadcrumb is added to the scope. When nothing is returned from the function, the breadcrumb is dropped. To pass the breadcrumb through, return the first argument, which contains the breadcrumb object. The callback typically gets a second argument (called a "hint") which contains the original object from which the breadcrumb was created to further customize what the breadcrumb should look like.

## [Tracing Options](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#tracing-options)

### [`tracesSampleRate`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#traces-sample-rate)

A number between `0` and `1`, controlling the percentage chance a given transaction will be sent to Sentry. (`0` represents 0% while `1` represents 100%.) Applies equally to all transactions created in the app. Either this or `tracesSampler` must be defined to enable tracing.

### [`tracesSampler`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#traces-sampler)

A function responsible for determining the percentage chance a given transaction will be sent to Sentry. It will automatically be passed information about the transaction and the context in which it's being created, and must return a number between `0` (0% chance of being sent) and `1` (100% chance of being sent). Can also be used for filtering transactions, by returning 0 for those that are unwanted. Either this or `tracesSampleRate` must be defined to enable tracing.

### [`tracePropagationTargets`](https://docs.sentry.io/platforms/kotlin/guides/kotlin-multiplatform/configuration/options.md#trace-propagation-targets)

An optional property that controls which downstream services receive tracing data, in the form of a `sentry-trace` and a `baggage` header attached to any outgoing HTTP requests.

The option may contain a list of strings or regex against which the URLs of outgoing requests are matched. If one of the entries in the list matches the URL of an outgoing request, trace data will be attached to that request. String entries do not have to be full matches, meaning the URL of a request is matched when it *contains* a string provided through the option.

If `tracePropagationTargets` is not provided, trace data is attached to every outgoing request from the instrumented client.
