Skip to content

Commit

Permalink
update runStoreWatcher logic
Browse files Browse the repository at this point in the history
  • Loading branch information
woophi committed Feb 2, 2024
1 parent eebfe60 commit dc5a47f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@sensearena/ui",
"version": "0.2.62",
"version": "0.2.63",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
Expand Down
15 changes: 5 additions & 10 deletions src/utils/sendExponeaEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@ declare global {
}
}

let exponeaEventsStore: Record<string, Record<string, any>> = {};

const runStoreWatcher = () => {
const runStoreWatcher = (exponeaEventsStore: Record<string, Record<string, any>>) => {
const timer = setInterval(() => {
if (window.exponea) {
console.debug('runStoreWatcher when BR is ready', exponeaEventsStore);
Expand All @@ -24,8 +22,6 @@ const runStoreWatcher = () => {

window.exponea.track(eventName, exponeaEventsStore[eventName]);
});

exponeaEventsStore = {};
clearInterval(timer);
}
}, 1000);
Expand All @@ -34,11 +30,10 @@ const runStoreWatcher = () => {
export const sendExponeaEvent = (eventName: string, eventData: Record<string, any>, email?: string) => {
if (!window.exponea) {
console.debug('[SA]: skip event, BR not inited', eventName);
exponeaEventsStore = {
...exponeaEventsStore,
eventName: eventData,
};
runStoreWatcher();

runStoreWatcher({
[eventName]: eventData,
});
return;
}
withIdentify(() => {
Expand Down

0 comments on commit dc5a47f

Please sign in to comment.