Skip to content

Commit

Permalink
refactor: integration constants based on pr comments
Browse files Browse the repository at this point in the history
  • Loading branch information
koladilip committed Dec 6, 2024
1 parent 83bca35 commit 48c13c9
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 169 deletions.

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion examples/chrome-extension/content-script-v3/foreground.js
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,9 @@
const DIR_NAME$17='Chartbeat';const DISPLAY_NAME$17='Chartbeat';

const DIR_NAME$16='Clevertap';const DISPLAY_NAME$16='CleverTap';


const DIR_NAME$15='Comscore';const DISPLAY_NAME$15='Comscore';

const DIR_NAME$14='Criteo';const DISPLAY_NAME$14='Criteo';

const DIR_NAME$13='CustomerIO';const DISPLAY_NAME$13='Customer IO';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { readdirSync, statSync } from 'fs';
import { join } from 'path';

const BaseIntegrationDir = join(__dirname, '../../../src/constants/integrations');
describe('Integration Constants', () => {
let allConstants: Record<string, string>;

beforeAll(async () => {
allConstants = await import(join(BaseIntegrationDir, 'Destinations'));
});

const integrations = readdirSync(BaseIntegrationDir);
integrations
// Skip non integration folders
.filter(dir => ['CommonIntegrationsConstant'].indexOf(dir) === -1)
.filter(dir => statSync(join(BaseIntegrationDir, dir)).isDirectory())
.forEach(integration => {
describe(`${integration} Integration`, () => {
let integrationConstants: { NAME: string; DISPLAY_NAME: string };

beforeAll(async () => {
const modulePath = join(BaseIntegrationDir, integration, 'constants');
integrationConstants = await import(modulePath);
});

it('should have the same NAME as defined in Destination constants', () => {
const { NAME } = integrationConstants;
expect(NAME).toBeDefined();
expect(NAME).toEqual(allConstants[`${NAME}_NAME`]);
});

it('should have the same DISPLAY_NAME as defined in Destination constants', () => {
const { NAME, DISPLAY_NAME } = integrationConstants;
expect(DISPLAY_NAME).toBeDefined();
expect(DISPLAY_NAME).toEqual(allConstants[`${NAME}_DISPLAY_NAME`]);
});
});
});
});
167 changes: 0 additions & 167 deletions packages/analytics-js-common/src/constants/Destinations.ts

This file was deleted.

1 change: 1 addition & 0 deletions scripts/update-integration-name-constants-references.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ integrationFiles.forEach(filePath => {
const updatedContent = `${nameImports}\n${withoutNameAndDisplayName}`;

writeFileSync(filePath, updatedContent, 'utf-8');

console.log(`Updated ${filePath}`);
});

Expand Down

0 comments on commit 48c13c9

Please sign in to comment.