Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FullStory is not loaded, please ensure the init function is invoked before calling FullStory API functions #70

Open
gaelbonjour opened this issue Sep 28, 2020 · 4 comments
Labels
bug Something isn't working

Comments

@gaelbonjour
Copy link

Hi,

It happens some of our users use a tracker blocker, that blocks, Segment or Fullstory or both.
Calling various api such as setUserVars should NOT throw an exception if FS si not initialized.

Current work arround : wrap every call to Fullstory API in try catch. If feels overkill for such a case

Expected behavior : Fullstory MAY warn in console, but since there is nothing more to be done to get fullstory to work if fs.js has been blocked.

Alternative behavior : Fullstory API could provide a "isInitialized" member, indicating wheather it is safe to call any other api functions.

@patrick-fs
Copy link
Member

patrick-fs commented Sep 28, 2020

Hi @gaelbonjour thanks for reaching out to us. If an ad blocker blocks fs.js, you should still be able to call API functions from the SDK without throwing errors as long as you've called init in your code before you invoke the API functions. The init function creates the window[window._fs_namespace] object and creates place holders for functions that can be invoked before fs.js is loaded. An error is thrown only if window[window._fs_namespace] doesn't exist when you try to call an API function.

Calling init is the same as running the FullStory snippet in the <head> of your markup. If you weren't using @fullstory/browser from NPM and you attempted to call API functions without running the snippet in the head, you'd also get errors when trying to call API functions.

Could you please verify that you're always calling API functions after the init function is called?

@gaelbonjour
Copy link
Author

We rely on Segment to load all the analytics and tracking tools, including Fullstory.
We do not add snipets nor call init for each tools since segment is meant to do that dynamically.

However, if for some reason, fs.js or segment are blocked, it should not throw if fs is not ready when calling the various api. Alternatively, I should be able to know if Fullstory is ready so I can skip the calls to the APIs.

@TrevorFSmith
Copy link

Hi, I'd like to track down exactly where you're seeing the exceptions and what kind of exceptions they are so that I'm sure to address your problem instead of assuming that I understand. Could you provide a quick snippet from your code where the exception is thrown and information from the JS console about which exception type it is? With that I can nail down what's happening and figure out a solution.

@TrevorFSmith TrevorFSmith added the bug Something isn't working label Oct 16, 2020
@jviall
Copy link

jviall commented Nov 7, 2023

I know it's been some time since this was opened, but it still is an issue even in version 2.0.0. When trying to init Fullstory in a SSR React App, the only valid method for initialization is within a useEffect(), but then the reported issue occurs. So it's very confusing why the documentation would say this:

Before the FS script is fully bootstrapped, all calls to the client API are enqueued to be processed when capture has begun. Once capture has begun, calls to the client API are immediately processed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants