User Identification
Call setUser to associate events with a known user.
let user = B2MUser(
userId: "user-123",
name: "Ada",
surname: "Lovelace",
email: "ada@example.com",
customAttributes: ["plan": AnyCodable("premium")]
)
B2MAnalytics.shared.setUser(user)
This logs a user_identify event and attaches the user's attributes to every subsequent event. Each call replaces the previously set user, and the user is not persisted across app launches — call setUser again on each launch once the user is known.
Note
Device-collected properties always win a key collision with a custom attribute (for example device_id, os_version).