Skip to content

journifyio/journify-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Journify SDK for Go

Installation

go get github.com/journifyio/journify-go

Documentation

You can find more detailed documentation at the following link: https://docs.journify.io/sources/go.

Usage

package main

import (
    "os"
	"fmt"

    "github.com/journifyio/journify-go"
)

func main() {
    // Instantiates a client to use send messages to the Journify API.
    client, err := journify.NewWithConfig(os.Getenv("JOURNIFY_WRITE_KEY"), journify.Config{
		BatchSize: 1,
	})
	
	if err != nil {
		fmt.Println("could not initialize journify client", err)
		os.Exit(1)
    }
	
    defer client.Close()
	
    _ = client.Enqueue(journify.Identify{
        UserId: "test-user-12345",
        Traits: map[string]any{
            "email": "[email protected]",
            "firstname": "Joe",
            "lastname": "Doe",
        },
    })
	
    _ = client.Enqueue(journify.Track{
        UserId: "test-user-12345",
        Event:  "test-snippet",
    })

    _ = client.Enqueue(journify.Group{
        UserId: "test-user-12345",
        GroupId: "test-group-12345",
        Traits:  map[string]any{
            "name":        "Initech",
            "description": "Accounting Software",
        },
    })

    _ = client.Enqueue(journify.Page{
        UserId:     "test-user-12345",
        Name:       "Home page",
        Properties: journify.NewProperties().
            SetURL("https://journify.io"),
    })
}

License

The library is released under the MIT license.