Repository: louislam/uptime-kuma
File: server/notification-providers/pagerduty.js (JavaScript)

Code before:
const { setting } = require("../util-server");
let successMessage = "Sent Successfully.";

class PagerDuty extends NotificationProvider {
    name = "PagerDuty";

    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        try {
            if (heartbeatJSON == null) {
                const title = "Uptime Kuma Alert";
                const monitor = {
                    type: "ping",
                    url: "UptimeKuma Test Button",
                };
                return await this.postNotification(notification, title, "", monitor);
            }

            if (heartbeatJSON.status === UP) {
                const title = "UptimeKuma Monitor ✅ Up";
                const eventAction = notification.pagerdutyAutoResolve || null;

                return await this.postNotification(notification, title, heartbeatJSON.msg, monitorJSON, eventAction);
            }

            if (heartbeatJSON.status === DOWN) {
                const title = "UptimeKuma Monitor 🔴 Down";
                return await this.postNotification(notification, title, heartbeatJSON.msg, monitorJSON, "trigger");
            }
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }

    // thrown if failed to check result, result code should be in range 2xx
    checkResult(result) {
        if (result.status == null) {
            throw new Error("PagerDuty notification failed with invalid response!");
        }
        if (result.status < 200 || result.status >= 300) {
            throw new Error("PagerDuty notification failed with status code " + result.status);
        }
    }

    async postNotification(notification, title, body, monitorInfo, eventAction = "trigger") {

        if (eventAction == null) {
            return "No action required";
        }

        let monitorUrl;
        if (monitorInfo.type === "port") {

Review comment (suggestion):
```suggestion
                const title = "Uptime Kuma Monitor 🔴 Down";
```


Code after:
const { setting } = require("../util-server");
let successMessage = "Sent Successfully.";

class PagerDuty extends NotificationProvider {
    name = "PagerDuty";

    /**
     * @inheritdoc
     */
    async send(notification, msg, monitorJSON = null, heartbeatJSON = null) {
        try {
            if (heartbeatJSON == null) {
                const title = "Uptime Kuma Alert";
                const monitor = {
                    type: "ping",
                    url: "Uptime Kuma Test Button",
                };
                return this.postNotification(notification, title, msg, monitor);
            }

            if (heartbeatJSON.status === UP) {
                const title = "Uptime Kuma Monitor ✅ Up";
                const eventAction = notification.pagerdutyAutoResolve || null;

                return this.postNotification(notification, title, heartbeatJSON.msg, monitorJSON, eventAction);
            }

            if (heartbeatJSON.status === DOWN) {
                const title = "Uptime Kuma Monitor 🔴 Down";
                return this.postNotification(notification, title, heartbeatJSON.msg, monitorJSON, "trigger");
            }
        } catch (error) {
            this.throwGeneralAxiosError(error);
        }
    }

    /**
     * Check if result is successful, result code should be in range 2xx
     * @param {Object} result Axios response object
     * @throws {Error} The status code is not in range 2xx
     */
    checkResult(result) {
        if (result.status == null) {
            throw new Error("PagerDuty notification failed with invalid response!");
        }
        if (result.status < 200 || result.status >= 300) {
            throw new Error("PagerDuty notification failed with status code " + result.status);
        }
    }

    /**