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

[PA-4600] feat(heap): update browser destination code to load heap js v5 script #19

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

cpsoinos
Copy link

@cpsoinos cpsoinos commented Jan 2, 2025

Summary

Update the Heap browser destination to use v5 of Heap's javascript snippet.

The Problem

Customers are running into issues with TikTok. We've seen that TT browser web views will strip duplicate key/value pairs on GET requests as an "optimization". Our request schema uses an arbitrary key for custom properties. For example, we'll have the query params: k=name1&k=false&k=name2&k=false&k=name3&k=true, but because of the way TT "optimizes", it will intercept the request before firing off and remove any duplicate query param values, leading to the request being fired having: k=name1&k=false&k=name2&k=name3&k=true, which ends up causing mismatched k/v pairing on the custom properties when we parse the request on the server-side.

The Solution

By upgrading to v5, we replace GET requests with POST so this fixes the issue.

Visuals

Segment dev center actions tester network tab

Hjsv5 being loaded and sending POST requests:
image

Heap live event view

Screenshot 2025-01-02 at 1 54 46 PM

Testing

Include any additional information about the testing you have completed to
ensure your changes behave as expected. For a speedy review, please check
any of the tasks you completed below during your testing.

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

@cpsoinos cpsoinos marked this pull request as ready for review January 2, 2025 19:07
@cpsoinos cpsoinos requested a review from jessi-heap January 2, 2025 19:07
await deps.loadScript(`https://${settings.hostname}/config/${settings.appId}/heap_config.js`)
} catch {
// fall back to loading from Heap's CDN if self-hosted script is not found
await deps.loadScript(`https://cdn.us.heap-api.com/config/${settings.appId}/heap_config.js`)

Choose a reason for hiding this comment

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

For security purposes (as in they are specifically avoiding pulling from our cdn if they are self-hosting), do we actually want to fallback on the cdn?

Copy link
Author

Choose a reason for hiding this comment

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

Good point. Removed the try/catch with the fallback

@cpsoinos cpsoinos requested a review from jessi-heap January 2, 2025 19:40
Copy link

@jessi-heap jessi-heap left a comment

Choose a reason for hiding this comment

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

lgtm - just two things to verify

  • should we fallback to heap cdn?
  • possibly check if there are any customers now that are using self hosting with this integration

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

Successfully merging this pull request may close these issues.

2 participants