Closed marvint24 closed 1 month ago
device
is a reserved key, that expects type Sentry.Protocol.Device
. It's a typed field you can access with context.Device.Name
for example. You don't need to assign a new instance of a hashmap.
Same for OS.
You can define with a key as string any custom context, like ['my_device']
should work with that syntax
I see. This seams to work:
Edit-SentryScope {
$_.Contexts.Device.Name = "My device"
}
Is this the right approach?
Is this the right approach?
yes, that looks correct.
Here's the link to the contexts available in .NET https://github.com/getsentry/sentry-dotnet/blob/main/src/Sentry/SentryContexts.cs
and specifically the device context: https://github.com/getsentry/sentry-dotnet/blob/main/src/Sentry/Protocol/Device.cs
okay, nice! Thank you 👍
Environment
Version 0.1.0
PowerShell:
Windows PowerShell 5.1 + PowerShell 7.4.2
Steps to Reproduce
Expected Result
If I understood https://docs.sentry.io/platforms/powershell/enriching-events/context/ correctly you should be able to enhance the context. For "os" it is working, but for "device" it is not.
(Maybe it would also be useful if user.username is default: $env:username and device.name is $env:computername)
Actual Result
You get this error:
[Sentry] An error occurred when capturing the event 5a38d6ae53214facb309aec8c3395c18. Expected a type of Sentry.Protocol.Device to exist for the key 'device'. Instead found a System.Collections.Hashtable. The likely cause of this is that the value for 'device' has been incorrectly set to an instance of a different type.