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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions integrations/heap/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
==================
2.2.0 / 2023-02-13

* Allow overriding heap loading snippet
* Allow configuring heap options

2.1.1 / 2018-07-06
==================
Expand Down
6 changes: 4 additions & 2 deletions integrations/heap/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.

.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.

.tag('<script src="//{{ hostname }}/js/heap-{{ appId }}.js">'));

/**
* Initialize.
Expand Down Expand Up @@ -61,7 +63,7 @@ Heap.prototype.initialize = function() {
});
};

window.heap.load(this.options.appId);
window.heap.load(this.options.appId, this.options.options);
this.load(this.ready);
};

Expand Down
2 changes: 1 addition & 1 deletion integrations/heap/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-integration-heap",
"description": "The Heap analytics.js integration.",
"version": "2.1.2",
"version": "2.2.0",
"keywords": [
"analytics.js",
"analytics.js-integration",
Expand Down