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

Code before:
                },
            ];

            // add time if available
            if (heartbeatJSON) {
                sectionWidgets.push({
                    textParagraph: {
                        text: `<b>Time (UTC):</b>\n${heartbeatJSON["localDateTime"]}`,
                    },
                });
            }

            // add button for monitor link if available
            const baseURL = await setting("primaryBaseURL");
            if (baseURL) {
                sectionWidgets.push({
                    buttonList: {
                        buttons: [
                            {
                                text: "Visit Uptime Kuma",
                                onClick: {
                                    openLink: {
                                        url:
                                            baseURL + (monitorJSON ? getMonitorRelativeURL(
                                                monitorJSON.id
                                            ) : "/"),
                                    },
                                },
                            },
                        ],
                    },
                });
            }

            // construct first section
            let chatSections = [
                {
                    widgets: sectionWidgets,
                },
            ];

            // construct json data
            let data = {
                cardsV2: [
                    {
                        card: {
                            header: chatHeader,
                            sections: chatSections,
                        },
                    },
                ],

Review comment (refactor):
nit:Extracting this might be more readable
```suggestion
                const urlPath = monitorJSON ? getMonitorRelativeURL(monitorJSON.id) : "/"
                sectionWidgets.push({
                    buttonList: {
                        buttons: [
                            {
                                text: "Visit Uptime Kuma",
                                onClick: {
                                    openLink: {
                                        url: baseURL + urlPath,
```

Code after:
                },
            ];

            // add time if available
            if (heartbeatJSON) {
                sectionWidgets.push({
                    textParagraph: {
                        text: `<b>Time (${heartbeatJSON["timezone"]}):</b>\n${heartbeatJSON["localDateTime"]}`,
                    },
                });
            }

            // add button for monitor link if available
            const baseURL = await setting("primaryBaseURL");
            if (baseURL) {
                const urlPath = monitorJSON ? getMonitorRelativeURL(monitorJSON.id) : "/";
                sectionWidgets.push({
                    buttonList: {
                        buttons: [
                            {
                                text: "Visit Uptime Kuma",
                                onClick: {
                                    openLink: {
                                        url: baseURL + urlPath,
                                    },
                                },
                            },
                        ],
                    },
                });
            }

            let chatSections = [
                {
                    widgets: sectionWidgets,
                },
            ];

            // construct json data
            let data = {
                cardsV2: [
                    {
                        card: {
                            header: chatHeader,
                            sections: chatSections,
                        },
                    },
                ],
            };

            await axios.post(notification.googleChatWebhookURL, data);