diff --git a/src/events/fetch-context/eventbrite.js b/src/events/fetch-context/eventbrite.js index 4227fdf..065ffa2 100644 --- a/src/events/fetch-context/eventbrite.js +++ b/src/events/fetch-context/eventbrite.js @@ -1,6 +1,10 @@ const fetch = require('node-fetch') const logger = require('@architect/shared/logger') +function name () { + return 'Eventbrite' +} + function isEventbriteUrl (url) { return ((url.indexOf('https://eventbrite.com') > -1) || (url.indexOf('https://www.eventbrite.com') > -1) || diff --git a/src/events/fetch-context/granary.js b/src/events/fetch-context/granary.js index 3b9a92b..7d7a9a2 100644 --- a/src/events/fetch-context/granary.js +++ b/src/events/fetch-context/granary.js @@ -1,6 +1,10 @@ const fetch = require('node-fetch') const logger = require('@architect/shared/logger') +function name () { + return 'Granary' +} + function getGranaryUrl (url) { const granaryBaseUrl = 'https://granary.io/' const safeUrl = encodeURIComponent(url) diff --git a/src/events/fetch-context/index.js b/src/events/fetch-context/index.js index 7f918a4..9933b3e 100644 --- a/src/events/fetch-context/index.js +++ b/src/events/fetch-context/index.js @@ -19,9 +19,11 @@ async function getContext (handler, url) { // if our fetching fails, fallback to OpenGraph const properties = await handler.fetchContext(url) if (properties) { + logger.info(`Context fetched ${url} using ${handler.name()}`, JSON.stringify(properties)) return properties } + logger.info(`Context fetching ${url} using fallback ${openGraph.name()}`, JSON.stringify(properties)) return await openGraph.fetchContext(url) } @@ -34,5 +36,4 @@ exports.handler = async function subscribe (event) { url, properties }) - logger.info(`Context fetched ${url}`, JSON.stringify(properties)) } diff --git a/src/events/fetch-context/meetup.js b/src/events/fetch-context/meetup.js index b914fe3..a62815a 100644 --- a/src/events/fetch-context/meetup.js +++ b/src/events/fetch-context/meetup.js @@ -1,6 +1,10 @@ const fetch = require('node-fetch') const logger = require('@architect/shared/logger') +function name () { + return 'Meetup' +} + function isMeetupUrl (url) { return ((url.indexOf('https://meetup.com') > -1) || (url.indexOf('https://www.meetup.com') > -1)) diff --git a/src/events/fetch-context/open-graph.js b/src/events/fetch-context/open-graph.js index 011541f..b1c5dc7 100644 --- a/src/events/fetch-context/open-graph.js +++ b/src/events/fetch-context/open-graph.js @@ -1,6 +1,10 @@ const ogs = require('open-graph-scraper') const logger = require('@architect/shared/logger') +function name () { + return 'OpenGraph' +} + function setName (result, properties) { if (result.ogTitle) { properties.name = [result.ogTitle]