Skip to content

Commit 2288ce0

Browse files
committed
Add analytics for the app behavior settings
Add some nice Posthog metrics for the application behavior in the commit analytics
1 parent c25bfa7 commit 2288ce0

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
import { autoSelectBranchNameFeature, stagingBehaviorFeature } from '$lib/config/uiFeatureFlags';
12
import { getFilterCountMap, getStackTargetTypeCountMap, type WorkspaceRule } from '$lib/rules/rule';
23
import { StackService } from '$lib/stacks/stackService.svelte';
34
import { UiState } from '$lib/state/uiState.svelte';
45
import { WorktreeService } from '$lib/worktree/worktreeService.svelte';
56
import { InjectionToken } from '@gitbutler/shared/context';
7+
import { get } from 'svelte/store';
68
import type { Commit } from '$lib/branches/v3';
79
import type { HunkAssignment } from '$lib/hunks/hunk';
810
import type RulesService from '$lib/rules/rulesService.svelte';
@@ -85,7 +87,9 @@ export class CommitAnalytics {
8587
// Total number of files that have not been assigned
8688
totalUnassignedFiles: this.getUnassignedFiles(assignments).length,
8789
// Rule metrics
88-
...this.getRuleMetrics(rules)
90+
...this.getRuleMetrics(rules),
91+
// Behavior metrics
92+
...this.getBehaviorMetrics()
8993
};
9094
} catch (error) {
9195
console.error('Failed to fetch commit analytics:', error);
@@ -173,6 +177,18 @@ export class CommitAnalytics {
173177

174178
return namespaceProps(ruleMetrics, 'workspaceRules');
175179
}
180+
181+
private getBehaviorMetrics(): EventProperties {
182+
// Placeholder for future behavior metrics
183+
const stagingBehavior = get(stagingBehaviorFeature);
184+
const autoSelectBranchName = get(autoSelectBranchNameFeature);
185+
const behaviorMetrics = {
186+
stagingBehavior,
187+
autoSelectBranchName
188+
};
189+
190+
return namespaceProps(behaviorMetrics, 'behavior');
191+
}
176192
}
177193

178194
function namespaceProps(props: EventProperties, namespace: string): EventProperties {

0 commit comments

Comments
 (0)