User context
User context lets you attach optional attributes to the people using your agent, so sessions and analytics carry richer detail. Identity is built in: every field below is optional and exists to give you deeper observability.
Create custom user and subscription attributes under Settings > Attribute Settings.
Identify a user
Section titled “Identify a user”Pass a context object to foldspace.identify() once the SDK is ready.
const context = { user: { id: '7d8da9a5-53f3-4bc0-8921-1cceecb8107', }, subscription: { id: 'subscription-12345' // add custom attributes here after creating them in Attribute Settings }}
foldspace('when', 'ready', () => { foldspace.identify(context);});Add custom user attributes (optional)
Section titled “Add custom user attributes (optional)”Add any of the optional attributes below to enrich the user record.
const context = { user: { id: '7d8da9a5-53f3-4bc0-8921-1cceecb8107', email: 'user12345@example.com', name: 'John Doe', role: 'admin', image: 'https://example.com/images/user12345.jpg', phone: '+1234567890', timezone: 'America/New_York', signUpDate: 1707164462000, location: { country: "USA", region: "Northeast", state: "New York", city: "New York City", postalCode: "10001" } // add custom attributes here after creating them in Attribute Settings
}, subscription: { id: 'subscription-12345' // add custom attributes here after creating them in Attribute Settings }}
foldspace('when', 'ready', () => { foldspace.identify(context);});