Skip to content

Commit 3b97589

Browse files
committed
save bundle size this time?
1 parent d778740 commit 3b97589

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

packages/core/src/integration.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ export function setupIntegration(client: Client, integration: Integration, integ
139139
client.addEventProcessor(processor);
140140
}
141141

142-
(['processSpan', 'processSegmentSpan'] as const).forEach(hook => {
143-
const callback = integration[hook];
144-
if (typeof callback === 'function') {
145-
// The cast is needed because TS can't resolve overloads when the discriminant is a union type.
146-
// Both overloads have the same callback signature so this is safe.
147-
client.on(hook as 'processSpan', (span: StreamedSpanJSON) => callback.call(integration, span, client));
148-
}
149-
});
142+
const processSpanCallback = integration.processSpan?.bind(integration);
143+
if (typeof processSpanCallback === 'function') {
144+
client.on('processSpan', span => processSpanCallback(span, client));
145+
}
146+
147+
const processSegmentSpanCallback = integration.processSegmentSpan?.bind(integration);
148+
if (typeof processSegmentSpanCallback === 'function') {
149+
client.on('processSegmentSpan', span => processSegmentSpanCallback(span, client));
150+
}
150151

151152
DEBUG_BUILD && debug.log(`Integration installed: ${integration.name}`);
152153
}

0 commit comments

Comments
 (0)