Skip to content
This repository was archived by the owner on Jun 27, 2023. It is now read-only.

Commit 9d51d3f

Browse files
authored
fix: remove import cycle in DestinationMetadataEnrichment (segmentio#505)
1 parent e5ab579 commit 9d51d3f

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

packages/core/src/plugins/DestinationMetadataEnrichment.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { DestinationPlugin, UtilityPlugin } from '../plugin';
22
import { PluginType, SegmentEvent } from '../types';
3-
import { SEGMENT_DESTINATION_KEY } from './SegmentDestination';
43

54
export class DestinationMetadataEnrichment extends UtilityPlugin {
65
type = PluginType.enrichment;
76

7+
private destinationKey: string;
8+
9+
constructor(destinationKey: string) {
10+
super();
11+
this.destinationKey = destinationKey;
12+
}
13+
814
execute(event: SegmentEvent): SegmentEvent {
915
const pluginSettings = this.analytics?.settings.get();
1016
const plugins = this.analytics?.getPlugins(PluginType.destination);
@@ -19,7 +25,7 @@ export class DestinationMetadataEnrichment extends UtilityPlugin {
1925
const bundled: string[] = [];
2026

2127
for (const key of destinations) {
22-
if (key === SEGMENT_DESTINATION_KEY) {
28+
if (key === this.destinationKey) {
2329
continue;
2430
}
2531

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

3137
const unbundled: string[] = [];
3238
const segmentInfo =
33-
(pluginSettings[SEGMENT_DESTINATION_KEY] as Record<string, any>) ?? {};
39+
(pluginSettings[this.destinationKey] as Record<string, any>) ?? {};
3440
const unbundledIntegrations: string[] =
3541
segmentInfo.unbundledIntegrations ?? [];
3642

packages/core/src/plugins/SegmentDestination.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export class SegmentDestination extends DestinationPlugin {
1717
super.configure(analytics);
1818

1919
// Enrich events with the Destination metadata
20-
this.add(new DestinationMetadataEnrichment());
20+
this.add(new DestinationMetadataEnrichment(SEGMENT_DESTINATION_KEY));
2121
}
2222

2323
execute(event: SegmentEvent): SegmentEvent | undefined {

0 commit comments

Comments
 (0)