Stateful Data Flow Beta Build composable event-driven data pipelines in minutes.

Get Started Now

Amplitude Analytics

With this guide, you can send events from InfinyOn Cloud to Amplitude. Connecting your services to this dataflow 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": "[email protected]",
    "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

# amplitude-connector.yaml
apiVersion: 0.1.0
meta:
  version: 0.2.5
  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/[email protected]
    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":"[email protected]","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.