@nitin15j/plugin-dora-frontend
Version:
Welcome to the dora-frontend plugin!
131 lines (128 loc) • 4.62 kB
JavaScript
import { jsx } from 'react/jsx-runtime';
import { MetricType } from '../types/metrics.esm.js';
import CheckCircleIcon from '@material-ui/icons/CheckCircle';
import WarningIcon from '@material-ui/icons/Warning';
import ErrorIcon from '@material-ui/icons/Error';
function getMetricInsights(metricType, value, percentageChange, styles, apiInsight) {
const insights = [];
if (apiInsight) {
insights.push({
icon: apiInsight.icon === "sparkles" ? /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }) : /* @__PURE__ */ jsx(WarningIcon, { className: styles.warningInsight }),
text: apiInsight.message,
type: "PERFORMANCE"
});
}
switch (metricType) {
case MetricType.Frequency:
if (value >= 1) {
insights.push({
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }),
text: "Meeting elite deployment frequency target",
type: "PERFORMANCE"
});
} else if (value >= 0.5) ; else {
insights.push({
icon: /* @__PURE__ */ jsx(ErrorIcon, { className: styles.criticalInsight }),
text: "Deployment frequency needs immediate attention",
type: "PERFORMANCE"
});
}
if (percentageChange > 0) {
insights.push({
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }),
text: "Deployment frequency is improving",
type: "TREND"
});
}
break;
case MetricType.LeadTime:
const leadTimeHours = value / 3600;
if (leadTimeHours <= 1) {
insights.push({
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }),
text: "Meeting elite lead time target",
type: "PERFORMANCE"
});
} else if (leadTimeHours <= 24) {
insights.push({
icon: /* @__PURE__ */ jsx(WarningIcon, { className: styles.warningInsight }),
text: "Consider optimizing CI/CD pipeline",
type: "PERFORMANCE"
});
} else {
insights.push({
icon: /* @__PURE__ */ jsx(ErrorIcon, { className: styles.criticalInsight }),
text: "Lead time needs immediate optimization",
type: "PERFORMANCE"
});
}
if (percentageChange < 0) {
insights.push({
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }),
text: "Lead time is improving",
type: "TREND"
});
}
break;
case MetricType.FailureRate:
if (value <= 15) {
insights.push({
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }),
text: "Meeting failure rate target",
type: "PERFORMANCE"
});
} else if (value <= 30) {
insights.push({
icon: /* @__PURE__ */ jsx(WarningIcon, { className: styles.warningInsight }),
text: "Consider improving test coverage",
type: "PERFORMANCE"
});
} else {
insights.push({
icon: /* @__PURE__ */ jsx(ErrorIcon, { className: styles.criticalInsight }),
text: "Failure rate needs immediate attention",
type: "PERFORMANCE"
});
}
if (percentageChange < 0) {
insights.push({
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }),
text: "Failure rate is improving",
type: "TREND"
});
}
break;
case MetricType.Mttr:
const mttrHours = value / 3600;
if (mttrHours <= 1) {
insights.push({
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }),
text: "Meeting elite MTTR target",
type: "PERFORMANCE"
});
} else if (mttrHours <= 24) {
insights.push({
icon: /* @__PURE__ */ jsx(WarningIcon, { className: styles.warningInsight }),
text: "Consider improving incident response",
type: "PERFORMANCE"
});
} else {
insights.push({
icon: /* @__PURE__ */ jsx(ErrorIcon, { className: styles.criticalInsight }),
text: "MTTR needs immediate improvement",
type: "PERFORMANCE"
});
}
if (percentageChange < 0) {
insights.push({
icon: /* @__PURE__ */ jsx(CheckCircleIcon, { className: styles.goodInsight }),
text: "Recovery time is improving",
type: "TREND"
});
}
break;
}
return insights;
}
export { getMetricInsights };
//# sourceMappingURL=insights.esm.js.map