splunk/splunk-sdk-javascript

Importing to create-react-app project

Closed this issue · 2 comments

using npm install splunk sdk
then let splunkjs = require('splunk-sdk');

throws this error

  19 | // Declare a process environment so that we can set
  20 | // some globals here and have interop with node
> 21 | process.env = process.env || {};
  22 | 
  23 | module.exports = root = {
  24 |     Logger          : require('./lib/log').Logger,

Hi @AlisonWonderlandApps, this library was originally written to be imported into node projects. You'll want to run the compiled client directory through browserify (or similar tools) in order to use it with react.

See my comment on the JS logging repo for a starting point: splunk/splunk-javascript-logging#4 (comment)

Feel free to re-open this issue if you get stuck!

For others that have asked for this, I have put up a PR to fix the error above and provide a create-react-app based example for how to use the SDK with React. Please have a look: #99