Hi guys,
Quick question here, im trying to create two JS enrichments, each one of them returns a different payload.
Problem is that is only using one single enrichment.
This is the config:
{
“schema”: “iglu:com.snowplowanalytics.snowplow/javascript_script_config/jsonschema/1-0-0”,
“data”: {
“vendor”: “com.snowplowanalytics.snowplow”,
“name”: “javascript_script_config”,
“enabled”: true,
“parameters”: {
“script”: “BASE64 (Didnt wanted to put the whole code here)”
}
}
}
I thought about renaming the name, but from what i got is mandatory to have the same.
code:
var regex_counter = [{“pattern”: “[^a]fish”}];
function process(event) {
var user_agent = event.getUseragent();
for (const element of regex_counter) {
var regex = new RegExp(element.pattern);
if (regex.test(user_agent)) {
return [{ schema: “iglu:com.company/counter_4/jsonschema/1-0-0”,
data: { counter4Bot: true, counter4BotName: element.pattern } }];
}
}
return [{ schema: “iglu:com.company/counter_4/jsonschema/1-0-0”,
data: { counter4Bot: false, counter4BotName: null } }];
}
Thank you!