Skip to content

Context Missing on Initial App Lifecycle Events #449

@kylegwalsh

Description

@kylegwalsh

It looks like the context and library information is missing on initial App Lifecycle events. The only thing I can think of is that there may be some kind of race condition with the initialization of the library and the sending of the first few lifecycle events.

  • analytics-react-native version: 2.1.4-beta
  • React Native version: 0.64.3
  • Both iOS and Android

Steps to reproduce

  1. Call createClient and attach appLifecycleEvents boolean:
const platformAnalytics = createClient({
  writeKey: Platform.select({
    ios: config.analytics.writeKeys.ios,
    android: config.analytics.writeKeys.android,
    default: '',
  }),
  trackAppLifecycleEvents: true,
  trackDeepLinks: true,
});
  1. Reinstall and open app

Expected behavior

App Lifecycle events would come in with complete context and library information (like the other events do after initialization):

{
  "context": {
    "app": {
      "build": "1.0.2",
      "name": "App Name",
      "namespace": "com.app",
      "version": "1.0.2"
    },
    "device": {
      "adTrackingEnabled": false,
      "id": "XXXXX-XXX-XXX-XXX-XXXXX",
      "manufacturer": "Apple",
      "model": "iPhone12,1",
      "name": "iPhone",
      "type": "ios"
    },
    "ip": "XX.XXX.XXX.XX",
    "library": {
      "name": "@segment/analytics-react-native",
      "version": "2.1.4-beta"
    },
    "locale": "en-US",
    "network": {
      "cellular": false,
      "wifi": true
    },
    "os": {
      "name": "iOS",
      "version": "15.2.1"
    },
    "screen": {
      "height": 896,
      "width": 414
    },
    "timezone": "America/New_York",
    "traits": {}
  },
 "event": "Application Installed",
  ...
}

Actual behavior

App Lifecycle events come in without any context or library information:

{
  "context": {
    "library": {
      "name": "unknown",
      "version": "unknown"
    }
  },
  "event": "Application Installed",
  ...
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugBug fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions