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

appsflyer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: MIT Imports: 8 Imported by: 0

README

appsflyer-go

A Go client library for the AppsFlyer Server-to-Server Events API

Installation

go get github.com/carpenterscode/appsflyer-go

Configuration

Set up the client with a JSON file of this format

[
  {
    "appId": "com.company.android",
    "devKey": "aaaaaaaaaaaaaaaaaaaaaa",
    "platform": "android"
  },
  {
    "appId": "id111111111",
    "bundleId": "com.company.ios",
    "devKey": "aaaaaaaaaaaaaaaaaaaaaa",
    "platform": "ios"
  }
]

Usage

import (
        "time"

        af "github.com/carpenterscode/appsflyer-go"
)

func main() {
        tracker, trackErr := af.NewTracker()
        if trackErr != nil {
                panic(trackErr)
        }
        tracker.SetConfig("appsflyer.json")

        startTrial(tracker)

        cancelSubscription(tracker)
}

func startTrial(tracker af.Tracker) {

        // User starts a trial
        evt := af.NewEvent("1111111111111-1111111", af.IOS)
        evt.SetName(af.StartTrial)
        evt.SetAdvertisingID("AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA")
        evt.SetBundleID("com.company.app")
        evt.SetDeviceIP("1.2.3.4")
        evt.SetRevenue(59.99, "USD")
        evt.SetDateValue("expiry", validDate)
        evt.SetEventTime(time.Now())

        if err := tracker.Send(evt); err != nil {
                panic(err)
        }
}

func cancelSubscription(tracker af.Tracker) {
        // User cancels a subscription
        evt := af.NewEvent("1111111111111-1111111", af.Android)
        evt.SetName(af.EventName("cancel_subscription"))
        evt.SetRevenue(-59.99, "USD")

        if err := tracker.Send(evt); err != nil {
                panic(err)
        }
}

Documentation

Official AppsFlyer docs

License

MIT

Documentation

Index

Constants

View Source
const (
	Android deviceOS = "android"
	IOS     deviceOS = "ios"
)

Variables

This section is empty.

Functions

func NewEvent

func NewEvent(appsFlyerID string, platform deviceOS) event

Types

type EventName

type EventName string
const (
	StartTrial EventName = "af_start_trial"
	Subscribe  EventName = "af_subscribe"
)

type EventParam

type EventParam string
const (
	ParamRevenue  EventParam = "af_revenue"
	ParamPrice    EventParam = "af_price"
	ParamCurrency EventParam = "af_currency"
)

type Tracker

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

func NewTracker

func NewTracker() (*Tracker, error)

func (Tracker) Send

func (t Tracker) Send(evt event) error

func (*Tracker) SetConfig

func (t *Tracker) SetConfig(configPath string) error

Jump to

Keyboard shortcuts

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