/// <summary> /// Creates an envelope that contains a single event. /// </summary> public static Envelope FromEvent( SentryEvent @event, IDiagnosticLogger?logger = null, IReadOnlyCollection <Attachment>?attachments = null, SessionUpdate?sessionUpdate = null) { var header = CreateHeader(@event.EventId); var items = new List <EnvelopeItem> { EnvelopeItem.FromEvent(@event) }; if (attachments is not null) { foreach (var attachment in attachments) { try { items.Add(EnvelopeItem.FromAttachment(attachment)); } catch (Exception exception) { if (logger is null) { throw; } logger.LogError("Failed to add attachment: {0}.", exception, attachment.FileName); } } } if (sessionUpdate is not null) { items.Add(EnvelopeItem.FromSession(sessionUpdate)); } return(new Envelope(header, items)); }
/// <summary> /// Creates an envelope that contains a single event. /// </summary> public static Envelope FromEvent( SentryEvent @event, IReadOnlyCollection <Attachment>?attachments = null, SessionUpdate?sessionUpdate = null) { var header = CreateHeader(@event.EventId); var items = new List <EnvelopeItem> { EnvelopeItem.FromEvent(@event) }; if (attachments is not null) { items.AddRange(attachments.Select(EnvelopeItem.FromAttachment)); } if (sessionUpdate is not null) { items.Add(EnvelopeItem.FromSession(sessionUpdate)); } return(new Envelope(header, items)); }