diff --git a/packages/core/src/plugins/DestinationMetadataEnrichment.ts b/packages/core/src/plugins/DestinationMetadataEnrichment.ts index 708f6b60..8020ba7b 100644 --- a/packages/core/src/plugins/DestinationMetadataEnrichment.ts +++ b/packages/core/src/plugins/DestinationMetadataEnrichment.ts @@ -1,10 +1,16 @@ import { DestinationPlugin, UtilityPlugin } from '../plugin'; import { PluginType, SegmentEvent } from '../types'; -import { SEGMENT_DESTINATION_KEY } from './SegmentDestination'; export class DestinationMetadataEnrichment extends UtilityPlugin { type = PluginType.enrichment; + private destinationKey: string; + + constructor(destinationKey: string) { + super(); + this.destinationKey = destinationKey; + } + execute(event: SegmentEvent): SegmentEvent { const pluginSettings = this.analytics?.settings.get(); const plugins = this.analytics?.getPlugins(PluginType.destination); @@ -19,7 +25,7 @@ export class DestinationMetadataEnrichment extends UtilityPlugin { const bundled: string[] = []; for (const key of destinations) { - if (key === SEGMENT_DESTINATION_KEY) { + if (key === this.destinationKey) { continue; } @@ -30,7 +36,7 @@ export class DestinationMetadataEnrichment extends UtilityPlugin { const unbundled: string[] = []; const segmentInfo = - (pluginSettings[SEGMENT_DESTINATION_KEY] as Record) ?? {}; + (pluginSettings[this.destinationKey] as Record) ?? {}; const unbundledIntegrations: string[] = segmentInfo.unbundledIntegrations ?? []; diff --git a/packages/core/src/plugins/SegmentDestination.ts b/packages/core/src/plugins/SegmentDestination.ts index 1289f024..55c0f477 100644 --- a/packages/core/src/plugins/SegmentDestination.ts +++ b/packages/core/src/plugins/SegmentDestination.ts @@ -17,7 +17,7 @@ export class SegmentDestination extends DestinationPlugin { super.configure(analytics); // Enrich events with the Destination metadata - this.add(new DestinationMetadataEnrichment()); + this.add(new DestinationMetadataEnrichment(SEGMENT_DESTINATION_KEY)); } execute(event: SegmentEvent): SegmentEvent | undefined {