# `mix posthog.package_source_code`
[🔗](https://github.com/posthog/posthog-elixir/blob/v2.18.0/lib/mix/tasks/posthog.package_source_code.ex#L6)

Packages source code into a binary file for source context in error tracking.

This task reads all `.ex` source files from the configured root paths and
writes a compressed binary into PostHog's own `priv/` directory. This file
is then bundled into the release and loaded at runtime to provide source
context in stack traces.

Run this task before building a release:

    mix posthog.package_source_code
    mix release

## Options

  * `--output` - Custom output path (default: PostHog's priv dir)
  * `--root-path` - Root source code path(s). Can be specified multiple times.
    Defaults to the current working directory.

## Configuration

This task reads the following from your application config:

    config :posthog,
      root_source_code_paths: [File.cwd!()],
      source_code_path_pattern: "**/*.ex",
      source_code_exclude_patterns: [~r"^_build/", ~r"^priv/", ~r"^test/"]

CLI options override config values.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
