botmetrics-rb 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +32 -5
- data/lib/botmetrics.rb +2 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cee50d258a296337e9a35afc509a0f11b76dd55
|
4
|
+
data.tar.gz: 4d5a8762e422814318ccb72526ae22cba39aed5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b21e93a64187138372c7c6957e6385ed43a9e52a4301edeec94927aece3cfae1fa456ad9a46e3401a6773e03483b0983487c862b838046c21191d36766e0629
|
7
|
+
data.tar.gz: d110efb340bf2fee7fdad04b44d192d81d818a9d6215422517c3eb0a7c2efa6eb408980120cb3d9e4716f56d032daa9d005d91e64e4b0603afed54e0dfeccefa
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
# Botmetrics
|
1
|
+
# Botmetrics
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
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
|
|
data/lib/botmetrics.rb
CHANGED
@@ -2,16 +2,12 @@ require "json"
|
|
2
2
|
require "excon"
|
3
3
|
|
4
4
|
class BotMetrics
|
5
|
-
VERSION = "0.0.
|
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}/
|
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.
|
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-
|
11
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|