-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add source to analytics events. #2750
Changes from 5 commits
44abffa
1a6ad98
e90f8ea
7c7ae9c
a6928da
bfef23d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -3,6 +3,7 @@ package rtwatcher | |||
import ( | ||||
"encoding/json" | ||||
"os" | ||||
"path/filepath" | ||||
"runtime/debug" | ||||
"strconv" | ||||
"time" | ||||
|
@@ -14,6 +15,7 @@ import ( | |||
"github.com/ActiveState/cli/internal/errs" | ||||
"github.com/ActiveState/cli/internal/logging" | ||||
"github.com/ActiveState/cli/internal/multilog" | ||||
"github.com/ActiveState/cli/internal/osutils" | ||||
"github.com/ActiveState/cli/internal/rtutils/ptr" | ||||
"github.com/ActiveState/cli/internal/runbits/panics" | ||||
) | ||||
|
@@ -30,7 +32,7 @@ type Watcher struct { | |||
} | ||||
|
||||
type analytics interface { | ||||
Event(category string, action string, dim ...*dimensions.Values) | ||||
EventWithSource(category, action, source string, dim ...*dimensions.Values) | ||||
} | ||||
|
||||
func New(cfg *config.Instance, an analytics) *Watcher { | ||||
|
@@ -97,7 +99,11 @@ func (w *Watcher) check() { | |||
|
||||
func (w *Watcher) RecordUsage(e entry) { | ||||
logging.Debug("Recording usage of %s (%d)", e.Exec, e.PID) | ||||
w.an.Event(anaConst.CatRuntimeUsage, anaConst.ActRuntimeHeartbeat, e.Dims) | ||||
source := anaConst.SrcExecutor | ||||
if filepath.Base(e.Exec) == constants.StateCmd+osutils.ExeExt { | ||||
source = anaConst.SrcStateTool | ||||
} | ||||
w.an.EventWithSource(anaConst.CatRuntimeUsage, anaConst.ActRuntimeHeartbeat, source, e.Dims) | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels too error prone to me. Could we instead add the source as an argument for the ReportRuntimeUsage resolver on the svc? The only place executors call this is here: Line 142 in be95799
Any other place would be state tool. I'd be fine defaulting to state tool if the source is empty. |
||||
} | ||||
|
||||
func (w *Watcher) Close() error { | ||||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved into analytics/constants.go