ScaleBun
Skip to article

Identity

react-nativeDeveloper

Attribute activity to a user instead of a device — identify, setUser, clearUser, and what happens to data captured before sign-in.

Updated Reviewed

Before you identify anyone, activity is attributed to a device. After, it is attributed to a user.

Identify after sign-in#

TypeScript
ScaleBun.identify('user_123', {  plan: 'pro',  email: 'ada@example.com',  signupDate: '2026-01-14',});

The first argument is your own stable user id. Use whatever your backend considers canonical — a database id or UUID. The traits object is optional and merges with whatever is already stored.

Calling identify before init#

Safe. Identity is buffered and applied once init() completes, so you do not need to order the two calls or await initialisation before you can identify.

TypeScript
ScaleBun.identify('user_123');   // bufferedawait ScaleBun.init({ /* … */ }); // identity applied here

Clear on sign-out#

TypeScript
ScaleBun.clearUser();

Call this on every sign-out. Skipping it on a shared device attributes the next person's activity to the previous user — which corrupts retention and funnel numbers in a way that is very hard to notice later.

clearUser() does not reset the device id. The device remains the same device; it simply stops being associated with that user.

setUser vs identify#

Both establish identity. They differ in shape:

identify(userId, traits?)setUser(user)
ShapeTwo argumentsOne ScaleBunUser object
FieldsAny traitsid, name, email, attributes, properties
Use whenNormal application flowYou already hold a user object
TypeScript
ScaleBun.setUser({  id: 'user_123',  name: 'Ada Lovelace',  email: 'ada@example.com',  attributes: { plan: 'pro', seats: 12 },});

identifyUser() also exists and behaves as identify() does; prefer identify() in new code.

Advertising and attribution identifiers#

Attribution needs device identifiers, which are separate from user identity and gated by platform consent. Supply them once you have permission:

TypeScript
ScaleBun.events.setIdentifiers({ idfa, gaid, idfv });

Requesting consent is your app's responsibility — the SDK never prompts on your behalf, because the prompt's timing and copy affect your opt-in rate and belong to your product.

For deferred deep-link attribution, record the click token:

TypeScript
ScaleBun.events.setAttributionClickId(clickId);

Replay identity#

Session replay keeps its own identity so it can be switched off independently of analytics:

TypeScript
ScaleBun.replay.setUser({ id: 'user_123' });ScaleBun.replay.clearUser();

If you use both, set both — identifying for analytics does not name the user on a replay.

Deleting a user's data#

Deletion is a server-side operation, not an SDK call. clearUser() stops attribution going forward; it does not remove anything already captured. Use the GDPR/CCPA data-request endpoints in the API reference to erase a user.

Identity · Get started · React Native SDK · ScaleBun