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

feat(cdp): record httpCalls for destinations #29186

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

meikelmosby
Copy link
Contributor

@meikelmosby meikelmosby commented Feb 25, 2025

Problem

Just as we migrated the old JavaScript transformations running in VM2 to inlined JavaScript transformations, we want to apply the same approach to destinations. Given the challenges we encountered with transformations, we need to take a more structured approach. The key aspects of destinations are HTTP calls and their responses, so we need a solution that records outgoing HTTP requests and their corresponding responses. By comparing these, we can ensure confidence in the migration.

Changes

I've implemented an HTTP recorder that captures and logs HTTP requests and their responses during plugin execution. This enhancement focuses on recording HTTP calls made by plugins during event processing without modifying the existing fetch implementation.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Does this work well for both Cloud and self-hosted?

How did you test this code?

  • unit tests for the single components
  • TODO: test it out locally

@meikelmosby meikelmosby marked this pull request as ready for review February 26, 2025 08:18
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

Implemented HTTP call recording for destinations to support migration from VM2 to inlined JavaScript transformations, focusing on capturing request/response details for comparison.

  • Added recorded-fetch.ts utility that wraps trackedFetch to record HTTP requests and responses without altering functionality
  • Integrated recording in run.ts with conditional activation based on DESTINATION_MIGRATION_DIFFING_ENABLED flag
  • Created global HTTP call recorder in imports.ts with both direct and conditional recording functions
  • Added comprehensive test coverage in vm-recorded-fetch.test.ts and recorded-fetch.test.ts for various scenarios
  • Implemented proper cleanup to prevent memory leaks and detailed logging of request/response information

7 file(s) reviewed, 4 comment(s)
Edit PR Review Bot Settings | Greptile

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.

2 participants