This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/application.py b/application.py | |
index 15cb3eb..d4a21d7 100644 | |
--- a/application.py | |
+++ b/application.py | |
@@ -11,6 +11,7 @@ from util import ThrottleQueue | |
from boto.dynamodb.table import Table | |
from boto.dynamodb.item import Item | |
from boto import connect_dynamodb | |
+from boto import connect_kinesis | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Firebase = require('firebase'); | |
var async = require('async'); | |
// Extract data from the kinesis event | |
exports.handler = function(event, context) { | |
// This function abstracts the expected structure of any Kinesis payload, | |
// which is a base64-encoded string of a JSON object, passing the data to | |
// a private function. | |
function handlePayload(record, callback) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
React = require('react') | |
Firebase = require('firebase') | |
ReactFireMixin = require('reactfire') | |
OdometerComponent = require('react-odometer') | |
firebaseApp = 'https://luminous-heat-2841.firebaseio.com/' | |
projectId = location.hash.substring(1) or 324 | |
ViewCount = React.createClass | |
mixins: [ReactFireMixin] | |
getInitialState: -> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var gutil = require('gulp-util'); | |
var del = require('del'); | |
var rename = require('gulp-rename'); | |
var install = require('gulp-install'); | |
var zip = require('gulp-zip'); | |
var AWS = require('aws-sdk'); | |
var fs = require('fs'); | |
var runSequence = require('run-sequence'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "adventr-lambda-video", | |
"version": "0.0.0", | |
"description": "Initial lambda functions for Adventr", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Adam Neary <[email protected]> (http://adamrneary.com/)", | |
"license": "MIT", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var dotenv = require('dotenv'); | |
var kinesis = require('kinesis'); | |
Transform = require('stream').Transform | |
dotenv.load(); | |
// Data is retrieved as Record objects, so let's transform into Buffers | |
var bufferify = new Transform({objectMode: true}) | |
bufferify._transform = function(record, encoding, cb) { | |
cb(null, record.Data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var kinesis = require('kinesis'); | |
Transform = require('stream').Transform; | |
dotenv = require('dotenv'); | |
es = require('event-stream'); | |
fs = require('fs'); | |
dotenv.load(); | |
// Data is retrieved as Record objects, so we transform into Buffers. | |
var bufferify = new Transform({objectMode: true}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Extract data from the kinesis event | |
exports.handler = function(event, context) { | |
// This function abstracts the expected structure of any Kinesis payload, | |
// which is a base64-encoded string of a JSON object, passing the data to | |
// a private function. | |
function handlePayload(record, callback) { | |
encodedPayload = record.kinesis.data; | |
rawPayload = new Buffer(encodedPayload, 'base64').toString('utf-8'); | |
handleData(JSON.parse(rawPayload), callback) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function mimics how our upstream code (in this case, the Flask beacon) | |
// pipes video events to Kinesis. | |
// | |
// campaignId - An Integer id for the campaign being viewed | |
// eventName - A String for the name of the event being recorded | |
// | |
// Returns a String containing the data as passed to Kinesis | |
function generateEvent(campaignId, eventName) { | |
var analyticsId = '123-' + campaignId + '-456'; | |
var properties = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('VideoEvents', function(){ | |
var projectRef = getFirebaseRef(); | |
var testId = getUniqueId(); | |
describe('Video View', function(){ | |
var eventName = 'Video View'; | |
before(function(done) { | |
projectRef | |
.child(testId) |