IE tracker fix
parent
580e74d842
commit
233ef6ed25
|
@ -0,0 +1,70 @@
|
||||||
|
//Polyfill for HTMLCollection.forEach and NodeList.forEach
|
||||||
|
if ('NodeList' in window && !NodeList.prototype.forEach) {
|
||||||
|
NodeList.prototype.forEach = function (callback, thisArg) {
|
||||||
|
thisArg = thisArg || window;
|
||||||
|
for (var i = 0; i < this.length; i++) {
|
||||||
|
callback.call(thisArg, this[i], i, this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if ('HTMLCollection' in window && !HTMLCollection.prototype.forEach) {
|
||||||
|
HTMLCollection.prototype.forEach = function (callback, thisArg) {
|
||||||
|
thisArg = thisArg || window;
|
||||||
|
for (var i = 0; i < this.length; i++) {
|
||||||
|
callback.call(thisArg, this[i], i, this);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//Polyfill fo URL
|
||||||
|
|
||||||
|
if (typeof window.URL !== 'function') {
|
||||||
|
window.URL = function (url) {
|
||||||
|
let protocol = url.split('//')[0],
|
||||||
|
comps = url
|
||||||
|
.split('#')[0]
|
||||||
|
.replace(/^(https:\/\/|http:\/\/)|(\/)$/g, '')
|
||||||
|
.split('/'),
|
||||||
|
host = comps[0],
|
||||||
|
search = comps[comps.length - 1].split('?')[1],
|
||||||
|
tmp = host.split(':'),
|
||||||
|
port = tmp[1],
|
||||||
|
hostname = tmp[0];
|
||||||
|
|
||||||
|
search = typeof search !== 'undefined' ? '?' + search : '';
|
||||||
|
|
||||||
|
const params = search
|
||||||
|
.slice(1)
|
||||||
|
.split('&')
|
||||||
|
.map(p => p.split('='))
|
||||||
|
.reduce((obj, pair) => {
|
||||||
|
const [key, value] = pair.map(decodeURIComponent);
|
||||||
|
return { ...obj, [key]: value };
|
||||||
|
}, {});
|
||||||
|
|
||||||
|
return {
|
||||||
|
hash: url.indexOf('#') > -1 ? url.substring(url.indexOf('#')) : '',
|
||||||
|
protocol,
|
||||||
|
host,
|
||||||
|
hostname,
|
||||||
|
href: url,
|
||||||
|
pathname:
|
||||||
|
'/' +
|
||||||
|
comps
|
||||||
|
.splice(1)
|
||||||
|
.map(function (o) {
|
||||||
|
return /\?/.test(o) ? o.split('?')[0] : o;
|
||||||
|
})
|
||||||
|
.join('/'),
|
||||||
|
search,
|
||||||
|
origin: protocol + '//' + host,
|
||||||
|
port: typeof port !== 'undefined' ? port : '',
|
||||||
|
searchParams: {
|
||||||
|
get: p => (p in params ? params[p] : ''),
|
||||||
|
getAll: () => params,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/* Polyfill IE 11 end */
|
File diff suppressed because it is too large
Load Diff
|
@ -96,9 +96,14 @@
|
||||||
"uuid": "^8.3.1"
|
"uuid": "^8.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.12.3",
|
||||||
|
"@babel/plugin-transform-runtime": "^7.12.1",
|
||||||
|
"@babel/preset-env": "^7.12.1",
|
||||||
"@formatjs/cli": "^2.13.5",
|
"@formatjs/cli": "^2.13.5",
|
||||||
"@prisma/cli": "2.10.1",
|
"@prisma/cli": "2.10.1",
|
||||||
|
"@rollup/plugin-babel": "^5.2.1",
|
||||||
"@rollup/plugin-buble": "^0.21.3",
|
"@rollup/plugin-buble": "^0.21.3",
|
||||||
|
"@rollup/plugin-commonjs": "^16.0.0",
|
||||||
"@rollup/plugin-node-resolve": "^10.0.0",
|
"@rollup/plugin-node-resolve": "^10.0.0",
|
||||||
"@rollup/plugin-replace": "^2.3.4",
|
"@rollup/plugin-replace": "^2.3.4",
|
||||||
"@svgr/webpack": "^5.4.0",
|
"@svgr/webpack": "^5.4.0",
|
||||||
|
|
|
@ -1,13 +1,31 @@
|
||||||
import 'dotenv/config';
|
import 'dotenv/config';
|
||||||
|
import babel, { getBabelOutputPlugin } from '@rollup/plugin-babel';
|
||||||
import buble from '@rollup/plugin-buble';
|
import buble from '@rollup/plugin-buble';
|
||||||
import resolve from '@rollup/plugin-node-resolve';
|
import resolve from '@rollup/plugin-node-resolve';
|
||||||
import { terser } from 'rollup-plugin-terser';
|
import { terser } from 'rollup-plugin-terser';
|
||||||
|
import commonjs from '@rollup/plugin-commonjs';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
input: 'tracker/index.js',
|
input: 'tracker/index.js',
|
||||||
output: {
|
output: {
|
||||||
file: 'public/umami.js',
|
file: 'public/umami.js',
|
||||||
format: 'iife',
|
format: 'cjs',
|
||||||
|
plugins: [
|
||||||
|
getBabelOutputPlugin({
|
||||||
|
presets: ['@babel/preset-env'],
|
||||||
|
plugins: [['@babel/plugin-transform-runtime', { useESModules: true }]],
|
||||||
|
}),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
plugins: [resolve(), buble({ objectAssign: true }), terser({ compress: { evaluate: false } })],
|
plugins: [
|
||||||
|
resolve(),
|
||||||
|
commonjs(),
|
||||||
|
babel({
|
||||||
|
babelHelpers: 'bundled',
|
||||||
|
presets: ['@babel/preset-env'],
|
||||||
|
}),
|
||||||
|
|
||||||
|
buble({ objectAssign: true, target: { ie: 9 } }),
|
||||||
|
terser({ compress: { evaluate: false } }),
|
||||||
|
],
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import '../lib/ie';
|
||||||
import { doNotTrack, hook } from '../lib/web';
|
import { doNotTrack, hook } from '../lib/web';
|
||||||
import { removeTrailingSlash } from '../lib/url';
|
import { removeTrailingSlash } from '../lib/url';
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue