Skip to main content
Identity commands connect AppsFlyer’s device-level attribution to your own user model. Everything here is forwarded to the native SDK. Email and phone are SHA256-hashed on the device before transmission, so raw PII never leaves the app.

Installation

npm install despia-native
pnpm add despia-native
yarn add despia-native
import despia from 'despia-native';

set_user_id

Call as soon as the user signs up or logs in. All subsequent events carry your internal user ID across AppsFlyer, Meta, and TikTok reporting, and raw-data exports become joinable with your own database.
const userId = "user_123"
despia("appsflyer://set_user_id?customer_user_id=" + encodeURIComponent(userId))
customer_user_id
string
required
Your internal, stable user identifier. Avoid emails or anything that changes.

set_email

Passes the user’s email for audience matching. The value is normalized and SHA256-hashed natively before it is sent.
const email = "user@example.com"
despia("appsflyer://set_email?email=" + encodeURIComponent(email))
Lowercase and trim the email in your web layer before sending. Hashes only match across systems when the input is normalized identically everywhere.

set_phone

Passes the user’s phone number, SHA256-hashed natively and attached to the user’s event data as phone_hash.
const phone = "+15550001234"
despia("appsflyer://set_phone?phone=" + encodeURIComponent(phone))
Send phone numbers in E.164 format (+<country code><number>, no spaces or dashes) so hashes are consistent.

get_uid

Reads the AppsFlyer device ID. It is already injected on every page load as despia.appsFlyerUID. Use the await pattern when you need a guaranteed-fresh value inline:
const data = await despia("appsflyer://get_uid", ["appsFlyerUID"])
const uid = data.appsFlyerUID
// e.g. store next to the user record for server-to-server events
await fetch("/api/users/me/af-uid", { method: "POST", body: uid })

1

Consent first

Forward the user’s cookie-banner choice with set_consent before identifying or logging anything.
2

Identify at signup or login

set_user_id, then set_email and set_phone if you have them.
3

Log events

Everything from here on is tied to the user. See Events.

Resources

NPM Package

despia-native