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: add analytics to CLI installer #4088

Open
Pantani opened this issue Apr 17, 2024 · 6 comments
Open

feat: add analytics to CLI installer #4088

Pantani opened this issue Apr 17, 2024 · 6 comments
Assignees
Labels
request Feature request.

Comments

@Pantani
Copy link
Collaborator

Pantani commented Apr 17, 2024

We have this installer to install the ignite binary thoughts curl (curl https://get.ignite.com/cli! | bash). We need to add analytics to it to track the number of downloads and which version.

@Pantani Pantani added the request Feature request. label Apr 17, 2024
@Pantani Pantani changed the title feat: add analytics to CLI [installer](https://github.com/ignite/installer) feat: add analytics to CLI installer Apr 17, 2024
@Pantani
Copy link
Collaborator Author

Pantani commented Apr 17, 2024

we should use the same proxy we are using to share the analytics from CLI, for we don't expose the token into the script. Because if we do curl https://get.ignite.com/cli\! without the bash this downloads all script content

@Pantani
Copy link
Collaborator Author

Pantani commented Apr 17, 2024

When the script is called, we should make an HTTP request to Google Analytics, passing the version of the Ignite into the request, like the CLI is doing:

// Send sends metric event to analytics.
func (c Client) Send(body Body) error {
// encode body
encoded, err := json.Marshal(body)
if err != nil {
return err
}
requestURL, err := url.Parse(c.endpoint)
if err != nil {
return err
}
v := requestURL.Query()
if c.measurementID != "" {
v.Set("measurement_id", c.measurementID)
}
if c.apiSecret != "" {
v.Set("api_secret", c.apiSecret)
}
requestURL.RawQuery = v.Encode()
// Create an HTTP request with the payload
resp, err := c.httpClient.Post(requestURL.String(), "application/json", bytes.NewBuffer(encoded))
if err != nil {
return errors.Wrapf(err, "error creating HTTP request: %s", requestURL.String())
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK &&
resp.StatusCode != http.StatusNoContent {
return errors.Errorf("error to add analytics metric. Status code: %d", resp.StatusCode)
}
return nil
}

The analytics should be sent at the end of the script and not fail in case the request fails.

@julienrbrt
Copy link
Member

Do note that installation on snap or homebrew won't be counted.
Those are public and can be found here:

Should we really keep promoting the manual install when we have package managers?

@toschdev
Copy link
Contributor

Can we track these installations @julienrbrt ?

@julienrbrt
Copy link
Member

Can we track these installations @julienrbrt ?

Those are both tracked yes. I can add you to the monthly emails for snaps if you want.

@Pantani
Copy link
Collaborator Author

Pantani commented Apr 18, 2024

We can get the brew analytics from the API. Can we easily collect this data to add to the analytics?

https://formulae.brew.sh/api/formula/ignite.json

{
  "analytics": {
    "install": {
      "30d": {
        "ignite": 76
      },
      "90d": {
        "ignite": 275
      },
      "365d": {
        "ignite": 275
      }
    },
    "install_on_request": {
      "30d": {
        "ignite": 76
      },
      "90d": {
        "ignite": 275
      },
      "365d": {
        "ignite": 275
      }
    },
    "build_error": {
      "30d": {
        "ignite": 0
      }
    }
  }
}

@Pantani Pantani assigned Pantani and unassigned mazzy89 Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
request Feature request.
Projects
Status: To Discuss
Development

No branches or pull requests

4 participants