Skip to content

Commit

Permalink
Making http.request optional
Browse files Browse the repository at this point in the history
  • Loading branch information
cauemarcondes committed Dec 23, 2019
1 parent 8ee7d87 commit f2efdd6
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,31 @@ describe('DetailView', () => {
expect(wrapper.exists()).toBe(true);
expect(wrapper).toMatchSnapshot();
});

it('should render without http request info', () => {
const errorGroup = {
occurrencesCount: 10,
transaction: undefined,
error: {
timestamp: {
us: 0
},
http: { response: { status_code: 404 } },
url: { full: 'myUrl' },
service: { name: 'myService' },
user: { id: 'myUserId' },
error: { exception: { handled: true } },
transaction: { id: 'myTransactionId', sampled: true }
} as any
};
expect(() =>
shallow(
<DetailView
errorGroup={errorGroup}
urlParams={{}}
location={{} as Location}
/>
)
).not.toThrowError();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function DetailView({ errorGroup, urlParams, location }: Props) {

const errorUrl = error.error.page?.url || error.url?.full;

const method = error.http?.request.method;
const method = error.http?.request?.method;
const status = error.http?.response?.status_code;

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,21 @@ describe('TransactionSummary', () => {
transaction
};

it('renders', () => {
expect(() =>
shallow(<TransactionSummary {...props} />)
).not.toThrowError();
});
});
describe('renders RUM transaction without request info', () => {
const transaction: Transaction = exampleTransactions.httpRumOK;

const props = {
errorCount: 0,
totalDuration: 0,
transaction
};

it('renders', () => {
expect(() =>
shallow(<TransactionSummary {...props} />)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const getTransactionResultSummaryItem = (transaction: Transaction) => {
: transaction.url?.full;

if (url) {
const method = transaction.http?.request.method;
const method = transaction.http?.request?.method;
const status = transaction.http?.response?.status_code;

return <HttpInfoSummaryItem method={method} status={status} url={url} />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,25 @@ export const httpOk: Transaction = {
duration: { us: 0 }
}
};

export const httpRumOK: Transaction = {
'@timestamp': '0',
agent: { name: 'rum-js', version: '0' },
http: {
response: { status_code: 200 }
},
processor: { event: 'transaction', name: 'transaction' },
service: { name: 'testServiceName' },
timestamp: { us: 0 },
trace: { id: 'testTrace' },
transaction: {
page: {
url: 'elastic.co'
},
name: 'testTransaction',
id: 'testId',
sampled: false,
type: 'testType',
duration: { us: 0 }
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

export interface Http {
request: { method: string; [key: string]: unknown };
request?: { method: string; [key: string]: unknown };
response?: { status_code: number; [key: string]: unknown };
version?: string;
}

0 comments on commit f2efdd6

Please sign in to comment.