View Source mix sentry.package_source_code (Sentry v10.8.0)

Packages source code for Sentry to use when reporting errors.

This task should be used in production settings, before building a release of your application. It packages all the source code of your application in a single file (called sentry.map), which is optimized for fast retrieval of source code lines. Sentry then uses this to report source code context. See the documentation for the Sentry module for configuration options related to the source code context.

This task is available since v10.0.0 of this library.

Usage

mix sentry.package_source_code

Using in Production

In production settings, call this task before building a release. This way, the source code packaged by this task will be included in the release.

For example, in a release script (this could also be in a Dockerfile, if you're using Docker):

# ...

mix sentry.package_source_code
mix release

Runtime Configuration

If you use config/runtime.exs for runtime configuration of your application and release, and you also configure the source-context-related options for the :sentry application in that file (such as :root_source_code_paths), you'll need to call the mix app.config task before calling this Mix task. mix app.config loads the config/runtime.exs configuration. Generally, we recommend configuring all the source-context-related options in compile-time config files (like config/config.exs or config/prod.exs).

Options

  • --debug - print more information about collecting and encoding source code
  • --output PATH - write source map file to the given PATH. If you don't specify this option, the file will be written to the default path, which is inside the priv directory of the :sentry application. If you use this option, remember to also configure the :source_code_map_path option, otherwise Sentry will try to read the file from the default location. See Sentry for more information. This option can be useful when the source priv directory is read-only, such as with NixOS and similar tools. Available since v10.2.0.
  • --no-compile - does not compile applications before running
  • --no-deps-check - does not check dependencies before running