Golang tracker events don't show up in database

Hi,

I have installed Snowplow successfully, and JS tracker is working fine and I am able to see the events in our database.

But the events from the Golang tracker don’t end up in the database. This is my code:

package snowplow

import (
	sp "github.com/snowplow/snowplow-golang-tracker/v2/tracker"
)

var (
	emitter *sp.Emitter
	tracker *sp.Tracker
	subject *sp.Subject
)

type Event struct {
	Category string
	Action   string
	Label    string
	Subject  *sp.Subject
}

func Init() {
	subject = sp.InitSubject()
	emitter = sp.InitEmitter(
		sp.RequireCollectorUri("<collector-uri>"),
		sp.OptionRequestType("POST"),
		sp.OptionProtocol("https"),
		sp.OptionSendLimit(500),
		sp.OptionByteLimitGet(40000),
		sp.OptionByteLimitPost(40000),
		sp.OptionDbName("/mnt/c/Users/Marwan/snowplow.db"),
	)
	tracker = sp.InitTracker(
		sp.RequireEmitter(emitter),
		sp.OptionAppId("<app-id>"),
		sp.OptionPlatform("backend"),
	)
}

func Record(event Event) {
	tracker.TrackPageView(sp.PageViewEvent{
		PageUrl: sp.NewString("<some-url>"),
		Subject: event.Subject,
	})
}

Actually, I want to use TrackStructEvent but it doesn’t work, and even TrackPageView doesn’t work. What am I missing?

Looks like the page views are showing up now after some edits. Will try the structured events.

Now the structured events are showing up.

I am not sure, but looks like the problem was setting the EventId and the Platform. Removing them made everything works.

1 Like

Hi @Marwan_abdel_moneim did you check the bad rows when you had those settings enabled? More than likely the pipeline encountered something it did not like.

Specifically for the platform there are a certain set of allowed values (documented here: Snowplow Tracker Protocol - Snowplow Docs)

So setting it to “backend” would have caused it to fail validation - this validation should be enforced in the tracker more than likely and does make it somewhat confusing as the SDK allows for any string.

Similarly the event_id must be a UUIDv4 for it to be validated so setting this to something else will also cause validation failures.

Note: With the Golang tracker at any decent volume you likely want to use the in-memory database as the performance does degrade writing everything to disk first.

Hope this helps!

2 Likes

Thanks for clarifying.

Changed it to StorageMemory, great tip.