Skip to content

ref: Use a Context type mapping to map[string]interface{}#444

Merged
phacops merged 9 commits intomasterfrom
pierre/context-as-map-string-interface
May 31, 2022
Merged

ref: Use a Context type mapping to map[string]interface{}#444
phacops merged 9 commits intomasterfrom
pierre/context-as-map-string-interface

Conversation

@phacops
Copy link
Copy Markdown
Contributor

@phacops phacops commented May 25, 2022

When Sentry processes an event, it only accepts a context being a key/value object. This PR aims to enforce we're passing a map[string]interface{} instead of an interface{}.

@phacops phacops requested a review from kamilogorek May 25, 2022 15:37
@phacops phacops force-pushed the pierre/context-as-map-string-interface branch from 49650f9 to f555dc7 Compare May 25, 2022 17:33
Comment thread .pre-commit-config.yaml Outdated
- id: go-fmt
- id: go-imports
- id: golangci-lint
- id: no-go-testing
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you move this to a separate PR?

Comment thread CHANGELOG.md Outdated
Comment thread interfaces.go Outdated
// An EventID must be 32 characters long, lowercase and not have any dashes.
type EventID string

type Context map[string]interface{}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm not sure if we should introduce a concrete Context type. It'll force people to pass sentry.Context explicitly. Where if we'd use type alias, type Context = map[string]interface{}, it'd still work with most cases where people already pass a valid dictionary.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I defined a new type since you mention on Slack it was a v0 and we should strive to make the API as it should. The type alias works too and the difference is minimal so that'll works well too.

@phacops phacops enabled auto-merge (squash) May 31, 2022 15:12
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