(cfg *config.Configuration)
| 236 | } |
| 237 | |
| 238 | func initializePostHog(cfg *config.Configuration) (posthog.Client, string) { |
| 239 | if cfg.TelemetryKey == "" { |
| 240 | logrus.Warn("telemetry is enabled but LEDGERFORGE_TELEMETRY_KEY is not configured; skipping telemetry") |
| 241 | return nil, "" |
| 242 | } |
| 243 | |
| 244 | phConfig := posthog.Config{} |
| 245 | if cfg.TelemetryEndpoint != "" { |
| 246 | phConfig.Endpoint = cfg.TelemetryEndpoint |
| 247 | } |
| 248 | |
| 249 | client, err := posthog.NewWithConfig(cfg.TelemetryKey, phConfig) |
| 250 | if err != nil { |
| 251 | logrus.WithError(err).Warn("failed to initialize telemetry client; skipping telemetry") |
| 252 | return nil, "" |
| 253 | } |
| 254 | heartbeatID := getOrCreateHeartbeatID() |
| 255 | sendHeartbeat(client, heartbeatID) |
| 256 | return client, heartbeatID |
| 257 | } |
| 258 | |
| 259 | func startServer(router *gin.Engine, port string) error { |
| 260 | server := &http.Server{ |
no test coverage detected