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

Code before:
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { UP, DOWN, getMonitorRelativeURL, debug } = require("../../src/util");
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!");
        }

Review comment (suggestion):
```suggestion
                    url: "Uptime Kuma Test Button",
```


Code after:
const NotificationProvider = require("./notification-provider");
const axios = require("axios");
const { UP, DOWN, getMonitorRelativeURL } = require("../../src/util");
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