Appwin Core
Appwin Core is the foundation every module builds on: device identity, authenticated session, network client. A person stays the same across Community, Support and the rest, and each request reaches your project from your App ID alone.
You never install Core separately: it comes with the first module, and it is always the first line of the generated setup.
What it does at startup
configure(projectAppId:): synchronous, called once. Sets up the device identity and the network client, and routes every request to your project.- It starts the event pipeline and the app lifecycle, whichever modules are installed: sessions and the automatic events begin here.
- It then opens the session by itself, in the background, with the first call that needs it. Nothing to call.
That is why the SDK is one URL and one configure rather than four: each
module's initialize() builds on the session Core opens.
Track an event
track() is the one way to describe what happened in your app, whichever
modules you install. The event reaches Analytics, can start a journey in
Notifications and goes to your ad networks, according to the customer's consent.
You never call AppwinAnalytics.track or AppwinNotifications.trackEvent
(deprecated, see below).
AppwinCore.track("onboarding_completed", props: [
"steps_count": 4,
"notifications_enabled": true,
])
Properties accept only strings, numbers, and booleans. Names follow the Analytics rules.
Core also sends the events nobody should write by hand, as soon as configure
returns: app_install, app_update, app_open, app_background,
session_start, session_end, screen_view, install_referrer (Android),
push_opt_in and push_opened. See
the automatic events. An app
with only Notifications or Support gets sessions and these events too.
Consent
Consent is answered per purpose:
| Purpose | What it sorts |
|---|---|
analytics | Storage in Analytics, replay and crash breadcrumbs. |
marketing | Journeys: the event reaches Notifications only if marketing is granted. |
advertising | Ad networks fed by the event stream. |
All three are granted by default: an app with no consent banner has nothing to
do. A state is granted, denied or unknown (ConsentState). unknown
keeps events on the device until the answer.
AppwinCore.setConsent(.unknown)
AppwinCore.setConsent(.granted) // uploads pending events
AppwinCore.setConsent(.denied) // purges the queue and stops collection
AppwinCore.setConsent(.denied, for: .marketing) // only marketing
Without a purpose, setConsent(state) sets the three at once. The sorting
happens in the SDK: if no purpose is granted, nothing is sent and the local queue
is emptied; otherwise each event is sent once, with the purposes granted at that
moment. A refusal also purges the session replay already recorded. A consent
refused before an update to 0.16 stays refused on the three purposes.
advertising is not AppwinAttribution.setAdvertisingConsent:
the purpose sorts the events of the stream, while the IDFA, the GAID and the ad
networks stay opt-in through setAdvertisingConsent, unchanged.
:::note
ConsentState replaces AnalyticsConsent (AppwinAnalyticsConsent on
Flutter and React Native), kept as a deprecated alias for the transition. On
Android, the alias is a Kotlin typealias: Java code, and libraries compiled
against 0.15, must use ConsentState.
:::
One identity, every module
Core recognises the device with no sign-up. Attach your user with identify at
sign-in (the id is kept across launches), push attributes with updateUser,
call logout at sign-out. They become the same person in every module and
across their devices: the modules have no identity of their own.
Always pass your user id, never a session or device id: two identifiers make two people. Full picture in Identity.
Which environment it talks to
By default, Core talks to https://api.appwin.io, routed to your project by
your App ID. The baseUrl parameter of configure is only for a different
entry point we hand you (a staging environment, for instance).