function dynamicSamplingContextToSentryBaggageHeader(
  // this also takes undefined for convenience and bundle size in other places
  dynamicSamplingContext,
) {
  if (!dynamicSamplingContext) {
    return undefined;
  }

  // Prefix all DSC keys with "sentry-" and put them into a new object
  const sentryPrefixedDSC = Object.entries(dynamicSamplingContext).reduce(
    (acc, [dscKey, dscValue]) => {
      if (dscValue) {
        acc[`${SENTRY_BAGGAGE_KEY_PREFIX}${dscKey}`] = dscValue;
      }
      return acc;
    },
    {},
  );

  return objectToBaggageHeader(sentryPrefixedDSC);
}
Turns a Dynamic Sampling Object into a baggage header by prefixing all the keys on the object with "sentry-".

@param dynamicSamplingContext The Dynamic Sampling Context to turn into a header. For convenience and compatibility
with the `getDynamicSamplingContext` method on the Transaction class ,this argument can also be `undefined`. If it is
`undefined` the function will return `undefined`.
@returns a baggage header, created from `dynamicSamplingContext`, or `undefined` either if `dynamicSamplingContext`
was `undefined`, or if `dynamicSamplingContext` didn't contain any values.