Running and debugging Analysis externally

I was able to run an Analysis externally, however the console logs did not display on my machine.

I also found the documentation possibly outdated, for instance in this page, the Tago Builder link does not work:
https://docs.tago.io/en/articles/174-running-analysis-as-external-using-node-js

Is there a detailed instruction on how to successfully debug analysis externally?

Thanks.

Hi @sanimesa,
When you run in external mode, it is not different from any other Node.JS environment.

Both context.log and console.log should work to show up logs in your terminal. If you’re not seeing the consoles, I’ll need you to send me screenshot of your code and your terminal with the analysis running.

Another way to Debug is using VSCode and run the Debugger in attach mode. Here is an example of the launch.json

{
   // Use IntelliSense to learn about possible attributes.
   // Hover to view descriptions of existing attributes.
   // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
   "version": "0.2.0",
   "configurations": [
     {
       "name": "Attach",
       "port": 9229,
       "request": "attach",
       "skipFiles": [
         "<node_internals>/**"
       ],
       "type": "pwa-node"
     }
   ]
}

Then you can run the script by using node --inspect ./analysis.js and run the Debugger on Vscode.


About the Tago-Builder, I’ll get in contact with the TagoIO team to have it fixed, thanks for reporting this.

Here are the screenshots. Also, I was actually able to attach the Chrome debugger, but same issue. Additionally, the code just runs through, is there a way to do line by line execution? I am sure I am missing something here.


Hi @sanimesa,
Try to change the context.log to console.log.

If it doesn’t work, try this:

TagoIO just updated their documentation: https://docs.tago.io/en/articles/174-running-analysis-as-external-using-node-js

About identifying the issue, your analysis seems to not connecting properly. You shouldn’t be receveing this “Disconnect from TagoIO” message.
In order to fix it, follow these steps:

  • Run the command “npm i --save @tago-io/sdk” in your terminal.
  • Change the “require(“tago”)” to “require(”@tago-io/sdk")"

Update: It did run now, but took a very long time. Thanks for your help!

I did go through all the install steps, the only reason I had to change the require statement is because otherwise I was getting an exception, since the earlier documentation was probably off.

In any case, I reran the install command per documentation and ran it again. Now it simply hangs at this:

C:\Shuvro\Development\node>node analysis.js

TagoIO-SDK: No region or env defined, using fallback as usa-1.
Connected to TagoIO, Getting analysis information…
Analysis [Analysis 1] Started.

Hi @sanimesa,
This result for your terminal is correct, everything should be working fine now.
You just need to go to TagoIO and trigger you analysis in some way: You can click in the RUN button or use actions/widgets to do that.

Another tips I can give you, is to use Nodemon to run the script. The nodemon library will watch any change to your script and restart it automatically. It really improves your time when developing.

npm i -g nodemon

Then run the script using

nodemon analysis.js

I’m glad I was able to help you.