Skip to content

Instantly share code, notes, and snippets.

@matthewdenobrega
Last active August 5, 2017 08:41
Show Gist options
  • Save matthewdenobrega/e3e4ed99a73c58913fee9cb810ec66f4 to your computer and use it in GitHub Desktop.
Save matthewdenobrega/e3e4ed99a73c58913fee9cb810ec66f4 to your computer and use it in GitHub Desktop.
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