Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions static/app/utils/analytics/preprodBuildAnalyticsEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {PreprodBuildsDisplay} from 'sentry/components/preprod/preprodBuildsDisplay';
import type {Organization} from 'sentry/types/organization';
import type {ArtifactType} from 'sentry/views/settings/project/preprod/types';

type BasePreprodBuildEvent = {
organization: Organization;
Expand All @@ -9,6 +10,11 @@ type BasePreprodBuildEvent = {
project_type?: string | null;
};

type PreprodSettingsEvent = {
organization: Organization;
project_slug: string;
};

export type BuildListPageSource =
| 'preprod_builds_list'
| 'releases_mobile_builds_tab'
Expand Down Expand Up @@ -60,6 +66,14 @@ export type PreprodBuildEventParameters = {
'preprod.releases.mobile-builds.tab-clicked': {
organization: Organization;
};
'preprod.settings.status_check_rule_created': PreprodSettingsEvent;
'preprod.settings.status_check_rule_deleted': PreprodSettingsEvent;
'preprod.settings.status_check_rule_updated': PreprodSettingsEvent & {
artifact_type: ArtifactType;
measurement: string;
metric: string;
value: number;
};
};

type PreprodBuildAnalyticsKey = keyof PreprodBuildEventParameters;
Expand All @@ -85,4 +99,10 @@ export const preprodBuildEventMap: Record<PreprodBuildAnalyticsKey, string | nul
'preprod.builds.onboarding.docs_clicked': 'Preprod Builds: Onboarding Docs Clicked',
'preprod.releases.mobile-builds.tab-clicked':
'Preprod Releases: Mobile Builds Tab Clicked',
'preprod.settings.status_check_rule_created':
'Preprod Settings: Status Check Rule Created',
'preprod.settings.status_check_rule_deleted':
'Preprod Settings: Status Check Rule Deleted',
'preprod.settings.status_check_rule_updated':
'Preprod Settings: Status Check Rule Updated',
};
17 changes: 17 additions & 0 deletions static/app/views/settings/project/preprod/statusCheckRules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import PanelBody from 'sentry/components/panels/panelBody';
import PanelHeader from 'sentry/components/panels/panelHeader';
import {IconAdd} from 'sentry/icons';
import {t} from 'sentry/locale';
import {trackAnalytics} from 'sentry/utils/analytics';
import {browserHistory} from 'sentry/utils/browserHistory';
import {useLocation} from 'sentry/utils/useLocation';
import useOrganization from 'sentry/utils/useOrganization';
Expand Down Expand Up @@ -45,6 +46,10 @@ export function StatusCheckRules() {
const handleAddRule = () => {
const newRule = createEmptyRule();
addRule(newRule);
trackAnalytics('preprod.settings.status_check_rule_created', {
organization,
project_slug: project.slug,
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Analytics track failed operations as successes

High Severity

Analytics events for rule create, update, and delete fire before their async operations complete. When addRule, updateRule, or deleteRule fail due to network errors or validation issues, the analytics still record successful operations, inflating metrics and misrepresenting actual adoption/usage. The tracking calls happen synchronously while the underlying saveRules mutation in useStatusCheckRules is asynchronous.

Additional Locations (2)

Fix in Cursor Fix in Web

setNewRuleId(newRule.id);
updateExpandedInUrl([...expandedRuleIds, newRule.id]);
};
Expand Down Expand Up @@ -117,11 +122,23 @@ export function StatusCheckRules() {
}
onSave={updated => {
updateRule(rule.id, updated);
trackAnalytics('preprod.settings.status_check_rule_updated', {
organization,
project_slug: project.slug,
metric: updated.metric,
measurement: updated.measurement,
artifact_type: updated.artifactType ?? 'all_artifacts',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent artifact_type default in analytics fallback

Low Severity

The fallback value for artifact_type uses 'all_artifacts', but the rule parsing logic in useStatusCheckRules.ts defaults to 'main_artifact' (via DEFAULT_ARTIFACT_TYPE). While the form should always provide an artifactType value making this fallback unused in practice, the inconsistency could cause confusion or incorrect analytics if the fallback is ever triggered.

Fix in Cursor Fix in Web

value: updated.value,
});
if (rule.id === newRuleId) {
setNewRuleId(null);
}
}}
onDelete={() => {
trackAnalytics('preprod.settings.status_check_rule_deleted', {
organization,
project_slug: project.slug,
});
deleteRule(rule.id);
if (rule.id === newRuleId) {
setNewRuleId(null);
Expand Down
Loading