Skip to content

Commit 4fe9996

Browse files
authored
feat: make user-agent headers more descriptive (#168)
1 parent 6328d73 commit 4fe9996

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

lib/unleash/configuration.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def refresh_backup_file!
5151

5252
def http_headers
5353
{
54+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
5455
'UNLEASH-INSTANCEID' => self.instance_id,
5556
'UNLEASH-APPNAME' => self.app_name,
5657
'Unleash-Client-Spec' => '5.0.2'

spec/unleash/client_spec.rb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
'Accept' => '*/*',
1212
'Content-Type' => 'application/json',
1313
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
14-
'User-Agent' => 'Ruby',
14+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
1515
'X-Api-Key' => '123'
1616
}
1717
)
@@ -22,7 +22,7 @@
2222
'Accept' => '*/*',
2323
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
2424
'Content-Type' => 'application/json',
25-
'User-Agent' => 'Ruby'
25+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]"
2626
}
2727
)
2828
.to_return(status: 200, body: "", headers: {})
@@ -46,7 +46,7 @@
4646
'Content-Type' => 'application/json',
4747
'Unleash-Appname' => 'my-test-app',
4848
'Unleash-Instanceid' => 'rspec/test',
49-
'User-Agent' => 'Ruby',
49+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
5050
'X-Api-Key' => '123'
5151
}
5252
)
@@ -117,7 +117,7 @@
117117
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
118118
'Unleash-Appname' => 'my-test-app',
119119
'Unleash-Instanceid' => 'rspec/test',
120-
'User-Agent' => 'Ruby',
120+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
121121
'X-Api-Key' => '123'
122122
}
123123
)
@@ -158,7 +158,7 @@
158158
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
159159
'Unleash-Appname' => 'my-test-app',
160160
'Unleash-Instanceid' => 'rspec/test',
161-
'User-Agent' => 'Ruby',
161+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
162162
'X-Api-Key' => '123'
163163
}
164164
)
@@ -256,7 +256,7 @@
256256
'Accept' => '*/*',
257257
'Content-Type' => 'application/json',
258258
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
259-
'User-Agent' => 'Ruby',
259+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
260260
'X-Api-Key' => '123'
261261
}
262262
)
@@ -270,7 +270,7 @@
270270
'Content-Type' => 'application/json',
271271
'Unleash-Appname' => 'my-test-app',
272272
'Unleash-Instanceid' => 'rspec/test',
273-
'User-Agent' => 'Ruby',
273+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
274274
'X-Api-Key' => '123'
275275
}
276276
)
@@ -304,7 +304,7 @@
304304
'Accept' => '*/*',
305305
'Content-Type' => 'application/json',
306306
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
307-
'User-Agent' => 'Ruby',
307+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
308308
'X-Api-Key' => '123'
309309
}
310310
)
@@ -328,7 +328,7 @@
328328
'Content-Type' => 'application/json',
329329
'Unleash-Appname' => 'my-test-app',
330330
'Unleash-Instanceid' => 'rspec/test',
331-
'User-Agent' => 'Ruby',
331+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
332332
'X-Api-Key' => '123'
333333
}
334334
)
@@ -606,7 +606,7 @@
606606
'Content-Type' => 'application/json',
607607
'Unleash-Appname' => 'my-test-app',
608608
'Unleash-Instanceid' => 'rspec/test',
609-
'User-Agent' => 'Ruby',
609+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
610610
'X-Api-Key' => '123'
611611
}
612612
)
@@ -620,7 +620,7 @@
620620
'Content-Type' => 'application/json',
621621
'Unleash-Appname' => 'my-test-app',
622622
'Unleash-Instanceid' => 'rspec/test',
623-
'User-Agent' => 'Ruby',
623+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]",
624624
'X-Api-Key' => '123'
625625
}
626626
)

spec/unleash/configuration_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,8 @@
146146
'X-API-KEY' => '123',
147147
'UNLEASH-APPNAME' => 'test-app',
148148
'UNLEASH-INSTANCEID' => config.instance_id,
149-
'Unleash-Client-Spec' => '5.0.2'
149+
'Unleash-Client-Spec' => '5.0.2',
150+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]"
150151
}
151152
)
152153
expect(custom_headers_proc).to have_received(:call).exactly(1).times

spec/unleash/metrics_reporter_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
'Content-Type' => 'application/json',
7070
'Unleash-Appname' => 'my-test-app',
7171
'Unleash-Instanceid' => 'rspec/test',
72-
'User-Agent' => 'Ruby'
72+
'User-Agent' => "UnleashClientRuby/#{Unleash::VERSION} #{RUBY_ENGINE}/#{RUBY_VERSION} [#{RUBY_PLATFORM}]"
7373
}
7474
)
7575
.to_return(status: 200, body: "", headers: {})

0 commit comments

Comments
 (0)