Skip to content

Commit

Permalink
Merge pull request #28478 from code-dot-org/jotform-api-reachability
Browse files Browse the repository at this point in the history
Jotform: Add a reachability check to api.jotform.com
  • Loading branch information
islemaster committed May 11, 2019
2 parents be8d19c + 5ae8ccf commit d647452
Showing 1 changed file with 31 additions and 19 deletions.
50 changes: 31 additions & 19 deletions apps/src/sites/studio/pages/jotformLoader.js
Expand Up @@ -14,30 +14,42 @@ function main(context) {
// cdn.jotfor.ms https://cdn.jotfor.ms/images/calendar.png 817B
checkReachability('https://cdn.jotfor.ms/images/calendar.png'),
// www.jotform.com https://www.jotform.com/favicon.ico 887B
checkReachability('https://www.jotform.com/favicon.ico')
checkReachability('https://www.jotform.com/favicon.ico'),
// api.jotform.com https://api.jotform.com/favicon.ico 592B
checkReachability('https://api.jotform.com/favicon.ico')
// Not using these yet, they're likely to fall under the same policy as www.jotform.com
// events.jotform.com
// files.jotform.com
// form.jotform.com
]).then(([jotFormFrameLoadedMs, cdnjotformsMs, wwwjotformcomMs]) => {
if (jotFormFrameLoadedMs === false) {
// Load failed if we specifically got 'false'
logToCloud.addPageAction(logToCloud.PageAction.JotFormLoadFailed, {
route: `GET ${context.location.pathname}`,
reachedCdnjotforms: false !== cdnjotformsMs,
reachedWwwjotformcom: false !== wwwjotformcomMs,
cdnjotformsMs,
wwwjotformcomMs
});
} else {
logToCloud.addPageAction(logToCloud.PageAction.JotFormFrameLoaded, {
route: `GET ${context.location.pathname}`,
jotFormFrameLoadedMs,
cdnjotformsMs,
wwwjotformcomMs
});
]).then(
([
jotFormFrameLoadedMs,
cdnjotformsMs,
wwwjotformcomMs,
apijotformcomMs
]) => {
if (jotFormFrameLoadedMs === false) {
// Load failed if we specifically got 'false'
logToCloud.addPageAction(logToCloud.PageAction.JotFormLoadFailed, {
route: `GET ${context.location.pathname}`,
reachedCdnjotforms: false !== cdnjotformsMs,
reachedWwwjotformcom: false !== wwwjotformcomMs,
reachedApijotformcom: false !== apijotformcomMs,
cdnjotformsMs,
wwwjotformcomMs,
apijotformcomMs
});
} else {
logToCloud.addPageAction(logToCloud.PageAction.JotFormFrameLoaded, {
route: `GET ${context.location.pathname}`,
jotFormFrameLoadedMs,
cdnjotformsMs,
wwwjotformcomMs,
apijotformcomMs
});
}
}
});
);
}

/**
Expand Down

0 comments on commit d647452

Please sign in to comment.