Last active
August 5, 2017 08:41
-
-
Save matthewdenobrega/e3e4ed99a73c58913fee9cb810ec66f4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
let enrichedEventMatrix: EnrichedEventMatrix // Needs to be populated | |
function enrichUserEvent(eventInfo: EventInfo, enrichedEventMatrix: EnrichedEventMatrix): void { | |
let enrichedEventType: EnrichedEventType = enrichedEventMatrix[eventInfo.type] | |
if (!enrichedEventType) { return } | |
let dataFromApi: any = api.runQuery(enrichedEventType.enrichGraphQLQuery) // Need to parameterise this | |
let enrichedEvent: enrichedEvent = enrichedEventType.enrichMappingFunction(dataFromApi) | |
peristEnrichedEvent(enrichedEvent, eventInfo.subject) | |
callWebhook(enrichedEvent) | |
} | |
function generateNextSteps(userGuid: string, relatedUserGuids: string[]): EnrichedEvent[] { | |
let conversions: EnrichedEvent[] = retrieveConversionHistory(userGuid, enrichedEventMatrix) | |
relatedUserGuids.forEach((userGuid: string) => { | |
conversions.concat(retrieveConversionHistory(userGuid, enrichedEventMatrix)) | |
}) | |
// We need relatedUserGuids in the below to identify inactivity | |
let recommendations: EnrichedEvent[] = generateRecommendations(conversions, relatedUserGuids, enrichedEventMatrix) | |
recommendations = consolidateAndWeight(recommendations) | |
recommendations = downWeightDismissed(recommendations, userGuid) | |
recommendations = sortByConversionValue(recommendations) | |
return slightlyRandomize(recommendations) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment