Skip to content
80 changes: 80 additions & 0 deletions docs/platforms/kotlin-multiplatform/configuration/gradle.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
title: Gradle Plugin
sidebar_order: 5
description: "Learn how to set up Sentry's Kotlin Multiplatform Gradle Plugin."
---

The [Sentry Kotlin Multiplatform Gradle Plugin](https://github.com/getsentry/sentry-kotlin-multiplatform/tree/main/sentry-kotlin-multiplatform-gradle-plugin) is a plugin that simplifies the set up process. It can be used to configure the Sentry SDK for Kotlin Multiplatform projects.

The Gradle Plugin supports the following features:
- Auto-installation of the Sentry Kotlin Multiplatform SDK.
- Auto-installation of the Sentry Cocoa SDK via Cocoapods (if the Kotlin Cocoapods plugin is applied).
- Automatic configuration of the Kotlin/Native linker for seamless usage with the Swift Package Manager.

## Setup

### Install

Using Gradle in your `shared/build.gradle.kts` add:

```kotlin {filename:shared/build.gradle.kts}
plugins {
id("io.sentry.kotlin.multiplatform.gradle") version "{{@inject packages.version('sentry.kotlin.kmp', '0.9.0') }}"
}
```

### Configure

We expose the following configuration values:

```kotlin {filename:shared/build.gradle.kts}
sentryKmp {
// Configure auto-installation of Sentry components.
autoInstall {
// Enable auto-installation of Sentry components:
// - Sentry Kotlin Multiplatform SDK
// - Sentry Cocoa SDK with Cocoapods if Kotlin Cocoapods plugin is applied.
// Default is enabled.
enabled = true

// Configure the commonMain source set.
commonMain {
// Enable auto-installation of the Sentry Kotlin Multiplatform SDK in commonMain.
// Default is enabled.
enabled = true

// Specify the version of the Sentry Kotlin Multiplatform SDK to use.
// Default is the corresponding Kotlin Multiplatform SDK version.
sentryKmpVersion = "{{@inject packages.version('sentry.kotlin.kmp', '0.9.0') }}"
}

// Configure the Cocoapods plugin.
cocoapods {
// Enable auto-installation of the Sentry Cocoa SDK with Cocoapods.
// Default is enabled.
enabled = true

// Specify the version of the Sentry Cocoa SDK to install.
// Default is the Cocoa SDK version used in the Kotlin Multiplatform SDK.
sentryCocoaVersion = "8.38.0"
}

// Configure the linker. This is only relevant if you are using SPM.
linker {
// Enable auto-configuration of the Kotlin/Native linker for Sentry Cocoa framework.
// Default is enabled.
enabled = true

// Path to the Xcode project that will be used to link the framework.
// This is used to find the derived data path in which the framework is stored for SPM.
// Default is the current project directory.
xcodeProjectPath = "path/to/your/project.xcodeproj"

// Path to the framework that will be linked.
// Takes precedence over xcodeprojPath if both are set.
// Default is null.
frameworkPath = "path/to/your/framework.framework"
}
}
}
```
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Configuration
description: "Additional configuration options for the SDK."
sidebar_order: 5
sidebar_order: 20
---

<PageGrid />
127 changes: 0 additions & 127 deletions docs/platforms/kotlin-multiplatform/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ This variable controls the total amount of breadcrumbs that should be captured.

</ConfigKey>

<ConfigKey name="max-cache-items">

The maximum number of [envelopes](https://develop.sentry.dev/sdk/data-model/envelopes/) to keep in cache. The SDKs use envelopes to send data, such as events, attachments, user feedback, and sessions to sentry.io. An envelope can contain multiple items, such as an event with a session and two attachments. Depending on the usage of the SDK, the size of an envelope can differ. If the number of envelopes in the local cache exceeds `max-cache-items`, the SDK deletes the oldest envelope and migrates the sessions to the next envelope to maintain the integrity of your release health stats. The default is `30`.

</ConfigKey>

<ConfigKey name="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.
Expand All @@ -91,93 +85,6 @@ Grouping in Sentry is different for events with stack traces and without. As a r

</ConfigKey>

<ConfigKey name="send-default-pii">

If this flag is enabled, certain personally identifiable information (PII) is added by active integrations. By default, no such data is sent.

<Note>

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

</Note>

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_](../../data-management/sensitive-data/).

</ConfigKey>

<ConfigKey name="server-name">

Comment on lines -94 to -111
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removing options that are currently not in KMP layer

This option can be used to supply a "server name." When provided, the name of the server is sent along and persisted in the event. For many integrations, the server name actually corresponds to the device hostname, even in situations where the machine is not actually a server.

Most SDKs will attempt to auto-discover this value.

</ConfigKey>

<ConfigKey name="in-app-include">

A list of string prefixes of module names that belong to the app. This option takes precedence over `in-app-exclude`.

Sentry differentiates stack frames that are directly related to your application ("in application") from stack frames that come from other packages such as the standard library, frameworks, or other dependencies. The application package is automatically marked as `inApp`. The difference is visible in [sentry.io](https://sentry.io), where only the "in application" frames are displayed by default.

</ConfigKey>

<ConfigKey name="in-app-exclude">

A list of string prefixes of module names that do not belong to the app, but rather to third-party packages. Modules considered not part of the app will be hidden from stack traces by default.

This option can be overridden using <PlatformIdentifier name="in-app-include" />.

</ConfigKey>

<ConfigKey name="ignored-exceptions-for-type">

A list of exception types that will be filtered out before sending to Sentry.

</ConfigKey>

<ConfigKey name="max-request-body-size">

This parameter controls whether integrations should capture HTTP request bodies. It can be set to one of the following values:

- `never`: Request bodies are never sent.
- `small`: Only small request bodies will be captured. The cutoff for small depends on the SDK (typically 4KB).
- `medium`: Medium and small requests will be captured (typically 10KB).
- `always`: The SDK will always capture the request body as long as Sentry can make sense of it.

</ConfigKey>

<ConfigKey name="enabled">

Specifies whether this SDK should send events to Sentry. Defaults to `true`. Setting this to `enabled: false` doesn't prevent all overhead from Sentry instrumentation. To disable Sentry completely, depending on environment, call `Sentry.init` conditionally.

</ConfigKey>

<ConfigKey name="send-client-reports">

Set this boolean to `false` to disable sending of client reports. Client reports are a protocol feature that let clients send status reports about themselves to Sentry. They are currently mainly used to emit outcomes for events that were never sent.

_(New in version 6.0.0)_

</ConfigKey>

## Integration Configuration

For many platform SDKs integrations can be configured alongside it. On some platforms that happen as part of the `init()` call, in some others, different patterns apply.

<ConfigKey name="integrations" />

In some SDKs, the integrations are configured through this parameter on library initialization. For more information, please see our documentation for a specific integration.

<ConfigKey name="default-integrations" notSupported={["java", "dart"]} />

This can be used to disable integrations that are added by default. When set to `false`, no default integrations are added.

<ConfigKey name="auto-enabling-integrations" supported={["python"]} />

This can be used to disable integrations that are enabled by default if the SDK detects that the corresponding framework or library is installed. When set to `false`, none of these integrations will be enabled by default, even if the corresponding framework/library is detected.

## Hooks

These options can be used to hook the SDK in various ways to customize the reporting of events.
Expand All @@ -203,36 +110,8 @@ The callback typically gets a second argument (called a "hint") which contains t

</ConfigKey>

## Transport Options

Transports are used to send events to Sentry. Transports can be customized to some degree to better support highly specific deployments.

<ConfigKey name="transport">

Switches out the transport used to send events. How this works depends on the SDK. It can, for instance, be used to capture events for unit-testing or to send it through some more complex setup that requires proxy authentication.

</ConfigKey>

<ConfigKey name="http-proxy">

When set, a proxy can be configured that should be used for outbound requests. This is also used for HTTPS requests unless a separate `https-proxy` is configured. However, not all SDKs support a separate HTTPS proxy. SDKs will attempt to default to the system-wide configured proxy, if possible. For instance, on Unix systems, the `http_proxy` environment variable will be picked up.

</ConfigKey>

<ConfigKey name="shutdown-timeout">

Controls how many seconds to wait before shutting down. Sentry SDKs send events from a background queue. This queue is given a certain amount to drain pending events. The default is SDK specific but typically around two seconds. Setting this value too low may cause problems for sending events from command line applications. Setting the value too high will cause the application to block for a long time for users experiencing network connectivity problems.

</ConfigKey>

## Tracing Options

<ConfigKey name="enable-tracing">

A boolean value, if true, transactions and trace data will be generated and captured. This will set the <PlatformIdentifier name="traces-sample-rate" /> to the recommended default of 1.0 if <PlatformIdentifier name="traces-sample-rate" /> is not defined. Note that <PlatformIdentifier name="traces-sample-rate" /> and <PlatformIdentifier name="traces-sampler" /> take precedence over this option.

</ConfigKey>

<ConfigKey name="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 <PlatformIdentifier name="traces-sampler" /> must be defined to enable tracing.
Expand All @@ -256,9 +135,3 @@ String entries do not have to be full matches, meaning the URL of a request is m
If <PlatformIdentifier name="trace-propagation-targets" /> is not provided, trace data is attached to every outgoing request from the instrumented client.

</ConfigKey>

<ConfigKey name="trace-options-requests">

Set this boolean to `false` to disable tracing for `OPTIONS` requests. This options default value will likely be changed in the next major version, meaning you will have to set it to `true` if you want to keep tracing `OPTIONS` requests.

</ConfigKey>
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: Upload Debug Symbols
description: "Learn more about how to upload debug symbols in Sentry Kotlin Multiplatform."
sidebar_order: 4
sidebar_order: 6
---

To symbolicate your stack traces, you need to provide debug information to Sentry.
Expand Down
31 changes: 31 additions & 0 deletions docs/platforms/kotlin-multiplatform/features/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
title: Features
sidebar_order: 1
description: "Learn about the features of Sentry's Kotlin Multiplatform SDK."
---

Sentry's Kotlin Multiplatform SDK enables automatic reporting of errors and exceptions.
Because the SDK provides a unified API for all supported platforms directly leveraging the native SDKs for each platform, it also supports the same features as the native SDKs. Click on a link below to see relevant features for your platform:

- [Apple features](/platforms/apple/features)
- [Android features](/platforms/android/features)
- [Java features](/platforms/java)

<Note>
Some functionality may not be available in the shared Kotlin Multiplatform layer yet. You may have to use the native SDKs directly, or write your own platform-specific code.

To access the native SDK init options, use the [Native Platform Options initialization](/platforms/kotlin-multiplatform/initialization-strategies/#native-platform-options).
</Note>

## Supported Platforms

The table below lists supported platforms and their corresponding presets.

| Target Platform | Target Preset |
| --------------- | ------------------------------------------------------------------------------------------------------------ |
| Android | <ul><li>`androidTarget`</li></ul> |
| Kotlin/JVM | <ul><li>`jvm`</li></ul> |
| iOS | <ul><li>`iosArm64`</li><li>`iosX64`</li><li>`iosSimulatorArm64`</li></ul> |
| macOS | <ul><li>`macosArm64`</li><li>`macosX64`</li></ul> |
| watchOS | <ul><li>`watchosArm32`</li><li>`watchosArm64`</li><li>`watchosX64`</li><li>`watchosSimulatorArm64`</li></ul> |
| tvOS | <ul><li>`tvosArm64`</li><li>`tvosX64`</li><li>`tvosSimulatorArm64`</li></ul> |
38 changes: 5 additions & 33 deletions docs/platforms/kotlin-multiplatform/index.mdx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
---
title: Kotlin Multiplatform
caseStyle: camelCase
fallbackPlatform: java
supportLevel: production
sdk: sentry.kotlin.kmp
categories:
Expand Down Expand Up @@ -38,36 +37,9 @@ Learn more about manually capturing an error or message in our <PlatformLink to=

To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.

## Supported Platforms
## Next Steps

The table below lists supported platforms and their corresponding presets.

| Target Platform | Target Preset |
| --------------- | ------------------------------------------------------------------------------------------------------------ |
| Android | <ul><li>`androidTarget`</li></ul> |
| Kotlin/JVM | <ul><li>`jvm`</li></ul> |
| iOS | <ul><li>`iosArm64`</li><li>`iosX64`</li><li>`iosSimulatorArm64`</li></ul> |
| macOS | <ul><li>`macosArm64`</li><li>`macosX64`</li></ul> |
| watchOS | <ul><li>`watchosArm32`</li><li>`watchosArm64`</li><li>`watchosX64`</li><li>`watchosSimulatorArm64`</li></ul> |
| tvOS | <ul><li>`tvosArm64`</li><li>`tvosX64`</li><li>`tvosSimulatorArm64`</li></ul> |

## Overview of Features

- Native crash reporting for Android and JVM, leveraging our [Android SDK](/platforms/android) and [Java SDK](/platforms/java)
- Native crash reporting for iOS, macOS, tvOS, and watchOS, leveraging our [Cocoa SDK](/platforms/apple)
- Automatic breadcrumbs for app lifecycle and UI events

## Apple Installation Methods

### Swift Package Manager (SPM)

Swift Package Manager (SPM) is a powerful tool for managing dependencies in Swift that allows developers to enjoy a more native integration experience with Xcode.
If you already use SPM or prefer it over other package managers on Apple platforms, this guide will show you how to install the Kotlin Multiplatform SDK while using Swift Package Manager.

#### Install

In order to install the Sentry Kotlin Multiplatform SDK, you need to use Cocoapods and Swift Package Manager simultaneously which might seem unconventional at first, especially if you're accustomed to using SPM for all your dependencies. However, you can achieve a smooth integration by using the Kotlin Cocoapods plugin specifically for compiling and building the shared framework. You can then continue to manage all other dependencies with SPM as usual.

Follow the steps for our primary installation method [Cocoapods](/platforms/kotlin-multiplatform/#install) to install the Sentry Kotlin Multiplatform SDK.

After you've consumed the shared framework in your application via Cocoapods, you can continue with SPM for other dependencies without disrupting your existing workflow.
- <PlatformLink to="/features">Learn more about Sentry's Kotlin Multiplatform SDK features</PlatformLink>
- <PlatformLink to="/initialization-strategies">Learn about different ways to initialize the SDK</PlatformLink>
- <PlatformLink to="/configuration/gradle">See configuration options for the Kotlin Multiplatform Gradle Plugin</PlatformLink>
- <PlatformLink to="/debug-symbols">Add readable stack traces to your errors</PlatformLink>
Loading