Skip to content

Commit 9dae8dc

Browse files
mergify[bot]Pantanijulienrbrt
authored
feat: migrate to matomo analytics (backport #4095) (#4182)
* 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> (cherry picked from commit e49e11d) # Conflicts: # ignite/internal/analytics/analytics.go # ignite/pkg/gacli/gacli.go * update changelog * fix merge conflicts --------- Co-authored-by: Danilo Pantani <[email protected]> Co-authored-by: Julien Robert <[email protected]>
1 parent 944283b commit 9dae8dc

File tree

6 files changed

+414
-73
lines changed

6 files changed

+414
-73
lines changed

Diff for: changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Changes
66

7+
- [#4095](https://github.com/ignite/cli/pull/4095) Migrate to matomo analytics
78
- [#4149](https://github.com/ignite/cli/pull/4149) Bump cometbft to `v0.38.7`
89
- [#4168](https://github.com/ignite/cli/pull/4168) Bump IBC to `v8.3.1`
910
If you are upgrading manually from `v8.2.0` to `v8.3.1`, add the following to your `ibc.go` file:

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,33 +1,33 @@
11
package analytics
22

33
import (
4+
"context"
45
"encoding/json"
56
"os"
67
"path/filepath"
7-
"runtime"
88
"strconv"
99
"strings"
1010
"sync"
1111

1212
"github.com/manifoldco/promptui"
1313
"github.com/spf13/cobra"
1414

15-
"github.com/ignite/cli/v28/ignite/pkg/gacli"
1615
"github.com/ignite/cli/v28/ignite/pkg/gitpod"
16+
"github.com/ignite/cli/v28/ignite/pkg/matomo"
1717
"github.com/ignite/cli/v28/ignite/pkg/randstr"
1818
"github.com/ignite/cli/v28/ignite/version"
1919
)
2020

2121
const (
22-
telemetryEndpoint = "https://telemetry-cli.ignite.com"
22+
telemetryEndpoint = "https://matomo-cli.ignite.com"
2323
envDoNotTrack = "DO_NOT_TRACK"
2424
envCI = "CI"
2525
envGitHubActions = "GITHUB_ACTIONS"
2626
igniteDir = ".ignite"
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

@@ -97,7 +124,7 @@ func checkDNT() (anonIdentity, error) {
97124
return i, nil
98125
}
99126

100-
i.Name = randstr.Runes(10)
127+
i.Name = randstr.Runes(16)
101128
i.DoNotTrack = false
102129

103130
prompt := promptui.Select{

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

-2
This file was deleted.

0 commit comments

Comments
 (0)