getsentry / sentry-fullstory

The Sentry-FullStory integration seamlessly integrates the Sentry and FullStory platforms.
MIT License
39 stars 13 forks source link

Support integration with @sentry/nextjs #80

Closed mcmxcdev closed 5 months ago

mcmxcdev commented 1 year ago

It seems that the current integration only works with @sentry/browser.

With Next.js, the FullStory.init() invocation is triggered inside a useEffect hook in _app.tsx, so it's pretty different from the instructions in the README and would need to be accounted for.

seanparmelee commented 6 months ago

You could call FullStory.init() in the sentry.client.config.ts file, passing in a callback that adds the integration to Sentry:

import * as FullStory from '@fullstory/browser';
import SentryFullStory from '@sentry/fullstory';
import * as Sentry from '@sentry/nextjs';

Sentry.init({
  dsn: __DSN__,
  // ...
});

FullStory.init({ orgId: '__FULLSTORY_ORG_ID__' }, () => {
  Sentry.getClient()?.addIntegration?.(
    new SentryFullStory('__SENTRY_ORG_SLUG__', { client: FullStory }),
  );
});