---
title: "Device & location enrichment — Refresh Tokens for Laravel | Roundly"
description: "Attach host-parsed browser, OS, device type and geolocation to a session with enrich() — typically from an async job."
url: https://roundly-consulting.com/open-source/docs/refresh-tokens-for-laravel/device-enrichment
language: en
---

[All packages](https://roundly-consulting.com/open-source.md)

[Refresh Tokens for Laravel](https://roundly-consulting.com/open-source/docs/refresh-tokens-for-laravel.md)

# Device & location enrichment

The package never parses a user agent or geolocates an IP — the host supplies already-parsed data through two DTOs:

```php
use RoundlyConsulting\RefreshTokens\DataTransferObjects\DeviceData;
use RoundlyConsulting\RefreshTokens\DataTransferObjects\LocationData;
use RoundlyConsulting\RefreshTokens\Enums\DeviceType;

// Pass the RefreshToken model you already hold, or its id:
RefreshTokens::session($new->token)->enrich(
    new DeviceData(browser: 'Firefox', os: 'Linux', deviceType: DeviceType::Desktop, isBot: false),
    new LocationData(country: 'Slovakia', city: 'Bratislava', countryCode: 'SK', ipAddress: '203.0.113.9'),
);
```

- DeviceData — browser, browserVersion, os, osVersion, deviceType (a DeviceType case or a string) and isBot. All optional.
- LocationData — country, city, countryCode and ipAddress. All optional.

## Write semantics

- session() accepts the RefreshToken model, an int or a string key; an unknown key throws SessionNotFoundException.
- It only ever touches device and geo columns — never token\_hash, revoked\_at, expires\_at, access\_reference or family\_id.
- The six device columns are always overwritten — an absent DeviceData field nulls its column.
- Location columns are written only when a LocationData is supplied, so a later device-only enrich never clobbers stored geo.
- Enriched data is carried forward to every replacement on rotation.

## Enrich asynchronously

Hook RefreshTokenIssued and do the parsing off the request path:

```php
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\RefreshTokens\Events\RefreshTokenIssued;

Event::listen(function (RefreshTokenIssued $event): void {
    // queue your own job: parse the user agent, geolocate the IP,
    // then call RefreshTokens::session($event->tokenId)->enrich($device, $location)
});
```

## Show your open-source love

This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.

[More ways to support, including crypto](https://roundly-consulting.com/support-us.md)

By donating, you agree to our [donation terms](https://roundly-consulting.com/donation-terms.md).

[Support our open source work (opens in a new tab)](https://donate.stripe.com/dRmeVe8FX5PF1Qd9pXcEw00) [Join us on Patreon (opens in a new tab)](https://www.patreon.com/cw/roundly)

## Want this built into your product?

We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.

[Get a quote in 48 hours](https://roundly-consulting.com/contact.md) [Browse all packages](https://roundly-consulting.com/open-source/docs/refresh-tokens-for-laravel.md)
