Skip to content

Commit

Permalink
Fix another nil pointer and make things nullable (#554)
Browse files Browse the repository at this point in the history
* Fix another nil pointer and make things nullable

* version bump
  • Loading branch information
jakthom authored May 3, 2023
1 parent 4f9eec6 commit 5f6caf6
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.16.2
v0.16.3
2 changes: 1 addition & 1 deletion deploy/terraform/aws/lambda/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ variable "buz_domain" {
variable "buz_version" {
description = "The version of Buz to run."
type = string
default = "v0.16.2"
default = "v0.16.3"
}

variable "buz_lambda_memory_limit" {
Expand Down
2 changes: 1 addition & 1 deletion deploy/terraform/gcp/cloud_run/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ variable "buz_domain" {
variable "buz_version" {
description = "The version of Buz to run."
type = string
default = "v0.16.2"
default = "v0.16.3"
}

variable "buz_service_timeout_seconds" {
Expand Down
2 changes: 1 addition & 1 deletion examples/quickstart/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ x-dependency:
services:
buz:
container_name: buz
image: ghcr.io/silverton-io/buz:v0.16.2
image: ghcr.io/silverton-io/buz:v0.16.3
volumes:
- type: bind
source: ./buz/quickstart.conf.yml
Expand Down
7 changes: 6 additions & 1 deletion pkg/protocol/snowplow/envelopeBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package snowplow

import (
"io"
"time"

"github.com/gin-gonic/gin"
"github.com/rs/zerolog/log"
Expand All @@ -19,7 +20,11 @@ import (

func buildSnowplowEnvelope(conf config.Config, e SnowplowEvent) envelope.Envelope {
n := envelope.NewEnvelope(conf.App)
n.Timestamp = *e.DvceCreatedTstamp
if e.DvceCreatedTstamp != nil {
n.Timestamp = *e.DvceCreatedTstamp
} else {
n.Timestamp = time.Now()
}
n.Protocol = protocol.SNOWPLOW
n.Schema = *e.SelfDescribingEvent.SchemaName()
n.Payload = e.Map()
Expand Down
28 changes: 14 additions & 14 deletions pkg/protocol/snowplow/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type SnowplowEvent struct {
// Application parameters - https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/snowplow-tracker-protocol/#common-parameters-platform-and-event-independent
NameTracker *string `json:"name_tracker"`
AppId *string `json:"app_id"`
Platform string `json:"platform"`
Platform *string `json:"platform"`
EtlTstamp *time.Time `json:"etl_tstamp"`
DvceCreatedTstamp *time.Time `json:"dvce_created_tstamp"`
DvceSentTstamp *time.Time `json:"dvce_sent_tstamp"`
Expand Down Expand Up @@ -158,19 +158,19 @@ func (e *SnowplowEvent) Map() map[string]interface{} {
}

type Page struct {
Url string `json:"url"`
Title *string `json:"title"`
Scheme string `json:"scheme"`
Host string `json:"host"`
Port string `json:"port"`
Path string `json:"path"`
Query map[string]interface{} `json:"query"`
Fragment *string `json:"fragment"`
Medium *string `json:"medium"`
Source *string `json:"source"`
Term *string `json:"term"`
Content *string `json:"content"`
Campaign *string `json:"campaign"`
Url *string `json:"url"`
Title *string `json:"title"`
Scheme *string `json:"scheme"`
Host *string `json:"host"`
Port *string `json:"port"`
Path *string `json:"path"`
Query *map[string]interface{} `json:"query"`
Fragment *string `json:"fragment"`
Medium *string `json:"medium"`
Source *string `json:"source"`
Term *string `json:"term"`
Content *string `json:"content"`
Campaign *string `json:"campaign"`
}

type PageViewEvent struct{}
Expand Down
39 changes: 20 additions & 19 deletions pkg/protocol/snowplow/eventBuilder.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,14 @@ func getPageFromParam(params map[string]interface{}, k string) (Page, error) {
}
qParams := util.QueryToMap(parsedUrl.Query())
frag := parsedUrl.Fragment
port := parsedUrl.Port()
page := Page{
Url: *p,
Scheme: parsedUrl.Scheme,
Host: parsedUrl.Host,
Port: parsedUrl.Port(),
Path: parsedUrl.Path,
Query: qParams,
Url: p,
Scheme: &parsedUrl.Scheme,
Host: &parsedUrl.Host,
Port: &port,
Path: &parsedUrl.Path,
Query: &qParams,
Fragment: &frag,
Medium: getQueryParam(*parsedUrl, "utm_medium"),
Source: getQueryParam(*parsedUrl, "utm_source"),
Expand Down Expand Up @@ -205,7 +206,7 @@ func setEvent(e *SnowplowEvent, params map[string]interface{}) {
eName := getStringParam(params, "e")
fingerprint := uuid.New()
e.AppId = getStringParam(params, "aid")
e.Platform = *getStringParam(params, "p")
e.Platform = getStringParam(params, "p")
e.Event = getEventType(*eName)
e.TxnId = getStringParam(params, "tid")
e.EventId = getStringParam(params, "eid")
Expand All @@ -230,13 +231,13 @@ func setPage(e *SnowplowEvent, params map[string]interface{}) {
page, _ := getPageFromParam(params, "url")
title := getStringParam(params, "page")
page.Title = title
e.PageUrl = &page.Url
e.PageUrl = page.Url
e.PageTitle = page.Title
e.PageUrlScheme = &page.Scheme
e.PageUrlHost = &page.Host
e.PageUrlPort = &page.Port
e.PageUrlPath = &page.Path
e.PageUrlQuery = &page.Query
e.PageUrlScheme = page.Scheme
e.PageUrlHost = page.Host
e.PageUrlPort = page.Port
e.PageUrlPath = page.Path
e.PageUrlQuery = page.Query
e.PageUrlFragment = page.Fragment
e.MktCampaign = page.Campaign
e.MktContent = page.Content
Expand All @@ -247,12 +248,12 @@ func setPage(e *SnowplowEvent, params map[string]interface{}) {

func setReferrer(e *SnowplowEvent, params map[string]interface{}) {
refr, _ := getPageFromParam(params, "refr")
e.PageReferrer = &refr.Url
e.RefrUrlScheme = &refr.Scheme
e.RefrUrlHost = &refr.Host
e.RefrUrlPort = &refr.Port
e.RefrUrlPath = &refr.Path
e.RefrUrlQuery = &refr.Query
e.PageReferrer = refr.Url
e.RefrUrlScheme = refr.Scheme
e.RefrUrlHost = refr.Host
e.RefrUrlPort = refr.Port
e.RefrUrlPath = refr.Path
e.RefrUrlQuery = refr.Query
e.RefrUrlFragment = refr.Fragment
e.RefrCampaign = refr.Campaign
e.RefrContent = refr.Content
Expand Down

0 comments on commit 5f6caf6

Please sign in to comment.