Event Logging Library for Avro Records
To build:
npm run build
build files on save
npm run watch
To run tests:
npm test
To release new version:
update version in package.json
This will publish a new version to npm registry upon build.
To configure for use in lambda
Set the environment variable ANALYTICS_EVENT_ENVELOPE
to the value chapin
.
We log a field called 'source' to track the origin of the data. As the default, 'source' is set to the value of AWS_LAMBDA_FUNCTION_NAME. However, if you would like to specify a different string as the 'source', set the ANALYTICS_SOURCE
environment variable.
An Example
const eventLogger = require('meetup-event-logger');
const sampleSchema = {
namespace: 'com.meetup.base.avro',
type: 'record',
name: 'Request',
doc: 'v1',
fields: [
{ name: 'timestamp', type: 'string' },
{ name: 'data', type: 'string' },
]
};
const sampleSchemaSeralizer = eventLogger.avroSerializer(sampleSchema);
eventLogger.log({
'timestamp':moment(new Date().toISOString()).tz('America/New_York').format()
'data':'some data',
}, sampleSchemaSeralizer);
eventLogger.log({
'timestamp':moment(new Date().toISOString()).tz('America/New_York').format()
'data':'some other data',
}, sampleSchemaSeralizer);
Sending test data
You can send test data in the same way using the logTestData
function like the following (assuming we're using the same sampleSchema and sampleSchemaSerializer defined above):
eventLogger.logTestData({
'timestamp':moment(new Date().toISOString()).tz('America/New_York').format()
'data':'some other data',
}, sampleSchemaSeralizer);