mirror of
https://github.com/gravitl/netmaker.git
synced 2025-11-10 00:30:37 +08:00
Add telemetry for EE and FreeTier flags
This commit is contained in:
parent
45850ef4a1
commit
c97d6cfd66
3 changed files with 25 additions and 1 deletions
|
|
@ -22,8 +22,10 @@ func InitEE() {
|
||||||
ValidateLicense()
|
ValidateLicense()
|
||||||
if Limits.FreeTier {
|
if Limits.FreeTier {
|
||||||
logger.Log(0, "proceeding with Free Tier license")
|
logger.Log(0, "proceeding with Free Tier license")
|
||||||
|
logic.SetFreeTierForTelemetry(true)
|
||||||
} else {
|
} else {
|
||||||
logger.Log(0, "proceeding with Paid Tier license")
|
logger.Log(0, "proceeding with Paid Tier license")
|
||||||
|
logic.SetFreeTierForTelemetry(false)
|
||||||
}
|
}
|
||||||
// == End License Handling ==
|
// == End License Handling ==
|
||||||
AddLicenseHooks()
|
AddLicenseHooks()
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,14 @@ var isEnterprise bool
|
||||||
|
|
||||||
// IsEnterprise - checks if enterprise binary or not
|
// IsEnterprise - checks if enterprise binary or not
|
||||||
func IsEnterprise() bool {
|
func IsEnterprise() bool {
|
||||||
|
logic.SetEEForTelemetry(isEnterprise)
|
||||||
return isEnterprise
|
return isEnterprise
|
||||||
}
|
}
|
||||||
|
|
||||||
// setIsEnterprise - sets server to use enterprise features
|
// setIsEnterprise - sets server to use enterprise features
|
||||||
func setIsEnterprise() {
|
func setIsEnterprise() {
|
||||||
isEnterprise = true
|
isEnterprise = true
|
||||||
|
logic.SetEEForTelemetry(isEnterprise)
|
||||||
}
|
}
|
||||||
|
|
||||||
// base64encode - base64 encode helper function
|
// base64encode - base64 encode helper function
|
||||||
|
|
|
||||||
|
|
@ -10,12 +10,28 @@ import (
|
||||||
"github.com/posthog/posthog-go"
|
"github.com/posthog/posthog-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// flags to keep for telemetry
|
||||||
|
var isFreeTier bool
|
||||||
|
var isEE bool
|
||||||
|
|
||||||
// posthog_pub_key - Key for sending data to PostHog
|
// posthog_pub_key - Key for sending data to PostHog
|
||||||
const posthog_pub_key = "phc_1vEXhPOA1P7HP5jP2dVU9xDTUqXHAelmtravyZ1vvES"
|
const posthog_pub_key = "phc_1vEXhPOA1P7HP5jP2dVU9xDTUqXHAelmtravyZ1vvES"
|
||||||
|
|
||||||
// posthog_endpoint - Endpoint of PostHog server
|
// posthog_endpoint - Endpoint of PostHog server
|
||||||
const posthog_endpoint = "https://app.posthog.com"
|
const posthog_endpoint = "https://app.posthog.com"
|
||||||
|
|
||||||
|
// setEEForTelemetry - store EE flag without having an import cycle when used for telemetry
|
||||||
|
// (as the ee package needs the logic package as currently written).
|
||||||
|
func SetEEForTelemetry(eeFlag bool) {
|
||||||
|
isEE = eeFlag
|
||||||
|
}
|
||||||
|
|
||||||
|
// setFreeTierForTelemetry - store free tier flag without having an import cycle when used for telemetry
|
||||||
|
// (as the ee package needs the logic package as currently written).
|
||||||
|
func SetFreeTierForTelemetry(freeTierFlag bool) {
|
||||||
|
isFreeTier = freeTierFlag
|
||||||
|
}
|
||||||
|
|
||||||
// sendTelemetry - gathers telemetry data and sends to posthog
|
// sendTelemetry - gathers telemetry data and sends to posthog
|
||||||
func sendTelemetry() error {
|
func sendTelemetry() error {
|
||||||
if servercfg.Telemetry() == "off" {
|
if servercfg.Telemetry() == "off" {
|
||||||
|
|
@ -54,7 +70,9 @@ func sendTelemetry() error {
|
||||||
Set("freebsd", d.Count.FreeBSD).
|
Set("freebsd", d.Count.FreeBSD).
|
||||||
Set("docker", d.Count.Docker).
|
Set("docker", d.Count.Docker).
|
||||||
Set("k8s", d.Count.K8S).
|
Set("k8s", d.Count.K8S).
|
||||||
Set("version", d.Version),
|
Set("version", d.Version).
|
||||||
|
Set("is_ee", isEE).
|
||||||
|
Set("is_free_tier", isFreeTier),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,6 +162,8 @@ type telemetryData struct {
|
||||||
Networks int
|
Networks int
|
||||||
Servers int
|
Servers int
|
||||||
Version string
|
Version string
|
||||||
|
IsEE bool
|
||||||
|
IsFreeTier bool
|
||||||
}
|
}
|
||||||
|
|
||||||
// clientCount - What types of netclients we're tallying
|
// clientCount - What types of netclients we're tallying
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue