Skip to main content

User Identification

Associate telemetry with specific users to track user behavior, debug user-specific issues, and understand user segments.

Setup

Ensure the Pulse SDK is properly initialized. See Quick Start for setup instructions.

Why Identify Users?

User identification helps you:

  • Debug user-specific issues - Find all errors and events for a particular user
  • Track user journeys - See the complete flow of actions a user takes
  • Analyze by segment - Compare behavior across different user types (free vs paid, regions, etc.)
  • Support users effectively - Quickly access a user's telemetry when they report an issue

Setting User ID

Set the user ID when a user logs in:

import { Pulse } from '@horizoneng/pulse-react-native';

// After successful login
Pulse.setUserId('user-abc123');

Clear the user ID when they log out:

// On logout
Pulse.setUserId(null);

Setting User Properties

Add additional context about the user with properties:

// Set individual properties
Pulse.setUserProperty('subscription', 'premium');
Pulse.setUserProperty('region', 'us-west');

// Or set multiple properties at once
Pulse.setUserProperties({
subscription: 'premium',
region: 'us-west',
verified: true,
signupDate: '2024-01-15'
});

Complete Example

Here's a typical implementation with login and logout:

import { Pulse } from '@horizoneng/pulse-react-native';

// After user login
async function handleLogin(credentials) {
const user = await loginUser(credentials);

// Set user ID
Pulse.setUserId(user.id);

// Set user properties
Pulse.setUserProperties({
subscription: user.subscription,
region: user.region,
verified: user.isVerified,
accountType: user.type
});

console.log('User identified:', user.id);
}

// On logout
function handleLogout() {
Pulse.setUserId(null);
console.log('User context cleared');
}

Privacy Considerations

Avoid Personally Identifiable Information (PII):

// ❌ Don't do this
Pulse.setUserProperty('email', 'user@example.com');
Pulse.setUserProperty('phone', '+1-555-0123');
Pulse.setUserProperty('name', 'John Doe');

// ✅ Use identifiers and categories instead
Pulse.setUserId('user-abc123');
Pulse.setUserProperty('subscription', 'premium');
Pulse.setUserProperty('region', 'north-america');

Use hashed or anonymized identifiers when possible, and never include sensitive data like passwords, credit card numbers, or other PII.