Skip to content

NodeJS and Attachment #4371

Description

@ErcinDedeoglu

Maybe it's not a bug, but I'm not sure. because there is no documentation for it.

We are trying to send an attachment of the issue to the sentry via the NodeJS backend application. I wrote the code below by commenting out the API, but it didn't work.

const sentryResponse = Sentry.captureException(err.original);
const client = Sentry.getCurrentHub().getClient();
const { host, path, projectId, port, protocol, user } = client.getDsn();
const endpoint = ${protocol}://${host}${port !== '' ? :${port}: ''}${ path !== '' ?/${path} : '' }/api/${projectId}/events/${sentryResponse}/attachments/?sentry_key=${user}&sentry_version=7&sentry_client=custom-javascript;

fetch(endpoint, {
  method: 'POST',
  body: {
    'variables.file': fs.createReadStream('./README.md')
  },
}).catch((ex) => {
  // we have to catch this otherwise it throws an infinite loop in Sentry
  console.error(ex);
});

} catch (ex) {
console.error(ex);
}

There has to be a simpler way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions