Home

Awesome

Hasura Segment Source

Docker Automated build GitHub

The easiest way to send Hasura Event Triggers to segment! Turbo charge your marketing, and analytics stacks!

Contents

Overview

This is a lightweight Go server that connects Hasura to Segment using Hasura's Event Triggers Feature. You can now easily your marketing and analytics stack using Segment whilst keeping your PostgreSQL DB as the single source of truth. The server exposes two endpoints on port 4004.

  1. POST /webhook - This is where Hasura needs to send the event triggers
  2. GET /health - Healthcheck

Configuration

Hasura Segment Source has a few configuration you need to setup.

Environment VariableRequiredDefaultDescription
SEGMENT_WRITE_API_KEYtruenullYour Segment Go Source write key.
USER_ID_FIELDfalseuser_idThe field container the user id. If this is incorrectly set or doesn't exist the user ID will be set to anonymous.

Deploying

Docker-compose

version: '3.6'
services:
  # PostgreSQL database
  postgres:
    image: mdillon/postgis
    restart: always
    ports:
      - '5432:5432'
    volumes:
      - pgdata:/var/lib/postgresql/data
    logging:
      driver: 'json-file'
      options:
        max-size: '100k'
        max-file: '2'

  # Hasura Graphql Server
  hasura:
    image: hasura/graphql-engine:v1.0.0
    ports:
      - '8080:8080'
    depends_on:
      - postgres
      - hasura-segment-source
    environment:
      HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
      HASURA_SEGMENT_SOURCE_WEBHOOK_URL: 'http://hasura-segment-source:4004/webhook'
    env_file:
      - hasura.env

  # Hasura Segment Source
  hasura-segment-source:
    image: aaronhayes/hasura-segment-source
    ports:
      - 4004:4004
    environemnt:
      - SEGMENT_WRITE_API_KEY: 'YOUR_SEGMENT_WRITE_KEY'
      - USER_ID_FIELD: 'user_id'

Zeit Now

Coming soon ...

Setting Up Segment

Follow this Segment's Guide to help find your SEGMENT_WRITE_API_KEY. You will need to choose the GoLang Server Source.

Setting Up Hasura

Follow Hasura's Offical Guide on creating an event trigger. Add the trigger to any insert/delete/update table you want to synced!

Roadmap