Skip to content

Commit 58fccc9

Browse files
committed
fix(metrics): address comments and fix tests
1 parent 35c776a commit 58fccc9

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

packages/core/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export { ServerRuntimeClient } from './server-runtime-client';
5555
export { initAndBind, setCurrentClient } from './sdk';
5656
export { createTransport } from './transports/base';
5757
export { makeOfflineTransport } from './transports/offline';
58-
export { makeMultiplexedTransport } from './transports/multiplexed';
58+
export { makeMultiplexedTransport, MULTIPLEXED_TRANSPORT_EXTRA_KEY } from './transports/multiplexed';
5959
export { getIntegrationsToSetup, addIntegration, defineIntegration, installedIntegrations } from './integration';
6060
export {
6161
_INTERNAL_skipAiProviderWrapping,

packages/core/src/transports/multiplexed.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,28 @@ function makeOverrideReleaseTransport<TO extends BaseTransportOptions>(
153153

154154
/** Overrides the DSN in the envelope header */
155155
function overrideDsn(envelope: Envelope, dsn: string): Envelope {
156+
const clonedItems = envelope[1].map(item => {
157+
if (Array.isArray(item) && item[0]?.type === 'trace_metric') {
158+
const [header, container] = item as [any, SerializedMetricContainer];
159+
return [
160+
{ ...header },
161+
{
162+
...container,
163+
items: container.items ? [...container.items] : [],
164+
},
165+
];
166+
}
167+
return item;
168+
});
169+
156170
return createEnvelope(
157171
dsn
158172
? {
159173
...envelope[0],
160174
dsn,
161175
}
162176
: envelope[0],
163-
envelope[1],
177+
clonedItems as (typeof envelope)[1],
164178
);
165179
}
166180

@@ -213,7 +227,10 @@ export function makeMultiplexedTransport<TO extends BaseTransportOptions>(
213227

214228
if (Array.isArray(routingValue)) {
215229
const validRoutes = routingValue.filter(
216-
(route): route is RouteTo => route !== null && route !== undefined && typeof route === 'object',
230+
(route): route is string | RouteTo =>
231+
route !== null &&
232+
route !== undefined &&
233+
(typeof route === 'string' || (typeof route === 'object' && 'dsn' in route)),
217234
);
218235
DEBUG_BUILD && debug.log('[Multiplexed Transport] Valid routes:', validRoutes);
219236
return validRoutes;

0 commit comments

Comments
 (0)