Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate to matomo analytics #4095

Merged
merged 32 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
fc2d6de
add matomo anlytics
Apr 22, 2024
b4c0d65
Merge remote-tracking branch 'origin/main' into feat/matomo-metrics
Apr 24, 2024
fbe9d26
Merge branch 'main' into feat/matomo-metrics
Pantani Apr 24, 2024
bcd9b8b
Merge branch 'main' into feat/matomo-metrics
Pantani Apr 26, 2024
35ff370
Merge branch 'main' into feat/matomo-metrics
Pantani May 3, 2024
1b8c061
Merge branch 'main' into feat/matomo-metrics
Pantani May 14, 2024
20f3697
Merge branch 'main' into feat/matomo-metrics
Pantani May 14, 2024
f454e2f
Merge branch 'main' into feat/matomo-metrics
Pantani May 15, 2024
d91378c
Merge branch 'main' into feat/matomo-metrics
Pantani May 16, 2024
067c0ef
Merge branch 'main' into feat/matomo-metrics
Pantani May 16, 2024
8a8f66f
Merge branch 'main' into feat/matomo-metrics
Pantani May 16, 2024
b9235d9
Merge branch 'main' into feat/matomo-metrics
Pantani May 16, 2024
51b0da9
matomo url
May 17, 2024
98dda16
Merge remote-tracking branch 'origin/main' into feat/matomo-metrics
May 22, 2024
28985e5
add changelog
May 22, 2024
149afbf
matomo analytics refacor
May 27, 2024
7b42ece
build analytics url
May 28, 2024
4df424e
fix matomo request parameters
May 28, 2024
9f680ea
remove unused parameters and improve readability
May 28, 2024
75f667d
Merge branch 'main' into feat/matomo-metrics
Pantani May 28, 2024
faffd9d
remove unused matomo request response parser
May 28, 2024
ebae6fe
Merge branch 'main' into feat/matomo-metrics
Pantani May 28, 2024
970cab4
Merge branch 'main' into feat/matomo-metrics
Pantani May 29, 2024
ecf2424
fix analytics data
May 29, 2024
69a63f7
change the source name to github
May 29, 2024
56b097b
Merge branch 'main' into feat/matomo-metrics
Pantani May 31, 2024
f5e216c
fix UTM values
May 31, 2024
88d1580
fix scaffold type condition
Jun 3, 2024
226722d
remove gacli pkg
Jun 3, 2024
5f11305
Merge branch 'main' into feat/matomo-metrics
Pantani Jun 4, 2024
a275964
Merge branch 'main' into feat/matomo-metrics
Pantani Jun 5, 2024
02d477e
Merge branch 'main' into feat/matomo-metrics
Pantani Jun 7, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
- [#4133](https://github.com/ignite/cli/pull/4133) Improve buf rate limit
- [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically
- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands
- [#4095](https://github.com/ignite/cli/pull/4095) Migrate to matomo analytics

### Changes

Expand Down
9 changes: 7 additions & 2 deletions ignite/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ func NewVersion() *cobra.Command {
c := &cobra.Command{
Use: "version",
Short: "Print the current build information",
Run: func(cmd *cobra.Command, _ []string) {
cmd.Println(version.Long(cmd.Context()))
RunE: func(cmd *cobra.Command, _ []string) error {
v, err := version.Long(cmd.Context())
if err != nil {
return err
}
cmd.Println(v)
return nil
},
}
return c
Expand Down
63 changes: 45 additions & 18 deletions ignite/internal/analytics/analytics.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package analytics

import (
"context"
"encoding/json"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"
Expand All @@ -13,21 +13,21 @@ import (
"github.com/spf13/cobra"

"github.com/ignite/cli/v29/ignite/config"
"github.com/ignite/cli/v29/ignite/pkg/gacli"
"github.com/ignite/cli/v29/ignite/pkg/gitpod"
"github.com/ignite/cli/v29/ignite/pkg/matomo"
"github.com/ignite/cli/v29/ignite/pkg/randstr"
"github.com/ignite/cli/v29/ignite/version"
)

const (
telemetryEndpoint = "https://telemetry-cli.ignite.com"
telemetryEndpoint = "https://matomo-cli.ignite.com"
envDoNotTrack = "DO_NOT_TRACK"
envCI = "CI"
envGitHubActions = "GITHUB_ACTIONS"
igniteAnonIdentity = "anon_identity.json"
)

var gaclient gacli.Client
var matomoClient matomo.Client

// anonIdentity represents an analytics identity file.
type anonIdentity struct {
Expand All @@ -38,7 +38,11 @@ type anonIdentity struct {
}

func init() {
gaclient = gacli.New(telemetryEndpoint)
matomoClient = matomo.New(
telemetryEndpoint,
matomo.WithIDSite(4),
matomo.WithSource("https://cli.ignite.com"),
)
}

// SendMetric send command metrics to analytics.
Expand All @@ -52,23 +56,46 @@ func SendMetric(wg *sync.WaitGroup, cmd *cobra.Command) {
return
}

path := cmd.CommandPath()
met := gacli.Metric{
Name: cmd.Name(),
Cmd: path,
Tag: strings.ReplaceAll(path, " ", "+"),
OS: runtime.GOOS,
Arch: runtime.GOARCH,
SessionID: dntInfo.Name,
Version: version.Version,
IsGitPod: gitpod.IsOnGitpod(),
IsCI: getIsCI(),
versionInfo, err := version.GetInfo(context.Background())
if err != nil {
return
}

var (
path = cmd.CommandPath()
scaffoldType = ""
)
if strings.Contains(path, "ignite scaffold") {
Pantani marked this conversation as resolved.
Show resolved Hide resolved
splitCMD := strings.Split(path, " ")
if len(splitCMD) > 2 {
scaffoldType = splitCMD[2]
}
}

met := matomo.Metric{
Name: cmd.Name(),
Cmd: path,
ScaffoldType: scaffoldType,
OS: versionInfo.OS,
Arch: versionInfo.Arch,
Version: versionInfo.CLIVersion,
CLIVersion: versionInfo.CLIVersion,
GoVersion: versionInfo.GoVersion,
SDKVersion: versionInfo.SDKVersion,
BuildDate: versionInfo.BuildDate,
SourceHash: versionInfo.SourceHash,
ConfigVersion: versionInfo.ConfigVersion,
Uname: versionInfo.Uname,
CWD: versionInfo.CWD,
BuildFromSource: versionInfo.BuildFromSource,
IsGitPod: gitpod.IsOnGitpod(),
IsCI: getIsCI(),
}

wg.Add(1)
go func() {
defer wg.Done()
_ = gaclient.SendMetric(met)
_ = matomoClient.SendMetric(dntInfo.Name, met)
}()
}

Expand Down Expand Up @@ -98,7 +125,7 @@ func checkDNT() (anonIdentity, error) {
return i, nil
}

i.Name = randstr.Runes(10)
i.Name = randstr.Runes(16)
i.DoNotTrack = false

prompt := promptui.Select{
Expand Down
2 changes: 0 additions & 2 deletions ignite/pkg/gacli/doc.go

This file was deleted.

125 changes: 0 additions & 125 deletions ignite/pkg/gacli/gacli.go
Pantani marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

Loading
Loading