diff --git a/integration/loki/loki.go b/integration/loki/loki.go index 5ac23f6..bc28fc7 100644 --- a/integration/loki/loki.go +++ b/integration/loki/loki.go @@ -151,9 +151,16 @@ func (l *Loki) Write(payload mpv2.Payload[any]) { l.l.Warn("buffer size reached", zap.Int("size", l.bufferSize)) } + var timestamp time.Time + if payload.TimestampMicros > 0 { + timestamp = time.UnixMicro(payload.TimestampMicros) + } else { + timestamp = time.Now() + } + l.entries <- logproto.Entry{ Line: string(lineBytes), - Timestamp: time.UnixMicro(payload.TimestampMicros), + Timestamp: timestamp, StructuredMetadata: push.LabelsAdapter{ { Name: "event_name", diff --git a/pkg/encoding/gtag/sst.go b/pkg/encoding/gtag/sst.go index 587f175..4712a9b 100644 --- a/pkg/encoding/gtag/sst.go +++ b/pkg/encoding/gtag/sst.go @@ -13,7 +13,7 @@ type SST struct { GCSub *string `json:"gcsub,omitempty" gtag:"gcsub,omitempty"` // Example: DE UC *string `json:"uc,omitempty" gtag:"uc,omitempty"` - // Example: 1708250245344 + // Session start time, time first seen. Example: 1708250245344 TFT *string `json:"tft,omitempty" gtag:"tft,omitempty"` // Example: 13l3l3l3l1 GCD *string `json:"gcd,omitempty" gtag:"gcd,omitempty"` diff --git a/pkg/encoding/gtagencode/mpv2.go b/pkg/encoding/gtagencode/mpv2.go index bdecc98..cbe7f28 100644 --- a/pkg/encoding/gtagencode/mpv2.go +++ b/pkg/encoding/gtagencode/mpv2.go @@ -29,9 +29,6 @@ func MPv2(source gtag.Payload, target any) error { "non_personalized_ads": source.NonPersonalizedAds, "debug_mode": source.IsDebug, } - if source.SST != nil && source.SST.TFT != nil { - targetData["timestamp_micros"] = gtag.Get(source.SST.TFT) + "000" - } // combine user properties targetUserProperties := map[string]any{} diff --git a/pkg/event/params/pageview.go b/pkg/event/params/pageview.go index 89c71a5..0bbc1a5 100644 --- a/pkg/event/params/pageview.go +++ b/pkg/event/params/pageview.go @@ -3,5 +3,6 @@ package params // PageView https://developers.google.com/analytics/devguides/collection/ga4/views?client_type=gtag#manually_send_page_view_events type PageView struct { PageTitle string `json:"page_title,omitempty"` + PageReferrer string `json:"page_referrer,omitempty"` PageLocation string `json:"page_location,omitempty"` }