Segment expects events to be reported for a specific user. Consequently, this integration only supports events from Stigg that are reported on customers.
Segment expects events to be reported on a specific user. In order to support this flow, we’ll need to map Stigg’s webhook payload to a Segment.track()event using a Segment’s source function.In Segment:
From your workspace, go to the Catalog and click the Functions tab.
Click “New Function”.
Select “Source Function” and click “Build” - when you click “Build”, a code editor appears.
Paste the below snippet.
Click “Configure” to name the source function.
Click “Create Function” to save it - once you do that, the source function appears on the Functions page in your workspace’s catalog.
Copy
Ask AI
// Learn more about source functions API at// https://segment.com/docs/connections/sources/source-functions/** * Handle incoming HTTP request * * @param {FunctionRequest} request * @param {FunctionSettings} settings */async function onRequest(request, settings) { const body = request.json(); // filter out events that are not reported on a customer if (!body.customer || !body.customer.id) { return; } // See https://segment.com/docs/connections/spec/track/ Segment.track({ event: body.type.split('.').join('_'), userId: body.customer.id, properties: body });}
Click on the row of the newly created webhook from the webhook list screen in order to view the webhook details.
Under the “Webhook events” section, click on the dotted menu icon of the relevant event that you’d like to test, and select the “Send test event” action.