Manually Reporting Exceptions
Nightwatch automatically listens to all exceptions reported within your Laravel application:📘 This is only needed in rare cases where exceptions are not captured automatically.
Reporting Manually Failed Jobs
If you want to report a manually failed job, you need to manually report an exception.Customizing User Details
Nightwatch automatically captures details about the authenticated user when an event occurs. By default, it captures the user’sid
, name
, and email
attributes.
Sometimes you may need to adjust what is captured, for example:
- Your app uses
first_name
andlast_name
instead of a singlename
field. - You run a multi-tenant app where the user IDs are not unique across tenants.
- You prefer not to store certain user details at all.
Nightwatch::user
method, which you can call inside your AppServiceProvider
.
Customizing User Fields
Here’s an example of how you can combinefirst_name
and last_name
as the name field:
Customizing User IDs
In systems where user IDs may not be unique, such as multi-tenant apps with auto-incrementing IDs, you can customise the ID to include the tenant identifier so Nightwatch can tell them apart.Omitting User Fields
If you don’t want Nightwatch to capture certain fields, you can simply leave them out of the returned array. Note that theid
will always be captured.
Monitoring Guzzle Requests
Nightwatch automatically captures outgoing HTTP requests made via Laravel’s Http client. If you’re using Guzzle directly, you can still capture these requests by attaching Nightwatch’s middleware to your Guzzle stack.$client
will now be monitored by Nightwatch.
Customizing the Agent Port
By default, the Nightwatch agent listens on port2407
. You can change this by setting a different ingest URI and using the --listen-on
flag when starting the agent.
To run the agent on port 2408
, update your .env file:
Running Multiple Agents
If you’re running more than one Laravel application or environment on the same server, you can run multiple Nightwatch agents in parallel — each on a unique port.Each agent must use a different port. See Customizing the Agent
Port for instructions on how to set this per
instance.
Unrecoverable Exceptions
If Nightwatch experiences an unrecoverable exception when recording events from your application, it can become unable to notify you of the issue. You may register a handler for these scenarios with theNightwatch::handleUnrecoverableExceptionsUsing
method. You should put this in your AppServiceProvider::register
method:
AppServiceProvider.php
This may generate a large number of logs in cases where Nightwatch is not
configured correctly and fails on every request to your application.