Skip to content

No traits on any events after updating from version 1.5.0 to 2.2.2 #578

@Wiingaard

Description

@Wiingaard

After updating from version 1.5.0 to version 2.2.2, traits no longer show up the the context.traits of any event.

When inspecting track events in the online debugger context.traits is an empty object on every event, even though identify has been called prior to the events.

  • analytics-react-native version: 2.2.2
  • Integrations versions: @segment/analytics-react-native-plugin-amplitude-session version 0.2.1
  • React Native version: 0.65.2
  • iOS or Android or both? Both

Steps to reproduce

In global scope I initialize the client like so:

import {createClient} from '@segment/analytics-react-native'
import {AmplitudeSessionPlugin} from '@segment/analytics-react-native-plugin-amplitude-session'
import config from './config'

const segmentKey = config.segmentId

const client = createClient({
    writeKey: segmentKey,
    trackAppLifecycleEvents: true,
    collectDeviceId: true,
    trackDeepLinks: true
})

client.add({plugin: new AmplitudeSessionPlugin()})

export default client

Once the users successfully signs in, I call identify like so:

import Analytics from 'src/lib/analytics'
...
Analytics.identify(userId, {firstName, lastName})

When the user performs some action, I track it events like so:

import Analytics from 'src/lib/analytics'
...
Analytics.track('Banner Clicked', {
    type: 'missing_details'
})

Behavior

When inspecting the online debugger I see the IDENTIFY log like so (cut down for privacy and brevity):

{
  "anonymousId": "kM_gljge4syZRiAqGiYSq",
  "context": {
    ...
    "traits": {}
  },
  ...
  "traits": {
    "firstName": "M*** A***",
    "lastName": "W***",
  },
  ...
  "type": "identify",
  "userId": "ca5ed865-0761-4181-ae7d-c26f2a12d4bd",
  ...
}

Notice: context.traits is empty but the "traits" property is set.

On a subsequent TRACK event, I still don't see context.traits:

{
  "anonymousId": "kM_gljge4syZRiAqGiYSq",
  "context": {
    ...
    "traits": {}
  },
  "event": "Banner Clicked",
  ...
  "properties": {
    "type": "missing_details"
  },
  ...
  "type": "track",
  "userId": "ca5ed865-0761-4181-ae7d-c26f2a12d4bd",
  ...
}

Why is context.traits empty even though I did the identify prior to the tracking call?

I experience this behavior both when running on Android and iOS.

Another comment is that this used to work before I updated the library from version 1.5.0 to version 2.2.2. When looking at tracking and identify events sent from app versions that are still running the old SDK version, I see that context.traits are filled as expected. I didn't change anything on the tracking or identify events during the update. All I did was following the migration guide which updated dependencies and moved the setup to global scope.

Any help would be much appreciated.. We're doing this update because of some notice that the android library linked to the version we're currently using is non-compliant with their User Data policy. Google is prompting us to update to version 4.10.1 or we'll not be able to submit new builds, so we're a bit in a hurry here..

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions