Skip to content

Commit bddbeed

Browse files
authored
Merge pull request #204 from segmentio/worktree-reported-version-fix
Fix reported version string and centralize version source of truth
2 parents a51c5e4 + 9c12504 commit bddbeed

15 files changed

Lines changed: 40 additions & 40 deletions

RELEASING.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Releasing
2+
3+
1. **Update the version constant** in `analytics.go`:
4+
```go
5+
const Version = "x.y.z"
6+
```
7+
8+
2. **Update `History.md`** with a summary of changes and the release date.
9+
10+
3. Commit both files:
11+
```
12+
git commit -m "Release vx.y.z"
13+
```
14+
15+
4. Push and merge to `v3.0`.
16+
17+
5. Tag the release from `v3.0` after the merge:
18+
```
19+
git tag vx.y.z
20+
git push origin vx.y.z
21+
```
22+
23+
> **Note:** The `Version` constant in `analytics.go` is the single source of truth — it is sent in the `User-Agent` header on every API request and is automatically used by the test fixtures. No other files need to be updated.

analytics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
)
1515

1616
// Version of the client.
17-
const Version = "3.0.0"
17+
const Version = "3.3.0"
1818

1919
// This interface is the main API exposed by the analytics package.
2020
// Values that satsify this interface are returned by the client constructors

analytics_test.go

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func fixture(name string) string {
139139
if err != nil {
140140
panic(err)
141141
}
142-
return string(b)
142+
return strings.ReplaceAll(string(b), `"__VERSION__"`, `"`+Version+`"`)
143143
}
144144

145145
func mockId() string { return "I'm unique" }
@@ -195,32 +195,9 @@ func ExampleTrack() {
195195
},
196196
})
197197

198-
fmt.Printf("%s\n", <-body)
199-
// Output:
200-
// {
201-
// "batch": [
202-
// {
203-
// "event": "Download",
204-
// "messageId": "I'm unique",
205-
// "properties": {
206-
// "application": "Segment Desktop",
207-
// "platform": "osx",
208-
// "version": "1.1.0"
209-
// },
210-
// "timestamp": "2009-11-10T23:00:00Z",
211-
// "type": "track",
212-
// "userId": "123456"
213-
// }
214-
// ],
215-
// "context": {
216-
// "library": {
217-
// "name": "analytics-go",
218-
// "version": "3.0.0"
219-
// }
220-
// },
221-
// "messageId": "I'm unique",
222-
// "sentAt": "2009-11-10T23:00:00Z"
223-
// }
198+
if res := string(<-body); res != fixture("test-enqueue-track.json") {
199+
fmt.Printf("unexpected output:\n%s\n", res)
200+
}
224201
}
225202

226203
func TestEnqueue(t *testing.T) {

fixtures/test-context-track.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"context": {
2020
"library": {
2121
"name": "analytics-go",
22-
"version": "3.0.0"
22+
"version": "__VERSION__"
2323
}
2424
},
2525
"messageId": "I'm unique",

fixtures/test-enqueue-alias.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"context": {
1212
"library": {
1313
"name": "analytics-go",
14-
"version": "3.0.0"
14+
"version": "__VERSION__"
1515
}
1616
},
1717
"messageId": "I'm unique",

fixtures/test-enqueue-group.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"context": {
1212
"library": {
1313
"name": "analytics-go",
14-
"version": "3.0.0"
14+
"version": "__VERSION__"
1515
}
1616
},
1717
"messageId": "I'm unique",

fixtures/test-enqueue-identify.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"context": {
1111
"library": {
1212
"name": "analytics-go",
13-
"version": "3.0.0"
13+
"version": "__VERSION__"
1414
}
1515
},
1616
"messageId": "I'm unique",

fixtures/test-enqueue-page.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"context": {
1212
"library": {
1313
"name": "analytics-go",
14-
"version": "3.0.0"
14+
"version": "__VERSION__"
1515
}
1616
},
1717
"messageId": "I'm unique",

fixtures/test-enqueue-screen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"context": {
1212
"library": {
1313
"name": "analytics-go",
14-
"version": "3.0.0"
14+
"version": "__VERSION__"
1515
}
1616
},
1717
"messageId": "I'm unique",

fixtures/test-enqueue-track.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"context": {
1717
"library": {
1818
"name": "analytics-go",
19-
"version": "3.0.0"
19+
"version": "__VERSION__"
2020
}
2121
},
2222
"messageId": "I'm unique",

0 commit comments

Comments
 (0)