sendHeartbeat initializes and maintains a periodic heartbeat to PostHog
(client posthog.Client, heartbeatID string)
| 138 | |
| 139 | // sendHeartbeat initializes and maintains a periodic heartbeat to PostHog |
| 140 | func sendHeartbeat(client posthog.Client, heartbeatID string) { |
| 141 | ticker := time.NewTicker(5 * time.Minute) |
| 142 | go func() { |
| 143 | for range ticker.C { |
| 144 | if err := client.Enqueue(posthog.Capture{ |
| 145 | DistinctId: heartbeatID, |
| 146 | Event: "server_heartbeat", |
| 147 | Timestamp: time.Now().UTC(), |
| 148 | Properties: map[string]interface{}{ |
| 149 | "timestamp": time.Now().UTC(), |
| 150 | }, |
| 151 | }); err != nil { |
| 152 | logrus.Errorf("Failed to send heartbeat: %v", err) |
| 153 | } |
| 154 | } |
| 155 | }() |
| 156 | } |
| 157 | |
| 158 | func healthCheckHandler(c *gin.Context) { |
| 159 | cfg, err := config.Fetch() |
no test coverage detected