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
http GET $BASE_DOMAIN/api/user/[email protected] | |
HTTP/1.1 200 OK | |
Connection: keep-alive | |
Content-Length: 976 | |
Content-Type: application/json | |
Date: Sat, 25 Apr 2020 09:17:07 GMT | |
Via: 1.1 5da47734f496c05ba90c546c024fb779.cloudfront.net (CloudFront) | |
X-Amz-Cf-Id: hfpCCsc632rf_84U_bPXU2HRZep6oK_U4vnHQTGoHT3olX7BmoXq1w== | |
X-Amz-Cf-Pop: LHR61-C2 | |
X-Amzn-Trace-Id: Root=1-5ea40012-442f3f982a8b83b4481e7856;Sampled=0 |
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
http GET $BASE_DOMAIN/api/anonymous/da8011b3-19bf-4d3d-b1b6-caa961cb5161 | |
HTTP/1.1 200 OK | |
Connection: keep-alive | |
Content-Length: 783 | |
Content-Type: application/json | |
Date: Sat, 25 Apr 2020 09:15:33 GMT | |
Via: 1.1 320b04684a5b16980772c5d36c63ecea.cloudfront.net (CloudFront) | |
X-Amz-Cf-Id: ONXCrxrOY2wufV6Gu8UtVjaCER_PHtWtA1JUw3Dx4fFK8OHQN1nL4g== | |
X-Amz-Cf-Pop: LHR61-C2 | |
X-Amzn-Trace-Id: Root=1-5ea3ffb5-b7e30caadb18a74e68163166;Sampled=0 |
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
// /src/handlers/api/getAnonymous.js | |
const { withStatusCode } = require('../../utils/response.util'); | |
const dynamoDBFactory = require('../../dynamodb.factory'); | |
const ok = withStatusCode(200, JSON.stringify); | |
const { SourceAttributionModel } = require('../../models/SourceAttribution'); | |
const dynamoDb = dynamoDBFactory(); | |
const model_source = new SourceAttributionModel(dynamoDb); |
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
// /src/handlers/api/getAnonymous.js | |
const { withStatusCode } = require('../../utils/response.util'); | |
const dynamoDBFactory = require('../../dynamodb.factory'); | |
const ok = withStatusCode(200, JSON.stringify); | |
const { SourceAttributionModel } = require('../../models/SourceAttribution'); | |
const dynamoDb = dynamoDBFactory(); | |
const model_source = new SourceAttributionModel(dynamoDb); |
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
// /src/handlers/api/getUser.js | |
const { withStatusCode } = require('../../utils/response.util'); | |
const dynamoDBFactory = require('../../dynamodb.factory'); | |
const { UserToAnonymousModel } = require('../../models/UserToAnonymous'); | |
const { SourceAttributionModel } = require('../../models/SourceAttribution'); | |
const dynamoDb = dynamoDBFactory(); | |
const model_usermap = new UserToAnonymousModel(dynamoDb); | |
const model_source = new SourceAttributionModel(dynamoDb); |
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
// /src/handlers/api/getUser.js | |
const { withStatusCode } = require('../../utils/response.util'); | |
const dynamoDBFactory = require('../../dynamodb.factory'); | |
const { UserToAnonymousModel } = require('../../models/UserToAnonymous'); | |
const { SourceAttributionModel } = require('../../models/SourceAttribution'); | |
const dynamoDb = dynamoDBFactory(); | |
const model_usermap = new UserToAnonymousModel(dynamoDb); | |
const model_source = new SourceAttributionModel(dynamoDb); |
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
service: solving-marketing-attribution | |
custom: | |
# sma = Solving Marketing Attribution | |
tableIdentify: 'sma-identify-${self:provider.stage}' | |
tablePage: 'sma-event-page-${self:provider.stage}' | |
tableAttribution: 'sma-event-attribution-${self:provider.stage}' | |
tableUserMapping: 'sma-event-user-map-${self:provider.stage}' | |
provider: |
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
// /src/models/SourceAttribution | |
const ATTRIBUTION_TABLE = process.env.ATTRIBUTION_TABLE; | |
const extractor = require('../utils/event_extraction.util'); | |
class SourceAttributionModel { | |
get _baseParams() { | |
return { | |
TableName: ATTRIBUTION_TABLE | |
}; |
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
// /processPage.js | |
const extractor = require('./src/utils/event_extraction.util'); | |
const referrer_detection = require('./src/utils/referrer_detection.util'); | |
const { unmarshallNewImageEvent } = require('./src/utils/dynamo_stream.util'); | |
const dynamoDBFactory = require('./src/dynamodb.factory'); | |
const { SourceAttributionModel } = require('./src/models/SourceAttribution'); | |
const dynamoDb = dynamoDBFactory(); |
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
// src/utils/event_extraction.util.js | |
module.exports = (request_body) => { | |
const referrer = request_body.context.page.referrer; | |
const href = request_body.context.page.url; | |
const anonymousId = request_body.anonymousId; | |
const messageId = request_body.messageId; | |
const userId = request_body.userId; | |
const type = request_body.type; | |
const timestamp = request_body.timestamp; |