Support for Client-Side Application? #4

Open
umcsdon opened this Issue Mar 2, 2016 · 11 comments

Projects

None yet

4 participants

@umcsdon
umcsdon commented Mar 2, 2016

Is it possible to use this plugin for Client-Side Javascript Application?

@umcsdon umcsdon changed the title from Support for Client-Side SDK? to Support for Client-Side Application? Mar 2, 2016
@bradoyler
bradoyler commented May 6, 2016 edited

I suppose you could use browserify to run this module client-side, but don't know if that's supported. Would love to see this as an option for simple logging.

@bradoyler

@umcsdon actually, looks like this: https://github.com/splunk/splunk-sdk-javascript#client-side-code-would be the "supported" option.
But this line:

 var service = new splunkjs.Service({username: "admin", password: "changeme"});

has me worried.
Why would I put a username/password in my client-side app?

@shakeelmohamed
Member

I suppose you could use browserify to run this module client-side, but don't know if that's supported. Would love to see this as an option for simple logging.

@bradoyler We've manually tested this library with browserify, and it appears to work just fine once you workaround CORS. To workaround CORS on the Splunk end, take a look at this blog post by @glennblock.

Once you have browserify installed (npm install -g browserify), you can run the following. Then just include splunk-javascript-logging-client.js in your web app.

browserify index.js --standalone SplunkLogger -o splunk-javascript-logging-client.js

Why would I put a username/password in my client-side app?

That code example is for a different project, the Splunk SDK for JavaScript, which is not intended to be used in public facing websites.

@bradoyler

@shakeelmohamed Thx.
I just came across https://github.com/splunk/splunk-bunyan-logger
Would this be a better option?

@glennblock

@bradoyler you'll need to use Browserify to use splunk-bunyan-logger or
splunk-javascript-logging.

As you mentioned, using splunk-sdk-javascript is not ideal as it requires
having valid Splunk login credentials, and having to send them from the
client.

We may add a browser-based logging library in the future. If you'd like to
see that, can you submit an idea at splunkdev.uservoice.com?

Thanks!
Glenn

On Thu, May 5, 2016 at 7:34 PM brad oyler notifications@github.com wrote:

@shakeelmohamed https://github.com/shakeelmohamed Thx.
I just came across https://github.com/splunk/splunk-bunyan-logger
Would this be a better option?

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#4 (comment)

@shakeelmohamed
Member

@bradoyler Either one will work fine (with browserify). Take a look at the examples in this repo and the bunyan logger repo and see which interface you prefer. Bunyan will automatically give you a bit more metadata as outlined in the examples

@bradoyler

@glennblock @shakeelmohamed Great Thx. I'll try to get CORS enabled and go from there. ๐Ÿป

@glennblock

Thanks!
On Thu, May 5, 2016 at 7:54 PM brad oyler notifications@github.com wrote:

@umcsdon https://github.com/umcsdon U can upvote @
https://splunkdev.uservoice.com/forums/235348-dev-platform/suggestions/13751736-event-logging-from-the-browser

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#4 (comment)

@glennblock

I gave you a vote :-)
On Thu, May 5, 2016 at 8:28 PM Glenn Block glenn.block@gmail.com wrote:

Thanks!
On Thu, May 5, 2016 at 7:54 PM brad oyler notifications@github.com
wrote:

@umcsdon https://github.com/umcsdon U can upvote @
https://splunkdev.uservoice.com/forums/235348-dev-platform/suggestions/13751736-event-logging-from-the-browser

โ€”
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#4 (comment)

@shakeelmohamed
Member

@umcsdon @bradoyler you might want to check out this project as it already has browser support https://github.com/vtex/splunkevents-js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment