segmentio / analytics-react-native

The hassle-free way to add analytics to your React-Native app.
https://segment.com/docs/sources/mobile/react-native/
MIT License
367 stars 191 forks source link

Amplitude events are reported as "outside session" #654

Closed rborn closed 2 years ago

rborn commented 2 years ago

Hello, I updated the module to v2 but now all the Amplitude events are "outside of session" (green) instead of "inside session" (blue)

https://help.amplitude.com/hc/en-us/articles/229313067-Look-up-event-data-for-individual-users#:~:text=Blue%20events%20in%20a%20session,or%20only%20show%20specific%20events.

Steps to reproduce

I just updated and adapted the module to version 2 (was 1.x before)

my code:

        Analytics = createClient({
            writeKey: configuration.apiKeys.segmentio,
            autoAddSegmentDestination: true,
            trackAppLifecycleEvents: true,
            trackAttributionData: true,
            debug: debugConfigs.segment,
            flushInterval: Config.APP_TYPE === 'test' || Config.APP_TYPE === 'demo' ? 1 : 20,
            flushAt: Config.APP_TYPE === 'test' || Config.APP_TYPE === 'demo' ? 1 : 20,
            trackDeepLinks: true
        });

        Analytics.add({ plugin: new AmplitudeSessionPlugin() });

Expected behavior

Amplitude should receive the events as being part of a session while they seem to be interpreted as being sent server side

Actual behavior

All events show as "outside"

Here is a sample of the difference: Screenshot 2022-08-24 at 16 32 09

We are measuring the time the users are stating in the app, and currently this is broken Screenshot 2022-08-24 at 16 47 12

Thank you ❤️

alanjcharles commented 2 years ago

Hi @rborn Sorry to hear you're having issues with your migration. I've added this to our current sprint and will take a look as soon as I have a chance. Thanks for your patience!

rborn commented 2 years ago

@alanjcharles thanks for looking into this. I think I have found something, we had the Segment/Amplitude connection since 3.5 years ago 😅, but it seems something changed and now there are 2 ways of doing this, "Actions" and "Classic" (we were Classic)

Screenshot 2022-08-25 at 10 58 41

I've redone the connection in the new Action mode and it seems the events start to pickup and be "blue" again. There are still users that keep being "green" but I believe the events will only be considered in a session if there is a session started, so if the users had the app in background probably won't show as blue.

I won't close the ticket for now, but I'll come back in a few days ( we'll make a new release) and update you.

If it turns to be this maybe this is something to mention in the docs?

Thanks for everything 🥰

alanjcharles commented 2 years ago

Hi @rborn Sorry I missed your message! I was just looking at this again to try and come up with a fix but it seems like you might have gotten it sorted! Please let me know whenever you have the chance. If that is the case, I'll be sure to add it to the documentation. Thanks so much!

rborn commented 2 years ago

@alanjcharles hey, yes all seems to be working after the new connection setup. Sorry for not getting back to you in time :(

alanjcharles commented 2 years ago

@rborn no problem at all ! Thanks for letting me know.