Skip to content
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
Fix tests
  • Loading branch information
timfish committed Apr 28, 2022
commit 8db66595300350a903007a06ae9002776a59f750
9 changes: 1 addition & 8 deletions packages/browser/src/client.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BaseClient, Scope, SDK_VERSION } from '@sentry/core';
import { AttachmentItem, ClientOptions, Event, EventHint, Options, Severity, SeverityLevel } from '@sentry/types';
import { attachmentItemFromAttachment, getGlobalObject, logger } from '@sentry/utils';
import { getGlobalObject, logger } from '@sentry/utils';

import { eventFromException, eventFromMessage } from './eventbuilder';
import { IS_DEBUG_BUILD } from './flags';
Expand Down Expand Up @@ -122,11 +122,4 @@ export class BrowserClient extends BaseClient<BrowserClientOptions> {
}
super._sendEvent(event, attachments);
}

/**
* @inheritDoc
*/
protected _getAttachments(scope: Scope | undefined): AttachmentItem[] {
return (scope?.getAttachments() || []).map(a => attachmentItemFromAttachment(a));
}
}
9 changes: 6 additions & 3 deletions packages/core/src/baseclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
Transport,
} from '@sentry/types';
import {
attachmentItemFromAttachment,
checkOrSetAlreadyCaught,
dateTimestampInSeconds,
isPlainObject,
Expand Down Expand Up @@ -656,6 +657,11 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
);
}

/** */
protected _getAttachments(scope: Scope | undefined): AttachmentItem[] {
return (scope?.getAttachments() || []).map(a => attachmentItemFromAttachment(a));
}

/**
* @inheritDoc
*/
Expand All @@ -671,9 +677,6 @@ export abstract class BaseClient<O extends ClientOptions> implements Client<O> {
_level?: Severity | SeverityLevel,
_hint?: EventHint,
): PromiseLike<Event>;

/** */
protected abstract _getAttachments(scope: Scope | undefined): AttachmentItem[];
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class NodeClient extends BaseClient<NodeClientOptions> {
* @inheritDoc
*/
protected _getAttachments(scope: Scope | undefined): AttachmentItem[] {
// TODO: load attachment from path...
// TODO: load any attachments from paths...
return (scope?.getAttachments() || []).map(a => attachmentItemFromAttachment(a));
}
}
5 changes: 4 additions & 1 deletion packages/utils/src/envelope.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ export function serializeEnvelope(envelope: Envelope): string | Uint8Array {
return hasBinaryAttachment ? serializeBinaryEnvelope(envelope) : serializeStringEnvelope(envelope);
}

function serializeStringEnvelope(envelope: Envelope): string {
/**
* Serializes an envelope to a string.
*/
export function serializeStringEnvelope(envelope: Envelope): string {
const [headers, items] = envelope;
const serializedHeaders = JSON.stringify(headers);

Expand Down
12 changes: 6 additions & 6 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, serializeEnvelope } from '../src/envelope';
import { addItemToEnvelope, createEnvelope, getEnvelopeType, serializeStringEnvelope } from '../src/envelope';
import { parseEnvelope } from './testutils';

describe('envelope', () => {
Expand All @@ -17,10 +17,10 @@ describe('envelope', () => {
});
});

describe('serializeEnvelope()', () => {
describe('serializeStringEnvelope()', () => {
it('serializes an envelope', () => {
const env = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' }, []);
expect(serializeEnvelope(env)).toMatchInlineSnapshot(
expect(serializeStringEnvelope(env)).toMatchInlineSnapshot(
'"{\\"event_id\\":\\"aa3ff046696b4bc6b609ce6d28fde9e2\\",\\"sent_at\\":\\"123\\"}"',
);
});
Expand All @@ -29,15 +29,15 @@ describe('envelope', () => {
describe('addItemToEnvelope()', () => {
it('adds an item to an envelope', () => {
const env = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' }, []);
const parsedEnvelope = parseEnvelope(serializeEnvelope(env));
const parsedEnvelope = parseEnvelope(serializeStringEnvelope(env));
expect(parsedEnvelope).toHaveLength(1);
expect(parsedEnvelope[0]).toEqual({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' });

const newEnv = addItemToEnvelope<EventEnvelope>(env, [
{ type: 'event' },
{ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2' },
]);
const parsedNewEnvelope = parseEnvelope(serializeEnvelope(newEnv));
const parsedNewEnvelope = parseEnvelope(serializeStringEnvelope(newEnv));
expect(parsedNewEnvelope).toHaveLength(3);
expect(parsedNewEnvelope[0]).toEqual({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' });
expect(parsedNewEnvelope[1]).toEqual({ type: 'event' });
Expand All @@ -49,7 +49,7 @@ describe('envelope', () => {
it('returns the type of the envelope', () => {
const env = createEnvelope<EventEnvelope>({ event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2', sent_at: '123' }, [
[{ type: 'event' }, { event_id: 'aa3ff046696b4bc6b609ce6d28fde9e2' }],
[{ type: 'attachment', filename: 'me.txt' }, '123456'],
[{ type: 'attachment', filename: 'me.txt', length: 6 }, new Uint8Array(6)],
]);
expect(getEnvelopeType(env)).toEqual('event');
});
Expand Down