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

Allow configuring heap integration settings #734

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

Conversation

mwudka
Copy link

@mwudka mwudka commented Feb 14, 2023

What does this PR do?
The current heap integration has two limitations which are proving challenging for our segment deployment:

  • the snippet is loaded from a hardcoded URL, so we can't configure it to load the heap JS from our CDN
  • there is no way to specify any heap configuration options, so we can't control the options like secureCookie or disableTextCapture.

This PR adds additional configuration options to the heap integration to support changing both.

Are there breaking changes in this PR?
No.

Testing
I used the (very slick and excellent) local runner to test manually. I didn't see an easy way to add any tests, since it's hard to mock the underlying heap object. I'm also not sure the tests would be hugely valuable, since they would essentially be asserting that the code exists as written rather than really testing behavior. I am open to suggestions about a better way to handle this!

Any background context you want to provide?
No

Is there parity with the server-side/android/iOS integration components (if applicable)?
N/A

Does this require a new integration setting? If so, please explain how the new setting works
This change introduces two new optional settings:

  1. hostname (string): Allows changing the URL from which the heap snippet is loaded. It defaults to "cdn.heapanalytics.com", the current hard-coded value, to preserve backwards compatibility.
  2. options (object): Allows passing an arbitrary set of configuration options to heap. They are passed to the heap JS code as is. Defaults to {} to preserve backwards compatibility.

Links to helpful docs and other external resources

Heap JS options

The heap integration previously did not allow configuring the CDN that serves
the heap snippet or passing any heap options. This change introduces new
options to allow configuring both.
@@ -21,7 +21,9 @@ var toString = Object.prototype.toString; // in case this method has been overri
var Heap = (module.exports = integration('Heap')
.global('heap')
.option('appId', '')
.tag('<script src="//cdn.heapanalytics.com/js/heap-{{ appId }}.js">'));
.option('hostname', 'cdn.heapanalytics.com')
Copy link
Author

Choose a reason for hiding this comment

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

There seems to be some variation in how different integrations name this sort of parameter, so I wasn't sure of the best name. I'm happy to change to something else.

@@ -21,7 +21,9 @@ var toString = Object.prototype.toString; // in case this method has been overri
var Heap = (module.exports = integration('Heap')
.global('heap')
.option('appId', '')
.tag('<script src="//cdn.heapanalytics.com/js/heap-{{ appId }}.js">'));
.option('hostname', 'cdn.heapanalytics.com')
.option('options', {})
Copy link
Author

Choose a reason for hiding this comment

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

The heap JS docs list some of the options, but there are additional options which are not documented. That leads me to believe that it might be best to just provide a single options object, since the allowed options might be account-specific and it might be confusing to provide some configuration options here that aren't available to all accounts. However, I'm happy to split this out into specific configuration options.

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.

1 participant