Reputation: 2516
I want one variable name to be kept after my code is minified. Not sure if this matters, but it also has to survive TypeScript being compiled to minified JavaScript.
Details:
ng build --prod
all my TypeScript is converted to a single minified JavaScript file.Here's the related info from the mouseflow knowledge base:
If you add the
mouseflowPath
variable and set it tovar mouseflowPath = '/shop/products/productdetail;'
on these pages, Mouseflow will treat all of these pages as one unique page and only generate one heatmap under the URL'/shop/products/productdetail'
.<script type="text/javascript"> window._mfq = window._mfq || []; // *** THIS NEEDS TO STAY *** var mouseflowPath = '/shop/products/productdetail'; (function() { var mf = document.createElement("script"); mf.type = "text/javascript"; mf.async = true; mf.src = "//cdn.mouseflow.com/projects/your-website-id.js"; document.getElementsByTagName("head")[0].appendChild(mf); })(); </script>
The only clear solution that comes to mind is forcing the mouseflowPath
variable to hold its original name through minification.
Upvotes: 3
Views: 1940
Reputation: 14185
Rather than this:
var mouseflowPath = '/your/new/path';
use this:
window['mouseflowPath'] = '/your/new/path';
Both results are precisely the same. Using property accessor syntax above will allow the string, and your global reference, to be preserved.
Upvotes: 5