Skip to content

Events and Monocle ​

Events ​

The package dispatches events as it works, in ExeQue\Qr\Events. Listen to them like any Laravel event; with nobody listening they cost nothing to speak of.

EventWhenHolds
QrRenderinga code is about to be drawn or servedcode, format
QrRendereda code was drawn, or served without drawingcode, format, rendered, milliseconds (per phase: encode, render, write, total), cached, version, errorCorrection, modules
QrCacheHitthe cache store had the codecode, format, key
QrCacheMissedthe cache store did notcode, format, key
QrGuardApplieda scan guard changed or warned about somethingcode, adjustment
php
use ExeQue\Qr\Events\QrRendered;
use Illuminate\Support\Facades\Event;

Event::listen(function (QrRendered $event) {
    if (! $event->cached && $event->milliseconds['total'] > 100) {
        Log::info('A slow QR code', ['format' => $event->format, 'modules' => $event->modules]);
    }
});

A code's content is in $event->code; take care not to log it, as codes hold passwords, phone numbers and addresses.

Monocle ​

With exeque/laravel-monocle installed, every request's codes show in their own section, with their style, timings and what the scan guards changed, but never their content. See Monocle.