Documentation
¶
Overview ¶
Package groups computes account-level (B2B) analytics — aggregate by a group property (company, account_id, team) instead of by user. Answers "which accounts are most active", "how many accounts", "account engagement" — the questions other tools gate behind expensive plans. Deterministic.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveWithin ¶ added in v0.30.0
ActiveWithin counts accounts with any activity in the window — the B2B health number that a user count cannot express, because one champion logging in daily and a fifty-seat rollout look identical at user grain.
Types ¶
type Grain ¶ added in v0.30.0
type Grain struct {
Property string `json:"property"`
// Groups is how many distinct accounts the re-keyed slice covers.
Groups int `json:"groups"`
// Events kept and dropped. Dropped events belong to nobody: their user never carried the group
// property on any event, so there is no account to attribute them to. Reporting an
// account-level funnel over a slice that quietly omits a third of the traffic would be exactly
// the truncated-denominator lie this codebase has spent its history removing, so the count
// travels with the result and every surface prints it.
Kept int `json:"events_kept"`
Dropped int `json:"events_dropped"`
// Unattributed is how many distinct USERS had no account at all — the number that says whether
// the group property is instrumented properly or only on a corner of the product.
Unattributed int `json:"users_unattributed"`
// Note states the coverage in words when it is poor enough to change how the report reads.
Note string `json:"note,omitempty"`
}
Grain is the result of re-keying, and the honesty half of the feature.
func Regroup ¶ added in v0.30.0
Regroup re-keys events so the unit of analysis is the account.
First-touch stamping runs first, and it is not optional. A group property is set once — on signup, or on an identify — and is absent from the pageviews and clicks that follow. Re-keying on the raw property would keep one event per user and drop the rest, so every account-level funnel would collapse to a single step. StampFirstTouch carries the account across all of a user's events, which is the same rule the segmented funnel already uses; using a different one here would make "conversion by company" and "the company funnel" two different reports.
type Group ¶
type Group struct {
Value string `json:"value"`
Events int `json:"events"`
Users int `json:"users"`
LastSeen time.Time `json:"last_seen"`
}
Group is one account: its activity, distinct users, and recency.