Skip to content

Commit

Permalink
feat: Increase stack trace length (#313)
Browse files Browse the repository at this point in the history
  • Loading branch information
ps863 committed Nov 30, 2022
1 parent 95e0edd commit 28e34c5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ telemetries: [

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| stackTraceLength | Number | `200` | The number of characters to record from a JavaScript error's stack trace (if available). |
| stackTraceLength | Number | `1000` | The number of characters to record from a JavaScript error's stack trace (if available). |
| ignore | Function | `() => false` | A function which accepts an [`ErrorEvent`](https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent) or a [`PromiseRejectionEvent`](https://developer.mozilla.org/en-US/docs/Web/API/PromiseRejectionEvent) and returns a value that coerces to true when the error should be ignored. By default, no errors are ignored. |

For example, the following telemetry config array causes the web client to ignore all errors whose message begins with "Warning:".
Expand Down Expand Up @@ -130,7 +130,7 @@ telemetries: [
| --- | --- | --- | --- |
| urlsToInclude | RegExp[] | `[/.*/]` | A list of HTTP request (`XMLHttpRequest` or `fetch`) URLs. These requests will be recorded, unless explicitly excluded by `urlsToExclude`. |
| urlsToExclude | RegExp[] | `[]` | A list of HTTP request (`XMLHttpRequest` or `fetch`) URLs. These requests will not be recorded. |
| stackTraceLength | Number | `200 ` | The number of characters to record from a JavaScript error's stack trace (if available). |
| stackTraceLength | Number | `1000 ` | The number of characters to record from a JavaScript error's stack trace (if available). |
| recordAllRequests | boolean | `false` | By default, only HTTP failed requests (i.e., those with network errors or status codes which are not 2xx) are recorded. When this field is `true`, the http telemetry will record all requests, including those with successful 2xx status codes. <br/><br/>This field does **does not apply** to X-Ray traces, where all requests are recorded. |
| addXRayTraceIdHeader | boolean | `false` | By default, the `X-Amzn-Trace-Id` header will not be added to the HTTP request. This means that the client-side trace and server-side trace will **not be linked** in X-Ray or the ServiceLens graph.<br/><br/> When this field is `true`, the `X-Amzn-Trace-Id` header will be added to HTTP requests (`XMLHttpRequest` or `fetch`). **Adding the header is dangerous and you must test your application before setting this field to `true` in a production environment.** The header could cause CORS to fail or invalidate the request's signature if the request is signed with sigv4.

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/event-plugins/JsErrorPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export type JsErrorPluginConfig = {
};

const defaultConfig: JsErrorPluginConfig = {
stackTraceLength: 200,
stackTraceLength: 1000,
ignore: () => false
};

Expand Down
22 changes: 11 additions & 11 deletions src/plugins/event-plugins/__integ__/JsErrorPlugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ test('when a TypeError is thrown then name and message are recorded', async (t:
.expect(REQUEST_BODY.textContent)
.contains('BatchId');

const json = removeUnwantedEvents(
JSON.parse(await REQUEST_BODY.textContent)
const events = JSON.parse(await REQUEST_BODY.textContent).RumEvents.filter(
(e) => e.type === JS_ERROR_EVENT_TYPE
);
const eventType = json.RumEvents[0].type;
const eventDetails = JSON.parse(json.RumEvents[0].details);
const eventType = events[0].type;
const eventDetails = JSON.parse(events[0].details);

await t
.expect(eventType)
Expand Down Expand Up @@ -99,11 +99,11 @@ test('stack trace is recorded by default', async (t: TestController) => {
.expect(REQUEST_BODY.textContent)
.contains('BatchId');

const json = removeUnwantedEvents(
JSON.parse(await REQUEST_BODY.textContent)
const events = JSON.parse(await REQUEST_BODY.textContent).RumEvents.filter(
(e) => e.type === JS_ERROR_EVENT_TYPE
);
const eventType = json.RumEvents[0].type;
const eventDetails = JSON.parse(json.RumEvents[0].details);
const eventType = events[0].type;
const eventDetails = JSON.parse(events[0].details);

await t
.expect(eventType)
Expand Down Expand Up @@ -198,9 +198,9 @@ test('when error invoked with record method then the plugin records the error',
.expect(REQUEST_BODY.textContent)
.contains('BatchId');

const json = removeUnwantedEvents(
JSON.parse(await REQUEST_BODY.textContent)
const events = JSON.parse(await REQUEST_BODY.textContent).RumEvents.filter(
(e) => e.type === JS_ERROR_EVENT_TYPE
);

await t.expect(json.RumEvents.length).eql(1);
await t.expect(events.length).eql(1);
});

0 comments on commit 28e34c5

Please sign in to comment.