mirror of
https://github.com/lukaszraczylo/go-telegram.git
synced 2026-06-05 22:43:59 +00:00
609c4ce649
Sends one fire-and-forget POST per process the first time a consumer constructs a Bot via client.New. Helps track real-world adoption and version spread of the library. No identifiers, no API contents. Implementation: - new client/version.go: exported Version var (currently 0.7.11) - new client/telemetry.go: sync.Once gate + telemetry.Send call - client.go New(): single fireTelemetryOnce() line at function entry - client/telemetry_test.go: TestMain disables outgoing pings during the library's own test suite README §Telemetry documents the payload, the opt-out env vars, and links to the upstream oss-telemetry source so consumers can audit what is sent. Opt out via any of: DO_NOT_TRACK=1 OSS_TELEMETRY_DISABLED=1 GO_TELEGRAM_DISABLE_TELEMETRY=1 osstelemetry.Disable() before the first client.New
34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package client
|
|
|
|
import (
|
|
"sync"
|
|
|
|
telemetry "github.com/lukaszraczylo/oss-telemetry"
|
|
)
|
|
|
|
// telemetryOnce guards the single anonymous "library used" ping that is sent
|
|
// on the first call to New. Long-running bots typically construct one Bot;
|
|
// short-lived programs or test suites may construct many, but the Once gate
|
|
// keeps the fire-and-forget call from amplifying into per-construction pings.
|
|
var telemetryOnce sync.Once
|
|
|
|
// fireTelemetryOnce dispatches a fire-and-forget anonymous adoption ping.
|
|
//
|
|
// The call is failproof by contract of oss-telemetry: it never blocks New,
|
|
// never panics, never returns errors, and silently no-ops if disabled or
|
|
// if the network is unavailable.
|
|
//
|
|
// Opt-out is honored via any of these environment variables (case-insensitive
|
|
// truthy values "1", "true", "yes", "on"):
|
|
//
|
|
// - DO_NOT_TRACK
|
|
// - OSS_TELEMETRY_DISABLED
|
|
// - GO_TELEGRAM_DISABLE_TELEMETRY
|
|
//
|
|
// See README §Telemetry for the full disclosure.
|
|
func fireTelemetryOnce() {
|
|
telemetryOnce.Do(func() {
|
|
telemetry.Send("go-telegram", Version)
|
|
})
|
|
}
|