Std.Analytics
Std.Analytics — typed product analytics (Layer 3 Sky source).
Types
type PropValue = VString String | VInt Int | VFloat Float | VBool Bool | VMoney Money | VPii Pii
type alias EventProp
type Pii = PiiEmail String | PiiRaw String
type alias Event
type Consent = Anonymous | Granted | Denied
type Sink = StderrSink | FileSink String | Custom (String -> Task Error ())
type alias AnalyticsEvent
Values
bool : String -> Bool -> EventProp
A `Bool` property.
configure : List Sink -> Task Error ()
Set the process-global sink list (default `[ StderrSink ]`). Call once at
erase : String -> Task Error Int
Right-to-erasure: delete every STORED event for an anonymous or user id,
event : String -> List EventProp -> Event
Build an event from a name and a list of typed properties.
eventCounts : () -> Task Error (List ( String, Int ))
Count per event name, most frequent first — e.g. `[ ("page_view", 128),
eventsStore : Store AnalyticsEvent
A `Std.Db.Store` over the analytics events table — so apps, admins and dev
float : String -> Float -> EventProp
A `Float` property.
identify : String -> List EventProp -> Task Error ()
Attach a user id (+ typed traits) to the CURRENT session. The user id is
int : String -> Int -> EventProp
An `Int` property.
money : String -> Money -> EventProp
A `Money` property — the right type for prices, revenue, and cart
openStore : () -> Task Error Db
Open a `Std.Db` connection to the analytics store (the console DB, or the
pii : String -> Pii -> EventProp
A PII property — the only way identity enters an event. Pair with
piiEmail : String -> Pii
Tag a value as an email address (PII).
piiRaw : String -> Pii
Tag an arbitrary identifier as PII (a phone number, a raw user id
recentEvents : Int -> Task Error (List AnalyticsEvent)
The last `n` events as TYPED `AnalyticsEvent` rows (v0.19.2 — previously
setConsent : Consent -> Task Error ()
Set the current session's consent posture (see `Consent`). Wire it to your
string : String -> String -> EventProp
A `String` property.
totalEvents : () -> Task Error Int
Total number of captured events in the store.
track : Event -> Task Error ()
Emit an event built with `event` + the typed prop builders. Writes a
trackEvent : a -> Task Error ()
Track a value of your app's OWN typed event union — the ergonomic path.
uniqueUsers : () -> Task Error Int
Count of DISTINCT identified users (events captured after `identify` under