Analytics

Analytics setup

Turn on screen, session and push-open analytics in the native-notify SDK.

Enable the flags

Every flag is off until you set it. Set them once at module scope, or on the registration call (native-notify v5.2+). The two merge.

import { NativeNotify } from "native-notify";

NativeNotify.init({
  appId: yourAppId,
  appToken: "yourAppToken",
  analytics: {
    screens: true,   // screen views ("which screens do users use most")
    sessions: true,  // foreground session length
    opens: true,     // push-notification open reporting
    deviceId: true,  // stable device id (see below)
  },
});

Analytics needs native-notify v5.1+, ideally 5.1.1 or later.

What each flag collects

FlagWhat it does
screensReports a screen name and timestamp per view, plus device context, when you call trackScreen() or use useNativeNotifyScreenTracking().
sessionsReports session start, end and duration. registerNNPushToken wires it: a session starts when the app opens and ends when it backgrounds.
opensReports which notification was tapped, read from the payload's nn_notification_id. One tap counts once.
deviceIdSends a stable device id with registrations and events, from expo-application if installed: getIosIdForVendorAsync() on iOS, getAndroidId() on Android. Without it, unique counts use the Expo push token.

What gets sent

  • Only screen names, event counts, a device identifier, app version and timezone are sent, all to your Native Notify app.
  • Events are best-effort: 10-second timeout, batched and throttled, and a failure never throws into your app. flushScreenQueue() forces a flush, and the SDK calls it when a session ends.
  • Raw app opens, session events and open events are kept for 365 days, per-device screen-view dedupe rows for 90. Daily totals stay, so long-range charts keep working.
  • Turning a flag off stops that collection on the next app run. Counts already collected age out normally.

Not using the SDK? Report events yourself with the Analytics API.