MCPcopy Create free account
hub / github.com/devaccuracy/ledgerforge / initializePostHog

Function initializePostHog

cmd/server.go:238–257  ·  view source on GitHub ↗
(cfg *config.Configuration)

Source from the content-addressed store, hash-verified

236}
237
238func 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
259func startServer(router *gin.Engine, port string) error {
260 server := &http.Server{

Callers 1

Calls 3

getOrCreateHeartbeatIDFunction · 0.85
sendHeartbeatFunction · 0.85
WarnMethod · 0.45

Tested by

no test coverage detected