Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
brew
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to JiHu GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
KMSCAKKSCFKA AKFACAMADCAS
brew
Commits
0ef21ddf
Commit
0ef21ddf
authored
8 years ago
by
Mike McQuaid
Browse files
Options
Downloads
Patches
Plain Diff
analytics: move to a class.
Global namespaces are good to avoid when possible.
parent
798c342f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
Library/Homebrew/formula_installer.rb
+1
-1
1 addition, 1 deletion
Library/Homebrew/formula_installer.rb
Library/Homebrew/utils/analytics.rb
+65
-59
65 additions, 59 deletions
Library/Homebrew/utils/analytics.rb
Library/brew.rb
+3
-3
3 additions, 3 deletions
Library/brew.rb
with
69 additions
and
63 deletions
Library/Homebrew/formula_installer.rb
+
1
−
1
View file @
0ef21ddf
...
@@ -204,7 +204,7 @@ class FormulaInstaller
...
@@ -204,7 +204,7 @@ class FormulaInstaller
if
formula
.
tap
&&
!
formula
.
tap
.
private?
if
formula
.
tap
&&
!
formula
.
tap
.
private?
options
=
effective_build_options_for
(
formula
).
used_options
.
to_a
.
join
(
" "
)
options
=
effective_build_options_for
(
formula
).
used_options
.
to_a
.
join
(
" "
)
report_a
nalytics_event
(
"install"
,
"
#{
formula
.
full_name
}
#{
options
}
"
.
strip
)
Utils
::
A
nalytics
.
report
_event
(
"install"
,
"
#{
formula
.
full_name
}
#{
options
}
"
.
strip
)
end
end
@@attempted
<<
formula
@@attempted
<<
formula
...
...
This diff is collapsed.
Click to expand it.
Library/Homebrew/utils/analytics.rb
+
65
−
59
View file @
0ef21ddf
def
analytics_label
module
Utils
@analytics_anonymous_prefix_and_os
||=
begin
module
Analytics
os
=
OS_VERSION
class
<<
self
prefix
=
", non-/usr/local"
if
HOMEBREW_PREFIX
.
to_s
!=
"/usr/local"
def
os_prefix_ci
ci
=
", CI"
if
ENV
[
"CI"
]
@anonymous_os_prefix_ci
||=
begin
"
#{
os
}#{
prefix
}#{
ci
}
"
os
=
OS_VERSION
end
prefix
=
", non-/usr/local"
if
HOMEBREW_PREFIX
.
to_s
!=
"/usr/local"
end
ci
=
", CI"
if
ENV
[
"CI"
]
"
#{
os
}#{
prefix
}#{
ci
}
"
end
end
def
report
_analytics
(
type
,
metadata
=
{})
def
report
(
type
,
metadata
=
{})
return
if
ENV
[
"HOMEBREW_NO_ANALYTICS"
]
||
ENV
[
"HOMEBREW_NO_ANALYTICS_THIS_RUN"
]
return
if
ENV
[
"HOMEBREW_NO_ANALYTICS"
]
||
ENV
[
"HOMEBREW_NO_ANALYTICS_THIS_RUN"
]
args
=
%W[
args
=
%W[
--max-time 3
--max-time 3
--user-agent
#{
HOMEBREW_USER_AGENT_CURL
}
--user-agent
#{
HOMEBREW_USER_AGENT_CURL
}
-d v=1
-d v=1
-d tid=
#{
ENV
[
"HOMEBREW_ANALYTICS_ID"
]
}
-d tid=
#{
ENV
[
"HOMEBREW_ANALYTICS_ID"
]
}
-d cid=
#{
ENV
[
"HOMEBREW_ANALYTICS_USER_UUID"
]
}
-d cid=
#{
ENV
[
"HOMEBREW_ANALYTICS_USER_UUID"
]
}
-d aip=1
-d aip=1
-d an=
#{
HOMEBREW_PRODUCT
}
-d an=
#{
HOMEBREW_PRODUCT
}
-d av=
#{
HOMEBREW_VERSION
}
-d av=
#{
HOMEBREW_VERSION
}
-d t=
#{
type
}
-d t=
#{
type
}
]
]
metadata
.
each
{
|
k
,
v
|
args
<<
"-d"
<<
"
#{
k
}
=
#{
v
}
"
if
k
&&
v
}
metadata
.
each
{
|
k
,
v
|
args
<<
"-d"
<<
"
#{
k
}
=
#{
v
}
"
if
k
&&
v
}
# Send analytics. Don't send or store any personally identifiable information.
# Send analytics. Don't send or store any personally identifiable information.
# https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Analytics.md
# https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Analytics.md
# https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
# https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
# https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
if
ENV
[
"HOMEBREW_ANALYTICS_DEBUG"
]
if
ENV
[
"HOMEBREW_ANALYTICS_DEBUG"
]
puts
Utils
.
popen_read
ENV
[
"HOMEBREW_CURL"
],
puts
Utils
.
popen_read
ENV
[
"HOMEBREW_CURL"
],
"https://www.google-analytics.com/debug/collect"
,
"https://www.google-analytics.com/debug/collect"
,
*
args
*
args
else
else
pid
=
fork
do
pid
=
fork
do
exec
ENV
[
"HOMEBREW_CURL"
],
exec
ENV
[
"HOMEBREW_CURL"
],
"https://www.google-analytics.com/collect"
,
"https://www.google-analytics.com/collect"
,
"--silent"
,
"--output"
,
"/dev/null"
,
"--silent"
,
"--output"
,
"/dev/null"
,
*
args
*
args
end
end
Process
.
detach
pid
Process
.
detach
pid
end
end
end
end
def
report_
analytics_
event
(
category
,
action
,
label
=
analytics_label
,
value
=
nil
)
def
report_event
(
category
,
action
,
label
=
os_prefix_ci
,
value
=
nil
)
report
_analytics
(
:event
,
report
(
:event
,
:ec
=>
category
,
:ec
=>
category
,
:ea
=>
action
,
:ea
=>
action
,
:el
=>
label
,
:el
=>
label
,
:ev
=>
value
)
:ev
=>
value
)
end
end
def
report_
analytics_
exception
(
exception
,
options
=
{})
def
report_exception
(
exception
,
options
=
{})
if
exception
.
is_a?
(
BuildError
)
&&
if
exception
.
is_a?
(
BuildError
)
&&
exception
.
formula
.
tap
&&
!
exception
.
formula
.
tap
.
private?
exception
.
formula
.
tap
&&
!
exception
.
formula
.
tap
.
private?
report_
analytics_
event
(
"BuildError"
,
exception
.
formula
.
full_name
)
report_event
(
"BuildError"
,
exception
.
formula
.
full_name
)
end
end
fatal
=
options
.
fetch
(
:fatal
,
true
)
?
"1"
:
"0"
fatal
=
options
.
fetch
(
:fatal
,
true
)
?
"1"
:
"0"
report
_analytics
(
:exception
,
report
(
:exception
,
:exd
=>
exception
.
class
.
name
,
:exd
=>
exception
.
class
.
name
,
:exf
=>
fatal
)
:exf
=>
fatal
)
end
end
def
report_analytics_screenview
(
screen_name
)
def
report_screenview
(
screen_name
)
report_analytics
(
:screenview
,
:cd
=>
screen_name
)
report
(
:screenview
,
:cd
=>
screen_name
)
end
end
end
end
end
This diff is collapsed.
Click to expand it.
Library/brew.rb
+
3
−
3
View file @
0ef21ddf
...
@@ -129,17 +129,17 @@ rescue Interrupt => e
...
@@ -129,17 +129,17 @@ rescue Interrupt => e
$stderr
.
puts
# seemingly a newline is typical
$stderr
.
puts
# seemingly a newline is typical
exit
130
exit
130
rescue
BuildError
=>
e
rescue
BuildError
=>
e
report_a
nalytics_exception
(
e
)
Utils
::
A
nalytics
.
report
_exception
(
e
)
e
.
dump
e
.
dump
exit
1
exit
1
rescue
RuntimeError
,
SystemCallError
=>
e
rescue
RuntimeError
,
SystemCallError
=>
e
report_a
nalytics_exception
(
e
)
Utils
::
A
nalytics
.
report
_exception
(
e
)
raise
if
e
.
message
.
empty?
raise
if
e
.
message
.
empty?
onoe
e
onoe
e
$stderr
.
puts
e
.
backtrace
if
ARGV
.
debug?
$stderr
.
puts
e
.
backtrace
if
ARGV
.
debug?
exit
1
exit
1
rescue
Exception
=>
e
rescue
Exception
=>
e
report_a
nalytics_exception
(
e
)
Utils
::
A
nalytics
.
report
_exception
(
e
)
onoe
e
onoe
e
if
internal_cmd
if
internal_cmd
$stderr
.
puts
"
#{
Tty
.
white
}
Please report this bug:"
$stderr
.
puts
"
#{
Tty
.
white
}
Please report this bug:"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment