From 86fed256b5c3a1594e8dd98938cbaa613ba18a92 Mon Sep 17 00:00:00 2001 From: the_aceix Date: Mon, 4 Mar 2024 11:29:56 +0000 Subject: [PATCH] feat(NET-1034): add trial data to telemetry --- logic/telemetry.go | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/logic/telemetry.go b/logic/telemetry.go index 12b7035c6e..be2ec060b0 100644 --- a/logic/telemetry.go +++ b/logic/telemetry.go @@ -67,7 +67,9 @@ func sendTelemetry() error { Set("k8s", d.Count.K8S). Set("version", d.Version). Set("is_ee", d.IsPro). // TODO change is_ee to is_pro for consistency, but probably needs changes in posthog - Set("is_free_tier", isFreeTier), + Set("is_free_tier", isFreeTier). + Set("is_pro_trial", d.IsProTrial). + Set("pro_trial_end_date", d.ProTrialEndDate), }) } @@ -87,6 +89,14 @@ func FetchTelemetryData() (telemetryData, error) { data.Nodes = len(nodes) data.Count = getClientCount(nodes) } + endDate, err := GetTrialEndDate() + if err != nil { + logger.Log(0, "error getting trial end date", err.Error()) + } + if endDate.After(time.Now()) { + data.IsProTrial = true + data.ProTrialEndDate = endDate + } return data, err } @@ -162,16 +172,18 @@ func getDBLength(dbname string) int { // telemetryData - What data to send to posthog type telemetryData struct { - Nodes int - Hosts int - ExtClients int - Users int - Count clientCount - Networks int - Servers int - Version string - IsPro bool - IsFreeTier bool + Nodes int + Hosts int + ExtClients int + Users int + Count clientCount + Networks int + Servers int + Version string + IsPro bool + IsFreeTier bool + IsProTrial bool + ProTrialEndDate time.Time } // clientCount - What types of netclients we're tallying