Skip to content

Commit 1261096

Browse files
authored
feat: variants instrumentation (#1272)
* feat: telemetry on registryVariants * chore: todo cleanup for types
1 parent be3735e commit 1261096

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

src/registry/variants.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77
import * as fs from 'node:fs';
88
import * as path from 'node:path';
9-
import { Logger, SfProject, SfProjectJson } from '@salesforce/core';
9+
import { Logger, SfProject, SfProjectJson, Lifecycle } from '@salesforce/core';
1010
import { deepFreeze } from '../utils/collections';
1111
import { MetadataRegistry } from './types';
1212
import * as registryData from './metadataRegistry.json';
@@ -16,7 +16,6 @@ export type RegistryLoadInput = {
1616
* will default to the current working directory
1717
* if no project file is found, the standard registry will be returned without modifications
1818
*/
19-
// TODO: this might be a string instead of an object if no other props are needed
2019
projectDir?: string;
2120
};
2221

@@ -49,6 +48,16 @@ const loadVariants = ({ projectDir }: RegistryLoadInput = {}): MetadataRegistry
4948
(prev, curr) => firstLevelMerge(prev, loadPreset(curr)),
5049
emptyRegistry
5150
);
51+
if (presets.length > 0 || Object.keys(customizations.types).length > 0) {
52+
void Lifecycle.getInstance().emitTelemetry({
53+
library: 'SDR',
54+
eventName: 'RegistryVariants',
55+
presetCount: presets.length,
56+
presets: presets.join(','),
57+
customizationsCount: Object.keys(customizations.types).length,
58+
customizationsTypes: Object.keys(customizations.types).join(','),
59+
});
60+
}
5261
return firstLevelMerge(registryFromPresets, customizations);
5362
};
5463

@@ -60,13 +69,6 @@ const maybeGetProject = (projectDir?: string): SfProjectJson | undefined => {
6069
}
6170
};
6271

63-
// TODO: this type should maybe live somewhere else and be part of the sfdx-project schema
64-
// but we don't want circular dependency from sfdx-core to SDR
65-
// type CustomRegistry = {
66-
// registryCustomizations: MetadataRegistry;
67-
// registryPresets: string[];
68-
// };
69-
7072
const loadPreset = (preset: string): MetadataRegistry => {
7173
const pathToCheck = path.join(__dirname, 'presets', `${preset}.json`);
7274

test/nuts/scale/perfUtils.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,11 @@ export const recordPerf = async (testName: string, performance: Performance): Pr
1717
fileTarget,
1818
JSON.stringify(
1919
existing.concat(
20-
performance
21-
.getEntriesByType('measure')
22-
// TODO: remove this when we upgrade to node16 and get its types
23-
.map((m: { name: string; duration: number }) => ({
24-
name: `${testName}-${m.name}-${os.platform()}`,
25-
value: Math.trunc(m.duration),
26-
unit: 'ms',
27-
}))
20+
performance.getEntriesByType('measure').map((m) => ({
21+
name: `${testName}-${m.name}-${os.platform()}`,
22+
value: Math.trunc(m.duration),
23+
unit: 'ms',
24+
}))
2825
),
2926
null,
3027
2

0 commit comments

Comments
 (0)