22 lines
1.1 KiB
JavaScript
22 lines
1.1 KiB
JavaScript
/*jshint node:true*/
|
|
module.exports = {
|
|
name: 'heap-analytics',
|
|
|
|
isDevelopingAddon: function() {
|
|
return true;
|
|
},
|
|
|
|
contentFor: function(type, config) {
|
|
var addonConfig = config['heap-analytics'];
|
|
|
|
if (type === 'head-footer' && addonConfig && addonConfig.key) {
|
|
return [
|
|
'<script type="text/javascript">',
|
|
'window.heap=window.heap||[],heap.load=function(e,t){window.heap.appid=e,window.heap.config=t=t||{};var r=t.forceSSL||"https:"===document.location.protocol,a=document.createElement("script");a.type="text/javascript",a.async=!0,a.src=(r?"https:":"http:")+"//cdn.heapanalytics.com/js/heap-"+e+".js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(a,n);for(var o=function(e){return function(){heap.push([e].concat(Array.prototype.slice.call(arguments,0)))}},p=["addEventProperties","addUserProperties","clearEventProperties","identify","removeEventProperty","setEventProperties","track","unsetEventProperty"],c=0;c<p.length;c++)heap[p[c]]=o(p[c])};',
|
|
'heap.load("' + addonConfig.key + '");',
|
|
'</script>',
|
|
].join('\n');
|
|
}
|
|
},
|
|
};
|