Skip to content

Commit

Permalink
feat: migrate to matomo analytics (#4095)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
Pantani authored and mergify[bot] committed Jun 7, 2024
1 parent 726d376 commit 77eea75
Show file tree
Hide file tree
Showing 6 changed files with 440 additions and 72 deletions.
20 changes: 20 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,26 @@

## Unreleased

### Features

- [#3707](https://github.com/ignite/cli/pull/3707) and [#4094](https://github.com/ignite/cli/pull/4094) Add collections support.
- [#3977](https://github.com/ignite/cli/pull/3977) Add `chain lint` command to lint the chain's codebase using `golangci-lint`
- [#3770](https://github.com/ignite/cli/pull/3770) Add `scaffold configs` and `scaffold params` commands
- [#4001](https://github.com/ignite/cli/pull/4001) Improve `xgenny` dry run
- [#3967](https://github.com/ignite/cli/issues/3967) Add HD wallet parameters `address index` and `account number` to the chain account config
- [#4004](https://github.com/ignite/cli/pull/4004) Remove all import placeholders using the `xast` pkg
- [#4076](https://github.com/ignite/cli/pull/4076) Remove the ignite `relayer` and `tools` commands with all ts-relayer logic
- [#4071](https://github.com/ignite/cli/pull/4071) Support custom proto path
- [#3718](https://github.com/ignite/cli/pull/3718) Add `gen-mig-diffs` tool app to compare scaffold output of two versions of ignite
- [#4077](https://github.com/ignite/cli/pull/4077) Merge the swagger files manually instead use nodetime `swagger-combine`
- [#4090](https://github.com/ignite/cli/pull/4090) Remove `protoc` pkg and also nodetime helpers `ts-proto` and `sta`
- [#4100](https://github.com/ignite/cli/pull/4100) Set the `proto-dir` flag only for the `scaffold chain` command and use the proto path from the config
- [#4111](https://github.com/ignite/cli/pull/4111) Remove vuex generation
- [#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

- [#4149](https://github.com/ignite/cli/pull/4149) Bump cometbft to `v0.38.7`
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
69 changes: 52 additions & 17 deletions ignite/internal/analytics/analytics.go
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
package analytics

import (
"context"
"encoding/json"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
"sync"

"github.com/manifoldco/promptui"
"github.com/spf13/cobra"

<<<<<<< HEAD

Check failure on line 15 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest)

missing import path

Check failure on line 15 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
"github.com/ignite/cli/v28/ignite/pkg/gacli"
"github.com/ignite/cli/v28/ignite/pkg/gitpod"
"github.com/ignite/cli/v28/ignite/pkg/randstr"
"github.com/ignite/cli/v28/ignite/version"
=======

Check failure on line 20 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
"github.com/ignite/cli/v29/ignite/config"
"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"
>>>>>>> e49e11df (feat: migrate to matomo analytics (#4095))

Check failure on line 26 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
)

const (

Check failure on line 29 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
telemetryEndpoint = "https://telemetry-cli.ignite.com"
telemetryEndpoint = "https://matomo-cli.ignite.com"
envDoNotTrack = "DO_NOT_TRACK"

Check failure on line 31 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
envCI = "CI"

Check failure on line 32 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
envGitHubActions = "GITHUB_ACTIONS"

Check failure on line 33 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
igniteDir = ".ignite"

Check failure on line 34 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
igniteAnonIdentity = "anon_identity.json"

Check failure on line 35 in ignite/internal/analytics/analytics.go

View workflow job for this annotation

GitHub Actions / Lint Go code

missing import path (typecheck)
)

var gaclient gacli.Client
var matomoClient matomo.Client

// anonIdentity represents an analytics identity file.
type anonIdentity struct {
Expand All @@ -38,7 +46,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 +64,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") {
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 @@ -97,7 +132,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.

Loading

0 comments on commit 77eea75

Please sign in to comment.