botmetrics-rb 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +32 -5
  3. data/lib/botmetrics.rb +2 -6
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 106cf210784c115147a4b15314e52dc43e0ba207
4
- data.tar.gz: 0169bea4d06d549d4e888f38f0c98b8a627cb4aa
3
+ metadata.gz: 6cee50d258a296337e9a35afc509a0f11b76dd55
4
+ data.tar.gz: 4d5a8762e422814318ccb72526ae22cba39aed5b
5
5
  SHA512:
6
- metadata.gz: 4d512ccaa2e792a4ebaee6df35e304de644e7f1d2ef05ec6c98a64863f24e19181e76d3e235a4e01214becbe0a674cbff160d85280dbd148fd57df19f96e5258
7
- data.tar.gz: b3851591573805073d9cee7c77b5b6402a5939f9d164f8c0dc598c19bca3d1afbf0fe3f42ac3e61ed48d0af1cf90735ad48474c86004fe3f71391bec5121a3d2
6
+ metadata.gz: 8b21e93a64187138372c7c6957e6385ed43a9e52a4301edeec94927aece3cfae1fa456ad9a46e3401a6773e03483b0983487c862b838046c21191d36766e0629
7
+ data.tar.gz: d110efb340bf2fee7fdad04b44d192d81d818a9d6215422517c3eb0a7c2efa6eb408980120cb3d9e4716f56d032daa9d005d91e64e4b0603afed54e0dfeccefa
data/README.md CHANGED
@@ -1,8 +1,8 @@
1
- # Botmetrics::Rb
1
+ # Botmetrics
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/botmetrics/rb`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ Botmetrics is a Ruby client to the
4
+ [BotMetrics](https://getbotmetrics.com) service which lets you collect
5
+ & analyze metrics for your bot.
6
6
 
7
7
  ## Installation
8
8
 
@@ -22,7 +22,34 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- TODO: Write usage instructions here
25
+ Log in to your [BotMetrics](https://getbotmetrics.com) account, navigate
26
+ to "Bot Settings" and find out your Team ID, Bot ID and API Key.
27
+
28
+ Set the following environment variables with the Team ID, Bot ID and API
29
+ Key respectively.
30
+
31
+ ```
32
+ BOTMETRICS_TEAM_ID=your-team-id
33
+ BOTMETRICS_BOT_ID=your-bot-id
34
+ BOTMETRICS_API_KEY=your-api-key
35
+ ```
36
+
37
+ Once you have that set up, every time you create a new Slack Bot (in the
38
+ OAuth2 callback), and assuming the bot token you received as part of the
39
+ OAuth2 callback is `bot-token`, make the following call:
40
+
41
+ ```ruby
42
+ BotMetrics.register_bot!('bot-token')
43
+ ```
44
+
45
+ ### Retroactive registration
46
+
47
+ If you created your bot in the past, you can pass in `created_at` with
48
+ the UNIX timestamp of when your bot was created, like so:
49
+
50
+ ```ruby
51
+ BotMetrics.register_bot!('bot-token', created_at: 1462318092)
52
+ ```
26
53
 
27
54
  ## Development
28
55
 
@@ -2,16 +2,12 @@ require "json"
2
2
  require "excon"
3
3
 
4
4
  class BotMetrics
5
- VERSION = "0.0.2"
5
+ VERSION = "0.0.3"
6
6
 
7
7
  def self.register_bot!(token, opts = {})
8
- team_id = opts[:team_id] || opts['team_id'] || ENV['BOTMETRICS_TEAM_ID']
9
8
  bot_id = opts[:bot_id] || opts['bot_id'] || ENV['BOTMETRICS_BOT_ID']
10
9
  api_key = opts[:api_key] || opts['api_key'] || ENV['BOTMETRICS_API_KEY']
11
10
 
12
- if team_id.nil? || team_id == ""
13
- raise ArgumentError.new("You have to either set the env variable BOTMETRICS_TEAM_ID or pass in an as argument team_id")
14
- end
15
11
  if bot_id.nil? || bot_id == ""
16
12
  raise ArgumentError.new("You have to either set the env variable BOTMETRICS_BOT_ID or pass in an as argument bot_id")
17
13
  end
@@ -34,7 +30,7 @@ class BotMetrics
34
30
  params["instance[created_at]"] = created_at.to_i if created_at.to_i != 0
35
31
  params["format"] = "json"
36
32
 
37
- url = "#{host}/teams/#{team_id}/bots/#{bot_id}/instances"
33
+ url = "#{host}/bots/#{bot_id}/instances"
38
34
  opts[:body] = URI.encode_www_form(params)
39
35
  opts[:headers] = { "Authorization" => api_key }
40
36
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: botmetrics-rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - arunthampi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-28 00:00:00.000000000 Z
11
+ date: 2016-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json