Skip to content

Commit 7617a5d

Browse files
committed
Update base.js
1 parent 65e08f2 commit 7617a5d

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

packages/script/src/base.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,32 @@
7575
// Initialize dubAnalytics
7676
if (window.dubAnalytics) {
7777
const original = window.dubAnalytics;
78+
const queue = original.q || [];
7879

79-
window.dubAnalytics = {
80-
q: original.q || [],
81-
ready(callback) {
82-
callback();
83-
},
84-
trackClick,
80+
// Create a callable function
81+
function dubAnalytics(method, ...args) {
82+
if (method === 'ready') {
83+
dubAnalytics.ready(...args);
84+
} else if (method === 'trackClick') {
85+
dubAnalytics.trackClick(...args);
86+
} else {
87+
console.warn('[dubAnalytics] Unknown method:', method);
88+
}
89+
}
90+
91+
// Attach properties and methods
92+
dubAnalytics.q = queue;
93+
94+
dubAnalytics.ready = function (callback) {
95+
callback();
8596
};
97+
98+
dubAnalytics.trackClick = function (...args) {
99+
trackClick(...args);
100+
};
101+
102+
// Replace window.dubAnalytics with the callable + augmented function
103+
window.dubAnalytics = dubAnalytics;
86104
}
87105

88106
// Cookie management

0 commit comments

Comments
 (0)