sdkMetadata.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. Object.defineProperty(exports, '__esModule', { value: true });
  2. const version = require('../version.js');
  3. /**
  4. * A builder for the SDK metadata in the options for the SDK initialization.
  5. *
  6. * Note: This function is identical to `buildMetadata` in Remix and NextJS and SvelteKit.
  7. * We don't extract it for bundle size reasons.
  8. * @see https://github.com/getsentry/sentry-javascript/pull/7404
  9. * @see https://github.com/getsentry/sentry-javascript/pull/4196
  10. *
  11. * If you make changes to this function consider updating the others as well.
  12. *
  13. * @param options SDK options object that gets mutated
  14. * @param names list of package names
  15. */
  16. function applySdkMetadata(options, name, names = [name], source = 'npm') {
  17. const metadata = options._metadata || {};
  18. if (!metadata.sdk) {
  19. metadata.sdk = {
  20. name: `sentry.javascript.${name}`,
  21. packages: names.map(name => ({
  22. name: `${source}:@sentry/${name}`,
  23. version: version.SDK_VERSION,
  24. })),
  25. version: version.SDK_VERSION,
  26. };
  27. }
  28. options._metadata = metadata;
  29. }
  30. exports.applySdkMetadata = applySdkMetadata;
  31. //# sourceMappingURL=sdkMetadata.js.map