Skip to content

Commit

Permalink
tweak example to send a lot more traffic and enabled gzip
Browse files Browse the repository at this point in the history
  • Loading branch information
jbeemster committed Oct 27, 2023
1 parent 6936f7a commit 8aba726
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions examples/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ func main() {
sp.RequireStorage(*storagememory.Init()),
sp.OptionRequestType("POST"),
sp.OptionProtocol("http"),
sp.OptionSendLimit(4),
sp.OptionSendLimit(1000),
sp.OptionEnableRequestPostGzip(true),
)

subject := sp.InitSubject()
Expand All @@ -40,20 +41,19 @@ func main() {
tracker := sp.InitTracker(
sp.RequireEmitter(emitter),
sp.OptionSubject(subject),
sp.OptionBase64Encode(true),
)

fmt.Println("Sending events to " + emitter.GetCollectorUrl())

pageView := sp.PageViewEvent{
PageUrl: sphelp.NewString("acme.com"),
}
tracker.TrackPageView(pageView)

screenView := sp.ScreenViewEvent{
Name: sphelp.NewString("name"),
Id: sphelp.NewString("Screen ID"),
}
tracker.TrackScreenView(screenView)

structEvent := sp.StructuredEvent{
Category: sphelp.NewString("shop"),
Expand All @@ -62,19 +62,19 @@ func main() {
Value: sphelp.NewFloat64(2),
}

tracker.TrackStructEvent(structEvent)

data := map[string]interface{}{
"targetUrl": "https://www.snowplow.io",
}

sdj := sp.InitSelfDescribingJson("iglu:com.snowplowanalytics.snowplow/link_click/jsonschema/1-0-1", data)

sde := sp.SelfDescribingEvent{Event: sdj}

tracker.TrackSelfDescribingEvent(sde)
for i := 0; i < 1000; i++ {
tracker.TrackPageView(pageView)
tracker.TrackScreenView(screenView)
tracker.TrackStructEvent(structEvent)
tracker.TrackSelfDescribingEvent(sde)
}

tracker.Emitter.Stop()
tracker.BlockingFlush(5, 10)

tracker.BlockingFlush(5, 1000)
}

0 comments on commit 8aba726

Please sign in to comment.