Add Barstool::context() for storing custom context on recordings - #13
Merged
Conversation
Allows attaching arbitrary key/value context (user IDs, tenant IDs, etc.) to recorded requests, stored in a new nullable JSON `context` column. Context is held as hidden data on Laravel's Context so it carries into queued jobs and resets between requests/workers automatically. The persist payload only includes the context key when context has been set, so upgrading without running the new migration is safe until the feature is used. Closes #7
This was referenced Jul 17, 2026
This was referenced Jul 17, 2026
craigpotter
added a commit
that referenced
this pull request
Jul 17, 2026
# Overview of change Documentation follow-up from #13/#15: the README previously documented queue support and the newer features but almost none of the config options. This PR: - Groups all configuration docs under a single **Configuration** section with subsections: enabling & disabling, choosing what gets recorded (`only`/`ignore`), keeping only failed responses, redacting sensitive request headers, excluding response bodies, response body limits, database connection, pruning, and queue support - Adds a short **Requirements** section (PHP 8.3+, Laravel 12+, Saloon v4) - Documents the placeholder values users see in the `barstools` table (`REDACTED`, `<Streamed Body>`, `<Multipart Body>`, `<Unsupported Barstool Response Content>`) and when each appears - Links the pruning setup from Installation instead of duplicating it there - Minor copy fixes, keeping the existing tone One non-README change: the `enabled` config comment mentioned a UI that doesn't exist, so that mention is removed. # Testing Docs only (plus a config comment) — full suite still green locally (31 passed, 154 assertions), Pint clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview of change
Adds the ability to attach custom context to Barstool recordings, stored in a new nullable JSON
contextcolumn:Every request recorded after this point stores the context on its row.
getContext()andflushContext()are also available.Implementation notes
Context::addHidden) under a namespaced key. This means it is carried into queued jobs automatically (set context in a controller, and API calls made inside a dispatched job still record it), it is reset between requests/workers by the framework, and it never leaks into the application's log context.contextkey when context has actually been set. Existing installs can upgrade the package without running the new migration and nothing breaks — the column is only referenced once you opt in to the feature. This makes it a safe minor release.add_context_to_barstools_tablemigration for existing installs (guarded withhasColumn, so it is a no-op on fresh installs where the create migration already includes the column).Related
X-Barstool-UUIDin a request header #6 — the README now documents the UUID read-back pattern for correlating your own models with a Barstool recording, and there is a test locking that behaviour in.Testing
composer test(25 passed),composer analyse(PHPStan level 8, clean),composer format(clean).