Skip to main content

User Identification

Associate telemetry with specific users to enable per-user analysis in the Pulse dashboard.

Set a User ID

Call setUserId after the user authenticates. All subsequent telemetry will carry this identity.

func onLoginSuccess(userId: String) {
Pulse.shared.setUserId(userId)
}

To clear the user ID (e.g. on logout), pass nil:

func onLogout() {
Pulse.shared.setUserId(nil)
}
note

User ID and properties are persisted across app sessions. They will only be cleared if the user explicitly logs out (you call setUserId(nil)) or if the app's data is cleared.

Set User Properties

Attach additional user context — plan, role, account type — that will appear on all telemetry.

// Single property
Pulse.shared.setUserProperty(name: "user.plan", value: AttributeValue.string("premium"))

// Multiple at once
Pulse.shared.setUserProperties([
"user.plan": AttributeValue.string("premium"),
"user.region": AttributeValue.string("us-east"),
])

To clear a property, pass nil as the value:

Pulse.shared.setUserProperty(name: "user.plan", value: nil)

Common Pattern: Login / Logout

class AuthManager {

func login(userId: String, plan: String) {
Pulse.shared.setUserId(userId)
Pulse.shared.setUserProperties([
"user.plan": AttributeValue.string(plan),
])
}

func logout() {
Pulse.shared.setUserId(nil)
}
}

Next Steps