humbug

package
v0.0.0-...-2cd74a2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2023 License: Apache-2.0 Imports: 8 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var No map[string]bool = map[string]bool{
	"0":     false,
	"f":     false,
	"n":     false,
	"F":     false,
	"N":     false,
	"false": false,
	"no":    false,
	"False": false,
	"No":    false,
	"FALSE": false,
	"NO":    false,
}

A set of values indicating a "no"

View Source
var ShortCircuitVar string = "BUGGER_OFF"

Short circuit environment variable. Humbug will never report errors if BUGGER_OFF=true (or any) other value in the Yes set.

View Source
var Yes map[string]bool = map[string]bool{
	"1":    true,
	"t":    true,
	"y":    true,
	"T":    true,
	"Y":    true,
	"true": true,
	"yes":  true,
	"True": true,
	"Yes":  true,
	"TRUE": true,
	"YES":  true,
}

A set of values indicating a "yes"

Functions

func MergeTags

func MergeTags(tags0, tags1 []string) []string

Types

type Consent interface {
	Check() bool
}

Consent is the interface that Humbug uses to determine user consent to reporting.

type ConsentMechanism

type ConsentMechanism func() bool

ConsentMechanism is a report-independent means of checking user consent.

var False ConsentMechanism = func() bool { return false }

False is a consent mechanism that always indicates denied consent

var True ConsentMechanism = func() bool { return true }

True is a consent mechanism that always indicates granted consent

func EnvironmentVariableConsent

func EnvironmentVariableConsent(envVar string, valueConsentMap map[string]bool, whenUndefined bool) ConsentMechanism

Reads consent from the value of the given environment variable. The valueConsentMap specifies which values for the environment variable correspond to consent or lack thereof. If the environment variable is not defined, the whenUndefined parameter determines the default behavior.

type HumbugConsent

type HumbugConsent struct {
	Mechanisms []ConsentMechanism
}

HumbugConsent is a concrete implementation of the Consent interface. It each of a list of consent mechanisms in order until one of them denies consent or all of them grant consent. It also includes a system-wide short circuit mechanism that a user can use to turn off all Humbug reporting (regardless of the tool that is integrated with Humbug).

func CreateHumbugConsent

func CreateHumbugConsent(mechanisms ...ConsentMechanism) *HumbugConsent

func (*HumbugConsent) Check

func (consent *HumbugConsent) Check() bool

type HumbugReporter

type HumbugReporter struct {
	BaseURL string
	// contains filtered or unexported fields
}

func CreateHumbugReporter

func CreateHumbugReporter(consent Consent, clientID string, sessionID string, reporterToken string) (*HumbugReporter, error)

func (*HumbugReporter) Publish

func (reporter *HumbugReporter) Publish(report Report)

func (*HumbugReporter) PublishBulk

func (reporter *HumbugReporter) PublishBulk(reports []Report)

func (*HumbugReporter) SetBaseURL

func (reporter *HumbugReporter) SetBaseURL(baseURL string)

func (*HumbugReporter) Tag

func (reporter *HumbugReporter) Tag(key, modifier string)

func (*HumbugReporter) Tags

func (reporter *HumbugReporter) Tags() []string

func (*HumbugReporter) Untag

func (reporter *HumbugReporter) Untag(key, modifier string)

type Report

type Report struct {
	Title   string
	Tags    []string
	Content string
}

func PanicReport

func PanicReport(message interface{}) Report

func SystemReport

func SystemReport() Report

type Reporter

type Reporter interface {
	Tag(key string, modifier string)
	Untag(key string, modifier string)
	Tags() []string
	Publish(report Report) error
	PublishBulk(report Report) error
}

Jump to

Keyboard shortcuts

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