User Context

Associate errors with specific users to understand who is affected and prioritize fixes.

Why Set User Context?

Setting user context helps you:

  • Identify which users are affected by an error
  • Prioritize fixes for premium or important users
  • Reach out to affected users proactively
  • Understand error patterns across user segments

Setting User Context

Laravel / PHP

use Alertiqo\Laravel\Facades\Alertiqo;

// After user logs in
Alertiqo::setUser([
    'id' => auth()->id(),
    'email' => auth()->user()->email,
    'name' => auth()->user()->name,
]);

// Or with additional data
Alertiqo::setUser([
    'id' => $user->id,
    'email' => $user->email,
    'name' => $user->name,
    'subscription' => $user->plan,
    'company' => $user->company_name,
]);

JavaScript

alertiqo.setUser({
  id: '12345',
  email: '[email protected]',
  username: 'johndoe'
});

// With additional data
alertiqo.setUser({
  id: user.id,
  email: user.email,
  username: user.username,
  subscription: user.plan,
  company: user.companyName
});

Node.js

alertiqo.setUser({
  id: '12345',
  email: '[email protected]',
  username: 'johndoe'
});

Python

alertiqo.set_user(
    user_id="12345",
    email="[email protected]",
    username="johndoe"
)

Go

client.SetUser(&alertiqo.User{
    ID:       "12345",
    Email:    "[email protected]",
    Username: "johndoe",
})

Ruby

Alertiqo.set_user(
  id: "12345",
  email: "[email protected]",
  username: "johndoe"
)

User Properties

Property Type Description
id string Unique user identifier (recommended)
email string User's email address
username string User's username or display name
* any Any additional custom properties

Clearing User Context

Clear user context when the user logs out:

Laravel / PHP

Alertiqo::setUser(null);

JavaScript / Node.js

alertiqo.setUser(null);

Best Practices

  • Always include a unique id for reliable user identification
  • Set user context as early as possible after authentication
  • Clear user context on logout
  • Avoid storing sensitive data like passwords or tokens
  • Consider GDPR/privacy implications when storing user data

Privacy Note: Be mindful of privacy regulations like GDPR. Only store user data that is necessary for debugging and ensure you have appropriate consent.