| 1 | package Sentry::Envelope; | ||
| 2 | use Mojo::Base -base, -signatures; | ||
| 3 | |||
| 4 | use Mojo::JSON qw(encode_json); | ||
| 5 | |||
| 6 | has event_id => undef; | ||
| 7 | has headers => sub ($self) { { | ||
| 8 | event_id => $self->event_id, | ||
| 9 | |||
| 10 | # sent_at => time | ||
| 11 | } }; | ||
| 12 | has body => sub { {} }; | ||
| 13 | has sample_rates => sub { [{ id => "client_rate", rate => "1" }] }; | ||
| 14 | has type => 'transaction'; | ||
| 15 | has item_headers => | ||
| 16 | sub ($self) { { type => $self->type, sample_rates => $self->sample_rates } }; | ||
| 17 | |||
| 18 | sub serialize ($self) { | ||
| 19 | my @lines = ($self->headers, $self->item_headers, $self->body); | ||
| 20 | return join("\n", map { encode_json($_) } @lines); | ||
| 21 | } | ||
| 22 | |||
| 23 | 1; |