Skip to content

Commit

Permalink
Fixes: #118
Browse files Browse the repository at this point in the history
  • Loading branch information
HazAT committed Nov 23, 2023
1 parent 9f9370f commit 4264095
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/core/_fixtures/envelope_php.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"event_id":"dcef34f4069c4e2db2fe59fa028ab8a8","sent_at":"2023-11-22T12:11:43Z","dsn":"https://c95c00c52d4177f7bf66a76dd2895550@o447951.ingest.sentry.io/4506269264052224","sdk":{"name":"sentry.php.laravel","version":"4.0.0"},"trace":{"trace_id":"633009776f2a4478a01bb8330058edc5","sample_rate":"1","transaction":"/","public_key":"c95c00c52d4177f7bf66a76dd2895550","environment":"local","sampled":"true"}}
{"type":"transaction","content_type":"application/json"}
{"timestamp":1700655103.176607,"platform":"php","sdk":{"name":"sentry.php.laravel","version":"4.0.0"},"start_timestamp":1700655103.12654,"transaction":"/","server_name":"myMacMiniM1.local","environment":"local","contexts":{"os":{"name":"Darwin","version":"23.1.0","build":"Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103","kernel_version":"Darwin myMacMiniM1.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:28:12 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T8103 arm64"},"runtime":{"name":"php","version":"8.2.12"},"trace":{"span_id":"407e000ff293467d","trace_id":"633009776f2a4478a01bb8330058edc5","op":"http.server","status":"ok","data":{"url":"/","http.request.method":"GET"}},"response":{"status_code":200}},"breadcrumbs":{"values":[{"type":"navigation","category":"route","level":"info","timestamp":1700655103.172407,"message":"/"}]},"request":{"url":"http://127.0.0.1:8000/","method":"GET","headers":{"host":["127.0.0.1:8000"],"connection":["keep-alive"],"cache-control":["max-age=0"],"sec-ch-ua":["\"Google Chrome\";v=\"119\", \"Chromium\";v=\"119\", \"Not?A_Brand\";v=\"24\""],"sec-ch-ua-mobile":["?0"],"sec-ch-ua-platform":["\"macOS\""],"dnt":["1"],"upgrade-insecure-requests":["1"],"user-agent":["Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36"],"accept":["text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7"],"sec-fetch-site":["same-origin"],"sec-fetch-mode":["navigate"],"sec-fetch-user":["?1"],"sec-fetch-dest":["document"],"referer":["http://127.0.0.1:8000/"],"accept-encoding":["gzip, deflate, br"],"accept-language":["en-GB,en;q=0.9,de-DE;q=0.8,de;q=0.7,zh-CN;q=0.6,zh;q=0.5,pl;q=0.4,en-US;q=0.3,ja;q=0.2,fr;q=0.1,ko;q=0.1,nl;q=0.1,it;q=0.1,it-IT;q=0.1,it-CH;q=0.1,la;q=0.1"],"cookie":["[Filtered]"]}},"spans":[{"span_id":"76ba00ee3fdb424a","trace_id":"633009776f2a4478a01bb8330058edc5","start_timestamp":1700655103.12654,"parent_span_id":"407e000ff293467d","timestamp":1700655103.170367,"op":"app.bootstrap"},{"span_id":"5668efea48894e25","trace_id":"633009776f2a4478a01bb8330058edc5","start_timestamp":1700655103.170367,"parent_span_id":"407e000ff293467d","timestamp":1700655103.17625,"op":"middleware.handle"},{"span_id":"c9187688fb514257","trace_id":"633009776f2a4478a01bb8330058edc5","start_timestamp":1700655103.174456,"parent_span_id":"5668efea48894e25","timestamp":1700655103.174599,"description":"Closure","op":"http.route"},{"span_id":"39a92152f5b84f77","trace_id":"633009776f2a4478a01bb8330058edc5","start_timestamp":1700655103.174639,"parent_span_id":"5668efea48894e25","timestamp":1700655103.175342,"op":"http.route.response"},{"span_id":"b5cb4bd9cd9e4b04","trace_id":"633009776f2a4478a01bb8330058edc5","start_timestamp":1700655103.174774,"parent_span_id":"39a92152f5b84f77","timestamp":1700655103.17526,"description":"welcome","op":"view.render"}],"transaction_info":{"source":"route"}}
7 changes: 7 additions & 0 deletions packages/core/src/integrations/sentry/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,11 @@ describe('Sentry Integration', () => {
const envelope = fs.readFileSync('./_fixtures/envelope_python.txt', 'utf-8');
expect(processEnvelope({ data: envelope, contentType: 'test' })).not.toBe(undefined);
});

test('Process PHP Transaction Envelope', () => {
const envelope = fs.readFileSync('./_fixtures/envelope_php.txt', 'utf-8');
const processedEnvelope = processEnvelope({ data: envelope, contentType: 'test' });
expect(processedEnvelope).not.toBe(undefined);
expect(processedEnvelope.event[1][0][1].type).toEqual('transaction');
});
});
6 changes: 6 additions & 0 deletions packages/core/src/integrations/sentry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ export function processEnvelope({ data }: RawEventContext) {
continue;
}
items.push([JSON.parse(rawEntries[i]), JSON.parse(rawEntries[i + 1])]);
// get type attribute from first and put it into the second
// this is needed because the type is not part of the envelope
// but we need it to determine the severity
if (items[i / 2][0].type) {
items[i / 2][1].type = items[i / 2][0].type;
}
}

const envelope = [header, items] as Envelope;
Expand Down

0 comments on commit 4264095

Please sign in to comment.