Help us shape the future of Go! Take the 2026 Go Developer Survey

opdgo

package module
v0.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2024 License: MIT Imports: 6 Imported by: 0

README

opdgo

Go Report Card PkgGoDev

Golang client for OpenPanel.dev

Usage

Local client
package main

import (
    "log"
	
    "github.com/onrik/opdgo"
)

func main() {
    client := opdgo.New("<client_id>", "<client_secret>", nil)

    client.Track("purchase_completed", {
        "product_id": "123",
        "price": 99.99,
        "currency": "USD"
    })
}

Global client
package main

import (
    "log"
	
    "github.com/onrik/opdgo"
)

func main() {
    opdgo.Init(
        opdgo.New("<client_id>", "<client_secret>", nil),
    )

    opdgo.Track("purchase_completed", {
        "product_id": "123",
        "price": 99.99,
        "currency": "USD"
    })
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init added in v0.2.0

func Init(client *Client)

func Track added in v0.2.0

func Track(action string, properties map[string]any)

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func Global added in v0.2.0

func Global() *Client

func New

func New(clientID, clientSecret string, options Options) *Client

func (*Client) ClearGlobal

func (c *Client) ClearGlobal()

func (*Client) SetGlobal

func (c *Client) SetGlobal(properties map[string]any)

func (*Client) Track

func (c *Client) Track(action string, properties map[string]any)

type Logger

type Logger interface {
	Error(msg string, args ...any)
	Debug(msg string, args ...any)
}

type Options

type Options struct {
	Logger     Logger
	ApiURL     string
	HttpClient *http.Client
	Debug      bool
}

type Payload

type Payload struct {
	Name       string         `json:"name"`
	ProfileID  string         `json:"profile_id,omitempty"`
	Properties map[string]any `json:"properties"`
}

func (*Payload) Add

func (p *Payload) Add(properties map[string]any)

type Request

type Request struct {
	Type    string  `json:"type,omitempty"`
	Payload Payload `json:"payload,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL