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
struct UserAttribute: Codable, Equatable { | |
// MARK: - JSON parse | |
var name: String? | |
var type: String? | |
var match: String? | |
var value: Any? | |
} |
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
function sendWebhook(data, done) { | |
var url = 'https://hooks.slack.com/services/LONG_UNIQUE_KEY'; | |
const options = { | |
hostname: 'hooks.slack.com', | |
protocol: 'https:', | |
//port: 80, | |
path: '/services/LONG_UNIQUE_KEY', | |
method: 'POST', | |
headers: { | |
'Content-Type': 'application/json' |
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 crypto = require('crypto'); | |
const hmac = crypto.createHmac('sha1', process.env.SECRET_KEY); | |
let hubHeader = event.headers['X-Hub-Signature']; | |
hmac.update(event.body); | |
let secretCompare = 'sha1=' + hmac.digest('hex'); | |
console.log(secretCompare + ' == ' + hubHeader, secretCompare == hubHeader); |
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
"body": "{\"project_id\":1234,\"timestamp\":1468447113,\"event\":\"project.datafile_updated\",\"data\":{\"revision\":1,\"origin_url\":\"https://optimizely.s3.amazonaws.com/json/1234.json\",\"cdn_url\":\"https://cdn.optimizely.com/json/1234.json\"}}", |
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
case 'POST': | |
let body = JSON.parse(event.body); | |
let projectId = body['project_id']; | |
let url = body['data']['cdn_url']; | |
console.log(‘project url:’, url); | |
break; |
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
'use strict'; | |
console.log('Loading function'); | |
const http = require('https'); | |
const doc = require('dynamodb-doc'); | |
const dynamo = new doc.DynamoDB(); |