initial for v1
This commit is contained in:
committed by
Carl-Gerhard Lindesvärd
parent
c770634e73
commit
15e997129a
27
packages/sdks/web/src/tracker.ts
Normal file
27
packages/sdks/web/src/tracker.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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(`op.js: ${t} is not a function`);
|
||||
}
|
||||
};
|
||||
|
||||
window.openpanel = op;
|
||||
}
|
||||
})(window);
|
||||
Reference in New Issue
Block a user