snowplow / enrich

Snowplow Enrichment jobs and library
https://snowplowanalytics.com
Other
21 stars 39 forks source link

Allow passing an object of parameters to the JS enrichment #871

Closed stanch closed 8 months ago

stanch commented 9 months ago

In #868, we add support for multiple JavaScript enrichments. This allows to implement new enrichments in JavaScript and easily add them to Enrich. However, most enrichments take parameters. So as it stands, people using these new JavaScript enrichments would need to modify the script itself every time they need to change parameters. This is very inconvenient, and prevents us from (in the future) hosting the script separately. The solution is to allow passing these parameters in the enrichment configuration, so instead of

{
  ...
  "script": "....." // base64-encoded
  ...
}

we would have:

{
  ...
  "script": ".....", // base64-encoded
  "config": {
    // arbitrary JSON that the enrichment code can consume
  }
  ...
}

This will also help in case we need to deal with secrets inside JavaScript code. (Currently, secrets can’t be substituted because the script code is in base64.)