Last active
November 28, 2017 04:32
-
-
Save weilandia/745b20836a2423074e737974d077dfd6 to your computer and use it in GitHub Desktop.
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
const serverless = require('serverless-http'); | |
const Mixpanel = require('mixpanel'); | |
const mixpanel = Mixpanel.init(process.env.MIXPANEL_TOKEN); | |
function handler(event, context, callback) { | |
let body = JSON.parse(event.body); | |
let eventsTracked = 0; | |
body.forEach((sendGridEvent) => { | |
mixpanel.track('SendGrid: ' + sendGridEvent.event, sendGridEvent); | |
eventsTracked += 1; | |
}); | |
const response = { | |
statusCode: 200, | |
eventsTracked: eventsTracked | |
}; | |
callback(null, response); | |
} | |
module.exports.mixpanel = mixpanel; | |
module.exports.handler = handler; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment