Skip to content

Commit 6449ecb

Browse files
committed
Namespace rule analytics props and add helper
- Renamed returned metrics object to ruleMetrics instead of returning directly. - Added namespaceProps helper function that takes EventProperties and a namespace string and returns a new object with keys prefixed by `${namespace}:`. - Updated function to return namespaceProps(ruleMetrics, 'rule') so all rule-related analytics properties are namespaced (e.g., 'rule:totalWorkspaceRules').
1 parent 0b2123e commit 6449ecb

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

apps/desktop/src/lib/soup/commitAnalytics.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export class CommitAnalytics {
160160
const filterCountByType = getFilterCountMap(rules);
161161
const assignmentTargetTypes = getStackTargetTypeCountMap(rules);
162162

163-
return {
163+
const ruleMetrics = {
164164
// Total number of rules in the workspace
165165
totalWorkspaceRules: rules.length,
166166
// Average number of filters per rule
@@ -170,7 +170,17 @@ export class CommitAnalytics {
170170
/// Count the stack target types used
171171
...assignmentTargetTypes
172172
};
173+
174+
return namespaceProps(ruleMetrics, 'rule');
175+
}
176+
}
177+
178+
function namespaceProps(props: EventProperties, namespace: string): EventProperties {
179+
const namespacedProps: EventProperties = {};
180+
for (const [key, value] of Object.entries(props)) {
181+
namespacedProps[`${namespace}:${key}`] = value;
173182
}
183+
return namespacedProps;
174184
}
175185

176186
function average(arr: number[]): number {

0 commit comments

Comments
 (0)