README.md in keen-0.6.1 vs README.md in keen-0.7.0
- old
+ new
@@ -21,17 +21,18 @@
* Rubinius
* jRuby (except for asynchronous methods - no TLS support for EM on jRuby)
### Usage
-Before making any API calls, you must supply keen-gem with a Project ID.
-(If you need a Keen IO account, [sign up here](https://keen.io/) - it's free.)
+Before making any API calls, you must supply keen-gem with a Project ID and one or both of your Write and Read Keys.
+(If you need a Keen IO account, [sign up here](https://keen.io/) - it's free.) The Write key is required for publishing
+events, and the Read key is required for running queries.
-The recommended way to do this is to set `KEEN_PROJECT_ID` in your
+The recommended way to do this is to set `KEEN_PROJECT_ID`, `KEEN_WRITE_KEY`, and `KEEN_READ_KEY` in your
environment. If you're using [foreman](http://ddollar.github.com/foreman/), add this to your `.env` file:
- KEEN_PROJECT_ID=xxxxxxxxxxxxxxxx
+ KEEN_PROJECT_ID=xxxxxxxxxxxxxxxx KEEN_WRITE_KEY=yyyyyyyyyyyyy KEEN_READ_KEY=zzzzzzzzzzzzz
If not, make to to export the variable into your shell or put it before the command you use to start your server.
When you deploy, make sure your production environment variables are set. For example,
set [config vars](https://devcenter.heroku.com/articles/config-vars) on Heroku. (We recommend this
@@ -93,13 +94,13 @@
### Running queries
The Keen IO API provides rich querying capabilities against your event data set. For more information, see the [Data Analysis API Guide](https://keen.io/docs/data-analysis/).
-Unlike event publishing, queries require that an API Key is provided. Just like project ID, we encourage that you set this as an environment variable:
+Queries require that a Read Key is provided. Just like project ID, we encourage that you set this as an environment variable:
- KEEN_API_KEY=your-api-key
+ KEEN_READ_KEY=yyyyyyyyyyyyyyyy
Here's are some examples of querying with keen-gem. Let's assume you've added some events to the "purchases" collection.
```ruby
Keen.count("purchases") # => 100
@@ -135,17 +136,21 @@
#### Authentication
To configure keen-gem in code, do as follows:
```ruby
-Keen.project_id = 'your-project-id'
+Keen.project_id = 'xxxxxxxxxxxxxxx'
+Keen.write_key = 'yyyyyyyyyyyyyyy'
+Keen.read_key = 'zzzzzzzzzzzzzzz'
```
You can also configure individual client instances as follows:
```ruby
-keen = Keen::Client.new(:project_id => 'your-project-id')
+keen = Keen::Client.new(:project_id => 'xxxxxxxxxxxxxxx',
+ :write_key => 'yyyyyyyyyyyyyyy',
+ :read_key => 'zzzzzzzzzzzzzzz')
```
#### em-synchrony
keen-gem can be used with [em-synchrony](https://github.com/igrigorik/em-synchrony).
@@ -160,16 +165,24 @@
In this situation, the JSON event data is passed by encoding it base-64 and adding it as a request parameter called `data`.
The `beacon_url` method found on the `Keen::Client` does this for you. Here's an example:
```ruby
+Keen.project_id = 'xxxxxx';
+Keen.write_key = 'yyyyyy';
Keen.beacon_url("sign_ups", :recipient => "foo@foo.com")
- # => "https://api.keen.io/3.0/projects/12345/events/email_opens?data=eyJyZWNpcGllbnQiOiJmb29AZm9vLmNvbSJ9"
+ # => "https://api.keen.io/3.0/projects/xxxxxx/events/email_opens?api_key=yyyyyy&data=eyJyZWNpcGllbnQiOiJmb29AZm9vLmNvbSJ9"
```
To track email opens, simply add an image to your email template that points to this URL.
### Changelog
+
+##### 0.7.0
++ BREAKING CHANGE! Added support for read and write scoped keys to reflect the new Keen IO security architecture.
+The advantage of scoped keys is finer grained permission control. Public clients that
+publish events (like a web browser) require a key that can write but not read. On the other hand, private dashboards and
+server-side querying processes require a Read key that should not be made public.
##### 0.6.1
+ Improved logging and exception handling.
##### 0.6.0