Skip to content

Commit

Permalink
Merge pull request #2817 from ActiveState/mitchell/dx-2237
Browse files Browse the repository at this point in the history
Remote installer should send a sessionToken to analytics.
  • Loading branch information
mitchell-as authored Oct 16, 2023
2 parents ebb45f5 + acb504f commit faebd57
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/state-remote-installer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ func main() {
return
}

// Store sessionToken to config
err = cfg.Set(anaConst.CfgSessionToken, "remote_"+constants.RemoteInstallerVersion)
if err != nil {
logging.Error("Unable to set session token: " + errs.JoinMessage(err))
}

an = sync.New(anaConst.SrcStateRemoteInstaller, cfg, nil, out)

// Set up prompter
Expand Down
14 changes: 14 additions & 0 deletions test/integration/remote_installer_int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"path/filepath"
"testing"

anaConst "github.com/ActiveState/cli/internal/analytics/constants"
"github.com/ActiveState/cli/internal/constants"
"github.com/ActiveState/cli/internal/environment"
"github.com/ActiveState/cli/internal/exeutils"
Expand Down Expand Up @@ -88,6 +89,19 @@ func (suite *RemoteInstallIntegrationTestSuite) TestInstall() {
}
cp.Expect("Built")
cp.ExpectExitCode(0)

// Verify analytics reported the correct sessionToken.
sessionTokenFound := false
events := parseAnalyticsEvents(suite, ts)
suite.Require().NotEmpty(events)
for _, event := range events {
if event.Category == anaConst.CatUpdates && event.Dimensions != nil {
suite.Assert().Contains(*event.Dimensions.SessionToken, constants.RemoteInstallerVersion)
sessionTokenFound = true
break
}
}
suite.Assert().True(sessionTokenFound, "sessionToken was not found in analytics")
})
}
}
Expand Down

0 comments on commit faebd57

Please sign in to comment.