Skip to main content
Version: 0.13.0

DataPipeline to Amplitude

With this guide, you can send events from InfinyOn Cloud to Amplitude. Connecting your services to this pipeline is simpler than microservices running around

To follow along in this guide you need:

Setup

Create secret

You can follow Amplitude's instructions for how to collect your api token so you can create a secret the connector can use when building the json request for Amplitude.

The Amplitude upload requests requires an api token, and all events for the production environment use the same api token. We'll transform the service event to include this value in the next step.

$ fluvio cloud secret set AMPLITUDE_API_TOKEN <api-token>
Secret "AMPLITUDE_API_TOKEN" set successfully

Create connector

Example event:

{
  "timestamp": "2023-09-06T12:02:29.658014825Z",
  "event": {
    "user_id": "user@example.com",
    "event_type": "ServiceAbcExampleEvent",
    "time": 1696629748241,
    "app_version": "c738ca3",
    "event_id": 5,
    "session_id": 9876645851321,
    "insert_id": "d768b1b3-1055-4db8-b214-619b5a321ef5"
  }
}

In this example, each service sends a json object to a topic containing a timestamp for when the event occurred and an Amplitude event object.

Before sending to Amplitude with an HTTP outbound connector, we'll transform the original payload into the Amplitude upload request json.

The transform consists of:

  • Removing the timestamp key
  • Adding the api_key key with the value from our AMPLITUDE_API_TOKEN secret
  • Shift the contents of the event key into an array with the key events

Example connector config w/ transforms

info

All versions are marked with x.y.z. To find the latest version, run:

  • fluvio hub connector list
  • fluvio hub smartmodule list
# amplitude-connector.yaml
apiVersion: 0.1.0
meta:
  version: x.y.z
  name: amplitude-connector
  type: http-sink
  topic: service-events
  secrets:
    - name: AMPLITUDE_API_TOKEN
http:
  endpoint: "https://api2.amplitude.com/2/httpapi"
transforms:
  - uses: infinyon/jolt@x.y.z
    with:
      spec:
        - operation: remove
          spec:
            timestamp: ""
        - operation: shift
          spec:
            "event": "events[0]"
        - operation: default
          spec:
            api_key: "${{ secrets.AMPLITUDE_API_TOKEN }}"

Save the config and run the following command to create the connector.

$ fluvio cloud connector create -c amplitude-connector.yaml
connector "amplitude-connector" (http-sink) created

Send a test event to topic

The following command will send an example event to the topic our connector is watching.

$ echo '{"timestamp":"2023-09-06T12:02:29.658014825Z","event":{"user_id":"user@example.com","event_type":"ServiceAbcExampleEvent"}}' | fluvio produce service-events

Look at Amplitude for your event

In the Amplitude dashboard, you should be able to verify the test event arrive under User Look-up

This is the end of the guide. Once you instrument your services, you should be able to quickly send analytics events to Amplitude from InfinyOn Cloud.