Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b78fdb5

Browse filesBrowse files
Set the extra user agent when a new rpc instance is created
1 parent f47399b commit b78fdb5
Copy full SHA for b78fdb5

File tree

1 file changed

+18
-0
lines changed
Filter options

1 file changed

+18
-0
lines changed

‎commands/instances.go

Copy file name to clipboardExpand all lines: commands/instances.go
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,24 @@ func (s *arduinoCoreServerImpl) Create(ctx context.Context, req *rpc.CreateReque
6767
var userAgent string
6868
if md, ok := metadata.FromIncomingContext(ctx); ok {
6969
userAgent = strings.Join(md.Get("user-agent"), " ")
70+
if userAgent != "" {
71+
// s.SettingsGetValue() returns an error if the key does not exist and for this reason we are accessing
72+
// network.user_agent_ext directly from s.settings.ExtraUserAgent() to set it
73+
if s.settings.ExtraUserAgent() == "" {
74+
if strings.Contains(userAgent, "arduino-ide/2") {
75+
// needed for analytics purposes
76+
userAgent = userAgent + " daemon"
77+
}
78+
_, err := s.SettingsSetValue(ctx, &rpc.SettingsSetValueRequest{
79+
Key: "network.user_agent_ext",
80+
ValueFormat: "cli",
81+
EncodedValue: userAgent,
82+
})
83+
if err != nil {
84+
return nil, err
85+
}
86+
}
87+
}
7088
}
7189

7290
// Setup downloads directory

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.