rudder-transformer icon indicating copy to clipboard operation
rudder-transformer copied to clipboard

[Posthog] fix swapped alias ids

Open mjeffrey18 opened this issue 1 year ago • 4 comments

What are the changes introduced in this PR?

This PR fixes an issue with how the alias call is mapped when sending events from Rudderstack to PostHog. It ensures the distinct_id and alias are correctly populated in the $create_alias event sent to PostHog.

Whenever I call this on the client

rudderstack_client.alias(
  previous_id: "old-id",
  user_id: "keep-id"
)

The resulting $create_alias event sent to PostHog has the distinct_id and alias swapped:

{
  "properties": {
    "distinct_id":  "old-id",
    "alias":  "keep-id"
  }
}  

According to the PostHog docs, the distinct_id should be the ID we want to keep as the primary user identifier, and alias should be the secondary ID we want to merge into the primary.

Solution

Update the transformer logic for the PostHog destination to correctly map:

  • user_id from the Rudderstack alias call to distinct_id
  • previous_id from the Rudderstack alias call to alias

After this change, the $create_alias event sent to PostHog for the example above should look like:

{
  "properties": {
    "distinct_id": "keep-id",
    "alias": "old-id"
  }
}

Developer checklist

  • [x] My code follows the style guidelines of this project

  • [x] No breaking changes are being introduced.

  • [x] All related docs linked with the PR?

  • [x] All changes manually tested?

  • [x] Any documentation changes needed with this change?

  • [x] Is the PR limited to 10 file changes?

  • [-] Is the PR limited to one linear task?

  • [-] Are relevant unit and component test-cases added in new readability format?

Reviewer checklist

  • [x] Is the type of change in the PR title appropriate as per the changes?

  • [x] Verified that there are no credentials or confidential data exposed with the changes.

mjeffrey18 avatar Jun 27 '24 11:06 mjeffrey18

Thank you for your contribution @mjeffrey18 Please sign the CLA. This is required for first-time contributors before merging a PR.

gitcommitshow avatar Jul 04 '24 18:07 gitcommitshow

This PR is considered to be stale. It has been open for 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR.

Thank you for your contribution @mjeffrey18 Please sign the CLA. This is required for first-time contributors before merging a PR.

@mjeffrey18 can you sign the above CLA form ?

krishna2020 avatar Jul 29 '24 06:07 krishna2020

Hi @mjeffrey18 , I see you didn't get a chance to sign the CLA. Let me know if you're facing any issues with this or have any question about it?

It shouldn't take more than a min, it is a quick online form that requires your confirmation. This is required before merging the code. This ensures your contributed code can be used according to the project's license.

gitcommitshow avatar Aug 15 '24 06:08 gitcommitshow

This PR is considered to be stale. It has been open for 20 days with no further activity thus it is going to be closed in 7 days. To avoid such a case please consider removing the stale label manually or add a comment to the PR.

@mjeffrey18 can you please sign the CLA so that we can go ahead

shrouti1507 avatar Sep 19 '24 06:09 shrouti1507

Hey guys, sorry for the delay. I tried to sign the CLA, but kept receipting a timeout. Screenshot 2024-09-22 at 11 43 41

mjeffrey18 avatar Sep 22 '24 07:09 mjeffrey18

Hi @mjeffrey18, sorry about that error. Don't worry about it. You have signed the CLA successfully at 2024-09-22T07:41:16.425Z.

@shrouti1507 you may go ahead with the review.

gitcommitshow avatar Sep 22 '24 11:09 gitcommitshow

@mjeffrey18 this PR's changes has been released to production now

gitcommitshow avatar Oct 04 '24 05:10 gitcommitshow