Usage

Verify Command

Validate your Sentry configuration and ensure exceptions can be flushed and delivered.

The package provides a built-in Ace command, sentry:verify, to verify that your Sentry DSN is correctly configured and able to communicate with the Sentry ingestion servers.

Running the Command

Execute the following command in your terminal:

node ace sentry:verify

How It Operates

When invoked, the command performs the following steps:

  1. Checks configuration: Verifies that config/sentry.ts exists. If missing, it outputs an error and exits with code 1.
  2. Checks enabled status: Checks if sentryConfig.enabled is true. If false, it logs an informational notice (Sentry is disabled) and exits cleanly.
  3. Ensures initialization: Initializes the Sentry SDK if it was not already initialized by an early preload file or the provider.
  4. Captures test exception: Throws and captures a synthetic test error (This is a test exception sent from the sentry adonisjs).
  5. Flushes the transport: Calls Sentry.flush(5000) to force the underlying network transport to transmit all queued events within 5 seconds.
  6. Reports status:
    • If delivered: Logs Event sent with ID: <eventId> and exits with code 0.
    • If flush times out: Logs an error indicating delivery failed and sets exitCode = 1.

Output Examples

Successful Delivery

[ DONE ] Event sent with ID: 4f88e63b655a40b793798cf85d95d820

Disabled State

[ INFO ] Sentry is disabled

Missing Configuration or Delivery Failure

[ ERROR ] Missing "config/sentry.ts" file. Run "node ace configure @eienjs/adonisjs-sentry"

or:

[ ERROR ] Event 4f88e63b655a40b793798cf85d95d820 could not be flushed before timeout

Usage in CI/CD and Deployments

Because sentry:verify exits with a non-zero exit code (1) on failure, you can incorporate it into your continuous integration (CI) workflows or container health checks:

# In your deployment script
node ace sentry:verify || exit 1
Remember to export a valid SENTRY_DSN in your environment prior to executing the command in staging or production validation checks.