Skip to content

feat: Add attachments API #5004

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 34 commits into from
May 18, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ed65564
Mostly there
timfish Apr 28, 2022
8db6659
Fix tests
timfish Apr 28, 2022
0dd456f
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
timfish Apr 28, 2022
7388581
Fix test spy and add implementation for creating attachment item
timfish Apr 28, 2022
8d70b13
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
timfish Apr 28, 2022
dcef2ab
Load attachments from paths in node
timfish Apr 28, 2022
dbd70d1
Few more minor fixes and additions
timfish Apr 28, 2022
9325e24
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
timfish Apr 30, 2022
1398bfc
Parse binary envelopes in tests
timfish Apr 30, 2022
23e1f90
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
timfish Apr 30, 2022
93960c6
Change `_attachmentsFromScope` return type
timfish Apr 30, 2022
23f4b29
Much improved
timfish Apr 30, 2022
fc3303c
More simplify
timfish May 1, 2022
68e077a
Final newline is optional
timfish May 1, 2022
735812e
Fix gatsby test
timfish May 1, 2022
fe7f49f
Fix node v8/v10
timfish May 1, 2022
22a8f07
Fix node session tests
timfish May 1, 2022
242292f
Don't override filename if it's supplied
timfish May 3, 2022
6d7e979
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
timfish May 3, 2022
d6a8e57
Improve tests
timfish May 3, 2022
0979245
Improve types
timfish May 3, 2022
6cc6d60
Couple more minor fixes
timfish May 3, 2022
232b75b
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
timfish May 3, 2022
99446c7
More type improve
timfish May 3, 2022
6c404f1
Spread headers
timfish May 4, 2022
2e85356
Remove node attachment loading special case
timfish May 5, 2022
2d25f86
Remove the need for custom jest env
timfish May 5, 2022
1731945
Fix gatsby tests
timfish May 6, 2022
250260b
Pass through hint
timfish May 12, 2022
723bfdb
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
timfish May 15, 2022
21a04d8
Lint
timfish May 15, 2022
870ae81
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
timfish May 15, 2022
be927c8
Remove erroneous changes
timfish May 15, 2022
c8d43eb
Review changes
timfish May 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'upstream/7.x' into feat/attachments
  • Loading branch information
timfish committed Apr 30, 2022
commit 9325e24b70b8c53dba487aac4f95f0392a2fdd44
1 change: 0 additions & 1 deletion packages/browser/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BaseClient, Scope, SDK_VERSION } from '@sentry/core';
import { AttachmentItem, ClientOptions, Event, EventHint, Options, Severity, SeverityLevel } from '@sentry/types';
import { getGlobalObject, logger } from '@sentry/utils';

import { eventFromException, eventFromMessage } from './eventbuilder';
import { Breadcrumbs } from './integrations';
Expand Down
19 changes: 18 additions & 1 deletion packages/utils/src/envelope.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Attachment, AttachmentItem, Envelope } from '@sentry/types';
import { Attachment, AttachmentItem, DataCategory, Envelope, EnvelopeItem, EnvelopeItemType } from '@sentry/types';

import { isPrimitive } from './is';

Expand Down Expand Up @@ -125,3 +125,20 @@ export function createAttachmentEnvelopeItem(attachment: Attachment): Attachment
buffer,
];
}

const ITEM_TYPE_TO_DATA_CATEGORY_MAP: Record<EnvelopeItemType, DataCategory> = {
session: 'session',
sessions: 'session',
attachment: 'attachment',
transaction: 'transaction',
event: 'error',
client_report: 'internal',
user_report: 'default',
};

/**
* Maps the type of an envelope item to a data category.
*/
export function envelopeItemTypeToDataCategory(type: EnvelopeItemType): DataCategory {
return ITEM_TYPE_TO_DATA_CATEGORY_MAP[type];
}
22 changes: 18 additions & 4 deletions packages/utils/test/envelope.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { EventEnvelope } from '@sentry/types';

import { addItemToEnvelope, createEnvelope, getEnvelopeType, serializeStringEnvelope } from '../src/envelope';
import { addItemToEnvelope, createEnvelope, forEachEnvelopeItem, serializeStringEnvelope } from '../src/envelope';
import { parseEnvelope } from './testutils';

describe('envelope', () => {
Expand Down Expand Up @@ -49,9 +49,23 @@ describe('envelope', () => {
it('loops through an envelope', () => {
const items: EventEnvelope[1] = [
[{ type: 'event' }, { event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2' }],
[{ type: 'attachment', filename: 'me.txt', length: 6 }, new Uint8Array(6)],
]);
expect(getEnvelopeType(env)).toEqual('event');
[{ type: 'attachment', filename: 'bar.txt', length: 6 }, new Uint8Array(6)],
[{ type: 'attachment', filename: 'foo.txt', length: 6 }, new Uint8Array(6)],
];

const env = createEnvelope<EventEnvelope>(
{ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' },
items,
);

expect.assertions(6);

let iteration = 0;
forEachEnvelopeItem(env, (item, type) => {
expect(item).toBe(items[iteration]);
expect(type).toBe(items[iteration][0].type);
iteration = iteration + 1;
});
});
});
});
You are viewing a condensed version of this merge commit. You can view the full changes here.