How to replace setExtras to provide metadata at message-level? #3285
dirtyhenry
started this conversation in
General
Replies: 1 comment
-
Hello @dirtyhenry You just need to use func remoteLog(
level: Logger.Level,
message: Logger.Message,
metadata: Logger.Metadata?
) {
let prettyMetadata = ...transform metadata into a human-readable string...
let userInfo = ["label": label, "metadata": prettyMetadata ?? "empty"]
// Send to Sentry
SentrySDK.capture(message: "\(message)") { scope in
scope.setContext(value: userInfo, key: "userInfo")
scope.setLevel(level.sentryLevel)
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I just realised today that
setExtra
had been deprecated in version 8.x.I was using it extensively to attach metadata linked to events and messages, as opposed to the global state of the application, like so:
I now read in the docs:
But my understanding of structured context is that it is relevant at a larger scale ie the application level, as opposed to just the message being captured.
I felt using extras had many benefits:
Am I missing something here? What should I do to replace my deprecated usage of
setExtras
? 🙏Beta Was this translation helpful? Give feedback.
All reactions