Skip to content

Commit

Permalink
Merge pull request #239 from newrelic/liz/instrumentation
Browse files Browse the repository at this point in the history
Notice error for NR1_SDK load failure
  • Loading branch information
jerelmiller authored Jun 24, 2020
2 parents 8468e9b + c630371 commit 1d16e3d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hooks/useApiDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ const useApiDoc = (name) => {

return useMemo(() => {
if (window.__NR1_SDK__ == null) {
const err = new Error('NR1_SDK not found');
window.NREUM && window.NREUM.noticeError(err);
return null;
}

Expand All @@ -33,6 +35,8 @@ const useApiDoc = (name) => {
}

if (!api) {
const err = new Error('NR1_SDK API not found');
window.NREUM && window.NREUM.noticeError(err, { apiName: name });
return null;
}

Expand Down
7 changes: 7 additions & 0 deletions src/hooks/useComponentDoc.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,17 @@ const useComponentDoc = (componentName) => {
if (typeof window === 'undefined') global.window = {};

return useMemo(() => {
if (window.__NR1_SDK__ == null) {
const err = new Error('NR1_SDK not found');
window.NREUM && window.NREUM.noticeError(err);
return null;
}
const sdk = window.__NR1_SDK__?.default ?? {};
const component = sdk[componentName];

if (!component) {
const err = new Error('NR1_SDK component not found');
window.NREUM && window.NREUM.noticeError(err, { componentName });
return null;
}

Expand Down

0 comments on commit 1d16e3d

Please sign in to comment.