1
1
package analytics
2
2
3
3
import (
4
+ "context"
4
5
"encoding/json"
5
6
"os"
6
7
"path/filepath"
7
- "runtime"
8
8
"strconv"
9
9
"strings"
10
10
"sync"
11
11
12
12
"github.com/manifoldco/promptui"
13
13
"github.com/spf13/cobra"
14
14
15
- "github.com/ignite/cli/v28/ignite/pkg/gacli"
16
15
"github.com/ignite/cli/v28/ignite/pkg/gitpod"
16
+ "github.com/ignite/cli/v28/ignite/pkg/matomo"
17
17
"github.com/ignite/cli/v28/ignite/pkg/randstr"
18
18
"github.com/ignite/cli/v28/ignite/version"
19
19
)
20
20
21
21
const (
22
- telemetryEndpoint = "https://telemetry -cli.ignite.com"
22
+ telemetryEndpoint = "https://matomo -cli.ignite.com"
23
23
envDoNotTrack = "DO_NOT_TRACK"
24
24
envCI = "CI"
25
25
envGitHubActions = "GITHUB_ACTIONS"
26
26
igniteDir = ".ignite"
27
27
igniteAnonIdentity = "anon_identity.json"
28
28
)
29
29
30
- var gaclient gacli .Client
30
+ var matomoClient matomo .Client
31
31
32
32
// anonIdentity represents an analytics identity file.
33
33
type anonIdentity struct {
@@ -38,7 +38,11 @@ type anonIdentity struct {
38
38
}
39
39
40
40
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
+ )
42
46
}
43
47
44
48
// SendMetric send command metrics to analytics.
@@ -52,23 +56,46 @@ func SendMetric(wg *sync.WaitGroup, cmd *cobra.Command) {
52
56
return
53
57
}
54
58
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 (),
66
93
}
67
94
68
95
wg .Add (1 )
69
96
go func () {
70
97
defer wg .Done ()
71
- _ = gaclient .SendMetric (met )
98
+ _ = matomoClient .SendMetric (dntInfo . Name , met )
72
99
}()
73
100
}
74
101
@@ -97,7 +124,7 @@ func checkDNT() (anonIdentity, error) {
97
124
return i , nil
98
125
}
99
126
100
- i .Name = randstr .Runes (10 )
127
+ i .Name = randstr .Runes (16 )
101
128
i .DoNotTrack = false
102
129
103
130
prompt := promptui.Select {
0 commit comments