in source/update_ddb_from_stream/update_ddb_from_stream.py [0:0]
def sendAnonymousData(event_time,dataDict):
log.debug("Sending Anonymous Data")
postDict = {}
postDict['Data'] = dataDict
postDict['TimeStamp'] = event_time
postDict['Solution'] = os.environ.get('SOLUTION_ID')
postDict['Version'] = os.environ.get('SOLUTION_VERSION')
postDict['UUID'] = os.environ.get('SOLUTION_UUID')
# API Gateway URL to make HTTP POST call
url = 'https://metrics.awssolutionsbuilder.com/generic'
data=dumps(postDict)
data_utf8 = data.encode('utf-8')
log.debug('sendAnonymousData data: %s', data)
headers = {
'content-type': 'application/json; charset=utf-8',
'content-length': len(data_utf8)
}
req = urllib.request.Request(url, data_utf8, headers)
rsp = urllib.request.urlopen(req)
rspcode = rsp.getcode()
content = rsp.read()
log.debug("Response from APIGateway: %s, %s", rspcode, content)