Skip to content

uchennaemeruche/go-logsnag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Logsnag's Golang implementation

Get notifications and track your project events. Please refer to the docs to learn more.

Test Package

Installation

go get github.com/uchennaemeruche/go-logsnag

Usage

Import Package

    logsnag "github.com/uchennaemeruche/go-logsnag"

Initialize Client

    l := logsnag.NewLogsnag(projectName, &logsnag.APIClient{Token: apiToken})

Publish Event

   	result, err := l.Publish(
		"user-create",
		"Uchenna created a new account",
		logsnag.IPublishPayloadOptions{
			Icon: "🎉",
			Tags: map[string]interface{}{
				"name":  "john doe",
				"email": "johndoe@example.com",
			},
			Description: "A new user has been created",
			Notify:      true,
		},
	)

Create Insight

   insights, err := l.Insight("user-create", "New Account", logsnag.InsightPayloadOptions{Icon: "👨"})

Example Implementation

package main

import (
	"fmt"
	logsnag "github.com/uchennaemeruche/go-logsnag"
)

func main() {
	apiToken := "<YOUR_API_TOKEN>"
	projectName := "<your_project_name_>"

	l := logsnag.NewLogsnag(projectName, &logsnag.APIClient{Token: apiToken})

    // Publish an event
	result, err := l.Publish(
		"waitlist",
		"User Joined",
		logsnag.IPublishPayloadOptions{
			Icon: "🎉",
			Tags: map[string]interface{}{
				"name":  "john doe",
				"email": "johndoe@example.com",
			},
			Description: "A new user has joined the waitlist",
			Notify:      true,
		},
	)
    if err != nil {
		fmt.Println(err)
	}
	fmt.Sprintln("event published:  %/s", result)

    // Create insight
	insights, err := l.Insight("User Count", "100", logsnag.InsightPayloadOptions{Icon: "👨"})
	if err != nil {
		fmt.Println(err)
	}
	fmt.Sprintln("Insights:  %/s", insights)

	fmt.Println(resp)
}

NOTE Check the cmd directory to see the sample implementation code.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages