Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor source with browserify for browser/server interoperability #208

Merged
merged 73 commits into from
Jan 2, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
9d68025
Break request handling into a swappable module
dustinlarimer Dec 6, 2014
b9ddab5
Set up build files
dustinlarimer Dec 7, 2014
bb9558c
Refactor core lib for node/browser harmony w/ browserify
dustinlarimer Dec 8, 2014
8b4c6bc
Move test folder into test/browser
dustinlarimer Dec 8, 2014
2c1848e
Set up node requestHandler with superagent
dustinlarimer Dec 8, 2014
ccea66b
Fix self-reference bug, add GET/POST structure for browser requests
dustinlarimer Dec 8, 2014
18ca3d9
Refactor request handling with client-level get, post and del methods
dustinlarimer Dec 8, 2014
cf7ce08
Bundle test libs with unit tests
dustinlarimer Dec 8, 2014
fda3b37
Clean up build files and test suite design
dustinlarimer Dec 8, 2014
ef08eab
Switch to gulp, refactor unit test setup
dustinlarimer Dec 9, 2014
7a96f94
Remove left behind test file
dustinlarimer Dec 9, 2014
23fae8c
Rename /node to /server, add unit/server.js
dustinlarimer Dec 9, 2014
95aa2a8
Add mocha gulp task for running server tests
dustinlarimer Dec 10, 2014
e124564
Mock HTTP requests in node with Nock, add contextual awareness to upl…
dustinlarimer Dec 10, 2014
baead06
Remove utils from core, move to build files
dustinlarimer Dec 10, 2014
ff6a44a
Put query in /core, create /helpers dir, clean up refs
dustinlarimer Dec 10, 2014
cccf0e4
Rearrange tests, add events-spec, clean up query/request files in core
dustinlarimer Dec 10, 2014
e748fb3
Refactor sendEvent and sendQuery
dustinlarimer Dec 11, 2014
3723fc4
Update Dataviz, begin Dataset
dustinlarimer Dec 11, 2014
7f2966b
Refactor Dataset to reduce file count
dustinlarimer Dec 11, 2014
a823cb3
Debugged, charts are loading
dustinlarimer Dec 11, 2014
e5f240a
Debuggery complete, all tests pass
dustinlarimer Dec 11, 2014
a3f2c61
Update C3.js and Chart.js adapters (visual confirmation)
dustinlarimer Dec 11, 2014
eedffd3
Update UMD header to avoid double-firing Keen.ready
dustinlarimer Dec 11, 2014
12c6e62
Revert last commit, enforce sync state to avoid double-firing Keen.ready
dustinlarimer Dec 11, 2014
915a9df
Delete _Keen.cache to avoid second Keen.ready on async load
dustinlarimer Dec 11, 2014
b950648
Breaking change:
dustinlarimer Dec 11, 2014
c50555e
Add keen-tracker and various gulp build tasks
dustinlarimer Dec 11, 2014
6ad0d8f
Add AWS gulp task, bump package and bower to v3.2.0
dustinlarimer Dec 11, 2014
5a960ee
AWS S3 deploy task successful
dustinlarimer Dec 11, 2014
fd617a7
Add testling field to package.json
dustinlarimer Dec 11, 2014
0fce2e3
Remove testling..
dustinlarimer Dec 11, 2014
105f552
Move UMD wrapper to template, process build and cleanup with gulp
dustinlarimer Dec 12, 2014
0aa3025
UMD wrapper testing complete, moved wrapper into src/wrappers dir
dustinlarimer Dec 12, 2014
ce54729
Add encrypt/decryptScopedKeys methods to server lib, tests pass
dustinlarimer Dec 13, 2014
976258e
Add basic functionality and tests for addEvents (browser/server)
dustinlarimer Dec 13, 2014
faa03b1
Chant client.url to include projects/project_id by default
dustinlarimer Dec 13, 2014
c2af37c
Split addEvent/s into different files for server and browser, clean u…
dustinlarimer Dec 13, 2014
dba0f9b
Karma + SauceLabs, rearrange gulp test tasks
dustinlarimer Dec 16, 2014
78e59d7
Add global install of browserify to travis before_script
dustinlarimer Dec 16, 2014
171ea0e
Remove gulp-clean (dep) with gulp-rimraf
dustinlarimer Dec 16, 2014
48240dd
Remove gulp-rimraf (dep, lol) with del
dustinlarimer Dec 16, 2014
00575ca
Create test tast w/out karma, for travis
dustinlarimer Dec 16, 2014
7ddecee
Remove unnecessary wrapper file
dustinlarimer Dec 16, 2014
9df9580
Remove travis before_script for shell setup
dustinlarimer Dec 16, 2014
7b53ac1
Clean up project directory, remove unneeded configs, validate package…
dustinlarimer Dec 16, 2014
6378bb5
Fix Keen.Request bug and add tests for <Client>.run method (server)
dustinlarimer Dec 16, 2014
b934df8
Add tests for Keen.Request and <Client>.run for the browser
dustinlarimer Dec 16, 2014
5e984a0
Fix demos, remove unnecessary event signature
dustinlarimer Dec 16, 2014
af9829d
Use superagent (w/ requestType plugin) for browser requests
dustinlarimer Dec 27, 2014
e8d8f88
addEvent(s) methods do the work, remove utils files
dustinlarimer Dec 27, 2014
9a5a247
Replace backbone events with Emitter
dustinlarimer Dec 27, 2014
4021edd
Move request handling directly into addEvent(s) methods
dustinlarimer Dec 27, 2014
0ebcc63
Rework Keen.Request to support #timeout method
dustinlarimer Dec 27, 2014
8364692
Clean up get/post methods, remove unnecessary /server files
dustinlarimer Dec 27, 2014
d206048
Move examples back into test/examples and del test/browser
dustinlarimer Dec 27, 2014
9474f50
Fix prettyNumber usage and default width
dustinlarimer Dec 28, 2014
65bf015
Bump version of jquery for IE8 debugging
dustinlarimer Dec 28, 2014
fd1da92
Extend superagent plugin to all synchronous xhr (hacky)
dustinlarimer Dec 28, 2014
3ac3e81
Clean up src/core/async.js
dustinlarimer Dec 28, 2014
1b61654
Remove commented code
dustinlarimer Dec 28, 2014
69d95c6
Update Dataviz docs with example for refreshing a request, resolves #203
dustinlarimer Dec 28, 2014
20a438a
Fix sync xhr call
dustinlarimer Dec 28, 2014
c34c2a3
Add changelog, back-fill with prev releases, prep notes for v3.2.0 [c…
dustinlarimer Dec 29, 2014
9c10bef
Add .npmignore file, update bower.json [ci skip]
dustinlarimer Dec 29, 2014
b5f30b1
Update bower.json (remove version), add repo [ci skip]
dustinlarimer Dec 29, 2014
afa0992
update README and docs to remove Keen.Visualization (pulled)
dustinlarimer Dec 29, 2014
13b5be0
Remove unnecessary resources from build entry points
dustinlarimer Dec 29, 2014
3a7237b
Update README and /docs with scoped keys, addEvents [ci skip]
dustinlarimer Dec 29, 2014
8c71a1f
Proofread docs, update version refs, expand on Dataset [ci skip]
dustinlarimer Dec 29, 2014
3f52cfb
Fix superagent plugin to properly handle async settings
dustinlarimer Dec 29, 2014
38bf38b
Add docs page for accessing collection/property data
dustinlarimer Dec 29, 2014
48455f7
Update CHANGELOG with details about the demise of Keen.Visualization …
dustinlarimer Dec 30, 2014
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
dist/*
.tmp
test/keen-unit-all.js
node_modules
bower_components
*.log
.DS_Store
.tmp
.awspublish-*
dist/*
bower_components
node_modules
test/keen-unit-all.js
test/unit/build/*
16 changes: 16 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.bowerrc
.DS_Store
.git*
*.log
*.md
*.yml
.tmp*
.awspublish-*

bower.json
gulpfile.js
karma.conf.js

docs
dist
test
16 changes: 2 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
language: node_js

node_js:
- "0.10"

branches:
only:
- master

env:
global:
- secure: |-
Expand All @@ -17,19 +14,10 @@ env:
AjvRPOjPEuDl8qwEUOk2V1HH6C5AoE8V0/1+twsnaEcgfHWGDk3g7oPfMOW3
ArybZFvN+wpvWfwoJAhRV7yQv9yoGT1fEtMtn3GB9mQiCFO70L/MrqXePJAr
ajs3LH0wqhj1zW8UUmhTxBSLvzRyW++W5yx2hYr92EkrlpFZZUg=
- LOGS_DIR=/tmp/keen-build/logs

install:
- npm install -g grunt-cli
- npm install -g browserify
- npm install -g bower
- npm install
- bower install

before_script:
- mkdir -p $LOGS_DIR
- chmod +x ./config/sauce_connect_setup.sh
- ./config/sauce_connect_setup.sh

notifications:
email:
on_success: never
email: never
204 changes: 204 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
<!--
<a name="unreleased"></a>
# Unreleased
-->

<a name="3.2.0"></a>
# 3.2.0 keen-js learns to node.js (2014-12-28)

This library now runs in the browser and the server, and can be installed via npm: `npm install keen-js`

## New to keen-js

* 'client.addEvents' - record multiple events with a single API call (#108)
* 'client.addEvent("collection", data, null, false)' - fourth argument of `null` invokes a synchronous XHR call, which is useful for sending events before a page unloads (#188)
* 'client.get' - execute a generic GET request (New approach to #139)
* 'client.put' - execute a generic PUT request
* 'client.post' - execute a generic POST request
* 'client.del' - execute a generic DELETE request (server-only)
* `Keen.utils.encryptScopedKeys` - create a new scoped key
* `Keen.utils.decryptScopedKeys` - decrypt an existing scoped key
* `Keen.noConflict` – avoid version collisions (#159)
* `Keen.Request` object supports timeouts (explained below), and must be explicitly run with `.refresh()` (#209, wip)
* "Metric" visualization shows raw value via the HTML element's `title` attribute (#206, wip)

```javascript
var req = new Keen.Request(client, [query1, query2], callback)
.timeout(300*1000)
.refresh();
```

## Keen.Visualization has been removed

This object doesn't add any value, and only creates more surface-area for new users to reason about.

Check out `Keen.Dataviz` for building customized visualizations. The docs have been updated to reflect this object's departure, and <Client>.run still works as expected.

## Breaking change to all callback signatures

All callbacks now use the single function `(err, res)` callback pattern common to node.js. This was done to make implementations portable between the browser and the server.

This:

```javascript
client.run(query, function(res){
// handle response
}, function(err){
// handle error
});
```

Now looks like this:

```javascript
client.run(query, function(err, res){
// if (err) handle err
// handle response
});
```

## Build/test-related

* Switched from [grunt](http://gruntjs.com/) to [gulp](http://gulpjs.com/)
* [Browserify](http://browserify.org/) builds browser-specific versions of the library
* [Karma](http://karma-runner.github.io/) runs tests on local browsers (Chrome, FF, Safari)
* [SauceLabs testing](https://saucelabs.com/u/keenlabs) tests IE + mobile


<a name="3.1.0"></a>
# 3.1.0 Visualization Reboot (2014-11-03)

Complete rewrite of `Keen.Visualization`, resulting in two brand new tools for creating dynamic, highly-customizable data visualizations.

## [Dataviz](https://github.com/keenlabs/keen-js/tree/master/src/dataviz)

* Composable interface for on-the-fly modifications of [pretty much everything](https://github.com/keenlabs/keen-js/tree/master/src/dataviz)
* Improved memory management, smaller footprint, better performance
* Charts render a million times faster (not benchmarked, but srsly, it's silly)
* Two new chart library adapters: [Chart.js](http://www.chartjs.org/) and [C3.js](http://c3js.org/). Either can be configured as the default
* Expanded color palette with 18 light+dark variants: now at 27 colors!
* Explicit methods for [handling different types of data](https://github.com/keenlabs/keen-js/tree/clean-viz/src/dataviz#data-handling)
* Explicit methods for updating charts, with full control of "loading" state spinner
* Display custom error messages
* Determine if intervals should be indexed by "timeframe.start" or "timeframe.end"
* Sort both groups and intervals, ascending or descending

## [Dataset](https://github.com/keenlabs/keen-js/tree/master/src/dataset)

Dataset is an abstraction layer that handles data inside of `Keen.Dataviz`. This tool unpacks arbitrary JSON into a 2-dimensional array (a table), and offers a set of simple but powerful tools for modifying, filtering and sorting that data. `Keen.Dataviz` charting adapters all know how to unpack this data format into their own crazy needs.

I'll build out a series of demos that showcase what this tool can do, but here are a few examples that you can accomplish with a few (like one or two) lines of javascript:

* For a group_by + interval query:
* Insert a new series that shows the median (sum/min/max/etc) value of all data points at each interval
* Sort groups bases the those same results (sort by sum of each series)
* Remove all records/series that fall below a given threshold (only show the top N results)
* Multiply all results by 100, or any number
* Join multiple queries into one chart

The big idea here is that it takes something that once took dozens or hundreds of lines of loopy JS magic and turns it into a quick, repeatable, easily-customizable use of a documented feature.

## Test Coverage

We added over **150 new tests** to cover these two classes, and have expanded our test coverage to include iOS (6-7.1), Android (4.1-4.4), and Chrome/Firefox Beta builds.

## Optimizations

Disable sending of events by setting `Keen.enabled = false;`. This is handy for disabling event recording from local or development environments.

Refactored our [loading script](https://gist.github.com/dustinlarimer/19fedf00c44d120ef8b4), makes it easy to stay up to date with the latest version. Now, when users see the JS blob for embedding our library in the page, it'll look like this:

```javascript
!function(i,o){i("Keen","//d26b395fwzu5fz.cloudfront.net/3.1.0/keen.min.js",o)}(function(a,b,c){var d,e,f;c["_"+a]={},c[a]=function(b){c["_"+a].clients=c["_"+a].clients||{},c["_"+a].clients[b.projectId]=this,this._config=b},c[a].ready=function(b){c["_"+a].ready=c["_"+a].ready||[],c["_"+a].ready.push(b)},d=["addEvent","setGlobalProperties","trackExternalLink","on"];for(var g=0;g<d.length;g++){var h=d[g],i=function(a){return function(){return this["_"+a]=this["_"+a]||[],this["_"+a].push(arguments),this}};c[a].prototype[h]=i(h)}e=document.createElement("script"),e.async=!0,e.src=b,f=document.getElementsByTagName("script")[0],f.parentNode.insertBefore(e,f)},this);
```

## Client configuration

**Internals have changed:** Client instances have an internal hash that contains properties, like `projectId` and `readKey`. This internal hash was previously called `client`, but has been renamed `config`. Reason being, "client" has become a popular name for new instances, resulting in strange references like `client.client.projectId`.

You can now also reference projectId and keys w/ a set of getter-setter methods, like so:

```javascript
var client = new Keen({
projectId: "123",
readKey: "123456789"
});
client.projectId(); // returns "123"
client.readKey(); // returns "123456789"
```

<a name="3.0.9"></a>
# 3.0.9 Improved request handling (2014-10-01)

This update greatly improves request handling for sending and querying events.

If JSONP is selected and the produced URL exceeds a given threshold, the library attempts to use XHR/POST if supported.

We have also added more robust support for XHR in older versions of IE, and expanded test coverage to include iOS (6-7.1), Android (4.1-4.4), and Chrome/Firefox Beta builds.

<a name="3.0.8"></a>
# 3.0.8 Improved memory management for Keen.Visualization (2014-08-18)

Call .remove() or .trigger("remove") on a chart for proper disposal.

<a name="3.0.7"></a>
# 3.0.7 Bug fixes, timezone fixes, query refreshing (2014-08-06)

__No notes, sorry__

<a name="3.0.6"></a>
# 3.0.6 [YANKED]

<a name="3.0.5"></a>
# 3.0.5 AMD Support

This release refactors internal dependency placement to allow for easy use with RequireJS. The library is loaded with an explicitly named module ID ("keen"), which presents a light configuration step, but prevents anonymous define() mismatch mayhem.

Example implementation:

```javascript
requirejs.config({
paths: {
"keen": "http://d26b395fwzu5fz.cloudfront.net/3.0.5/keen.js"
}
});
require([ "keen" ], function(Keen) {
var client = new Keen({ ... });
});
```

<a name="3.0.4"></a>
# 3.0.4 Important patch for IE11

Fixed a type-check method that caused queries to fail in IE11 (#96).

<a name="3.0.3"></a>
# 3.0.3 Visual Error Messages

client.draw() now visualizes API response messages when errors occur.

<a name="3.0.2"></a>
# 3.0.2 Fixed trackExternalLink and data sorting

Fixed an issue with trackExternalLink ignoring `target="_blank"` attributes, and failing to execute when anchor tags have nested DOM elements like `<span>` tags.

Applied column sorting to static group-by queries, for better arrangment in pie and bar charts.

Fixed #73, #90 and #92

<a name="3.0.1"></a>
# 3.0.1 Visualization bug fixes and enhancements

* Keen.Metric now supports chartOptions.prefix, chartOptions.suffix, and has more stable colors handling.
* Grouped interval responses are presented with a multi-line chart now.
* Changed chartType: "datatable" to table. datatable was left behind from an internal project, but breaks the naming pattern we want to establish with underlying libraries.
* Expanded color palette

![Color wheel](https://s3.amazonaws.com/uploads.hipchat.com/14465/113676/MjoVfScQYOcEbie/upload.png)

Resolves #72, #74, #76, #80, #82, #85, #86, #87

<a name="3.0.0"></a>
# 3.0.0 Hello, world

Initial re-release of keen-js!
9 changes: 6 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ $ npm install
$ bower install

# Build and launch project site
$ grunt dev
$ gulp

# Build and launch with tests
$ gulp with-tests

# View test results at http://localhost:9999
```

## Pull Request Template
## Pull Request Template

Please use the PR template below.

Expand All @@ -26,7 +29,7 @@ Please use the PR template below.

#### How should this be manually tested? (if appropriate)

* run `grunt dev`
* run `gulp with-tests`
* tests run at `localhost:9999/`

#### Are there any related issues open?
Expand Down
Loading