Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: posthog swapped alias ids #3507

Merged
merged 3 commits into from
Sep 27, 2024

Conversation

mjeffrey18
Copy link
Contributor

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

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • 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

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

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

@mjeffrey18 mjeffrey18 requested a review from a team as a code owner June 27, 2024 11:23
@gitcommitshow
Copy link
Contributor

gitcommitshow commented Jul 4, 2024

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

@devops-github-rudderstack
Copy link
Contributor

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.

@shrouti1507 shrouti1507 removed the Stale label Jul 29, 2024
@krishna2020
Copy link
Collaborator

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 ?

@gitcommitshow
Copy link
Contributor

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.

@devops-github-rudderstack
Copy link
Contributor

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.

@shrouti1507
Copy link
Contributor

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

@mjeffrey18
Copy link
Contributor Author

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

@gitcommitshow
Copy link
Contributor

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.

@koladilip koladilip changed the title [Posthog] fix swapped alias ids fix: posthog swapped alias ids Sep 23, 2024
Copy link
Contributor

@shrouti1507 shrouti1507 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mjeffrey18 can you edit the test cases as well? In files test/integrations/destinations/posthog/processor/data.ts and test/integrations/destinations/posthog/router/data.ts file. To confirm if the test cases are passing you can run npm run test:ts -- component --destination=posthog

@shrouti1507 shrouti1507 changed the base branch from develop to posthog-mapping September 27, 2024 07:20
@shrouti1507 shrouti1507 merged commit 757ac26 into rudderlabs:posthog-mapping Sep 27, 2024
12 of 21 checks passed
@shrouti1507 shrouti1507 mentioned this pull request Sep 27, 2024
10 tasks
utsabc pushed a commit that referenced this pull request Sep 30, 2024
* fix: posthog swapped alias ids (#3507)

[Posthog] fix swapped alias ids

Co-authored-by: shrouti1507 <[email protected]>

* fix: test case update for posthog

---------

Co-authored-by: Marc Jeffrey <[email protected]>
@gitcommitshow
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants