|
| 1 | +--- |
| 2 | +title: Options |
| 3 | +sidebar_order: 1 |
| 4 | +description: "Learn more about how the SDK can be configured via options. These are being passed to the init function and therefore set when the SDK is first initialized." |
| 5 | +--- |
| 6 | + |
| 7 | +<PlatformContent includePath="configuration/config-intro" /> |
| 8 | + |
| 9 | +## Core Options |
| 10 | + |
| 11 | +Options that can be read from an environment variable (`SENTRY_DSN`, `SENTRY_ENVIRONMENT`, `SENTRY_RELEASE`) are read automatically. |
| 12 | + |
| 13 | +<ConfigKey name="dsn"> |
| 14 | + |
| 15 | +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. |
| 16 | + |
| 17 | +In runtimes without a process environment (such as the browser) that fallback does not apply. |
| 18 | + |
| 19 | +Learn more about [DSN utilization](/product/sentry-basics/dsn-explainer/#dsn-utilization). |
| 20 | + |
| 21 | +</ConfigKey> |
| 22 | + |
| 23 | +<ConfigKey name="debug"> |
| 24 | + |
| 25 | +Turns debug mode on or off. If `debug` is enabled, the SDK will print useful debugging information to standard output. These messages do not appear in the Godot console or log file but can be seen when launching Godot application from a terminal. It's generally not recommended to turn it on in production, though turning `debug` mode on will not cause any safety concerns. |
| 26 | + |
| 27 | +In the Project Settings, this option appears as `Debug Printing` and defaults to `Auto`. When set to `Auto`, the `debug` is enabled in debug builds (such as the editor and debug exports), and disabled in release export. |
| 28 | + |
| 29 | +</ConfigKey> |
| 30 | + |
| 31 | +<ConfigKey name="release"> |
| 32 | + |
| 33 | +Release version of the application. This value must be unique across all projects in your organization. By default, the SDK reads from the `application/config/name` and `application/config/version` project settings to generate the release identifier in the format `"{app_name}@{app_version}"`. Alternatively, you can set `release` to a custom value, optionally using the `{app_name}` and `{app_version}` placeholders in a [configuration script](#configuration-script). |
| 34 | + |
| 35 | +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](/product/releases/) or the <SandboxLink scenario="releases">sandbox</SandboxLink>. |
| 36 | + |
| 37 | +</ConfigKey> |
| 38 | + |
| 39 | +<ConfigKey name="dist"> |
| 40 | + |
| 41 | +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. |
| 42 | + |
| 43 | +</ConfigKey> |
| 44 | + |
| 45 | +<ConfigKey name="environment"> |
| 46 | + |
| 47 | +Sets the environment. Environments indicate where an error occurred, such as in a release export, headless server, QA build, or another deployment. A release can be associated with more than one environment to separate them in the UI (think `staging` vs `production` or similar). |
| 48 | + |
| 49 | +The SDK automatically detects Godot-specific environments, such as `headless_server` and `export_release`, but you can also set it to your own value in a [configuration script](#configuration-script). |
| 50 | + |
| 51 | +</ConfigKey> |
| 52 | + |
| 53 | +<ConfigKey name="sample-rate"> |
| 54 | + |
| 55 | +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. |
| 56 | + |
| 57 | +</ConfigKey> |
| 58 | + |
| 59 | +<ConfigKey name="max-breadcrumbs"> |
| 60 | + |
| 61 | +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. |
| 62 | + |
| 63 | +</ConfigKey> |
| 64 | + |
| 65 | +<ConfigKey name="send-default-pii"> |
| 66 | + |
| 67 | +If enabled, the SDK will include PII (Personally Identifiable Information) with the events. |
| 68 | + |
| 69 | +This option is disabled 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/). |
| 70 | + |
| 71 | +</ConfigKey> |
| 72 | + |
| 73 | +<ConfigKey name="enabled"> |
| 74 | + |
| 75 | +If `false`, the SDK will not initialize. This is useful for temporarily disabling the SDK in the Project Settings, or in a [configuration script](#configuration-script). |
| 76 | + |
| 77 | +</ConfigKey> |
| 78 | + |
| 79 | +<ConfigKey name="disabled-in-editor"> |
| 80 | + |
| 81 | +If `true`, the SDK will not initialize in the Godot editor. |
| 82 | + |
| 83 | +</ConfigKey> |
| 84 | + |
| 85 | +<ConfigKey name="attach-log"> |
| 86 | + |
| 87 | +If enabled, the SDK will attach the Godot log file to the event. |
| 88 | + |
| 89 | +</ConfigKey> |
| 90 | + |
| 91 | +## Error Logger Options |
| 92 | + |
| 93 | +<ConfigKey name="error-logger-enabled"> |
| 94 | + |
| 95 | +If `true`, the SDK will capture logged errors as events and/or breadcrumbs, as defined by `error_logger_event_mask` and `error_logger_breadcrumb_mask` options. Crashes are always captured. |
| 96 | + |
| 97 | +</ConfigKey> |
| 98 | + |
| 99 | +<ConfigKey name="error-logger-breadcrumb-mask"> |
| 100 | + |
| 101 | +Specifies the types of errors captured as breadcrumbs. Accepts a single value or a bitwise combination of `GodotErrorMask` masks. |
| 102 | + |
| 103 | +`GodotErrorMask` values: |
| 104 | +- `MASK_NONE`: No logger errors will be captured. |
| 105 | +- `MASK_ERROR`: Native errors will be captured. These are typically C++ errors, which may also originate from a script. |
| 106 | +- `MASK_WARNING`: Warnings will be captured. |
| 107 | +- `MASK_SCRIPT`: Script errors will be captured. |
| 108 | +- `MASK_SHADER`: Shader errors will be captured. |
| 109 | + |
| 110 | +```gdscript |
| 111 | +var mask = SentryOptions.MASK_ERROR | SentryOptions.MASK_SCRIPT |
| 112 | +options.error_logger_breadcrumb_mask = mask |
| 113 | +``` |
| 114 | + |
| 115 | +</ConfigKey> |
| 116 | + |
| 117 | +<ConfigKey name="error-logger-event-mask"> |
| 118 | + |
| 119 | +Specifies the types of errors captured as events. Accepts a single value or a bitwise combination of `GodotErrorMask` masks. |
| 120 | + |
| 121 | +```gdscript |
| 122 | +var mask = SentryOptions.MASK_ERROR | SentryOptions.MASK_SCRIPT |
| 123 | +options.error_logger_event_mask = mask |
| 124 | +``` |
| 125 | + |
| 126 | +</ConfigKey> |
| 127 | + |
| 128 | +<ConfigKey name="error-logger-include-source"> |
| 129 | + |
| 130 | +If `true`, the SDK will include the surrounding source code of logged errors, if available in the exported project. |
| 131 | + |
| 132 | +</ConfigKey> |
| 133 | + |
| 134 | +<ConfigKey name="error-logger-limits"> |
| 135 | + |
| 136 | +Defines throttling limits for the error logger. These limits are used to prevent the SDK from sending too many non-critical and repeating error events. |
| 137 | + |
| 138 | +This option contains multiple properties that govern the behavior of throttling. The following paragraphs explain each of those properties in detail. |
| 139 | + |
| 140 | +`events_per_frame` specifies the maximum number of error events to send per processed frame. If exceeded, no further errors will be captured until the next frame. This serves as a safety measure to prevent the SDK from overloading a single frame. |
| 141 | + |
| 142 | +`repeated_error_window_ms` specifies the minimum time interval in milliseconds between two identical errors. If exceeded, no further errors from the same line of code will be captured until the next interval. |
| 143 | + |
| 144 | +`throttle_events` specifies the maximum number of events allowed within a sliding time window of `throttle_window_ms` milliseconds. If exceeded, errors will be captured as breadcrumbs only until capacity is freed. |
| 145 | + |
| 146 | +`throttle_window_ms` specifies the time window in milliseconds for `throttle_events`. |
| 147 | + |
| 148 | +</ConfigKey> |
| 149 | + |
| 150 | +## Hooks |
| 151 | + |
| 152 | +These options can be used to hook the SDK in various ways to customize the reporting of events. |
| 153 | + |
| 154 | +The callbacks you set as hooks will be called on the thread where the event happened. So you can only use |
| 155 | +thread-safe APIs and only use Godot-specific APIs after you've checked that you're on the main thread. |
| 156 | + |
| 157 | +<ConfigKey name="before-send"> |
| 158 | + |
| 159 | +If assigned, this callback runs before a message or error event is sent to Sentry. It takes `SentryEvent` as a parameter and returns either the same event object, with or without modifications, or `null` to skip reporting the event. You can assign it in a [configuration script](#configuration-script). This can be used, for instance, for stripping PII before sending. |
| 160 | + |
| 161 | +```gdscript |
| 162 | +func _before_send(event: SentryEvent) -> SentryEvent: |
| 163 | + if event.environment.contains("editor"): |
| 164 | + # Discard event if running from the editor. |
| 165 | + return null |
| 166 | + if event.message.contains("Bruno"): |
| 167 | + # Remove sensitive information from the event. |
| 168 | + event.message = event.message.replace("Bruno", "REDACTED") |
| 169 | + return event |
| 170 | +``` |
| 171 | + |
| 172 | +</ConfigKey> |
| 173 | + |
| 174 | +<ConfigKey name="on-crash"> |
| 175 | + |
| 176 | +If assigned, this callback runs before a crash event is sent to Sentry. In contrast to `before_send`, it is only called when a crash occurred. It takes `SentryEvent` as a parameter and returns either the same event object, with or without modifications, or `null` to skip reporting the event. You can assign it in a [configuration script](#configuration-script). |
| 177 | + |
| 178 | +```gdscript |
| 179 | +func _on_crash(event: SentryEvent) -> SentryEvent: |
| 180 | + if event.environment.contains("editor"): |
| 181 | + # Discard event if running from the editor. |
| 182 | + return null |
| 183 | + if event.message.contains("Bruno"): |
| 184 | + # Remove sensitive information from the event. |
| 185 | + event.message = event.message.replace("Bruno", "REDACTED") |
| 186 | + return event |
| 187 | +``` |
| 188 | + |
| 189 | +</ConfigKey> |
0 commit comments