fullstory-babel-plugin-annotate-react icon indicating copy to clipboard operation
fullstory-babel-plugin-annotate-react copied to clipboard

Disable for production?

Open rushi opened this issue 1 year ago • 1 comments

Your Questions My goal is to only run this in dev & test environments so we can easily debug and track down problems to the right component.

Context In production I don't want our customers to see filenames, component names etc. However I wouldn't mind sending the info to FS - Just don't want component and filenames being seen by customers via view-source

Attempts I tried to add a selective export using process.env.NODE_ENV in my babel export and it didn't seem to work.

rushi avatar Jan 29 '24 05:01 rushi

Hi @rushi! thanks for the question here and sorry we didn't get back to you sooner—we try to keep an eye out here for questions, but in the future if you contact FullStory Support ([email protected] / help.fullstory.com/hc/requests/new) we'll be able to get back to you much quicker. 🙂

We've had a similar question come up before and here's some code we've suggested for running it only in production, which you could modify to suit your use case / environments you wish to apply the plugin in. Hope this helps!

module.exports = function(api) {
  api.cache(true);

  const plugins = ['@fullstory/react-native'];

  // Check if NODE_ENV is set to 'production'
  if (process.env.NODE_ENV === 'production') {
    // Add the @fullstory/annotate-react plugin only in production
    plugins.push(["@fullstory/annotate-react", {
      native: true,
      setFSTagName: true,
    }]);
  }

  return {
    // Other Babel config options like presets
    presets: ['module:metro-react-native-babel-preset'],
    plugins: plugins,
  };
};

1etoy avatar Mar 12 '24 17:03 1etoy

Closing. @rushi Let us know if this doesn't work for you.

RyanCommits avatar Jul 25 '24 21:07 RyanCommits