Debug script in browser's devtools
Answered(As a newbie) I see people advocate editing JavaScript
widget.on('processresult', function(sender, ev) { //etc
}
I'd like to debug my code in there, in the browser (F12).
I can see the Sisense code but I cannot find my code.
-
Hi Marc,
You can do that by adding the "debugger;" keyword anywhere in your widget or dashboard script, opening the developer console and refreshing. As the script is processed by the browser, it will stop execution at this point in the script and behave just like a manually added breakpoint.
prism.on("beforemenu", function(){
debugger;
}); -
Hi Bruce,
It should work in plugins without issue. First of all, try placing a "console.log" at the exact location of your "debugger" statement and see if that does work - that is, if that line is really reached. If console.log works but "debugger" doesn't please let me know and we'll look into that.
Additionally, with plugins you can use Chrome's DevTools to place breakpoints anywhere in your code. You can find the plugin code in the location outlined in this screenshot below - find the code you're interested in, place a breakpoint and reload to see if that does stop. This is generally a better way to debug plugins than the "debugger" method, which is what I'd recommend only for widget & dashboard scripts.
-
Hey Moti - thanks for the response. Seems that my issue was that entry.json was not set proper;y in my local instance (isProd was true).
```
{
"isProd": false,
"watchIgnore": [
".hg$",
".git$",
"node_modules"
]
}```
After that the code was non-minified and I could debug normally. Thanks.
Please sign in to leave a comment.
Comments
6 comments