fullstorydev / fullstory-browser-sdk

Official FullStory SDK for JavaScript, for web browsers
MIT License
55 stars 17 forks source link

Sentry Issues in Fullstory init #88

Closed marseam closed 3 years ago

marseam commented 3 years ago

i'm using the Sentry/FS integration

i'm getting this issue in Sentry constantly

 if (!snippetLoaded) {
    throw Error('FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions');
  }

In index.js basically setup like this:

` Sentry.init({ dsn: '', environment: environment, integrations: [new ConsolePlugin({ levels: this.sentryLevel <= Logger.WARN ? ['warn', 'error'] : ['error'] }), new SentryFullStory('')], });

FullStory.init({ orgId: '' }); ` outside the component render

Any thoughts on how to debug this? :)

patrick-fs commented 3 years ago

Hey @marseam thanks for letting us know. You should be able to eliminate that error if you reverse the order of operations where FullStory is initialized before Sentry:

FullStory.init({ orgId: 'ZFBHF' });

Sentry.init({
dsn: '',
environment: environment,
integrations: [new ConsolePlugin({ levels: this.sentryLevel <= Logger.WARN ? ['warn', 'error'] : ['error'] }),
new SentryFullStory('')],
});

Please give that a shot and let me know if that resolves your issue.

marseam commented 3 years ago

Thanks @patrick-fs for your quick response, I've added above but still seeing that issue (it logs few thousand times a day in sentry)

Any thoughts on how to debug/resolve this?

I'm using below libraries:

"@fullstory/browser": "^1.4.6", "@sentry/fullstory": "^1.1.5", "@sentry/integrations": "^6.1.0", "@sentry/react": "^6.1.0",

patrick-fs commented 3 years ago

Hey @marseam, that error will only be thrown if a call is made to a FullStory SDK function prior to invoking init. As long as FullStory.init is called at the root of your react application, you should be good. Are there any code paths that could be calling FullStory SDK functions before init? That would be a good place to start looking.

Is it also possible that some assets have gotten cached (in the users' browser or somewhere else along the way)? This could be delivering stale JS files that don't have the change you made above.

marseam commented 3 years ago

Hi @patrick-fs , an update on this, it looks to have fixed the issue.

The error rate dropped day by day to 0 so might of been caching issue but looks to be resolved now :)

thanks!