Skip to content

Segment client did not initialize correctly #1085

@xuanmai-agilityio

Description

@xuanmai-agilityio

I got a weird issue with the Segment client initialization. The client did not initialize correctly due to the processing of pending events. It happened from the second time.
It does not happen on the latest Segment version, but the upgrade does not help due to the cache is still persisted between app updates.

  • analytics-react-native version: 2.20.0
  • Integrations versions (if used): no
  • React Native version: 0.74.3 (Expo SDK 51.0.20)
  • iOS or Android or both? Tested on iOS 17

Steps to reproduce

  • Integrate Segment as normal.
  • Open the app for the first time.
  • Quit the app completely, kill it in the recent menu.
  • Open the app again, and it throws an error (An internal error occurred: [Error: Client did not initialize correctly]). No events can be sent.

Expected behavior

  • The Segment client initializes successfully, and events are sent to the dashboard following the flush policy.

Actual behavior

  • The second time the app opens, Segment client inits the pending events as an object instead of an array.
  • I placed a log in the SegmentClient class -> onReady function. It shows pending is not an array, which causes the next code block (the for of loop) to throw a type error and stop the initialization process.
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions