Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture notification duration #104

Merged
merged 5 commits into from
Feb 17, 2025
Merged

Capture notification duration #104

merged 5 commits into from
Feb 17, 2025

Conversation

avosalmon
Copy link
Collaborator

@avosalmon avosalmon commented Feb 14, 2025

We currently don't capture notification durations.
This PR captures the duration by listening to the NotificationSending and NotificationSent events and calculating the difference between their timestamps.

We cannot capture failed notifications because the framework doesn't dispatch the NotificationFailed event. When a notification fails, it will show up as an exception record on the Nightwatch app.

if (str_contains($event->notification::class, "@anonymous\0")) {
$class = Str::before($event->notification::class, "\0");
} else {
$class = $event->notification::class;
}

$this->duration ??= (int) round(($now - $this->startTime) * 1_000_000);
Copy link
Member

@timacdonald timacdonald Feb 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the ??= operator here instead of =?

Looking at this, it seems we would always want to recompute the duration at this point for notifications?

Tests seem to pass without it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, we don't. I can't imagine a scenario where we want to reuse the same duration. I've updated the code. Thank you for spotting this!

@avosalmon avosalmon merged commit 651c95f into 1.x Feb 17, 2025
4 checks passed
@avosalmon avosalmon deleted the notification-duration branch February 17, 2025 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants