1. I am using Segment[expo-analytics-segment] to send tracking info to Amplitude(Configured as the destination in app.segment.com) in an expo react native app. Though I am sending session info(epoch time) - The session always gets registered as -1, hence I am unable to access 'funnel' feature in Amplitude.
  2. Also - How do we enable automatic page tracking in expo segment+amplitude configuration?

This is what I have done so far in App.tsx

Segment.initialize({
  androidWriteKey: 'androidKey', // from Segment
  iosWriteKey: 'iOsKey', // from segment
});

global.epochInMilliSeconds = Date.now();
Segment.identifyWithTraits(
  user.sub,
  { email: '[email protected]' },
  {
    event: 'App Started',
    integrations: {
      Amplitude: {
        sessionId: global.epochInMilliSeconds,
      },
    },
  }
);

Segment.trackWithProperties(
  'App Started',
  { email: '[email protected]' },
  { integrations: { Amplitude: { session_id: global.epochInMilliSeconds } } }
); <------------------- Did not work. Session id is -1**

Segment.track('App Started'); // <-----------------------Session id is -1

More info - https://github.com/expo/expo/issues/10559

I followed this example for the above code sample: https://community.amplitude.com/instrumentation-and-data-management-57/how-do-we-set-session-in-amplitude-while-using-segment-in-cloud-mode-111

1

There are 1 best solutions below

4
On

Amplitude website mentions that session Ids are not automatically tracked.

https://help.amplitude.com/hc/en-us/articles/217934128-Segment-Amplitude-Integration

In case the link changes, it says:

6. Why do all of my events have a sessionId of -1?

You need to use Segment's client-side bundled integration to have our native SDKs track Session IDs for you.