Files
pmg/internal/analytics/analytics_test.go
0e17378d3e feat: add posthog analytics support (#52)
* feat: add posthog analytics events

* Update internal/analytics/analytics.go

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>

---------

Signed-off-by: Sahil Bansal <bansalsahil315@gmail.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-06-30 09:47:14 +05:30

30 lines
587 B
Go

package analytics
import (
"os"
"testing"
"github.com/stretchr/testify/assert"
)
func TestIsDisabled(t *testing.T) {
t.Run("returns true if PMG_DISABLE_TELEMETRY is set to true", func(t *testing.T) {
os.Setenv(telemetryDisableEnvKey, "true")
defer os.Unsetenv(telemetryDisableEnvKey)
assert.True(t, IsDisabled())
})
t.Run("returns false if PMG_DISABLE_TELEMETRY is not set", func(t *testing.T) {
assert.False(t, IsDisabled())
})
}
func TestCloseIsImmutable(t *testing.T) {
Close()
assert.Nil(t, globalPosthogClient)
Close()
assert.Nil(t, globalPosthogClient)
}