{
    "tailapp": 2,
    "manifest": {
        "format": 2,
        "app_id": "uptime",
        "name": "Uptime",
        "version": 2,
        "schema": "tailapps/v0",
        "exported_at": 1794851020,
        "from": "gallery",
        "connections": [],
        "files": {
            "app.json": "237fafdb603e67af257deb95e7f5f4ed1facf4de7a50745a960c73899ede6870"
        },
        "signature": "VLs74Z+LILTyJXIh/iUL6JZmewcYARyhpbNQI6K1OiWRjMtPRkI2c1Ar7amcxhsjiMlzDLMv9Al4acK0bVbGCg==",
        "key_id": "gallery-1"
    },
    "app": {
        "schema": "tailapps/v0",
        "app": "uptime",
        "name": "Uptime",
        "description": "Pings tailstats.com every 30 s; red when it's down or slow. For iPhone alerts when it goes down or comes back: turn on \"Alert my other devices\" on the Mac, then Sync to My Devices.",
        "icon": "waveform.path.ecg",
        "version": 2,
        "permissions": [
            "net:tailstats.com",
            "notify",
            "inbox:alerts",
            "send:alerts"
        ],
        "settings": {
            "alert_devices": {
                "type": "toggle",
                "label": "Alert my other devices",
                "default": false
            }
        },
        "state": {
            "health": {
                "type": "text",
                "default": "good"
            },
            "alerts": {
                "type": "list",
                "default": []
            }
        },
        "sources": {
            "site": {
                "fetch": "https://tailstats.com",
                "raw": true,
                "every": 30,
                "timeout": 10,
                "on_change": {
                    "action": "check",
                    "watch": "{$site.status | tone:{good:'<400', else:'bad'}}-{$site.ms | tone:{good:'<1500', else:'bad'}}"
                }
            },
            "incoming": {
                "inbox": "alerts",
                "on_receive": "received"
            }
        },
        "cards": [
            {
                "id": "main",
                "layout": {
                    "column": [
                        {
                            "row": [
                                {
                                    "stat": "$site.ms | number",
                                    "label": "Response (ms)",
                                    "tone": "$health"
                                },
                                {
                                    "spacer": true
                                },
                                {
                                    "badge": "$health | map:{good:'Up', else:'Down or slow'}",
                                    "tone": "$health"
                                }
                            ],
                            "align": "center"
                        },
                        {
                            "text": "HTTP {$site.status} \u00b7 checked {$meta.site.updated | ago}",
                            "size": "s",
                            "emphasis": "subtle"
                        },
                        {
                            "text": "$site.error",
                            "tone": "bad",
                            "size": "s",
                            "when": "$site.error"
                        },
                        {
                            "section": "Recent alerts",
                            "collapsible": true,
                            "collapsed": true,
                            "when": "$alerts",
                            "children": [
                                {
                                    "list": "$alerts",
                                    "limit": 5,
                                    "item": {
                                        "row": [
                                            {
                                                "badge": "$item.health | map:{good:'Back up', else:'Down'}",
                                                "tone": "$item.health"
                                            },
                                            {
                                                "text": "$item.device | default:'This device'",
                                                "size": "s",
                                                "grow": true
                                            },
                                            {
                                                "text": "$item.at | ago",
                                                "size": "s",
                                                "emphasis": "subtle"
                                            }
                                        ],
                                        "align": "center",
                                        "gap": "s"
                                    }
                                }
                            ]
                        }
                    ],
                    "gap": "m"
                }
            }
        ],
        "actions": {
            "check": {
                "steps": [
                    {
                        "set": {
                            "health": "$args.value | map:{good-good:'good', else:'bad'}"
                        }
                    },
                    {
                        "if": "$health | map:{bad:true, else:false}",
                        "then": [
                            {
                                "if": "$args.previous | default:'good-good' | map:{good-good:true, else:false}",
                                "then": [
                                    {
                                        "notify": {
                                            "title": "tailstats.com is down or slow",
                                            "body": "HTTP {$site.status} in {$site.ms} ms"
                                        }
                                    },
                                    {
                                        "push": {
                                            "alerts": {
                                                "health": "bad",
                                                "device": "",
                                                "at": "$now"
                                            }
                                        },
                                        "max": 20
                                    },
                                    {
                                        "if": "$settings.alert_devices",
                                        "then": [
                                            {
                                                "send": {
                                                    "alerts": {
                                                        "health": "bad",
                                                        "status": "$site.status",
                                                        "ms": "$site.ms",
                                                        "at": "$now"
                                                    }
                                                },
                                                "alert": "tailstats.com is down or slow"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ],
                        "else": [
                            {
                                "if": "$args.previous | default:'good-good' | map:{good-good:false, else:true}",
                                "then": [
                                    {
                                        "push": {
                                            "alerts": {
                                                "health": "good",
                                                "device": "",
                                                "at": "$now"
                                            }
                                        },
                                        "max": 20
                                    },
                                    {
                                        "if": "$settings.alert_devices",
                                        "then": [
                                            {
                                                "send": {
                                                    "alerts": {
                                                        "health": "good",
                                                        "status": "$site.status",
                                                        "ms": "$site.ms",
                                                        "at": "$now"
                                                    }
                                                },
                                                "alert": "tailstats.com is back up"
                                            }
                                        ]
                                    }
                                ]
                            }
                        ]
                    }
                ]
            },
            "received": {
                "steps": [
                    {
                        "if": "$args.event.health",
                        "then": [
                            {
                                "push": {
                                    "alerts": {
                                        "health": "$args.event.health | map:{good:'good', else:'bad'}",
                                        "device": "$args.from",
                                        "at": "$args.event.at"
                                    }
                                },
                                "max": 20
                            }
                        ]
                    }
                ]
            }
        },
        "views": {
            "menubar": {
                "icon": "waveform.path.ecg",
                "card": "main",
                "in_menu": "row",
                "label": "{$health | map:{good:'', else:'Down \u00b7 '}}{$site.ms} ms",
                "label_tone": "$health",
                "label_icon": "$health | map:{good:'waveform.path.ecg', else:'exclamationmark.triangle.fill'}"
            }
        }
    },
    "app_json": "{\n  \"schema\": \"tailapps/v0\",\n  \"app\": \"uptime\",\n  \"name\": \"Uptime\",\n  \"description\": \"Pings tailstats.com every 30 s; red when it's down or slow. For iPhone alerts when it goes down or comes back: turn on \\\"Alert my other devices\\\" on the Mac, then Sync to My Devices.\",\n  \"icon\": \"waveform.path.ecg\",\n  \"version\": 2,\n  \"permissions\": [\"net:tailstats.com\", \"notify\", \"inbox:alerts\", \"send:alerts\"],\n  \"settings\": {\n    \"alert_devices\": { \"type\": \"toggle\", \"label\": \"Alert my other devices\", \"default\": false }\n  },\n  \"state\": {\n    \"health\": { \"type\": \"text\", \"default\": \"good\" },\n    \"alerts\": { \"type\": \"list\", \"default\": [] }\n  },\n  \"sources\": {\n    \"site\": { \"fetch\": \"https://tailstats.com\", \"raw\": true, \"every\": 30, \"timeout\": 10,\n      \"on_change\": { \"action\": \"check\", \"watch\": \"{$site.status | tone:{good:'<400', else:'bad'}}-{$site.ms | tone:{good:'<1500', else:'bad'}}\" } },\n    \"incoming\": { \"inbox\": \"alerts\", \"on_receive\": \"received\" }\n  },\n  \"cards\": [{ \"id\": \"main\", \"layout\": { \"column\": [\n    { \"row\": [\n      { \"stat\": \"$site.ms | number\", \"label\": \"Response (ms)\", \"tone\": \"$health\" },\n      { \"spacer\": true },\n      { \"badge\": \"$health | map:{good:'Up', else:'Down or slow'}\", \"tone\": \"$health\" }\n    ], \"align\": \"center\" },\n    { \"text\": \"HTTP {$site.status} \u00b7 checked {$meta.site.updated | ago}\", \"size\": \"s\", \"emphasis\": \"subtle\" },\n    { \"text\": \"$site.error\", \"tone\": \"bad\", \"size\": \"s\", \"when\": \"$site.error\" },\n    { \"section\": \"Recent alerts\", \"collapsible\": true, \"collapsed\": true, \"when\": \"$alerts\", \"children\": [\n      { \"list\": \"$alerts\", \"limit\": 5, \"item\": { \"row\": [\n        { \"badge\": \"$item.health | map:{good:'Back up', else:'Down'}\", \"tone\": \"$item.health\" },\n        { \"text\": \"$item.device | default:'This device'\", \"size\": \"s\", \"grow\": true },\n        { \"text\": \"$item.at | ago\", \"size\": \"s\", \"emphasis\": \"subtle\" }\n      ], \"align\": \"center\", \"gap\": \"s\" } }\n    ] }\n  ], \"gap\": \"m\" } }],\n  \"actions\": {\n    \"check\": { \"steps\": [\n      { \"set\": { \"health\": \"$args.value | map:{good-good:'good', else:'bad'}\" } },\n      { \"if\": \"$health | map:{bad:true, else:false}\", \"then\": [\n        { \"if\": \"$args.previous | default:'good-good' | map:{good-good:true, else:false}\", \"then\": [\n          { \"notify\": { \"title\": \"tailstats.com is down or slow\", \"body\": \"HTTP {$site.status} in {$site.ms} ms\" } },\n          { \"push\": { \"alerts\": { \"health\": \"bad\", \"device\": \"\", \"at\": \"$now\" } }, \"max\": 20 },\n          { \"if\": \"$settings.alert_devices\", \"then\": [\n            { \"send\": { \"alerts\": { \"health\": \"bad\", \"status\": \"$site.status\", \"ms\": \"$site.ms\", \"at\": \"$now\" } }, \"alert\": \"tailstats.com is down or slow\" }\n          ] }\n        ] }\n      ], \"else\": [\n        { \"if\": \"$args.previous | default:'good-good' | map:{good-good:false, else:true}\", \"then\": [\n          { \"push\": { \"alerts\": { \"health\": \"good\", \"device\": \"\", \"at\": \"$now\" } }, \"max\": 20 },\n          { \"if\": \"$settings.alert_devices\", \"then\": [\n            { \"send\": { \"alerts\": { \"health\": \"good\", \"status\": \"$site.status\", \"ms\": \"$site.ms\", \"at\": \"$now\" } }, \"alert\": \"tailstats.com is back up\" }\n          ] }\n        ] }\n      ] }\n    ] },\n    \"received\": { \"steps\": [\n      { \"if\": \"$args.event.health\", \"then\": [\n        { \"push\": { \"alerts\": { \"health\": \"$args.event.health | map:{good:'good', else:'bad'}\", \"device\": \"$args.from\", \"at\": \"$args.event.at\" } }, \"max\": 20 }\n      ] }\n    ] }\n  },\n  \"views\": {\n    \"menubar\": { \"icon\": \"waveform.path.ecg\", \"card\": \"main\", \"in_menu\": \"row\",\n      \"label\": \"{$health | map:{good:'', else:'Down \u00b7 '}}{$site.ms} ms\",\n      \"label_tone\": \"$health\",\n      \"label_icon\": \"$health | map:{good:'waveform.path.ecg', else:'exclamationmark.triangle.fill'}\" }\n  }\n}\n",
    "files": []
}