export function loadSnippet()

in src/shippers/fullstory/src/load_snippet.ts [43:71]


export function loadSnippet({
  scriptUrl = 'https://edge.fullstory.com/s/fs.js',
  fullStoryOrgId,
  host = 'fullstory.com',
  namespace = 'FS',
  debug = false,
  captureOnStartup,
}: FullStorySnippetConfig): FullStoryApi {
  window._fs_debug = debug;
  window._fs_host = host;
  window._fs_script = scriptUrl;
  window._fs_org = fullStoryOrgId;
  window._fs_namespace = namespace;

  // Only set it if the option is provided, since documentation doesn't show it as a "normal" thing to set up.
  if (typeof captureOnStartup === 'boolean') {
    window._fs_capture_on_startup = captureOnStartup;
  }

  require('./raw_snippet'); // load and execute the snippet. Moved to a separate file so that we can disable type-checks.

  const fullStoryApi = window[namespace as 'FS'];

  if (!fullStoryApi) {
    throw new Error('FullStory snippet failed to load. Check browser logs for more information.');
  }

  return fullStoryApi;
}