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: track sdk selected on setup #221

Merged
merged 4 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions internal/analytics/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ type Tracker interface {
optOut bool,
step string,
)
SendSetupSDKSelectedEvent(
accessToken,
baseURI string,
optOut bool,
sdk string,
)
SendSetupFlagToggledEvent(
accessToken,
baseURI string,
Expand Down Expand Up @@ -159,6 +165,23 @@ func (c *Client) SendSetupStepStartedEvent(
)
}

func (c *Client) SendSetupSDKSelectedEvent(
accessToken,
baseURI string,
optOut bool,
sdk string,
) {
c.sendEvent(
accessToken,
baseURI,
optOut,
"CLI Setup SDK Selected",
map[string]interface{}{
"sdk": sdk,
},
)
}

func (c *Client) SendSetupFlagToggledEvent(
accessToken,
baseURI string,
Expand Down Expand Up @@ -210,6 +233,14 @@ func (c *NoopClient) SendSetupStepStartedEvent(
) {
}

func (c *NoopClient) SendSetupSDKSelectedEvent(
accessToken,
baseURI string,
optOut bool,
sdk string,
) {
}

func (c *NoopClient) SendSetupFlagToggledEvent(
accessToken,
baseURI string,
Expand Down Expand Up @@ -285,6 +316,23 @@ func (m *MockTracker) SendSetupStepStartedEvent(
)
}

func (m *MockTracker) SendSetupSDKSelectedEvent(
accessToken,
baseURI string,
optOut bool,
sdk string,
) {
m.sendEvent(
accessToken,
baseURI,
optOut,
"CLI Setup SDK Selected",
map[string]interface{}{
"sdk": sdk,
},
)
}

func (m *MockTracker) SendSetupFlagToggledEvent(
accessToken,
baseURI string,
Expand Down
10 changes: 9 additions & 1 deletion internal/quickstart/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,15 @@ func (m ContainerModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.currentStep.String(),
))

if (m.currentStep == stepToggleFlag) && m.flagToggled {
if m.currentStep == stepShowSDKInstructions {
cmd = tea.Batch(cmd, trackSetupSDKSelectedEvent(
m.analyticsTracker,
m.accessToken,
m.baseUri,
m.analyticsOptOut,
m.sdk.canonicalName,
))
} else if (m.currentStep == stepToggleFlag) && m.flagToggled {
cmd = tea.Batch(cmd, trackSetupFlagToggledEvent(
m.analyticsTracker,
m.accessToken,
Expand Down
8 changes: 8 additions & 0 deletions internal/quickstart/messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,14 @@ func trackSetupStepStartedEvent(tracker analytics.Tracker, accessToken, baseURI
}
}

func trackSetupSDKSelectedEvent(tracker analytics.Tracker, accessToken, baseURI string, optOut bool, sdk string) tea.Cmd {
return func() tea.Msg {
tracker.SendSetupSDKSelectedEvent(accessToken, baseURI, optOut, sdk)

return eventTrackedMsg{}
}
}

func trackSetupFlagToggledEvent(tracker analytics.Tracker, accessToken, baseURI string, optOut, on bool, count int, duration_ms int64) tea.Cmd {
return func() tea.Msg {
tracker.SendSetupFlagToggledEvent(accessToken, baseURI, optOut, on, count, duration_ms)
Expand Down
Loading