fix: don't use tft timestamp

This commit is contained in:
Kevin Franklin Kim 2024-11-20 08:22:57 +01:00
parent 2770d4f32f
commit fe5b8c9f0f
No known key found for this signature in database
4 changed files with 10 additions and 5 deletions

View File

@ -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",

View File

@ -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"`

View File

@ -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{}

View File

@ -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"`
}