Skip to main content
By default, Grantiva identifies devices anonymously. You can optionally associate a user identity for:
  • Feature flags targeted by user properties
  • Feedback that persists across devices for the same user
  • Analytics grouped by user rather than device

Identify a user

Or with just a user ID:
Both overloads are asyncidentify clears the feedback and flag caches so the next read re-fetches under the new identity. All services (feedback, flags) automatically use this context after identification. Caches are cleared on identity change so services re-fetch with the new context.

UserContext

Properties are used for feature flag targeting and segmentation. Common examples:
  • "plan": "free", "pro", "business"
  • "country": "US", "DE", "JP"
  • "beta_tester": "true"
  • "company_size": "50"

Subject ID (subscription sharing unit)

Separate from user identity, setSubjectId links the device to a sharing unit (family/household) for subscription entitlement claims (SDK 2.1.0+, Enterprise):
Unlike identify, these three are synchronous and do not clear any caches. Set the subject id before calling validateAttestation(). The id rides the next attestation or token refresh; the backend then projects custom_claims.subscription into the JWT for every device sharing the same id. Use the identical value as the StoreKit appAccountToken and Stripe client_reference_id. Don’t confuse the two:

Device context (automatic)

The SDK automatically collects device context — you don’t need to set this:
DeviceContext is captured when you construct the UserContext, so it reflects the app and OS at that moment. You can’t set these fields yourself; your own properties take precedence if you use the same key.

Clear identity

Call on user logout:
Services fall back to device-based identity. Feedback submitted before logout remains associated with the user.

Read current identity