Skip to content

Commit 610a89d

Browse files
author
Garrett Johnson
committed
Initial commit
0 parents  commit 610a89d

18 files changed

+771
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
*.log
3+
tmp

.jscsrc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"requireSpaceAfterKeywords": [
3+
"if",
4+
"else",
5+
"for",
6+
"while",
7+
"switch",
8+
"return",
9+
"try",
10+
"catch"
11+
],
12+
"requireParenthesesAroundIIFE": true,
13+
"disallowSpacesInFunctionExpression": {
14+
"beforeOpeningRoundBrace": true,
15+
"beforeOpeningCurlyBrace": true
16+
},
17+
"disallowSpacesInFunctionExpression": {
18+
"beforeOpeningRoundBrace": true,
19+
"beforeOpeningCurlyBrace": true
20+
},
21+
"disallowSpacesInsideArrayBrackets": true,
22+
"disallowSpacesInsideParentheses": true,
23+
"requireSpacesInsideObjectBrackets": "allButNested",
24+
"disallowQuotedKeysInObjects": "allButReserved",
25+
"disallowSpaceAfterObjectKeys": true,
26+
"requireCommaBeforeLineBreak": true,
27+
"disallowMultipleLineStrings": true,
28+
"disallowMultipleLineBreaks": true,
29+
"disallowMixedSpacesAndTabs": true,
30+
"disallowTrailingWhitespace": true,
31+
"disallowKeywordsOnNewLine": ["else"],
32+
"requireDotNotation": true,
33+
"validateJSDoc": {
34+
"checkParamNames": true,
35+
"checkRedundantParams": true,
36+
"requireParamTypes": true
37+
}
38+
}

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
test/

History.md

Whitespace-only changes.

Makefile

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
TESTS = $(wildcard test/*.js)
3+
SRC = $(wildcard lib/*.js)
4+
GREP ?=.
5+
6+
default: node_modules test-style test-cov
7+
8+
node_modules: package.json
9+
@npm install
10+
11+
test:
12+
@TZ=UTC ./node_modules/.bin/mocha $(TESTS) \
13+
--timeout 20000 \
14+
--require should \
15+
--reporter spec \
16+
--inline-diffs \
17+
--grep "$(GREP)"
18+
19+
test-cov:
20+
@TZ=UTC ./node_modules/.bin/istanbul cover \
21+
node_modules/.bin/_mocha -- $(TESTS) \
22+
--timeout 20s \
23+
--require should \
24+
--reporter spec \
25+
--inline-diffs \
26+
--ui exports
27+
28+
test-style:
29+
@node_modules/.bin/jscs lib test
30+
31+
clean:
32+
rm -rf coverage node_modules *.log
33+
34+
.PHONY: test test-cov test-style

Readme.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
[![Build Status](https://circleci.com/gh/segmentio/integration-heap.png)](https://circleci.com/gh/segmentio/integration-heap)
2+
3+
# Heap server-side integration.
4+
5+
Write me...
6+
7+
8+
## License
9+
10+
(The MIT License)
11+
12+
Copyright (c) 2014 Segment.io <[email protected]>
13+
14+
Permission is hereby granted, free of charge, to any person obtaining
15+
a copy of this software and associated documentation files (the
16+
'Software'), to deal in the Software without restriction, including
17+
without limitation the rights to use, copy, modify, merge, publish,
18+
distribute, sublicense, and/or sell copies of the Software, and to
19+
permit persons to whom the Software is furnished to do so, subject to
20+
the following conditions:
21+
22+
The above copyright notice and this permission notice shall be
23+
included in all copies or substantial portions of the Software.
24+
25+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
26+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
28+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
29+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
30+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
31+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

circle.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
machine:
2+
node:
3+
version: 0.10.33
4+
python:
5+
version: 2.7.3
6+
services:
7+
- redis
8+
9+
dependencies:
10+
pre:
11+
- pip install awscli
12+
13+
test:
14+
post:
15+
- if [ -n "$FORCE" ]; then curl -l -s $BOOSH | sh > /dev/null; fi
16+
17+
deployment:
18+
s3:
19+
branch: master
20+
owner: segmentio
21+
commands:
22+
- curl -l -s $BOOSH | sh > /dev/null

lib/index.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
2+
/**
3+
* Module dependencies.
4+
*/
5+
6+
var integration = require('segmentio-integration');
7+
var mapper = require('./mapper');
8+
9+
/**
10+
* Expose `Heap`
11+
*/
12+
13+
var Heap = module.exports = integration('Heap')
14+
.endpoint('https://heapanalytics.com/api')
15+
.channels(['server', 'mobile'])
16+
.ensure('settings.appId')
17+
.mapper(mapper)
18+
.retries(2);
19+
20+
/**
21+
* Track.
22+
*
23+
* @param {Track} track
24+
* @param {Function} fn
25+
* @api public
26+
*/
27+
28+
Heap.prototype.track = function(payload, fn){
29+
return this
30+
.post('/track')
31+
.type('json')
32+
.send(payload)
33+
.end(this.handle(fn));
34+
};
35+
36+
/**
37+
* Identify.
38+
*
39+
* @param {Identify} identify
40+
* @param {Function} fn
41+
* @api public
42+
*/
43+
44+
Heap.prototype.identify = function(payload, fn){
45+
return this
46+
.post('/identify')
47+
.type('json')
48+
.send(payload)
49+
.end(this.handle(fn));
50+
};

lib/mapper.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Module dependencies.
3+
*/
4+
5+
var reject = require('reject');
6+
7+
/**
8+
* Map `track`.
9+
*
10+
* @param {Track} track
11+
* @return {Object}
12+
* @api private
13+
*/
14+
15+
exports.track = function(track){
16+
var props = track.properties();
17+
return {
18+
app_id: this.settings.appId,
19+
identity: id(track),
20+
event: track.event(),
21+
properties: reject.types(props, ['array', 'object', 'date'])
22+
};
23+
};
24+
25+
/**
26+
* Map `identify`.
27+
*
28+
* @param {Identify} identify
29+
* @return {Object}
30+
* @api private
31+
*/
32+
33+
exports.identify = function(identify){
34+
var traits = identify.traits();
35+
return {
36+
app_id: this.settings.appId,
37+
identity: id(identify),
38+
properties: reject.types(traits, ['array', 'object', 'date'])
39+
};
40+
};
41+
42+
/**
43+
* Id.
44+
*
45+
* @param {Track} message
46+
* @return {String}
47+
* @api private
48+
*/
49+
50+
function id(message){
51+
return message.email() || message.username() || message.userId();
52+
}

package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "integration-heap",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "Heap server-side integration",
6+
"author": "Segment <[email protected]>",
7+
"repository": {
8+
"type": "git",
9+
"url": "https://github.com/segmentio/integration-heap"
10+
},
11+
"main": "lib/index.js",
12+
"scripts": {
13+
"test": "make test"
14+
},
15+
"dependencies": {
16+
"reject": "0.0.1",
17+
"segmentio-integration": "^2.3.3"
18+
},
19+
"devDependencies": {
20+
"istanbul": "0.x",
21+
"jscs": "1.x",
22+
"merge-util": "^0.1.0",
23+
"mocha": "2.x",
24+
"ms": "0.x",
25+
"segmentio-facade": "^2.0.5",
26+
"segmentio-integration-tester": "^1.0.5",
27+
"should": "^4.3.0",
28+
"uid": "0.0.2",
29+
"unix-time": "1.x"
30+
}
31+
}

0 commit comments

Comments
 (0)