userfeedback.js 858 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { dsnToString, createEnvelope } from '@sentry/utils';
  2. /**
  3. * Creates an envelope from a user feedback.
  4. */
  5. function createUserFeedbackEnvelope(
  6. feedback,
  7. {
  8. metadata,
  9. tunnel,
  10. dsn,
  11. }
  12. ,
  13. ) {
  14. const headers = {
  15. event_id: feedback.event_id,
  16. sent_at: new Date().toISOString(),
  17. ...(metadata &&
  18. metadata.sdk && {
  19. sdk: {
  20. name: metadata.sdk.name,
  21. version: metadata.sdk.version,
  22. },
  23. }),
  24. ...(!!tunnel && !!dsn && { dsn: dsnToString(dsn) }),
  25. };
  26. const item = createUserFeedbackEnvelopeItem(feedback);
  27. return createEnvelope(headers, [item]);
  28. }
  29. function createUserFeedbackEnvelopeItem(feedback) {
  30. const feedbackHeaders = {
  31. type: 'user_report',
  32. };
  33. return [feedbackHeaders, feedback];
  34. }
  35. export { createUserFeedbackEnvelope };
  36. //# sourceMappingURL=userfeedback.js.map