Skip to content
This repository has been archived by the owner on Dec 10, 2022. It is now read-only.

Commit

Permalink
Minor tweaks; incl completely remove blank data
Browse files Browse the repository at this point in the history
  • Loading branch information
tdmalone committed Jan 28, 2018
1 parent 110e11b commit 2773f99
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,19 @@ A simple [AWS Lambda](https://aws.amazon.com/lambda/) function that 'queues' geo

This function attempts to normalise the data received from the app, because sometimes it sends JSON and sometimes it sends `x-www-form-urlencoded` data, with different fields provided for each. I'm not sure why, but there you go. This function will get you - as much as possible - the same fields no matter what.

It also performs minor cleanups on the data and drops any `Visit:Exit` events, because they're unlike any of the other events in that they send an address that you _were_ at, some time after the app detects that you left, which means it is no longer current and is superceded by any other events, such as `Location:Update`.
It also performs minor cleanups on the data and drops any `Visit:Exit` events, because they're unlike any of the other events in that they send an address that you _were_ at, some time after the app detects that you left, which means it is no longer current and is superceded by any other event, such as `Location:Update`.

Other than that, this function tries to do its job quickly and get out of the way, while providing some error reporting if something goes wrong. I suggest using [cloudwatchToPapertrail](https://github.com/tdmalone/cloudwatch-to-papertrail) or another log monitoring tool to pick up what's happening.

Oh, and this function will also combine anything you add in the GET parameters - which can often be useful to indicate which phone the input is coming from!

There are no dependencies to install.

## Usage

Full instructions coming soon. For now, the instructions basically are to set up an API Gateway endpoint and a Lambda function :). Create your geofences on the app, and set them and any other events you wish to send a POST request to your API Gateway endpoint. Add GET parameters if you wish - eg. `?phone=work-phone`.
Full instructions coming soon.

For now, the instructions basically are to set up an API Gateway endpoint and a Lambda function 😀. Create your geofences on the app, and set them - and any other events you wish to send - with a POST request to your API Gateway endpoint. You can also add context via GET parameters if you wish - eg. `?phone=work-phone`.

There are no dependencies to install.

## Tests

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ exports.handler = ( event, context, callback ) => {
geoEventData = normalizeFormData( geoEventData );
}

// Ensure no data is going through as a blank string, but rather than it's set to null.
// Ensure no data is going through as a blank string.
Object.keys( geoEventData ).forEach( ( key ) => {
if ( '' === geoEventData[ key ]) geoEventData[ key ] = null;
if ( '' === geoEventData[ key ]) delete geoEventData[ key ];
});

// Store an SNS message to process everything else we need, so we can return quickly.
Expand Down

0 comments on commit 2773f99

Please sign in to comment.