Skip to content

Commit e701d6f

Browse files
authored
feat: add dmt support for cloned destinations (#2434)
* feat: add dmt support for cloned destinations * test: unit tests * chore: review comment addressed
1 parent 015269a commit e701d6f

10 files changed

Lines changed: 1208 additions & 54 deletions

File tree

packages/analytics-js-common/src/types/Destination.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export type DestinationConfig = BaseDestinationConfig & {
146146

147147
export type Destination = {
148148
id: string;
149+
originalId?: string;
149150
displayName: string;
150151
userFriendlyId: string;
151152
shouldApplyDeviceModeTransformation: boolean;

packages/analytics-js-plugins/__tests__/deviceModeDestinations/utils.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,9 @@ describe('deviceModeDestinations utils', () => {
581581
// Enabled status should match override
582582
expect(dest1Clones[0]?.enabled).toBe(true);
583583
expect(dest1Clones[1]?.enabled).toBe(true);
584+
// cloned destination should have originalId and originalId should be the original destination id
585+
expect(dest1Clones[0]?.originalId).toBe('dest1');
586+
expect(dest1Clones[1]?.originalId).toBe('dest1');
584587

585588
// dest2 and dest3 should be unchanged
586589
expect(result.find(d => d.id === 'dest3')).toBe(mockDestinations[2]);
@@ -606,6 +609,7 @@ describe('deviceModeDestinations utils', () => {
606609
expect(dest2Clones[0]).toBeDefined();
607610
expect(dest2Clones[0]?.id).toBe('dest2_1');
608611
expect(dest2Clones[0]?.userFriendlyId).toBe('dest2_friendly_1');
612+
expect(dest2Clones[0]?.originalId).toBe('dest2');
609613

610614
// Config and enabled status should match each override
611615
expect(dest2Clones[0]?.config.apiKey).toBe('cloneA');
@@ -646,6 +650,9 @@ describe('deviceModeDestinations utils', () => {
646650
expect(dest3Clones[1]?.config?.extra).toBe(123);
647651
expect(dest3Clones[0]?.enabled).toBe(true);
648652
expect(dest3Clones[1]?.enabled).toBe(true);
653+
// cloned destination should have originalId and originalId should be the original destination id
654+
expect(dest3Clones[0]?.originalId).toBe('dest3');
655+
expect(dest3Clones[1]?.originalId).toBe('dest3');
649656
// inherit other config properties
650657
expect(dest3Clones[0]?.config?.eventFilteringOption).toBe('disable');
651658
expect(dest3Clones[1]?.config?.eventFilteringOption).toBe('disable');

0 commit comments

Comments
 (0)