From 4b91893c4a89164403d874402486ffa38851b9f0 Mon Sep 17 00:00:00 2001 From: "evgeny.iva" Date: Wed, 14 Aug 2024 18:41:46 +0300 Subject: [PATCH 1/7] specify uuid --- CHANGELOG.md | 9 ++++++-- README.md | 12 +++++++++++ capture.go | 6 +++++- config.go | 19 ----------------- fixtures/test-enqueue-capture-with-uuid.json | 22 ++++++++++++++++++++ fixtures/test-enqueue-capture.json | 3 ++- fixtures/test-interval-capture.json | 3 ++- fixtures/test-many-capture.json | 9 +++++--- fixtures/test-merge-capture.json | 3 ++- fixtures/test-timestamp-capture.json | 3 ++- posthog_test.go | 16 +++++--------- 11 files changed, 65 insertions(+), 40 deletions(-) create mode 100644 fixtures/test-enqueue-capture-with-uuid.json diff --git a/CHANGELOG.md b/CHANGELOG.md index e2ae27b..9f4a33d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# Changelog + +## 1.3.0 - 2024-08-14 + +1. Added the ability to explicitly specify the uuid for capturing events. If uuid is not specified, Posthog will calculate it automatically (suitable for most cases). +2. Removed unused config function `uid()`. + ## 1.2.16 * [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.15...v1.2.16) @@ -54,8 +61,6 @@ * [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.3) -# Changelog - ## 1.2.2 - 2024-08-08 1. Adds logging to error responses from the PostHog API so that users can see how a call failed (e.g. rate limiting) from the SDK itself. diff --git a/README.md b/README.md index 4a263a8..07d37cc 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,18 @@ func main() { Properties: posthog.NewProperties(). Set("$current_url", "https://example.com"), }) + + // Capture event with calculated uuid to deduplicate repeated events. + // The library github.com/google/uuid is used + key := myEvent.Id + myEvent.Project + uid := uuid.NewSHA1(uuid.NameSpaceX500, []byte(key)).String() + client.Enqueue(posthog.Capture{ + Uuid: uid, + DistinctId: "test-user", + Event: "$pageview", + Properties: posthog.NewProperties(). + Set("$current_url", "https://example.com"), + }) // Check if a feature flag is enabled isMyFlagEnabled, err := client.IsFeatureEnabled( diff --git a/capture.go b/capture.go index b54acde..936153b 100644 --- a/capture.go +++ b/capture.go @@ -9,7 +9,9 @@ type Capture struct { // This field is exported for serialization purposes and shouldn't be set by // the application, its value is always overwritten by the library. Type string - + // You don't usually need to specify this field - Posthog will generate it automatically. + // Use it only when necessary - for example, to prevent duplicate events. + Uuid string DistinctId string Event string Timestamp time.Time @@ -44,6 +46,7 @@ func (msg Capture) Validate() error { type CaptureInApi struct { Type string `json:"type"` + Uuid string `json:"uuid"` Library string `json:"library"` LibraryVersion string `json:"library_version"` Timestamp time.Time `json:"timestamp"` @@ -71,6 +74,7 @@ func (msg Capture) APIfy() APIMessage { } apified := CaptureInApi{ + Uuid: msg.Uuid, Type: msg.Type, Library: library, LibraryVersion: libraryVersion, diff --git a/config.go b/config.go index 51ff05d..8e120a1 100644 --- a/config.go +++ b/config.go @@ -3,8 +3,6 @@ package posthog import ( "net/http" "time" - - "github.com/google/uuid" ) // Instances of this type carry the different configuration options that may @@ -79,12 +77,6 @@ type Config struct { // If not set the client will fallback to use a default retry policy. RetryAfter func(int) time.Duration - // A function called by the client to generate unique message identifiers. - // The client uses a UUID generator if none is provided. - // This field is not exported and only exposed internally to let unit tests - // mock the id generation. - uid func() string - // A function called by the client to get the current time, `time.Now` is // used by default. // This field is not exported and only exposed internally to let unit tests @@ -173,10 +165,6 @@ func makeConfig(c Config) Config { c.RetryAfter = DefaultBacko().Duration } - if c.uid == nil { - c.uid = uid - } - if c.now == nil { c.now = time.Now } @@ -187,10 +175,3 @@ func makeConfig(c Config) Config { return c } - -// This function returns a string representation of a UUID, it's the default -// function used for generating unique IDs. -func uid() string { - new_uuid, _ := uuid.NewRandom() - return new_uuid.String() -} diff --git a/fixtures/test-enqueue-capture-with-uuid.json b/fixtures/test-enqueue-capture-with-uuid.json new file mode 100644 index 0000000..fcd5fe7 --- /dev/null +++ b/fixtures/test-enqueue-capture-with-uuid.json @@ -0,0 +1,22 @@ +{ + "api_key": "Csyjlnlun3OzyNJAafdlv", + "batch": [ + { + "distinct_id": "123456", + "event": "Download", + "library": "posthog-go", + "library_version": "1.0.0", + "properties": { + "$lib": "posthog-go", + "$lib_version": "1.0.0", + "application": "PostHog Go", + "platform": "macos", + "version": "1.0.0" + }, + "send_feature_flags": false, + "timestamp": "2009-11-10T23:00:00Z", + "type": "capture", + "uuid": "11111111-1111-1111-1111-111111111111" + } + ] +} diff --git a/fixtures/test-enqueue-capture.json b/fixtures/test-enqueue-capture.json index 0b96c42..2120bfd 100644 --- a/fixtures/test-enqueue-capture.json +++ b/fixtures/test-enqueue-capture.json @@ -15,7 +15,8 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture" + "type": "capture", + "uuid": "" } ] } diff --git a/fixtures/test-interval-capture.json b/fixtures/test-interval-capture.json index 0b96c42..2120bfd 100644 --- a/fixtures/test-interval-capture.json +++ b/fixtures/test-interval-capture.json @@ -15,7 +15,8 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture" + "type": "capture", + "uuid": "" } ] } diff --git a/fixtures/test-many-capture.json b/fixtures/test-many-capture.json index 7fbd131..87d52b2 100644 --- a/fixtures/test-many-capture.json +++ b/fixtures/test-many-capture.json @@ -14,7 +14,8 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture" + "type": "capture", + "uuid": "" }, { "distinct_id": "123456", @@ -29,7 +30,8 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture" + "type": "capture", + "uuid": "" }, { "distinct_id": "123456", @@ -44,7 +46,8 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture" + "type": "capture", + "uuid": "" } ] } diff --git a/fixtures/test-merge-capture.json b/fixtures/test-merge-capture.json index d754fdd..e5d7a07 100644 --- a/fixtures/test-merge-capture.json +++ b/fixtures/test-merge-capture.json @@ -16,7 +16,8 @@ }, "send_feature_flags": false, "timestamp": "2015-07-10T23:00:00Z", - "type": "capture" + "type": "capture", + "uuid": "" } ] } diff --git a/fixtures/test-timestamp-capture.json b/fixtures/test-timestamp-capture.json index 94d6e36..f863e41 100644 --- a/fixtures/test-timestamp-capture.json +++ b/fixtures/test-timestamp-capture.json @@ -15,7 +15,8 @@ }, "send_feature_flags": false, "timestamp": "2015-07-10T23:00:00Z", - "type": "capture" + "type": "capture", + "uuid": "" } ] } diff --git a/posthog_test.go b/posthog_test.go index 2daf1c6..85ffbcf 100644 --- a/posthog_test.go +++ b/posthog_test.go @@ -152,8 +152,6 @@ func fixture(name string) string { return string(b) } -func mockId() string { return "I'm unique" } - func mockTime() time.Time { // time.Unix(0, 0) fails on Circle return time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) @@ -191,11 +189,11 @@ func ExampleCapture() { Endpoint: server.URL, BatchSize: 1, now: mockTime, - uid: mockId, }) defer client.Close() client.Enqueue(Capture{ + Uuid: "00000000-0000-0000-0000-000000000000", Event: "Download", DistinctId: "123456", Properties: Properties{ @@ -225,7 +223,8 @@ func ExampleCapture() { // }, // "send_feature_flags": false, // "timestamp": "2009-11-10T23:00:00Z", - // "type": "capture" + // "type": "capture", + // "uuid": "00000000-0000-0000-0000-000000000000" // } // ] // } @@ -297,8 +296,9 @@ func TestEnqueue(t *testing.T) { }, "*capture": { - strings.TrimSpace(fixture("test-enqueue-capture.json")), + strings.TrimSpace(fixture("test-enqueue-capture-with-uuid.json")), &Capture{ + Uuid: "11111111-1111-1111-1111-111111111111", Event: "Download", DistinctId: "123456", Properties: Properties{ @@ -320,7 +320,6 @@ func TestEnqueue(t *testing.T) { Logger: t, BatchSize: 1, now: mockTime, - uid: mockId, }) defer client.Close() @@ -378,7 +377,6 @@ func TestCaptureWithInterval(t *testing.T) { Verbose: true, Logger: t, now: mockTime, - uid: mockId, }) defer client.Close() @@ -415,7 +413,6 @@ func TestCaptureWithTimestamp(t *testing.T) { Logger: t, BatchSize: 1, now: mockTime, - uid: mockId, }) defer client.Close() @@ -449,7 +446,6 @@ func TestCaptureWithDefaultProperties(t *testing.T) { Logger: t, BatchSize: 1, now: mockTime, - uid: mockId, }) defer client.Close() @@ -482,7 +478,6 @@ func TestCaptureMany(t *testing.T) { Logger: t, BatchSize: 3, now: mockTime, - uid: mockId, }) defer client.Close() @@ -1685,7 +1680,6 @@ func TestCaptureSendFlags(t *testing.T) { Logger: t, BatchSize: 1, now: mockTime, - uid: mockId, PersonalApiKey: "some very secret key", }) From 9ce2afaec6b22a00fbe59228881e7c036bbbb850 Mon Sep 17 00:00:00 2001 From: "evgeny.iva" Date: Wed, 14 Aug 2024 18:44:04 +0300 Subject: [PATCH 2/7] tidy --- go.mod | 5 +---- go.sum | 4 +--- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/go.mod b/go.mod index 036d7d3..043d70d 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,7 @@ module github.com/posthog/posthog-go go 1.18 -require ( - github.com/google/uuid v1.3.0 - github.com/urfave/cli v1.22.5 -) +require github.com/urfave/cli v1.22.5 require ( github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect diff --git a/go.sum b/go.sum index 03d0eb7..74dc48f 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= -github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= @@ -12,4 +10,4 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= \ No newline at end of file +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 7f12943409e9fb3e93cab3c2792c7dcaa4248714 Mon Sep 17 00:00:00 2001 From: "evgeny.iva" Date: Wed, 14 Aug 2024 18:55:41 +0300 Subject: [PATCH 3/7] fix --- README.md | 6 +++--- capture.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 07d37cc..97ece82 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,9 @@ func main() { }) // Capture event with calculated uuid to deduplicate repeated events. - // The library github.com/google/uuid is used - key := myEvent.Id + myEvent.Project - uid := uuid.NewSHA1(uuid.NameSpaceX500, []byte(key)).String() + // The library github.com/google/uuid is used + key := myEvent.Id + myEvent.Project + uid := uuid.NewSHA1(uuid.NameSpaceX500, []byte(key)).String() client.Enqueue(posthog.Capture{ Uuid: uid, DistinctId: "test-user", diff --git a/capture.go b/capture.go index 936153b..31db77d 100644 --- a/capture.go +++ b/capture.go @@ -74,8 +74,8 @@ func (msg Capture) APIfy() APIMessage { } apified := CaptureInApi{ - Uuid: msg.Uuid, Type: msg.Type, + Uuid: msg.Uuid, Library: library, LibraryVersion: libraryVersion, Timestamp: msg.Timestamp, From 5893386ca1f4fbf18f5cd843d91c05dfeb78e52b Mon Sep 17 00:00:00 2001 From: "evgeny.iva" Date: Wed, 14 Aug 2024 19:32:09 +0300 Subject: [PATCH 4/7] rename package --- .github/workflows/bump-version.yml | 2 +- CHANGELOG.md | 28 ++++++++++++++-------------- README.md | 8 ++++---- cmd/cli/main.go | 4 ++-- examples/capture.go | 2 +- examples/featureflags.go | 2 +- go.mod | 2 +- posthog_test.go | 2 +- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index f591479..a6ea112 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -59,7 +59,7 @@ jobs: run: | current_version="${{ steps.bump-version.outputs.current_version }}" new_version="${{ steps.bump-version.outputs.new_version }}" - echo -e "## $new_version\n\n* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v${current_version}...v${new_version})\n\n$(cat CHANGELOG.md)" > CHANGELOG.md + echo -e "## $new_version\n\n* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v${current_version}...v${new_version})\n\n$(cat CHANGELOG.md)" > CHANGELOG.md - name: Commit and push changes env: diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f4a33d..2433cec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,59 +7,59 @@ ## 1.2.16 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.15...v1.2.16) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v1.2.15...v1.2.16) ## 1.2.15 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.14...v1.2.15) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v1.2.14...v1.2.15) ## 1.2.14 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.13...v1.2.14) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v1.2.13...v1.2.14) ## 1.2.13 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.12...v1.2.13) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v1.2.12...v1.2.13) ## 1.2.12 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.12) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.12) ## 1.2.11 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.11) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.11) ## 1.2.10 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.10) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.10) ## 1.2.9 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.9) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.9) ## 1.2.8 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.8) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.8) ## 1.2.7 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.7) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.7) ## 1.2.6 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.6) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.6) ## 1.2.5 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.5) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.5) ## 1.2.4 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.4) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.4) ## 1.2.3 -* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.3) +* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.3) ## 1.2.2 - 2024-08-08 diff --git a/README.md b/README.md index 97ece82..49cc6e4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Specifically, the [Go integration](https://posthog.com/docs/integrations/go-inte Install posthog to your gopath ```bash -$ go get github.com/posthog/posthog-go +$ go get github.com/Cado-Labs/posthog-go ``` Go 🦔! @@ -17,7 +17,7 @@ package main import ( "os" - "github.com/posthog/posthog-go" + "github.com/Cado-Labs/posthog-go" ) func main() { @@ -98,11 +98,11 @@ module example/posthog-go-app go 1.22.5 -require github.com/posthog/posthog-go v0.0.0-20240327112532-87b23fe11103 +require github.com/Cado-Labs/posthog-go v0.0.0-20240327112532-87b23fe11103 require github.com/google/uuid v1.3.0 // indirect -replace github.com/posthog/posthog-go => /path-to-your-local/posthog-go +replace github.com/Cado-Labs/posthog-go => /path-to-your-local/posthog-go ``` ## Questions? diff --git a/cmd/cli/main.go b/cmd/cli/main.go index c58317d..447f6fa 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -6,7 +6,7 @@ import ( "log" "os" - "github.com/posthog/posthog-go" + "github.com/Cado-Labs/posthog-go" "github.com/urfave/cli" ) @@ -91,7 +91,7 @@ func main() { os.Exit(1) } - return nil + return nil } err := app.Run(os.Args) diff --git a/examples/capture.go b/examples/capture.go index 9b46913..87c8fcf 100644 --- a/examples/capture.go +++ b/examples/capture.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/posthog/posthog-go" + "github.com/Cado-Labs/posthog-go" ) func TestCapture() { diff --git a/examples/featureflags.go b/examples/featureflags.go index 72a9705..03c3de7 100644 --- a/examples/featureflags.go +++ b/examples/featureflags.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/posthog/posthog-go" + "github.com/Cado-Labs/posthog-go" ) func TestIsFeatureEnabled() { diff --git a/go.mod b/go.mod index 043d70d..64aadf1 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/posthog/posthog-go +module github.com/Cado-Labs/posthog-go go 1.18 diff --git a/posthog_test.go b/posthog_test.go index 85ffbcf..bfa25bf 100644 --- a/posthog_test.go +++ b/posthog_test.go @@ -1686,7 +1686,7 @@ func TestCaptureSendFlags(t *testing.T) { defer client.Close() // Without this call client.Close hangs forever - // Ref: https://github.com/PostHog/posthog-go/issues/28 + // Ref: https://github.com/Cado-Labs/posthog-go/issues/28 client.IsFeatureEnabled( FeatureFlagPayload{ Key: "simpleFlag", From 4fabcef2a731cc21522a7d39c9b4f3ddac1331c3 Mon Sep 17 00:00:00 2001 From: "evgeny.iva" Date: Wed, 14 Aug 2024 19:33:17 +0300 Subject: [PATCH 5/7] rollback --- .github/workflows/bump-version.yml | 2 +- CHANGELOG.md | 28 ++++++++++++++-------------- README.md | 8 ++++---- cmd/cli/main.go | 2 +- examples/capture.go | 2 +- examples/featureflags.go | 2 +- go.mod | 2 +- posthog_test.go | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/.github/workflows/bump-version.yml b/.github/workflows/bump-version.yml index a6ea112..f591479 100644 --- a/.github/workflows/bump-version.yml +++ b/.github/workflows/bump-version.yml @@ -59,7 +59,7 @@ jobs: run: | current_version="${{ steps.bump-version.outputs.current_version }}" new_version="${{ steps.bump-version.outputs.new_version }}" - echo -e "## $new_version\n\n* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v${current_version}...v${new_version})\n\n$(cat CHANGELOG.md)" > CHANGELOG.md + echo -e "## $new_version\n\n* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v${current_version}...v${new_version})\n\n$(cat CHANGELOG.md)" > CHANGELOG.md - name: Commit and push changes env: diff --git a/CHANGELOG.md b/CHANGELOG.md index 2433cec..9f4a33d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,59 +7,59 @@ ## 1.2.16 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v1.2.15...v1.2.16) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.15...v1.2.16) ## 1.2.15 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v1.2.14...v1.2.15) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.14...v1.2.15) ## 1.2.14 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v1.2.13...v1.2.14) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.13...v1.2.14) ## 1.2.13 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v1.2.12...v1.2.13) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.12...v1.2.13) ## 1.2.12 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.12) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.12) ## 1.2.11 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.11) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.11) ## 1.2.10 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.10) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.10) ## 1.2.9 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.9) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.9) ## 1.2.8 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.8) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.8) ## 1.2.7 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.7) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.7) ## 1.2.6 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.6) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.6) ## 1.2.5 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.5) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.5) ## 1.2.4 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.4) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.4) ## 1.2.3 -* [Full Changelog](https://github.com/Cado-Labs/posthog-go/compare/v...v1.2.3) +* [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.3) ## 1.2.2 - 2024-08-08 diff --git a/README.md b/README.md index 49cc6e4..97ece82 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Specifically, the [Go integration](https://posthog.com/docs/integrations/go-inte Install posthog to your gopath ```bash -$ go get github.com/Cado-Labs/posthog-go +$ go get github.com/posthog/posthog-go ``` Go 🦔! @@ -17,7 +17,7 @@ package main import ( "os" - "github.com/Cado-Labs/posthog-go" + "github.com/posthog/posthog-go" ) func main() { @@ -98,11 +98,11 @@ module example/posthog-go-app go 1.22.5 -require github.com/Cado-Labs/posthog-go v0.0.0-20240327112532-87b23fe11103 +require github.com/posthog/posthog-go v0.0.0-20240327112532-87b23fe11103 require github.com/google/uuid v1.3.0 // indirect -replace github.com/Cado-Labs/posthog-go => /path-to-your-local/posthog-go +replace github.com/posthog/posthog-go => /path-to-your-local/posthog-go ``` ## Questions? diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 447f6fa..da30b09 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -6,7 +6,7 @@ import ( "log" "os" - "github.com/Cado-Labs/posthog-go" + "github.com/posthog/posthog-go" "github.com/urfave/cli" ) diff --git a/examples/capture.go b/examples/capture.go index 87c8fcf..9b46913 100644 --- a/examples/capture.go +++ b/examples/capture.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/Cado-Labs/posthog-go" + "github.com/posthog/posthog-go" ) func TestCapture() { diff --git a/examples/featureflags.go b/examples/featureflags.go index 03c3de7..72a9705 100644 --- a/examples/featureflags.go +++ b/examples/featureflags.go @@ -4,7 +4,7 @@ import ( "fmt" "time" - "github.com/Cado-Labs/posthog-go" + "github.com/posthog/posthog-go" ) func TestIsFeatureEnabled() { diff --git a/go.mod b/go.mod index 64aadf1..043d70d 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/Cado-Labs/posthog-go +module github.com/posthog/posthog-go go 1.18 diff --git a/posthog_test.go b/posthog_test.go index bfa25bf..85ffbcf 100644 --- a/posthog_test.go +++ b/posthog_test.go @@ -1686,7 +1686,7 @@ func TestCaptureSendFlags(t *testing.T) { defer client.Close() // Without this call client.Close hangs forever - // Ref: https://github.com/Cado-Labs/posthog-go/issues/28 + // Ref: https://github.com/PostHog/posthog-go/issues/28 client.IsFeatureEnabled( FeatureFlagPayload{ Key: "simpleFlag", From 101b8791b1fcb854c27d9f324568d91103569c01 Mon Sep 17 00:00:00 2001 From: "evgeny.iva" Date: Mon, 19 Aug 2024 15:17:56 +0300 Subject: [PATCH 6/7] rollback all --- CHANGELOG.md | 9 ++------ README.md | 12 ----------- capture.go | 6 +----- config.go | 19 +++++++++++++++++ fixtures/test-enqueue-capture-with-uuid.json | 22 -------------------- fixtures/test-enqueue-capture.json | 3 +-- fixtures/test-interval-capture.json | 3 +-- fixtures/test-many-capture.json | 9 +++----- fixtures/test-merge-capture.json | 3 +-- fixtures/test-timestamp-capture.json | 3 +-- go.mod | 5 ++++- go.sum | 4 +++- posthog_test.go | 16 +++++++++----- 13 files changed, 47 insertions(+), 67 deletions(-) delete mode 100644 fixtures/test-enqueue-capture-with-uuid.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f4a33d..e2ae27b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,3 @@ -# Changelog - -## 1.3.0 - 2024-08-14 - -1. Added the ability to explicitly specify the uuid for capturing events. If uuid is not specified, Posthog will calculate it automatically (suitable for most cases). -2. Removed unused config function `uid()`. - ## 1.2.16 * [Full Changelog](https://github.com/PostHog/posthog-go/compare/v1.2.15...v1.2.16) @@ -61,6 +54,8 @@ * [Full Changelog](https://github.com/PostHog/posthog-go/compare/v...v1.2.3) +# Changelog + ## 1.2.2 - 2024-08-08 1. Adds logging to error responses from the PostHog API so that users can see how a call failed (e.g. rate limiting) from the SDK itself. diff --git a/README.md b/README.md index 97ece82..4a263a8 100644 --- a/README.md +++ b/README.md @@ -62,18 +62,6 @@ func main() { Properties: posthog.NewProperties(). Set("$current_url", "https://example.com"), }) - - // Capture event with calculated uuid to deduplicate repeated events. - // The library github.com/google/uuid is used - key := myEvent.Id + myEvent.Project - uid := uuid.NewSHA1(uuid.NameSpaceX500, []byte(key)).String() - client.Enqueue(posthog.Capture{ - Uuid: uid, - DistinctId: "test-user", - Event: "$pageview", - Properties: posthog.NewProperties(). - Set("$current_url", "https://example.com"), - }) // Check if a feature flag is enabled isMyFlagEnabled, err := client.IsFeatureEnabled( diff --git a/capture.go b/capture.go index 31db77d..b54acde 100644 --- a/capture.go +++ b/capture.go @@ -9,9 +9,7 @@ type Capture struct { // This field is exported for serialization purposes and shouldn't be set by // the application, its value is always overwritten by the library. Type string - // You don't usually need to specify this field - Posthog will generate it automatically. - // Use it only when necessary - for example, to prevent duplicate events. - Uuid string + DistinctId string Event string Timestamp time.Time @@ -46,7 +44,6 @@ func (msg Capture) Validate() error { type CaptureInApi struct { Type string `json:"type"` - Uuid string `json:"uuid"` Library string `json:"library"` LibraryVersion string `json:"library_version"` Timestamp time.Time `json:"timestamp"` @@ -75,7 +72,6 @@ func (msg Capture) APIfy() APIMessage { apified := CaptureInApi{ Type: msg.Type, - Uuid: msg.Uuid, Library: library, LibraryVersion: libraryVersion, Timestamp: msg.Timestamp, diff --git a/config.go b/config.go index 8e120a1..51ff05d 100644 --- a/config.go +++ b/config.go @@ -3,6 +3,8 @@ package posthog import ( "net/http" "time" + + "github.com/google/uuid" ) // Instances of this type carry the different configuration options that may @@ -77,6 +79,12 @@ type Config struct { // If not set the client will fallback to use a default retry policy. RetryAfter func(int) time.Duration + // A function called by the client to generate unique message identifiers. + // The client uses a UUID generator if none is provided. + // This field is not exported and only exposed internally to let unit tests + // mock the id generation. + uid func() string + // A function called by the client to get the current time, `time.Now` is // used by default. // This field is not exported and only exposed internally to let unit tests @@ -165,6 +173,10 @@ func makeConfig(c Config) Config { c.RetryAfter = DefaultBacko().Duration } + if c.uid == nil { + c.uid = uid + } + if c.now == nil { c.now = time.Now } @@ -175,3 +187,10 @@ func makeConfig(c Config) Config { return c } + +// This function returns a string representation of a UUID, it's the default +// function used for generating unique IDs. +func uid() string { + new_uuid, _ := uuid.NewRandom() + return new_uuid.String() +} diff --git a/fixtures/test-enqueue-capture-with-uuid.json b/fixtures/test-enqueue-capture-with-uuid.json deleted file mode 100644 index fcd5fe7..0000000 --- a/fixtures/test-enqueue-capture-with-uuid.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "api_key": "Csyjlnlun3OzyNJAafdlv", - "batch": [ - { - "distinct_id": "123456", - "event": "Download", - "library": "posthog-go", - "library_version": "1.0.0", - "properties": { - "$lib": "posthog-go", - "$lib_version": "1.0.0", - "application": "PostHog Go", - "platform": "macos", - "version": "1.0.0" - }, - "send_feature_flags": false, - "timestamp": "2009-11-10T23:00:00Z", - "type": "capture", - "uuid": "11111111-1111-1111-1111-111111111111" - } - ] -} diff --git a/fixtures/test-enqueue-capture.json b/fixtures/test-enqueue-capture.json index 2120bfd..0b96c42 100644 --- a/fixtures/test-enqueue-capture.json +++ b/fixtures/test-enqueue-capture.json @@ -15,8 +15,7 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture", - "uuid": "" + "type": "capture" } ] } diff --git a/fixtures/test-interval-capture.json b/fixtures/test-interval-capture.json index 2120bfd..0b96c42 100644 --- a/fixtures/test-interval-capture.json +++ b/fixtures/test-interval-capture.json @@ -15,8 +15,7 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture", - "uuid": "" + "type": "capture" } ] } diff --git a/fixtures/test-many-capture.json b/fixtures/test-many-capture.json index 87d52b2..7fbd131 100644 --- a/fixtures/test-many-capture.json +++ b/fixtures/test-many-capture.json @@ -14,8 +14,7 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture", - "uuid": "" + "type": "capture" }, { "distinct_id": "123456", @@ -30,8 +29,7 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture", - "uuid": "" + "type": "capture" }, { "distinct_id": "123456", @@ -46,8 +44,7 @@ }, "send_feature_flags": false, "timestamp": "2009-11-10T23:00:00Z", - "type": "capture", - "uuid": "" + "type": "capture" } ] } diff --git a/fixtures/test-merge-capture.json b/fixtures/test-merge-capture.json index e5d7a07..d754fdd 100644 --- a/fixtures/test-merge-capture.json +++ b/fixtures/test-merge-capture.json @@ -16,8 +16,7 @@ }, "send_feature_flags": false, "timestamp": "2015-07-10T23:00:00Z", - "type": "capture", - "uuid": "" + "type": "capture" } ] } diff --git a/fixtures/test-timestamp-capture.json b/fixtures/test-timestamp-capture.json index f863e41..94d6e36 100644 --- a/fixtures/test-timestamp-capture.json +++ b/fixtures/test-timestamp-capture.json @@ -15,8 +15,7 @@ }, "send_feature_flags": false, "timestamp": "2015-07-10T23:00:00Z", - "type": "capture", - "uuid": "" + "type": "capture" } ] } diff --git a/go.mod b/go.mod index 043d70d..036d7d3 100644 --- a/go.mod +++ b/go.mod @@ -2,7 +2,10 @@ module github.com/posthog/posthog-go go 1.18 -require github.com/urfave/cli v1.22.5 +require ( + github.com/google/uuid v1.3.0 + github.com/urfave/cli v1.22.5 +) require ( github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect diff --git a/go.sum b/go.sum index 74dc48f..03d0eb7 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= @@ -10,4 +12,4 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV github.com/urfave/cli v1.22.5 h1:lNq9sAHXK2qfdI8W+GRItjCEkI+2oR4d+MEHy1CKXoU= github.com/urfave/cli v1.22.5/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= \ No newline at end of file diff --git a/posthog_test.go b/posthog_test.go index 85ffbcf..2daf1c6 100644 --- a/posthog_test.go +++ b/posthog_test.go @@ -152,6 +152,8 @@ func fixture(name string) string { return string(b) } +func mockId() string { return "I'm unique" } + func mockTime() time.Time { // time.Unix(0, 0) fails on Circle return time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC) @@ -189,11 +191,11 @@ func ExampleCapture() { Endpoint: server.URL, BatchSize: 1, now: mockTime, + uid: mockId, }) defer client.Close() client.Enqueue(Capture{ - Uuid: "00000000-0000-0000-0000-000000000000", Event: "Download", DistinctId: "123456", Properties: Properties{ @@ -223,8 +225,7 @@ func ExampleCapture() { // }, // "send_feature_flags": false, // "timestamp": "2009-11-10T23:00:00Z", - // "type": "capture", - // "uuid": "00000000-0000-0000-0000-000000000000" + // "type": "capture" // } // ] // } @@ -296,9 +297,8 @@ func TestEnqueue(t *testing.T) { }, "*capture": { - strings.TrimSpace(fixture("test-enqueue-capture-with-uuid.json")), + strings.TrimSpace(fixture("test-enqueue-capture.json")), &Capture{ - Uuid: "11111111-1111-1111-1111-111111111111", Event: "Download", DistinctId: "123456", Properties: Properties{ @@ -320,6 +320,7 @@ func TestEnqueue(t *testing.T) { Logger: t, BatchSize: 1, now: mockTime, + uid: mockId, }) defer client.Close() @@ -377,6 +378,7 @@ func TestCaptureWithInterval(t *testing.T) { Verbose: true, Logger: t, now: mockTime, + uid: mockId, }) defer client.Close() @@ -413,6 +415,7 @@ func TestCaptureWithTimestamp(t *testing.T) { Logger: t, BatchSize: 1, now: mockTime, + uid: mockId, }) defer client.Close() @@ -446,6 +449,7 @@ func TestCaptureWithDefaultProperties(t *testing.T) { Logger: t, BatchSize: 1, now: mockTime, + uid: mockId, }) defer client.Close() @@ -478,6 +482,7 @@ func TestCaptureMany(t *testing.T) { Logger: t, BatchSize: 3, now: mockTime, + uid: mockId, }) defer client.Close() @@ -1680,6 +1685,7 @@ func TestCaptureSendFlags(t *testing.T) { Logger: t, BatchSize: 1, now: mockTime, + uid: mockId, PersonalApiKey: "some very secret key", }) From 46fabd4d5c3403766aa812f810b223bfbb57e360 Mon Sep 17 00:00:00 2001 From: "evgeny.iva" Date: Sun, 25 Aug 2024 14:27:50 +0300 Subject: [PATCH 7/7] init --- feature_flags_test.go | 6 +++--- message.go | 2 +- posthog.go | 2 +- posthog_test.go | 10 +++++----- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/feature_flags_test.go b/feature_flags_test.go index a55320d..3f19ca1 100644 --- a/feature_flags_test.go +++ b/feature_flags_test.go @@ -332,7 +332,7 @@ func TestFlagGroup(t *testing.T) { w.Write([]byte(fixture("test-decide-v3.json"))) } else if strings.HasPrefix(r.URL.Path, "/api/feature_flag/local_evaluation") { w.Write([]byte(fixture("feature_flag/test-flag-group-properties.json"))) - } else if strings.HasPrefix(r.URL.Path, "/batch/") { + } else if strings.HasPrefix(r.URL.Path, "/capture/") { // Ignore batch requests } else { t.Error("Unknown request made by library") @@ -4436,7 +4436,7 @@ func TestFlagWithTimeoutExceeded(t *testing.T) { w.Write([]byte(fixture("test-decide-v3.json"))) } else if strings.HasPrefix(r.URL.Path, "/api/feature_flag/local_evaluation") { w.Write([]byte(fixture("feature_flag/test-flag-group-properties.json"))) - } else if strings.HasPrefix(r.URL.Path, "/batch/") { + } else if strings.HasPrefix(r.URL.Path, "/capture/") { // Ignore batch requests } else { t.Error("Unknown request made by library") @@ -4538,7 +4538,7 @@ func TestFlagDefinitionsWithTimeoutExceeded(t *testing.T) { } else if strings.HasPrefix(r.URL.Path, "/api/feature_flag/local_evaluation") { time.Sleep(11 * time.Second) w.Write([]byte(fixture("feature_flag/test-flag-group-properties.json"))) - } else if strings.HasPrefix(r.URL.Path, "/batch/") { + } else if strings.HasPrefix(r.URL.Path, "/capture/") { // Ignore batch requests } else { t.Error("Unknown request made by library") diff --git a/message.go b/message.go index 2edd4ed..7f00a97 100644 --- a/message.go +++ b/message.go @@ -51,7 +51,7 @@ func makeTimestamp(t time.Time, def time.Time) time.Time { return t } -// This structure represents objects sent to the /batch/ endpoint. We don't +// This structure represents objects sent to the /capture/ endpoint. We don't // export this type because it's only meant to be used internally to send groups // of messages in one API call. type batch struct { diff --git a/posthog.go b/posthog.go index d6ffcfd..72925d7 100644 --- a/posthog.go +++ b/posthog.go @@ -462,7 +462,7 @@ func (c *client) send(msgs []message) { // Upload serialized batch message. func (c *client) upload(b []byte) error { - url := c.Endpoint + "/batch/" + url := c.Endpoint + "/capture/" req, err := http.NewRequest("POST", url, bytes.NewReader(b)) if err != nil { c.Errorf("creating request - %s", err) diff --git a/posthog_test.go b/posthog_test.go index e36e619..49b60d4 100644 --- a/posthog_test.go +++ b/posthog_test.go @@ -911,7 +911,7 @@ func TestGetFeatureFlagPayloadWithNoPersonalApiKey(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if strings.HasPrefix(r.URL.Path, "/decide") { w.Write([]byte(fixture("test-decide-v3.json"))) - } else if !strings.HasPrefix(r.URL.Path, "/batch") { + } else if !strings.HasPrefix(r.URL.Path, "/capture") { t.Errorf("client called an endpoint it shouldn't have: %s", r.URL.Path) } })) @@ -1097,7 +1097,7 @@ func TestGetFeatureFlagWithNoPersonalApiKey(t *testing.T) { server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { if strings.HasPrefix(r.URL.Path, "/decide") { w.Write([]byte(fixture("test-decide-v3.json"))) - } else if !strings.HasPrefix(r.URL.Path, "/batch") { + } else if !strings.HasPrefix(r.URL.Path, "/capture") { t.Errorf("client called an endpoint it shouldn't have: %s", r.URL.Path) } })) @@ -1543,7 +1543,7 @@ func TestComplexFlag(t *testing.T) { w.Write([]byte(fixture("test-decide-v3.json"))) } else if strings.HasPrefix(r.URL.Path, "/api/feature_flag/local_evaluation") { w.Write([]byte(fixture("test-api-feature-flag.json"))) - } else if !strings.HasPrefix(r.URL.Path, "/batch") { + } else if !strings.HasPrefix(r.URL.Path, "/capture") { t.Errorf("client called an endpoint it shouldn't have") } })) @@ -1595,7 +1595,7 @@ func TestMultiVariateFlag(t *testing.T) { w.Write([]byte(fixture("test-decide-v3.json"))) } else if strings.HasPrefix(r.URL.Path, "/api/feature_flag/local_evaluation") { w.Write([]byte("{}")) - } else if !strings.HasPrefix(r.URL.Path, "/batch") { + } else if !strings.HasPrefix(r.URL.Path, "/capture") { t.Errorf("client called an endpoint it shouldn't have") } })) @@ -1647,7 +1647,7 @@ func TestDisabledFlag(t *testing.T) { w.Write([]byte(fixture("test-decide-v3.json"))) } else if strings.HasPrefix(r.URL.Path, "/api/feature_flag/local_evaluation") { w.Write([]byte("{}")) - } else if !strings.HasPrefix(r.URL.Path, "/batch") { + } else if !strings.HasPrefix(r.URL.Path, "/capture") { t.Errorf("client called an endpoint it shouldn't have") } }))