4
  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: 'notgood@gmail.com' },
  {
    event: 'App Started',
    integrations: {
      Amplitude: {
        sessionId: global.epochInMilliSeconds,
      },
    },
  }
);

Segment.trackWithProperties(
  'App Started',
  { email: 'fancyemail@gmail.com' },
  { 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

Mogsdad
  • 44,709
  • 21
  • 151
  • 275
int-i
  • 661
  • 1
  • 12
  • 28
  • Have you verified global.epochInMilliSeconds isn't somehow always -1 at the time the line is evaluated? – Atmas Sep 27 '21 at 03:12
  • @Atmas I verified that. It is properly calculated here `global.epochInMilliSeconds = Date.now();` – int-i Sep 27 '21 at 13:12
  • I noticed in your attached page it showed "session_id" and not "sessionId" in the Amplitude object for the first use. You seem to use both. Is that OK? The page refers to it in both ways but only ever uses the underscore version in examples.. seems like it could be a point of confusion. – Atmas Sep 27 '21 at 15:42
  • @Atmas Tried both. No difference. Still registers as -1. – int-i Sep 28 '21 at 01:21

1 Answers1

1

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.

int-i
  • 661
  • 1
  • 12
  • 28
Atmas
  • 2,389
  • 5
  • 13
  • I went through above link before posting this question. Solution for -1 is provided in segment documentation(To provide epoch time) - Which is not working – int-i Sep 30 '21 at 02:18
  • See - https://segment.com/blog/facts-vs-stories-why-segment-has-no-sessions-api/ – int-i Sep 30 '21 at 02:18
  • Also this - https://segment.com/docs/connections/destinations/catalog/amplitude/ – int-i Sep 30 '21 at 02:19
  • 1
    That's unfortunate. I read your links to learn more too. I'm afraid I am probably not the right person to continue analysis but I'll leave this answer up in case it helps a different traveler especially now that you added these extra links too. – Atmas Sep 30 '21 at 02:57