Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize properties map when sending feature flags #26

Merged
merged 2 commits into from
Feb 8, 2024

Conversation

zaynetro
Copy link
Contributor

When capturing an event with SendFeatureFlags set to true and no properties defined posthog panics with nil pointer.

Panic:

github.com/posthog/posthog-go.(*client).Enqueue(0x4000abba00, {0x420b130?, 0x40015705a0?)

  /root/go/pkg/mod/github.com/posthog/[email protected]/posthog.go:194

Example:

client.Enqueue(posthog.Capture{
	DistinctId: user.ID,
	Event:      "test_event",
	SendFeatureFlags: true,
})

When capturing an event with SendFeatureFlags set to true and no
properties defined posthog panics with nil pointer.

Panic:

```
github.com/posthog/posthog-go.(*client).Enqueue(0x4000abba00, {0x420b130?, 0x40015705a0?)
    /root/go/pkg/mod/github.com/posthog/[email protected]/posthog.go:194
```

Example:

```go
client.Enqueue(posthog.Capture{
	DistinctId: user.ID,
	Event:      "test_event",
	SendFeatureFlags: true,
})
```
@@ -189,6 +189,11 @@ func (c *client) Enqueue(msg Message) (err error) {
if err != nil {
c.Errorf("unable to get feature variants - %s", err)
}

if m.Properties == nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great catch, thanks @zaynetro , could you please also add a testcase for sendFeatureFlags in capture?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test

@neilkakkar neilkakkar merged commit d15691c into PostHog:master Feb 8, 2024
1 check passed
@neilkakkar
Copy link
Contributor

lovely, thanks!

@zaynetro zaynetro deleted the fix-capture-nil-panic branch February 8, 2024 11:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants