Skip to content

[Bug]: is it possible to store some context alongside the request data ( eg. current auth user, ... ) #7

Closed

Description

@olivM

What happened?

is it possible to store some context alongside the request data ( eg. current auth user, ... ) ?
thx

How to reproduce the bug

is it possible to store some context alongside the request data ( eg. current auth user, ... ) ?
thx

Package Version

1.1.1

PHP Version

8.5

Laravel Version

13

Which operating systems does with happen with?

No response

Notes

No response

Activity

  1. added
    bugSomething isn't working
    on Jun 3, 2026
  2. allmanaj commented on Jun 3, 2026

    @allmanaj

    @olivM This was an issues I faced as well! I needed extra information about the requests being sent. I opened PR #6 which, if it's merged, will allow the user to specify X-Barstool-UUID as a request header when sending a Saloon request.This way you could pre-define a uuid when sending the request and can then save that against a row in a different table of logs as a barstool_id. So you can store extra information with a direct link to the barstool logs without bloating the barstools table.

    My instance was that we were syncing users from a third party platform and needed to keep track of if something went wrong. We had a user_sync_logs table were were using anyway and adding barstool_id to it would increase visibility of any issues.

    It would allow your code to look something like this:

    $barstoolId = Str::uuid();
    $request = new RequestWhichAcceptsCustomHeaders(headers: ['X-Barstool-UUID' => $barstoolId]);
    $response = $request->send();
    if($response->failed()) {
        UserSyncLog::create([
            'user_id' => auth()->id,
            'barstool_id' => $barstoolId,
        ]);
    }
  3. added
    enhancementNew feature or request
    and removed
    bugSomething isn't working
    on Jul 14, 2026
  4. craigpotter commented on Jul 14, 2026

    @craigpotter
    Collaborator

    Thanks, sorry for the delaying in coming back to you on this.

    @allmanaj PR looks good, I have one small amend then I will release it.

    Hope you guys are finding Barstool useful!

  5. craigpotter commented on Jul 17, 2026

    @craigpotter
    Collaborator

    Hey @olivM — an update on this: #13 adds exactly what you asked for. You'll be able to attach context to recordings and it gets stored in a new context JSON column on the barstools table:

    use Saloon\Barstool\Barstool;
    
    Barstool::context([
        'user_id' => auth()->id(),
        'tenant_id' => $tenant->id,
    ]);

    It's built on Laravel Context under the hood, so context set in a controller is carried into queued jobs automatically and reset between requests. Existing installs will just need to publish and run a small migration to add the column.

    I'll close this issue once the PR is merged and released. Thanks for the suggestion!

  6. self-assigned this
    on Jul 17, 2026
  7. added a commit that references this issue on Jul 18, 2026
    2344fa0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions