GoodAnalytics.Core.Events.UrlNormalizer (GoodAnalytics v0.1.1)

Copy Markdown View Source

URL normalization helpers for analytics grouping.

Single source of truth for host and path values written to ga_events. Raw URLs stay on ga_events.url; these helpers produce the normalized host and path columns used for indexed analytics queries.

Summary

Functions

Returns the normalized host from a URL.

Returns the normalized path from a URL.

Returns a stable grouping key made from scheme, host, and normalized path.

Functions

host(url)

@spec host(String.t() | nil) :: String.t() | nil

Returns the normalized host from a URL.

Lowercase, default ports stripped (80 for http, 443 for https). Returns nil when no host is present.

path(url)

@spec path(String.t() | nil) :: String.t()

Returns the normalized path from a URL.

Defaults to /, query/fragment stripped, duplicate slashes collapsed, trailing slash trimmed except for root.

path_for_grouping(url)

@spec path_for_grouping(String.t() | nil) :: String.t()

Returns a stable grouping key made from scheme, host, and normalized path.

Query strings and fragments are removed. Duplicate slashes in the path are collapsed, and a trailing slash is stripped except for the root path.