Events
The SDK records what happens in your app as events, queues them on the phone for the user signed in, and sends them in batches: every 30 seconds, as soon as 50 are queued, and when the app goes to the background. Your team uses them in segments, message triggers, workflows and goals.
What you draw: nothing. If your settings let users turn product analytics off, that switch is yours (Turning events off).
Sent by themselves
Section titled “Sent by themselves”Without any code of yours, the SDK records:
| Event | When |
|---|---|
app_opened | The app starts, or comes back to the front. |
session_ended | The app goes to the background, with how long it was in front. |
app_updated | The first start of a new appVersion. |
push_opened | A push tap you handed to handlePushTap (Push). |
link_opened | A link the SDK followed (Links). |
push_permission_changed, location_permission_changed | A permission answer you reported changed. |
screen_viewed | crm.screen(name), or each Activity with autoScreenViews on. |
and everything users do with in-app messages and the messenger, which go to PurrCRM by their own routes. These are standard events, on Settings › your app › Data › Events.
The app is in front while at least one of its Activities is started; an Activity recreated for a rotation is not a trip to the background. With CrmConfig.followLifecycle = false, call crm.appPaused() and crm.appResumed() yourself.
Screens
Section titled “Screens”Name each of your screens as it shows:
crm.screen("wallet") // records screen_viewed {screen: wallet}Use a name, the same every time; never a path or an id. The same name twice in a row is recorded once. CrmConfig(autoScreenViews = true) records each Activity shown by its class name instead, which suits an app with one Activity per screen; leave it off with Compose or fragments, and name your screens yourself.
Your own events
Section titled “Your own events”-
Define them on Settings › your app › Data › Events, and declare them in
CrmConfig.customEvents:CrmConfig(apiBase = "https://app.purrcrm.com",appKey = BuildConfig.CRM_APP_KEY,appVersion = BuildConfig.VERSION_NAME,customEvents = setOf("order_placed", "table_booked"),) -
Record them:
crm.track("order_placed", mapOf("total" to "1250", "items" to "3"))
Names are lower case with underscores. Props are strings, at most ten, each cut to 120 characters; PurrCRM reads a number, a date or money from its string by the event’s definition. Money is a whole number of the smallest unit, such as pence: 1250 for £12.50.
The SDK drops a name that is neither one of its own nor in customEvents, since PurrCRM would refuse the whole batch it was in; with debug on it says so in the log. On PurrCRM, a new event is accepted the first time and marked for review, unless your app has Strict data on, when it must be defined on Settings › your app › Data first. See Data.
crm.flush() (a suspend call) sends what is queued now.
The queue
Section titled “The queue”Events are queued on the phone for the user signed in: at most 500, and none older than a week. A batch that fails is kept and sent later; one PurrCRM refuses is dropped, and the setup check’s Queue row says why. Nothing is recorded while nobody is signed in.
Permissions
Section titled “Permissions”Tell the SDK when the user answers a permission, with push or location:
crm.permissionChanged("push", granted) // true, false, or null when you cannot tellcrm.permissionChanged("location", granted)The SDK keeps the last answer on the phone, and records an event only when it changed.
Turning events off
Section titled “Turning events off”If a user turns product analytics off in your settings, start their session with CrmSession(guestId = id, productEventsOff = true): nothing is recorded or sent for them, and what was queued is dropped. What they write to your team, and their answers to messages and surveys, still go: those are the conversation itself.
What the SDK sends
Section titled “What the SDK sends”For Google Play’s Data safety form, the SDK sends, to your PurrCRM only:
- the user’s id in your app, and a display name if you give one;
- product interactions: the events above, with your props, the app’s version, the phone’s time zone and language;
- what the user writes to your team: messages, the pictures they attach, ratings, survey answers, and their answers to the help bot (an email or an order reference when it asks);
- the device’s push token, while a user is signed in.
Nothing is sent for advertising, or to anyone else. On the phone it keeps only the event queue, the last app version, the permissions last reported, the app’s public face and a deferred link’s claim; never a token.
From your backend
Section titled “From your backend”Events your servers see, such as a payment, are better sent from the backend, with the server API.