Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions packages/core/src/plugins/DestinationMetadataEnrichment.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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;
}

Expand All @@ -30,7 +36,7 @@ export class DestinationMetadataEnrichment extends UtilityPlugin {

const unbundled: string[] = [];
const segmentInfo =
(pluginSettings[SEGMENT_DESTINATION_KEY] as Record<string, any>) ?? {};
(pluginSettings[this.destinationKey] as Record<string, any>) ?? {};
const unbundledIntegrations: string[] =
segmentInfo.unbundledIntegrations ?? [];

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/plugins/SegmentDestination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down