All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.build.npm.esm.userfeedback.js Maven / Gradle / Ivy

There is a newer version: 8.40.0
Show newest version
import { dsnToString, createEnvelope } from '@sentry/utils';

/**
 * Creates an envelope from a user feedback.
 */
function createUserFeedbackEnvelope(
  feedback,
  {
    metadata,
    tunnel,
    dsn,
  }

,
) {
  const headers = {
    event_id: feedback.event_id,
    sent_at: new Date().toISOString(),
    ...(metadata &&
      metadata.sdk && {
        sdk: {
          name: metadata.sdk.name,
          version: metadata.sdk.version,
        },
      }),
    ...(!!tunnel && !!dsn && { dsn: dsnToString(dsn) }),
  };
  const item = createUserFeedbackEnvelopeItem(feedback);

  return createEnvelope(headers, [item]);
}

function createUserFeedbackEnvelopeItem(feedback) {
  const feedbackHeaders = {
    type: 'user_report',
  };
  return [feedbackHeaders, feedback];
}

export { createUserFeedbackEnvelope };
//# sourceMappingURL=userfeedback.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy