Skip to content

Commit

Permalink
Merge pull request #939 from bitrise-io/cli-cleanup
Browse files Browse the repository at this point in the history
Merge `cli-cleanup` into `master`
  • Loading branch information
ofalvai authored Apr 11, 2024
2 parents ddae9dd + d17bd84 commit ba9a64f
Show file tree
Hide file tree
Showing 43 changed files with 156 additions and 996 deletions.
8 changes: 7 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
linters:
enabled:
enable:
- revive
- unparam
disable: []

linters-settings:
revive:
rules:
- name: empty-block
disabled: true

issues:
exclude-rules:
- path: cli/update.go
Expand Down
14 changes: 0 additions & 14 deletions analytics/state_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,13 @@ import (
)

const (
// DisabledEnvKey controls both the old (analytics plugin) and new (v2) implementations
DisabledEnvKey = "BITRISE_ANALYTICS_DISABLED"
// V2DisabledEnvKey controls only the new (v2) implementation
V2DisabledEnvKey = "BITRISE_ANALYTICS_V2_DISABLED"
// V2AsyncDisabledEnvKey can be used to disable the default async queries
V2AsyncDisabledEnvKey = "BITRISE_ANALYTICS_V2_ASYNC_DISABLED"

trueEnv = "true"
)

type StateChecker interface {
Enabled() bool
UseAsync() bool
}

type stateChecker struct {
Expand All @@ -29,13 +23,5 @@ func NewStateChecker(repository env.Repository) StateChecker {
}

func (s stateChecker) Enabled() bool {
if s.envRepository.Get(V2DisabledEnvKey) == trueEnv {
return false
}

return s.envRepository.Get(DisabledEnvKey) != trueEnv
}

func (s stateChecker) UseAsync() bool {
return s.envRepository.Get(V2AsyncDisabledEnvKey) != trueEnv
}
22 changes: 12 additions & 10 deletions analytics/tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const (
timeoutProperty = "timeout"
runTimeProperty = "runtime"
osProperty = "os"
stackRevIdProperty = "stack_rev_id"
stackRevIDProperty = "stack_rev_id"
snapshotProperty = "snapshot"
toolVersionsProperty = "tool_versions"

Expand All @@ -72,8 +72,8 @@ const (
buildSlugEnvKey = "BITRISE_BUILD_SLUG"
appSlugEnvKey = "BITRISE_APP_SLUG"
StepExecutionIDEnvKey = "BITRISE_STEP_EXECUTION_ID"
stackRevIdKey = "BITRISE_STACK_REV_ID"
macStackRevIdKey = "BITRISE_OSX_STACK_REV_ID"
stackRevIDKey = "BITRISE_STACK_REV_ID"
macStackRevIDKey = "BITRISE_OSX_STACK_REV_ID"

bitriseVersionKey = "bitrise"
envmanVersionKey = "envman"
Expand Down Expand Up @@ -108,6 +108,7 @@ type Tracker interface {
SendStepFinishedEvent(properties analytics.Properties, result StepResult)
SendCLIWarning(message string)
SendToolVersionSnapshot(toolVersions, snapshotType string)
IsTracking() bool
Wait()
}

Expand All @@ -128,9 +129,6 @@ func NewDefaultTracker() Tracker {

logger := log.NewUtilsLogAdapter()
tracker := analytics.NewDefaultTracker(&logger)
if stateChecker.UseAsync() {
tracker = analytics.NewDefaultTracker(&logger)
}

return NewTracker(tracker, envRepository, stateChecker, &logger)
}
Expand Down Expand Up @@ -210,16 +208,16 @@ func (t tracker) SendToolVersionSnapshot(toolVersions, snapshotType string) {
return
}

stackRevId := t.envRepository.Get(stackRevIdKey)
if stackRevId == "" {
stackRevID := t.envRepository.Get(stackRevIDKey)
if stackRevID == "" {
// Legacy
stackRevId = t.envRepository.Get(macStackRevIdKey)
stackRevID = t.envRepository.Get(macStackRevIDKey)
}

properties := analytics.Properties{
ciModeProperty: t.envRepository.Get(configs.CIModeEnvKey) == "true",
osProperty: runtime.GOOS,
stackRevIdProperty: stackRevId,
stackRevIDProperty: stackRevID,
snapshotProperty: snapshotType,
toolVersionsProperty: toolVersions,
}
Expand Down Expand Up @@ -278,6 +276,10 @@ func (t tracker) Wait() {
t.tracker.Wait()
}

func (t tracker) IsTracking() bool {
return t.stateChecker.Enabled()
}

func prepareStartProperties(info StepInfo) analytics.Properties {
properties := analytics.Properties{}
properties.AppendIfNotEmpty(stepIDProperty, info.StepID)
Expand Down
4 changes: 0 additions & 4 deletions bitrise/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,6 @@ var PluginDependencyMap = map[string]PluginDependency{
Source: "https://github.com/bitrise-io/bitrise-workflow-editor.git",
MinVersion: "1.3.305",
},
"analytics": {
Source: "https://github.com/bitrise-io/bitrise-plugins-analytics.git",
MinVersion: "0.13.2",
},
}

// RunSetupIfNeeded ...
Expand Down
Loading

0 comments on commit ba9a64f

Please sign in to comment.