-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package events | ||
|
||
import ( | ||
_ "embed" | ||
"time" | ||
|
||
v1 "github.com/vinceanalytics/vince/gen/go/events/v1" | ||
"google.golang.org/protobuf/encoding/protojson" | ||
) | ||
|
||
//go:embed testdata/sample.json | ||
var sample []byte | ||
|
||
type sampleOptions struct { | ||
now func() time.Time | ||
step time.Duration | ||
} | ||
|
||
type SampleOption func(*sampleOptions) | ||
|
||
func WithNow(now func() time.Time) SampleOption { | ||
return func(so *sampleOptions) { | ||
so.now = now | ||
} | ||
} | ||
|
||
func WithStep(step time.Duration) SampleOption { | ||
return func(so *sampleOptions) { | ||
so.step = step | ||
} | ||
} | ||
|
||
func Samples(opts ...SampleOption) *v1.List { | ||
o := &sampleOptions{ | ||
now: time.Now, | ||
step: time.Second, | ||
} | ||
for _, v := range opts { | ||
v(o) | ||
} | ||
var ls v1.List | ||
protojson.Unmarshal(sample, &ls) | ||
now := o.now().UTC() | ||
for i, e := range ls.GetItems() { | ||
e.Timestamp = now.Add(time.Duration(i) * o.step).UnixMilli() | ||
} | ||
return &ls | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
{ | ||
"items": [ | ||
{ | ||
"timestamp": "1708693696665", | ||
"id": "-153093840780285821", | ||
"bounce": true, | ||
"session": true, | ||
"view": true, | ||
"browser": "Chrome Webview", | ||
"browserVersion": "112.0.5615.135", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.eg", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696671", | ||
"id": "7185465862254995008", | ||
"bounce": true, | ||
"session": true, | ||
"view": true, | ||
"browser": "Chrome Mobile", | ||
"browserVersion": "105.0.0.0", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.cy", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696672", | ||
"id": "7185465862254995008", | ||
"bounce": false, | ||
"view": true, | ||
"duration": 0.001, | ||
"browser": "Chrome Mobile", | ||
"browserVersion": "105.0.0.0", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"exitPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.co", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696673", | ||
"id": "7185465862254995008", | ||
"bounce": false, | ||
"view": true, | ||
"duration": 0.001, | ||
"browser": "Chrome Mobile", | ||
"browserVersion": "105.0.0.0", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"exitPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.do", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696678", | ||
"id": "-8846038784045917376", | ||
"bounce": true, | ||
"session": true, | ||
"view": true, | ||
"browser": "Chrome Mobile", | ||
"browserVersion": "95.0.4638.74", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.cy", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696683", | ||
"id": "-7731778067934062273", | ||
"bounce": true, | ||
"session": true, | ||
"view": true, | ||
"browser": "Chrome", | ||
"browserVersion": "103.0.0.0", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.ec", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696684", | ||
"id": "-153093840780285821", | ||
"bounce": false, | ||
"view": true, | ||
"duration": 0.019, | ||
"browser": "Chrome Webview", | ||
"browserVersion": "112.0.5615.135", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"exitPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.bz", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696689", | ||
"id": "-5530366380598135793", | ||
"bounce": true, | ||
"session": true, | ||
"view": true, | ||
"browser": "Chrome Mobile", | ||
"browserVersion": "99.0.4844.88", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.do", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696690", | ||
"id": "-7731778067934062273", | ||
"bounce": false, | ||
"view": true, | ||
"duration": 0.007, | ||
"browser": "Chrome", | ||
"browserVersion": "103.0.0.0", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"exitPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.et", | ||
"source": "Google Blogsearch" | ||
}, | ||
{ | ||
"timestamp": "1708693696691", | ||
"id": "7185465862254995008", | ||
"bounce": false, | ||
"view": true, | ||
"duration": 0.018, | ||
"browser": "Chrome Mobile", | ||
"browserVersion": "105.0.0.0", | ||
"device": "mobile", | ||
"domain": "vinceanalytics.com", | ||
"entryPage": "/", | ||
"exitPage": "/", | ||
"host": "vinceanalytics.com", | ||
"os": "Android", | ||
"osVersion": "11", | ||
"page": "/", | ||
"referrer": "https://blogsearch.google.com.et", | ||
"source": "Google Blogsearch" | ||
} | ||
] | ||
} |