Skip to content
This repository was archived by the owner on Jul 28, 2020. It is now read-only.

Commit 0704dc5

Browse files
Andy Voellmerekcasey
authored andcommitted
fixed analyticsd bug on windows
Signed-off-by: Steve Hiehn <[email protected]>
1 parent 48ae4b3 commit 0704dc5

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

analyticsd/daemon/daemon.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ var (
9797
)
9898

9999
func (d *Daemon) Start() {
100-
err := d.do(true)
100+
err := d.do(false)
101101
if err != nil {
102102
d.logger.Println(err)
103103
}
@@ -106,7 +106,8 @@ func (d *Daemon) Start() {
106106
case <-d.doneChan:
107107
return
108108
case <-time.NewTicker(d.pollingInterval).C:
109-
err := d.do(false)
109+
isTimestampSet := d.lastTime != nil
110+
err := d.do(isTimestampSet)
110111

111112
if err != nil {
112113
d.logger.Println(err)
@@ -119,7 +120,7 @@ func (d *Daemon) Stop() {
119120
d.doneChan <- true
120121
}
121122

122-
func (d *Daemon) do(isFirstTime bool) error {
123+
func (d *Daemon) do(isTimestampSet bool) error {
123124
var (
124125
nextURL *string = nil
125126
resources []Resource
@@ -138,10 +139,9 @@ func (d *Daemon) do(isFirstTime bool) error {
138139

139140
params := url.Values{}
140141
params.Add("q", "type IN "+eventTypesFilter())
141-
if !isFirstTime {
142+
if isTimestampSet {
142143
params.Add("q", "timestamp>"+d.lastTime.Format(ccTimeStampFormat))
143144
}
144-
145145
err := fetch(params)
146146
if err != nil {
147147
return err
@@ -186,7 +186,7 @@ func (d *Daemon) do(isFirstTime bool) error {
186186
"version": d.version,
187187
}
188188

189-
if !isFirstTime {
189+
if isTimestampSet {
190190
err = d.analyticsClient.Enqueue(analytics.Track{
191191
UserId: d.UUID,
192192
Event: eventType,
@@ -199,10 +199,8 @@ func (d *Daemon) do(isFirstTime bool) error {
199199
return fmt.Errorf("failed to send analytics: %v", err)
200200
}
201201
}
202-
203202
return nil
204203
}
205-
206204
func (d *Daemon) fetch(params url.Values, dest interface{}) error {
207205
req, err := http.NewRequest(http.MethodGet, d.ccHost+"/v2/events", nil)
208206
if err != nil {

go.sum

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8=
4646
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
4747
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
4848
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
49+
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214 h1:WgfvpuKg42WVLkxNwzfFraXkTXPK36bMqXvMFN67clI=
4950
github.com/hooklift/assert v0.0.0-20170704181755-9d1defd6d214/go.mod h1:kj6hFWqfwSjFjLnYW5PK1DoxZ4O0uapwHRmd9jhln4E=
5051
github.com/hooklift/iso9660 v1.0.0 h1:GYN0ejrqTl1qtB+g+ics7xxWHp7J2B1zmr25O9EyG3c=
5152
github.com/hooklift/iso9660 v1.0.0/go.mod h1:sOC47ru8lB0DlU0EZ7BJ0KCP5rDqOvx0c/5K5ADm8H0=

0 commit comments

Comments
 (0)