I’ve implemented server-side logging for my project using the simplified API. When a user loads my homepage, three events are logged like this:
{
"event": "APP_LOAD_SUCCEEDED",
"properties": {
"distinct_id": "$device:5ff9dcfd-880e-4303-8a7a-131e6aebb724",
"$device_id": "5ff9dcfd-880e-4303-8a7a-131e6aebb724",
}
}
{
"event": "LANDING_PAGE_MOUNTED",
"properties": {
"distinct_id": "$device:5ff9dcfd-880e-4303-8a7a-131e6aebb724",
"$device_id": "5ff9dcfd-880e-4303-8a7a-131e6aebb724",
}
}
{
"event": "CREATE_DATASET_SCREEN_MOUNTED",
"properties": {
"distinct_id": "iSYUjPGqIrf6wp5oyzbBNLSMx303",
"$device_id": "5ff9dcfd-880e-4303-8a7a-131e6aebb724",
"$user_id": "iSYUjPGqIrf6wp5oyzbBNLSMx303",
}
}The problem - Mixpanel doesn’t retroactively associate the first two events with the same user once the $user_id is available (see below) Is there a reason Mixpanel isn’t automatically linking these events to the user once the $user_id is identified? Does server-side logging require an explicit call to mixpanel.identify() to achieve this? I do not want to resort to calling identify() from the client because this will be blocked in ~30% of cases.
have you tried sending user ID to first 2 events and see the result?
User ID is not available at the time the first two events are logged
interesting, server side events do not have context who is calling the function hence sending user ID is important to identify
All 3 events contain the same device_id. When user id is not set mixpanel uses this as the distinct id. The json payloads above are what is sent to mixpanel
You can maybe get away with just adding an alias call to link the two distinct_id's to each other when you fire that final event? We don't send anonymous events from the server, only the FE, but once we know the user we'll have the FE send an alias to link the anonymous ID with the identified ID etc.
