sdkMetadata.js 1.0 KB

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