pbrisbin / bugsnag-haskell

Bugsnag error reporter for Haskell
10 stars 7 forks source link

Maybe fields should encode as omitted, not null #25

Closed pbrisbin closed 6 years ago

pbrisbin commented 6 years ago

Concrete example:

bugsnagSession { bsUserId = Just "x" }

Results in a User tab of:

email: null
id: x
username: null

Sometimes, this can even result in a tab of all null values. For example, if you use a simple approach like this:

mUserId <- maybeAuthId
bugsnagSession { bsUserId = mUserId }

This is because we model optional fields as Maybe, but they're encoded as present with null by the standard Aeson encoder. I think this is easy to configure.

As a nice side-benefit, this would also expose any bugs where we fail to POST because we've got a field as Maybe that's actually required (but accepted if present and null).