chore: Add analytics setup - #104
Conversation
|
This pull request has been linked to Shortcut Story #235719: Add event tracking to segment.io. |
| args []string, | ||
| ) ([]byte, error) { | ||
| rootCmd, err := NewRootCommand( | ||
| analytics.MockClient{}, |
There was a problem hiding this comment.
I'm not sure we need to test anything against the analytics client, so this is hardcoded.
| log.Fatal(err) | ||
| } | ||
|
|
||
| err = client.Track( |
There was a problem hiding this comment.
An example call. I used my own segment source to manually test this.
| func main() { | ||
| cmd.Execute(version) | ||
| client := analytics.NewSegmentioClient( | ||
| segmentio.New("TODO"), |
There was a problem hiding this comment.
We'll need to get the write key from the environment.
There was a problem hiding this comment.
just want to make sure. Is leaving todo here intentional for now? Are we gonna add a .env.template later?
da5d0e8 to
c6333a5
Compare
c6333a5 to
2045e86
Compare
868f537 to
0026710
Compare
0026710 to
3ca7563
Compare
| required: true | ||
| outputs: | ||
| hashes: | ||
| hashes: |
There was a problem hiding this comment.
These are removing trailing newlines since my editor does that automatically.
| return err | ||
| } | ||
|
|
||
| analyticsTracker.SendEvent( |
There was a problem hiding this comment.
This is an example event. We're going to come up with a list of events to track and will implement those in another PR.
| c.wg.Add(1) | ||
| body, err := json.Marshal(input) | ||
| if err != nil { //nolint:staticcheck | ||
| // TODO: log error |
There was a problem hiding this comment.
We'll probably want to add debugging at some point with a flag to enable it.
| } | ||
| analyticsClient := &analytics.Client{HTTPClient: httpClient} | ||
| cmd.Execute(analyticsClient, version) | ||
| analyticsClient.Wait() |
There was a problem hiding this comment.
This is created here so we can call Wait() to block the analytics request after everything else has finished.
| args: release ${{ inputs.dry-run == 'true' && '--skip=publish' || '' }} | ||
| env: | ||
| GITHUB_TOKEN: ${{ inputs.token }} | ||
| HOMEBREW_DEPLOY_KEY: ${{ inputs.homebrew-gh-secret }} |
There was a problem hiding this comment.
did we mean to remove the HOMEBREW_DEPLOY_KEY?
There was a problem hiding this comment.
Nope. Probably a weird merge.
Send async analytics events to our own system to proxy instead of using vendor-specific code.