alias

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package alias joins anonymous pre-login activity to the logged-in user — identity stitching. The SDK sends the anonymous id as a breadcrumb on identify(); we record anon→canonical here, and a Store decorator rewrites ids at read time so funnels, retention, and journeys survive the login boundary. GDPR erasure fans out across a user's aliases, so "delete user u123" also erases their pre-login trail.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RecordFrom added in v0.9.0

func RecordFrom(a *Map, e event.Event)

RecordFrom records an identity edge from an identity event, so the HTTP ingest path and the import path stitch the same way and can never drift. It understands both conventions PostHog (and our own SDK) emit:

  • $identify: the logged-in event carries the visitor's prior anonymous id in $anon_distinct_id → Add(anon, user).
  • $create_alias: merges a second id into the person, carried in the alias property → Add(alias, user). PostHog uses this for its own person merges, so importing a PostHog export with these events reconstructs its stitched identities instead of splitting one human into two "users" (which silently corrupts retention/funnels).

Any other event is ignored. A nil map is a no-op so callers needn't guard.

Types

type Map

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

func Open

func Open(p string) (*Map, error)

func (*Map) Add

func (a *Map) Add(anon, canonical string) error

Add records anon→canonical. Guards: the shared cookieless sentinel, empty ids, self-aliases, and canonical ids that are themselves aliased (one hop only — a chain would make resolution order-dependent).

func (*Map) AliasesOf

func (a *Map) AliasesOf(canonical string) []string

AliasesOf returns every id that resolves to canonical (excluding itself).

func (*Map) Clear

func (a *Map) Clear() error

func (*Map) Forget

func (a *Map) Forget(id string) error

Forget removes every alias touching id (called after erasure).

func (*Map) Resolve

func (a *Map) Resolve(id string) string

Resolve returns the canonical id for any id (identity for unaliased ids).

type Store

type Store struct {
	store.Store
	// contains filtered or unexported fields
}

Store decorates a store.Store with read-time canonicalization: every event comes back under its canonical id, so the engine computes joined journeys without the storage layer knowing aliases exist.

func Wrap

func Wrap(s store.Store, a *Map) *Store

func (*Store) Clear

func (s *Store) Clear() error

func (*Store) DeleteUser

func (s *Store) DeleteUser(id string) (int, error)

DeleteUser erases the canonical id AND every alias pointing at it — the GDPR request must take the pre-login trail with it — then forgets the aliases.

func (*Store) Range

func (s *Store) Range(from, to time.Time) ([]event.Event, error)

func (*Store) Scan

func (s *Store) Scan(from, to time.Time, fn func(event.Event) error) error

Jump to

Keyboard shortcuts

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