MCPcopy Index your code
hub / github.com/getsentry/sentry / CreateAlertFromViewButton

Function CreateAlertFromViewButton

static/app/components/createAlertButton.tsx:55–125  ·  view source on GitHub ↗
({
  projects,
  eventView,
  organization,
  referrer,
  onClick,
  alertType,
  disableMetricDataset,
  ...buttonProps
}: CreateAlertFromViewButtonProps)

Source from the content-addressed store, hash-verified

53 * Emits incompatible query issues on click
54 */
55export function CreateAlertFromViewButton({
56 projects,
57 eventView,
58 organization,
59 referrer,
60 onClick,
61 alertType,
62 disableMetricDataset,
63 ...buttonProps
64}: CreateAlertFromViewButtonProps) {
65 const project = projects.find(p => p.id === `${eventView.project[0]}`);
66 const queryParams = eventView.generateQueryStringObject();
67 if (queryParams.query?.includes(`project:${project?.slug}`)) {
68 queryParams.query = (queryParams.query as string).replace(
69 `project:${project?.slug}`,
70 ''
71 );
72 }
73
74 const alertTemplate = alertType
75 ? // @ts-expect-error TS(7053): Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
76 AlertWizardRuleTemplates[alertType]
77 : DEFAULT_WIZARD_TEMPLATE;
78
79 const shouldDirectToMonitors = organization.features.includes('workflow-engine-ui');
80
81 const to = shouldDirectToMonitors
82 ? getMetricMonitorUrl({
83 project,
84 environment: queryParams.environment,
85 aggregate: queryParams.yAxis ?? alertTemplate.aggregate,
86 dataset: alertTemplate.dataset,
87 organization,
88 query: decodeScalar(queryParams.query),
89 referrer,
90 eventTypes: alertTemplate.eventTypes,
91 })
92 : {
93 pathname: makeAlertsPathname({
94 path: '/new/metric/',
95 organization,
96 }),
97 query: {
98 ...queryParams,
99 createFromDiscover: true,
100 disableMetricDataset,
101 referrer,
102 ...alertTemplate,
103 project: project?.slug,
104 aggregate: queryParams.yAxis ?? alertTemplate.aggregate,
105 },
106 };
107
108 const handleClick = () => {
109 onClick?.();
110 };
111
112 const createButtonLabel = shouldDirectToMonitors

Callers

nothing calls this directly

Calls 7

getMetricMonitorUrlFunction · 0.90
decodeScalarFunction · 0.90
makeAlertsPathnameFunction · 0.90
findMethod · 0.80
tFunction · 0.50
replaceMethod · 0.45

Tested by

no test coverage detected