Skip to content
This repository has been archived by the owner on Jun 13, 2023. It is now read-only.

Commit

Permalink
fix(web): support amplify (#11)
Browse files Browse the repository at this point in the history
  • Loading branch information
NavaBeginsky authored Jul 11, 2021
1 parent fa190e0 commit 5e426d6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This package provides tracing to front end of web applications for the collectio

To install Epsagon, simply run:
```sh
npm install @epsagon/react
npm install @epsagon/react --save
```

## Usage
Expand Down
8 changes: 5 additions & 3 deletions packages/web/src/exporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,17 @@ class EpsagonExporter extends CollectorTraceExporter {
const spanErrs = [];
const finalSpans = [];
spansList[rootSpan.doc.position].spans.map((span) => {
if (!spanErrs.includes(span.attributes[0].value.stringValue)) {
if (span.name === 'error' && !spanErrs.includes(span.attributes[0].value.stringValue)) {
const errAttr = span.attributes.filter((attr) => attr.key === 'message');
spanErrs.push(errAttr[0].value.stringValue);
const spanStringError = errAttr && errAttr.length ? errAttr[0].value.stringValue : 'exception'

spanErrs.push(spanStringError);
const attributesLength = this.addFinalGenericSpanAttrs(span.attributes, span.attributes.length, span);
span.name = window.location.pathname;
span.events.unshift({
name: 'exception',
attributes: [
{ key: 'exception.message', value: { stringValue: errAttr[0].value.stringValue } },
{ key: 'exception.message', value: { stringValue: spanStringError } },
],
});
finalSpans.push(span);
Expand Down
4 changes: 4 additions & 0 deletions packages/web/src/instrumentation/fetchInstrumentation.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ class EpsagonFetchInstrumentation extends FetchInstrumentation {
plugin._tasksCount++;
return original
.apply(this, [url, options])
.catch(ex => {
console.log(ex)
console.log(JSON.stringify(ex))
})
.then(onSuccess.bind(this, createdSpan, resolve), onError.bind(this, createdSpan, reject));
}));
};
Expand Down

0 comments on commit 5e426d6

Please sign in to comment.