Skip to content

Instantly share code, notes, and snippets.

@patrick-fs
Last active June 6, 2023 12:56
Show Gist options
  • Save patrick-fs/8066c2a0c97aec6cca6d355a55a52506 to your computer and use it in GitHub Desktop.
Save patrick-fs/8066c2a0c97aec6cca6d355a55a52506 to your computer and use it in GitHub Desktop.
Integrating Sentry + FullStory without NPM
Sentry.init({
dsn: 'your Sentry DSN', // if you're logged into Sentry, you can find your DSN in ths sample code on this page: https://docs.sentry.io/platforms/javascript/react/
beforeSend(event, hint) {
const error = hint.originalException;
event.extra = event.extra || {};
var _fs = window[window._fs_namespace]];
if (typeof _fs !== 'function') {
event.extra.fullstory = 'FullStory is not installed';
return;
}
// getCurrentSessionURL isn't available until after the FullStory script is fully bootstrapped.
// If an error occurs before getCurrentSessionURL is ready, make a note in Sentry and move on.
// More on getCurrentSessionURL here: https://help.fullstory.com/develop-js/getcurrentsessionurl
event.extra.fullstory = typeof _fs.getCurrentSessionURL === 'function' ? _fs.getCurrentSessionURL(true) : 'current session URL API not ready';
// FS.event is immediately ready even if FullStory isn't fully bootstrapped
_fs.event('Application error', {
name: error.name,
message: error.message,
fileName: error.fileName,
sentryEventId: hint.event_id,
// sentryUrl: `https://sentry.io/organizations/{your Sentry Org Id here}/issues/?project={your Sentry Project ID here}&query=${hint.event_id}`;
});
return event;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment