mirror of
https://git.mirrors.martin98.com/https://github.com/SigNoz/signoz
synced 2025-08-14 05:55:59 +08:00
fix: redirect to docs on clicking alert setup guide in create alert page (#6265)
This commit is contained in:
parent
580f0b816e
commit
92cdb36879
@ -73,6 +73,19 @@ export enum AlertDetectionTypes {
|
|||||||
ANOMALY_DETECTION_ALERT = 'anomaly_rule',
|
ANOMALY_DETECTION_ALERT = 'anomaly_rule',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ALERT_SETUP_GUIDE_URLS: Record<AlertTypes, string> = {
|
||||||
|
[AlertTypes.METRICS_BASED_ALERT]:
|
||||||
|
'https://signoz.io/docs/alerts-management/metrics-based-alerts/?utm_source=product&utm_medium=alert-creation-page',
|
||||||
|
[AlertTypes.LOGS_BASED_ALERT]:
|
||||||
|
'https://signoz.io/docs/alerts-management/log-based-alerts/?utm_source=product&utm_medium=alert-creation-page',
|
||||||
|
[AlertTypes.TRACES_BASED_ALERT]:
|
||||||
|
'https://signoz.io/docs/alerts-management/trace-based-alerts/?utm_source=product&utm_medium=alert-creation-page',
|
||||||
|
[AlertTypes.EXCEPTIONS_BASED_ALERT]:
|
||||||
|
'https://signoz.io/docs/alerts-management/exceptions-based-alerts/?utm_source=product&utm_medium=alert-creation-page',
|
||||||
|
[AlertTypes.ANOMALY_BASED_ALERT]:
|
||||||
|
'https://signoz.io/docs/alerts-management/anomaly-based-alerts/?utm_source=product&utm_medium=alert-creation-page',
|
||||||
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||||
function FormAlertRules({
|
function FormAlertRules({
|
||||||
alertType,
|
alertType,
|
||||||
@ -702,6 +715,29 @@ function FormAlertRules({
|
|||||||
|
|
||||||
const isRuleCreated = !ruleId || ruleId === 0;
|
const isRuleCreated = !ruleId || ruleId === 0;
|
||||||
|
|
||||||
|
function handleRedirection(option: AlertTypes): void {
|
||||||
|
let url;
|
||||||
|
if (
|
||||||
|
option === AlertTypes.METRICS_BASED_ALERT &&
|
||||||
|
alertTypeFromURL === AlertDetectionTypes.ANOMALY_DETECTION_ALERT
|
||||||
|
) {
|
||||||
|
url = ALERT_SETUP_GUIDE_URLS[AlertTypes.ANOMALY_BASED_ALERT];
|
||||||
|
} else {
|
||||||
|
url = ALERT_SETUP_GUIDE_URLS[option];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (url) {
|
||||||
|
logEvent('Alert: Check example alert clicked', {
|
||||||
|
dataSource: ALERTS_DATA_SOURCE_MAP[alertDef?.alertType as AlertTypes],
|
||||||
|
isNewRule: !ruleId || ruleId === 0,
|
||||||
|
ruleId,
|
||||||
|
queryType: currentQuery.queryType,
|
||||||
|
link: url,
|
||||||
|
});
|
||||||
|
window.open(url, '_blank');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isRuleCreated) {
|
if (!isRuleCreated) {
|
||||||
logEvent('Alert: Edit page visited', {
|
logEvent('Alert: Edit page visited', {
|
||||||
@ -752,7 +788,11 @@ function FormAlertRules({
|
|||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Button className="periscope-btn" icon={<ExternalLink size={14} />}>
|
<Button
|
||||||
|
className="periscope-btn"
|
||||||
|
onClick={(): void => handleRedirection(alertDef.alertType as AlertTypes)}
|
||||||
|
icon={<ExternalLink size={14} />}
|
||||||
|
>
|
||||||
Alert Setup Guide
|
Alert Setup Guide
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user