From 2fb2f7cb87dbe8b31fdae509dfc900283b6e74de Mon Sep 17 00:00:00 2001 From: Yusuf Umac Date: Thu, 26 May 2022 20:31:12 +0300 Subject: [PATCH] feat: option to exclude specific events --- index.js | 5 +++++ plugin.json | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/index.js b/index.js index 205d91b..fdb86e9 100644 --- a/index.js +++ b/index.js @@ -29,6 +29,7 @@ export async function setupPlugin({ config, global }) { try { const eventNames = config.eventsToSend ? config.eventsToSend.split(',').filter(Boolean) : [] + const excludedEventNames = config.eventsToExclude ? config.eventsToExclude.split(',').filter(Boolean) : []; global.buffer = createBuffer({ limit: (1 / 5) * 1024 * 1024, // 200kb @@ -40,6 +41,10 @@ export async function setupPlugin({ config, global }) { continue } + if (excludedEventNames.length > 0 && excludedEventNames.includes(event.event)) { + continue; + } + try { await exportToCustomerio(event, global.customerioAuthHeader, config) } catch (error) { diff --git a/plugin.json b/plugin.json index bd7866d..25d7754 100644 --- a/plugin.json +++ b/plugin.json @@ -29,6 +29,12 @@ "type": "string", "hint": "Comma separated list of events to include if specified" }, + { + "key": "eventsToExclude", + "name": "List of events to be excluded from sending to Customer.io", + "type": "string", + "hint": "Comma separated list of events to exclude if specified" + }, { "key": "sendEventsFromAnonymousUsers", "name": "Send events from anonymous users to Customer.io",