## Browser features

Some features require injecting JS into the debugged application. They are enabled by default, but you can disable them in your config.

```elixir
# config/dev.exs

# Disables all browser features and does not inject LiveDebugger JS
config :live_debugger, :browser_features?, false

# Used when LiveDebugger's assets are exposed on other address (e.g. when run inside Docker)
config :live_debugger, :external_url, "http://localhost:9007"
```

## Content Security Policy

In `router.ex` of your Phoenix app, make sure your locally running Phoenix app can access the LiveDebugger JS files on port 4007. To achieve that you may need to extend your CSP in `:dev` mode:

```elixir
  @csp "{...your CSP} #{if Mix.env() == :dev, do: "http://127.0.0.1:4007"}"

  pipeline :browser do
    # ...
    plug :put_secure_browser_headers, %{"content-security-policy" => @csp}
```

## Maximum memory size

There are 2 memory-consuming background processes: `Tracer` and `TraceHandler`. You can set maximum size of heap (in Gigabytes) which these processes can take. Default value for both is `5`.

```elixir
# config/dev.exs

config :live_debugger, 
  tracer_max_heap_size: 5,
  trace_handler_max_heap_size: 5
```

## Update checks

LiveDebugger comes with optional update checks that inform about newer versions when the debugger interface loads. By default, this feature is enabled and will fetch version information, displaying a notification popup if a newer version is available. You can disable this feature by setting `:update_checks?` to `false` in your configuration:

```elixir
# config/dev.exs

config :live_debugger, :update_checks?, false
```

## Disabling LiveDebugger

In case you need LiveDebugger to not run at the start of your application but want to keep the dependency, you can disable it manually in your config:

```elixir
# config/dev.exs

config :live_debugger, :disabled?, true
```

## Default Settings

In LiveDebugger, you can set the default values of settings (available in the settings panel) through your application's config. When starting LiveDebugger, settings will always be set to the values defined in the config, but you can still change them temporarily in the settings panel. However, keep in mind that these changes will reset to the config-defined values when you restart the application. This configuration should be used when you want to explicitly force a given behavior of LiveDebugger always in your project. If you want settings to persist across restarts (not reset to config values), you need to remove those entries from your application's config file.

```elixir
# config/dev.exs

config :live_debugger,
  dead_view_mode: true,
  garbage_collection: true,
  debug_button: false,
  tracing_enabled_on_start: true,
  highlight_in_browser: true
```

## Unix Socket Support

LiveDebugger can listen on a Unix domain socket instead of a TCP ip/port. To do this, set `ip` to `{:local, "/path/to/socket"}` and `port` to `0`:

```elixir
# config/dev.exs

config :live_debugger,
  ip: {:local, "/tmp/live_debugger.sock"},
  port: 0
```

Note: when using a Unix socket, browser features (debug button, elements inspection) require an `:external_url` to be set, since the socket path cannot be used as a URL:

```elixir
config :live_debugger,
  ip: {:local, "/tmp/live_debugger.sock"},
  port: 0,
  external_url: "http://your_external_url"
```

## Port Conflict Handling

LiveDebugger provides two options for dealing with port conflicts (e.g. when running multiple application instances).

### Auto-select next available port

Set `auto_port: true` to make LiveDebugger automatically find the next free port if the configured port is already in use:

```elixir
# config/dev.exs

config :live_debugger,
  port: 4007,
  auto_port: true
```

LiveDebugger will try up to 3 consecutive ports starting from the configured one, logging a warning for each port that is skipped.

Note: `auto_port` is ignored when using a Unix socket (`ip: {:local, path}`).

### Ignore startup errors

Set `ignore_startup_errors: true` to allow the host application to continue running even if LiveDebugger fails to start (e.g. due to a port conflict). LiveDebugger will be unavailable, but your application will not crash:

```elixir
# config/dev.exs

config :live_debugger, :ignore_startup_errors, true
```

An error will be logged when startup fails. Both options can be combined: `auto_port` is attempted first, and if the endpoint still fails to start, `ignore_startup_errors` prevents the crash.

## Other Settings

```elixir
# config/dev.exs

# LiveDebugger endpoint config
config :live_debugger,
  ip: {127, 0, 0, 1}, # IP on which LiveDebugger will be hosted
  port: 4007, # Port on which LiveDebugger will be hosted
  secret_key_base: "YOUR_SECRET_KEY_BASE", # Secret key used for LiveDebugger.Endpoint
  signing_salt: "your_signing_salt", # Signing salt used for LiveDebugger.Endpoint
  adapter: Bandit.PhoenixAdapter, # Adapter used in LiveDebugger.Endpoint
  server: true, # Forces LiveDebugger to start even if project is not started with the `mix phx.server`
  drainer: [shutdown: 1000] # Wait a maximum of 1000ms before forcefully terminating connections. You can also switch it off with `false`.


# Name for LiveDebugger PubSub (it will create new one so don't put already used name)
config :live_debugger, :pubsub_name, LiveDebugger.CustomPubSub
```
