@@ -178,27 +178,7 @@ func New(ctx context.Context, name, description string, opts ...Option) Event {
178
178
return (& definition {name : name , description : description }).New (ctx , opts ... )
179
179
}
180
180
181
- var errMarshalData = errors .Define ("marshal_data" , "marshal data" )
182
-
183
181
func marshalData (data any ) (anyPB * anypb.Any , err error ) {
184
- // TODO: https://github.com/TheThingsIndustries/lorawan-stack-support/issues/1163.
185
- // Remove this after the issue is fixed.
186
- defer func () {
187
- if p := recover (); p != nil {
188
- if pErr , ok := p .(error ); ok {
189
- err = errMarshalData .WithCause (pErr )
190
- } else {
191
- err = errMarshalData .WithAttributes ("panic" , p )
192
- }
193
- event := sentryerrors .NewEvent (err )
194
- sentry .CaptureEvent (event )
195
- }
196
- }()
197
-
198
- return mustMarshalData (data )
199
- }
200
-
201
- func mustMarshalData (data any ) (anyPB * anypb.Any , err error ) {
202
182
if protoMessage , ok := data .(proto.Message ); ok {
203
183
anyPB , err = anypb .New (protoMessage )
204
184
if err != nil {
@@ -242,14 +222,47 @@ func Proto(e Event) (*ttnpb.Event, error) {
242
222
pb .Context = ctx
243
223
if evt .data != nil {
244
224
var err error
245
- pb .Data , err = marshalData (e .Data ())
225
+ // TODO: uncomment masrshalData and remove mustMarshalEventData after the issue mentioned
226
+ // below (7632) is fixed.
227
+ // pb.Data, err = marshalData(e.Data())
228
+ pb .Data , err = mustMarshalEventData (e )
246
229
if err != nil {
247
230
return nil , err
248
231
}
249
232
}
250
233
return pb , nil
251
234
}
252
235
236
+ // TODO: remove after issue is resolved
237
+ // https://github.com/TheThingsNetwork/lorawan-stack/issues/7623
238
+ var errMarshalData = errors .Define ("marshal_data" , "marshal data" )
239
+
240
+ func mustMarshalEventData (e Event ) (* anypb.Any , error ) {
241
+ defer func () {
242
+ if p := recover (); p != nil {
243
+ var err error
244
+ if pErr , ok := p .(error ); ok {
245
+ err = errMarshalData .WithCause (pErr ).WithAttributes (
246
+ "event_name" , e .Name (),
247
+ "event_correlation_ids" , e .CorrelationIds (),
248
+ "event_identifiers" , e .Identifiers (),
249
+ )
250
+ } else {
251
+ err = errMarshalData .WithAttributes (
252
+ "panic" , p ,
253
+ "event_name" , e .Name (),
254
+ "event_correlation_ids" , e .CorrelationIds (),
255
+ "event_identifiers" , e .Identifiers (),
256
+ )
257
+ }
258
+ event := sentryerrors .NewEvent (err )
259
+ sentry .CaptureEvent (event )
260
+ }
261
+ }()
262
+
263
+ return marshalData (e .Data ())
264
+ }
265
+
253
266
// FromProto returns the event from its protobuf representation.
254
267
func FromProto (pb * ttnpb.Event ) (Event , error ) {
255
268
ctx , err := unmarshalContext (context .Background (), pb .Context )
0 commit comments