diff --git a/api/RestHandler.go b/api/RestHandler.go index 963c043..6ffe5ba 100644 --- a/api/RestHandler.go +++ b/api/RestHandler.go @@ -12,10 +12,23 @@ import ( "strconv" ) +const ( + TelemetryApiKeyEndpoint string = "aHR0cHM6Ly90ZWxlbWV0cnkuZGV2dHJvbi5haS9kZXZ0cm9uL3RlbGVtZXRyeS9hcGlrZXk=" + TelemetryOptOutApiBaseUrl string = "aHR0cHM6Ly90ZWxlbWV0cnkuZGV2dHJvbi5haS9kZXZ0cm9uL3RlbGVtZXRyeS9vcHQtb3V0" + PosthogEndpointUrl string = "https://app.posthog.com" +) + +type PosthogConfig struct { + PosthogEndpoint string `json:"posthogEndpoint,omitempty"` + TelemetryApiKeyEndpoint string `json:"telemetryApiKeyEndpoint,omitempty"` +} + type RestHandler interface { GetReleases(w http.ResponseWriter, r *http.Request) ReleaseWebhookHandler(w http.ResponseWriter, r *http.Request) GetModules(w http.ResponseWriter, r *http.Request) + GetPostHogInfo(w http.ResponseWriter, r *http.Request) + GetPostHogOptOutApiBaseUrl(w http.ResponseWriter, r *http.Request) } func NewRestHandlerImpl(logger *zap.SugaredLogger, releaseNoteService pkg.ReleaseNoteService, @@ -158,3 +171,21 @@ func (impl *RestHandlerImpl) ReleaseWebhookHandler(w http.ResponseWriter, r *htt impl.WriteJsonResp(w, err, flag, http.StatusOK) return } + +func (impl *RestHandlerImpl) GetPostHogInfo(w http.ResponseWriter, r *http.Request) { + impl.logger.Debug("Get PostHog Info") + setupResponse(&w, r) + posthogConfig := &PosthogConfig{ + PosthogEndpoint: PosthogEndpointUrl, + TelemetryApiKeyEndpoint: TelemetryApiKeyEndpoint, + } + impl.WriteJsonResp(w, nil, posthogConfig, http.StatusOK) + return +} + +func (impl *RestHandlerImpl) GetPostHogOptOutApiBaseUrl(w http.ResponseWriter, r *http.Request) { + impl.logger.Debug("Get PostHog Opt-out Base Url") + setupResponse(&w, r) + impl.WriteJsonResp(w, nil, TelemetryOptOutApiBaseUrl, http.StatusOK) + return +} diff --git a/api/Router.go b/api/Router.go index 7cf906c..0bf60e6 100644 --- a/api/Router.go +++ b/api/Router.go @@ -38,5 +38,6 @@ func (r MuxRouter) Init() { r.Router.Path("/release/notes").HandlerFunc(r.restHandler.GetReleases).Methods("GET") r.Router.Path("/release/webhook").HandlerFunc(r.restHandler.ReleaseWebhookHandler).Methods("POST") r.Router.Path("/modules").HandlerFunc(r.restHandler.GetModules).Methods("GET") - + r.Router.Path("/telemetry").HandlerFunc(r.restHandler.GetPostHogInfo).Methods("GET") + r.Router.Path("/telemetry/optouturl").HandlerFunc(r.restHandler.GetPostHogOptOutApiBaseUrl).Methods("GET") }