Skip to content

Commit 5f6caf6

Browse files
authored
Fix another nil pointer and make things nullable (#554)
* Fix another nil pointer and make things nullable * version bump
1 parent 4f9eec6 commit 5f6caf6

File tree

7 files changed

+44
-38
lines changed

7 files changed

+44
-38
lines changed

.VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v0.16.2
1+
v0.16.3

deploy/terraform/aws/lambda/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ variable "buz_domain" {
2929
variable "buz_version" {
3030
description = "The version of Buz to run."
3131
type = string
32-
default = "v0.16.2"
32+
default = "v0.16.3"
3333
}
3434

3535
variable "buz_lambda_memory_limit" {

deploy/terraform/gcp/cloud_run/variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ variable "buz_domain" {
2828
variable "buz_version" {
2929
description = "The version of Buz to run."
3030
type = string
31-
default = "v0.16.2"
31+
default = "v0.16.3"
3232
}
3333

3434
variable "buz_service_timeout_seconds" {

examples/quickstart/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ x-dependency:
2020
services:
2121
buz:
2222
container_name: buz
23-
image: ghcr.io/silverton-io/buz:v0.16.2
23+
image: ghcr.io/silverton-io/buz:v0.16.3
2424
volumes:
2525
- type: bind
2626
source: ./buz/quickstart.conf.yml

pkg/protocol/snowplow/envelopeBuilder.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package snowplow
66

77
import (
88
"io"
9+
"time"
910

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

2021
func buildSnowplowEnvelope(conf config.Config, e SnowplowEvent) envelope.Envelope {
2122
n := envelope.NewEnvelope(conf.App)
22-
n.Timestamp = *e.DvceCreatedTstamp
23+
if e.DvceCreatedTstamp != nil {
24+
n.Timestamp = *e.DvceCreatedTstamp
25+
} else {
26+
n.Timestamp = time.Now()
27+
}
2328
n.Protocol = protocol.SNOWPLOW
2429
n.Schema = *e.SelfDescribingEvent.SchemaName()
2530
n.Payload = e.Map()

pkg/protocol/snowplow/event.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type SnowplowEvent struct {
3737
// Application parameters - https://docs.snowplowanalytics.com/docs/collecting-data/collecting-from-own-applications/snowplow-tracker-protocol/#common-parameters-platform-and-event-independent
3838
NameTracker *string `json:"name_tracker"`
3939
AppId *string `json:"app_id"`
40-
Platform string `json:"platform"`
40+
Platform *string `json:"platform"`
4141
EtlTstamp *time.Time `json:"etl_tstamp"`
4242
DvceCreatedTstamp *time.Time `json:"dvce_created_tstamp"`
4343
DvceSentTstamp *time.Time `json:"dvce_sent_tstamp"`
@@ -158,19 +158,19 @@ func (e *SnowplowEvent) Map() map[string]interface{} {
158158
}
159159

160160
type Page struct {
161-
Url string `json:"url"`
162-
Title *string `json:"title"`
163-
Scheme string `json:"scheme"`
164-
Host string `json:"host"`
165-
Port string `json:"port"`
166-
Path string `json:"path"`
167-
Query map[string]interface{} `json:"query"`
168-
Fragment *string `json:"fragment"`
169-
Medium *string `json:"medium"`
170-
Source *string `json:"source"`
171-
Term *string `json:"term"`
172-
Content *string `json:"content"`
173-
Campaign *string `json:"campaign"`
161+
Url *string `json:"url"`
162+
Title *string `json:"title"`
163+
Scheme *string `json:"scheme"`
164+
Host *string `json:"host"`
165+
Port *string `json:"port"`
166+
Path *string `json:"path"`
167+
Query *map[string]interface{} `json:"query"`
168+
Fragment *string `json:"fragment"`
169+
Medium *string `json:"medium"`
170+
Source *string `json:"source"`
171+
Term *string `json:"term"`
172+
Content *string `json:"content"`
173+
Campaign *string `json:"campaign"`
174174
}
175175

176176
type PageViewEvent struct{}

pkg/protocol/snowplow/eventBuilder.go

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -161,13 +161,14 @@ func getPageFromParam(params map[string]interface{}, k string) (Page, error) {
161161
}
162162
qParams := util.QueryToMap(parsedUrl.Query())
163163
frag := parsedUrl.Fragment
164+
port := parsedUrl.Port()
164165
page := Page{
165-
Url: *p,
166-
Scheme: parsedUrl.Scheme,
167-
Host: parsedUrl.Host,
168-
Port: parsedUrl.Port(),
169-
Path: parsedUrl.Path,
170-
Query: qParams,
166+
Url: p,
167+
Scheme: &parsedUrl.Scheme,
168+
Host: &parsedUrl.Host,
169+
Port: &port,
170+
Path: &parsedUrl.Path,
171+
Query: &qParams,
171172
Fragment: &frag,
172173
Medium: getQueryParam(*parsedUrl, "utm_medium"),
173174
Source: getQueryParam(*parsedUrl, "utm_source"),
@@ -205,7 +206,7 @@ func setEvent(e *SnowplowEvent, params map[string]interface{}) {
205206
eName := getStringParam(params, "e")
206207
fingerprint := uuid.New()
207208
e.AppId = getStringParam(params, "aid")
208-
e.Platform = *getStringParam(params, "p")
209+
e.Platform = getStringParam(params, "p")
209210
e.Event = getEventType(*eName)
210211
e.TxnId = getStringParam(params, "tid")
211212
e.EventId = getStringParam(params, "eid")
@@ -230,13 +231,13 @@ func setPage(e *SnowplowEvent, params map[string]interface{}) {
230231
page, _ := getPageFromParam(params, "url")
231232
title := getStringParam(params, "page")
232233
page.Title = title
233-
e.PageUrl = &page.Url
234+
e.PageUrl = page.Url
234235
e.PageTitle = page.Title
235-
e.PageUrlScheme = &page.Scheme
236-
e.PageUrlHost = &page.Host
237-
e.PageUrlPort = &page.Port
238-
e.PageUrlPath = &page.Path
239-
e.PageUrlQuery = &page.Query
236+
e.PageUrlScheme = page.Scheme
237+
e.PageUrlHost = page.Host
238+
e.PageUrlPort = page.Port
239+
e.PageUrlPath = page.Path
240+
e.PageUrlQuery = page.Query
240241
e.PageUrlFragment = page.Fragment
241242
e.MktCampaign = page.Campaign
242243
e.MktContent = page.Content
@@ -247,12 +248,12 @@ func setPage(e *SnowplowEvent, params map[string]interface{}) {
247248

248249
func setReferrer(e *SnowplowEvent, params map[string]interface{}) {
249250
refr, _ := getPageFromParam(params, "refr")
250-
e.PageReferrer = &refr.Url
251-
e.RefrUrlScheme = &refr.Scheme
252-
e.RefrUrlHost = &refr.Host
253-
e.RefrUrlPort = &refr.Port
254-
e.RefrUrlPath = &refr.Path
255-
e.RefrUrlQuery = &refr.Query
251+
e.PageReferrer = refr.Url
252+
e.RefrUrlScheme = refr.Scheme
253+
e.RefrUrlHost = refr.Host
254+
e.RefrUrlPort = refr.Port
255+
e.RefrUrlPath = refr.Path
256+
e.RefrUrlQuery = refr.Query
256257
e.RefrUrlFragment = refr.Fragment
257258
e.RefrCampaign = refr.Campaign
258259
e.RefrContent = refr.Content

0 commit comments

Comments
 (0)