3 comments

[ 4.0 ms ] story [ 14.8 ms ] thread
Engineer on the Segment Functions product here. Happy to discuss any questions about how it works and how we built it.
Are you using AWS Lambda to provide the sandboxing? If so:

How does the user code actually end up running on the Lambda? Do you have a generic wrapper Lambda which `eval`s the user code, or do you deploy an individual Lambda for each function, etc?

Yes we are using Lambda under the hood.

Every customer's custom source or destination is its own Lambda function. This gives us a ton of fine-grained isolation, scalability and visibility out of the box.

We ask customers to implement a single function that converts an incoming webhook to Segment data points:

  async function onRequest(request, settings) {
    Segment.track(...)
  }
Inside the function we save the users code to `handler.js` and inject index.js that loads and calls the users `onRequest` function.