PostHog / posthog-node

Official PostHog Node library
MIT License
21 stars 19 forks source link

Fix bug where distinct_id was being flushed #51

Closed alexkim205 closed 2 years ago

alexkim205 commented 2 years ago

There's some weirdness in how we clean and standardize alias calls that's mapping correct id's to "undefined" string distinct id's. Today we nullify distinct_id and distinctId while keeping distinct_id in the properties object. In enqueue(), there's a:

        if (message.distinctId) {
            message.distinct_id = message.distinctId
            delete message.distinctId
        }

that seems to protect against incorrect/null/undefined distinct_id's but that doesn't work if we flush it out already in alias().

Captured conversation here - https://posthogusers.slack.com/archives/CT7HXDEG3/p1633637368418400

Tagging @yakkomajuri here in case I'm missing some historical context.

Checklist