Skip to content

Commit

Permalink
feat(crawler): update to new user-agent format
Browse files Browse the repository at this point in the history
  • Loading branch information
Jerska committed Sep 2, 2016
1 parent 27c35df commit 9508d8d
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions crawler/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.6.5
3 changes: 3 additions & 0 deletions crawler/algolia.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require 'algoliasearch'
require './config.rb'
require './user_agent.rb'

Algolia.init(
application_id: CONFIG['algolia_app_id'],
api_key: CONFIG['algolia_api_key']
)

Algolia.set_extra_header 'User-Agent', UserAgent.to_s
25 changes: 25 additions & 0 deletions crawler/user_agent.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'algoliasearch'

class UserAgent
class Version
def self.crawler
File.read('VERSION').strip
end

def self.client
Algolia::VERSION
end

def self.ruby
RUBY_VERSION
end
end

def self.to_s
[
"Zendesk Integration (#{Version.crawler})",
"Algolia for Ruby (#{Version.client})",
"Ruby (#{Version.ruby})"
].join('; ')
end
end

0 comments on commit 9508d8d

Please sign in to comment.