
* add campaign store(getter, actions and mutations) * add campaign store module * add get campaigns api * add fetch campaign action widget load * add specs * code cleanup * trigger campaig api fixes * integrate campaign trigger action * code cleanup * revert changes * trigger api fixes * review fixes * code beautification * chore: Fix multiple campaigns being send because of race condition * chore: rubocop * chore: Fix specs * disable campaigns Co-authored-by: Nithin David Thomas <webofnithin@gmail.com> Co-authored-by: Sojan <sojan@pepalo.com>
14 lines
378 B
JavaScript
14 lines
378 B
JavaScript
import { triggerCampaign } from 'widget/api/campaign';
|
|
const startTimer = async ({ allCampaigns }) => {
|
|
allCampaigns.forEach(campaign => {
|
|
const {
|
|
trigger_rules: { time_on_page: timeOnPage },
|
|
id: campaignId,
|
|
} = campaign;
|
|
setTimeout(async () => {
|
|
await triggerCampaign({ campaignId });
|
|
}, timeOnPage * 1000);
|
|
});
|
|
};
|
|
|
|
export { startTimer };
|