multisource

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// SourcePropertyKey is the event property used to identify the analytics source (e.g. ios, web).
	// For PostHog, where a single API key is shared across sources, this property distinguishes events.
	SourcePropertyKey = "source"
)

Variables

View Source
var (
	// Providers are what we provide to dependency injection.
	Providers = wire.NewSet(
		ProvideMultiSourceEventReporter,
	)
)

Functions

func RegisterMultiSourceEventReporter

func RegisterMultiSourceEventReporter(i do.Injector)

RegisterMultiSourceEventReporter registers a *MultiSourceEventReporter with the injector. Prerequisite: map[string]*analyticscfg.SourceConfig must be registered in the injector.

Types

type MultiSourceEventReporter

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

MultiSourceEventReporter delegates events to per-source EventReporters.

func NewMultiSourceEventReporter

func NewMultiSourceEventReporter(
	reporters map[string]analytics.EventReporter,
	logger logging.Logger,
	tracerProvider tracing.TracerProvider,
) *MultiSourceEventReporter

NewMultiSourceEventReporter returns a new MultiSourceEventReporter.

func ProvideMultiSourceEventReporter

func ProvideMultiSourceEventReporter(
	ctx context.Context,
	proxySources map[string]*analyticscfg.SourceConfig,
	logger logging.Logger,
	tracerProvider tracing.TracerProvider,
	metricsProvider metrics.Provider,
) (*MultiSourceEventReporter, error)

ProvideMultiSourceEventReporter builds a MultiSourceEventReporter from proxy sources config. For each source, attempts to create an EventReporter via ProvideCollector. If creation fails (e.g. missing credentials) or provider is unset, uses Noop for that source.

For PostHog: a single API key is shared across all sources. One PostHog client is created and reused for every PostHog source; the source name is logged as a property on each event.

func (*MultiSourceEventReporter) TrackAnonymousEvent

func (m *MultiSourceEventReporter) TrackAnonymousEvent(ctx context.Context, source, event, anonymousID string, properties map[string]any) error

TrackAnonymousEvent records an event for an anonymous user.

func (*MultiSourceEventReporter) TrackEvent

func (m *MultiSourceEventReporter) TrackEvent(ctx context.Context, source, event, userID string, properties map[string]any) error

TrackEvent records an event for an identified user.

Jump to

Keyboard shortcuts

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