Skip to content

Commit e49e11d

Browse files
authored
feat: migrate to matomo analytics (#4095)
* add matomo anlytics * matomo url * add changelog * matomo analytics refacor * build analytics url * fix matomo request parameters * remove unused parameters and improve readability * remove unused matomo request response parser * fix analytics data * change the source name to github * fix UTM values * fix scaffold type condition * remove gacli pkg --------- Co-authored-by: Pantani <Pantani>
1 parent 24770f1 commit e49e11d

File tree

7 files changed

+414
-198
lines changed

7 files changed

+414
-198
lines changed

Diff for: changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
- [#4133](https://github.com/ignite/cli/pull/4133) Improve buf rate limit
2121
- [#4113](https://github.com/ignite/cli/pull/4113) Generate chain config documentation automatically
2222
- [#4131](https://github.com/ignite/cli/pull/4131) Support `bytes` as data type in the `scaffold` commands
23+
- [#4095](https://github.com/ignite/cli/pull/4095) Migrate to matomo analytics
2324

2425
### Changes
2526

Diff for: ignite/cmd/version.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,13 @@ func NewVersion() *cobra.Command {
1111
c := &cobra.Command{
1212
Use: "version",
1313
Short: "Print the current build information",
14-
Run: func(cmd *cobra.Command, _ []string) {
15-
cmd.Println(version.Long(cmd.Context()))
14+
RunE: func(cmd *cobra.Command, _ []string) error {
15+
v, err := version.Long(cmd.Context())
16+
if err != nil {
17+
return err
18+
}
19+
cmd.Println(v)
20+
return nil
1621
},
1722
}
1823
return c

Diff for: ignite/internal/analytics/analytics.go

+45-18
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
package analytics
22

33
import (
4+
"context"
45
"encoding/json"
56
"os"
67
"path/filepath"
7-
"runtime"
88
"strconv"
99
"strings"
1010
"sync"
@@ -13,21 +13,21 @@ import (
1313
"github.com/spf13/cobra"
1414

1515
"github.com/ignite/cli/v29/ignite/config"
16-
"github.com/ignite/cli/v29/ignite/pkg/gacli"
1716
"github.com/ignite/cli/v29/ignite/pkg/gitpod"
17+
"github.com/ignite/cli/v29/ignite/pkg/matomo"
1818
"github.com/ignite/cli/v29/ignite/pkg/randstr"
1919
"github.com/ignite/cli/v29/ignite/version"
2020
)
2121

2222
const (
23-
telemetryEndpoint = "https://telemetry-cli.ignite.com"
23+
telemetryEndpoint = "https://matomo-cli.ignite.com"
2424
envDoNotTrack = "DO_NOT_TRACK"
2525
envCI = "CI"
2626
envGitHubActions = "GITHUB_ACTIONS"
2727
igniteAnonIdentity = "anon_identity.json"
2828
)
2929

30-
var gaclient gacli.Client
30+
var matomoClient matomo.Client
3131

3232
// anonIdentity represents an analytics identity file.
3333
type anonIdentity struct {
@@ -38,7 +38,11 @@ type anonIdentity struct {
3838
}
3939

4040
func init() {
41-
gaclient = gacli.New(telemetryEndpoint)
41+
matomoClient = matomo.New(
42+
telemetryEndpoint,
43+
matomo.WithIDSite(4),
44+
matomo.WithSource("https://cli.ignite.com"),
45+
)
4246
}
4347

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

55-
path := cmd.CommandPath()
56-
met := gacli.Metric{
57-
Name: cmd.Name(),
58-
Cmd: path,
59-
Tag: strings.ReplaceAll(path, " ", "+"),
60-
OS: runtime.GOOS,
61-
Arch: runtime.GOARCH,
62-
SessionID: dntInfo.Name,
63-
Version: version.Version,
64-
IsGitPod: gitpod.IsOnGitpod(),
65-
IsCI: getIsCI(),
59+
versionInfo, err := version.GetInfo(context.Background())
60+
if err != nil {
61+
return
62+
}
63+
64+
var (
65+
path = cmd.CommandPath()
66+
scaffoldType = ""
67+
)
68+
if strings.Contains(path, "ignite scaffold") {
69+
splitCMD := strings.Split(path, " ")
70+
if len(splitCMD) > 2 {
71+
scaffoldType = splitCMD[2]
72+
}
73+
}
74+
75+
met := matomo.Metric{
76+
Name: cmd.Name(),
77+
Cmd: path,
78+
ScaffoldType: scaffoldType,
79+
OS: versionInfo.OS,
80+
Arch: versionInfo.Arch,
81+
Version: versionInfo.CLIVersion,
82+
CLIVersion: versionInfo.CLIVersion,
83+
GoVersion: versionInfo.GoVersion,
84+
SDKVersion: versionInfo.SDKVersion,
85+
BuildDate: versionInfo.BuildDate,
86+
SourceHash: versionInfo.SourceHash,
87+
ConfigVersion: versionInfo.ConfigVersion,
88+
Uname: versionInfo.Uname,
89+
CWD: versionInfo.CWD,
90+
BuildFromSource: versionInfo.BuildFromSource,
91+
IsGitPod: gitpod.IsOnGitpod(),
92+
IsCI: getIsCI(),
6693
}
6794

6895
wg.Add(1)
6996
go func() {
7097
defer wg.Done()
71-
_ = gaclient.SendMetric(met)
98+
_ = matomoClient.SendMetric(dntInfo.Name, met)
7299
}()
73100
}
74101

@@ -98,7 +125,7 @@ func checkDNT() (anonIdentity, error) {
98125
return i, nil
99126
}
100127

101-
i.Name = randstr.Runes(10)
128+
i.Name = randstr.Runes(16)
102129
i.DoNotTrack = false
103130

104131
prompt := promptui.Select{

Diff for: ignite/pkg/gacli/doc.go

-2
This file was deleted.

Diff for: ignite/pkg/gacli/gacli.go

-125
This file was deleted.

0 commit comments

Comments
 (0)