Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/areahq/go-heapanalytics

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/areahq/go-heapanalytics

  • v0.0.0-20160520170812-9bb71a3bec91
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-heapanalytics

Codeship Status for AreaHQ/go-heapanalytics

Provides a simple adapter for using the heap analytics API. See the heap documentation for information on the API covered.

Go Docs

Area

Client options

There are a number of client options that can be set.

The pattern used here is based on Dave Cheneys blog post

It's nice and clean as nil or blank values do not need to be passed in where default values are needed.

Some predefined options have been setup as listed below.

URL

source

Allows you to customise the client base url used by the adapter.

HttpClient

source, example

Allows you to customise the http client used by the adapter.

Examples

Below is example code for using the adapter.

Track using default parameters:

package main

import (
	"fmt"

	"github.com/AreaHQ/go-heapanalytics"
)

func main() {
	// test id used in documentation
	appID := "11"

	c := heapanalytics.NewClient(appID)

	identity := "my@identifier.net"
	event := "test_event"
	properties := map[string]interface{}{"test_prop": "test_val"}

	err := c.Track(identity, event, properties)
	if err != nil {
		fmt.Printf("Error sending track: %s", err.Error())
	} else {
		fmt.Println("Event sent.")
	}
}

Track with HttpClient Option:

package main

import (
	"fmt"
	"net/http"

	"github.com/AreaHQ/go-heapanalytics"
)

func main() {
	// test id used in documentation
	appID := "11"

	// this may be a custom client that you're reusing
	httpClient := http.DefaultClient

	c := heapanalytics.NewClient(appID, heapanalytics.HttpClient(httpClient))

	identity := "my@identifier.net"
	event := "test_event"
	properties := map[string]interface{}{"test_prop": "test_val"}

	err := c.Track(identity, event, properties)
	if err != nil {
		fmt.Printf("Error sending track: %s", err.Error())
	} else {
		fmt.Println("Event sent.")
	}
}

Add user properties using default parameters

package main

import (
	"fmt"
	"net/http"

	"github.com/AreaHQ/go-heapanalytics"
)

func main() {
	// test id used in documentation
	appID := "11"

	// this may be a custom client that you're reusing
	httpClient := http.DefaultClient

	c := heapanalytics.NewClient(appID, heapanalytics.HttpClient(httpClient))

	identity := "my@identifier.net"
	properties := map[string]interface{}{"test_prop": "test_val"}

	err := c.AddUserProperties(identity, properties)
	if err != nil {
		fmt.Printf("Error sending track: %s", err.Error())
	} else {
		fmt.Println("User properties sent.")
	}
}

FAQs

Package last updated on 20 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc