Files
stats/packages/sdks/web/src/tracker.ts
Carl-Gerhard Lindesvärd 03cee826ff update docs
2024-08-09 23:00:38 +02:00

28 lines
649 B
TypeScript

import { OpenPanel } from './index';
((window) => {
if (window.op && 'q' in window.op) {
const queue = window.op.q || [];
// @ts-expect-error
const op = new OpenPanel(queue.shift()[1]);
queue.forEach((item) => {
if (item[0] in op) {
// @ts-expect-error
op[item[0]](...item.slice(1));
}
});
window.op = (t, ...args) => {
const fn = op[t] ? op[t].bind(op) : undefined;
if (typeof fn === 'function') {
// @ts-expect-error
fn(...args);
} else {
console.warn(`OpenPanel: ${t} is not a function`);
}
};
window.openpanel = op;
}
})(window);