Analysis is what allows you to create powerful applications on TagoIO.  When creating analysis you have to choose between running it at TagoIO or External, which means that you will run on your machine.

You can choose to run the analysis on an external machine for a few reasons:

  1. Development Progress: While developing an analysis is best to have a full IDE and debugging mode, which is only available with Node.js on your machine.
  2.  Security: Could be the case of your company to have legal issues with the code, and you can't or don't want to upload the code to TagoIO services.
  3.  Using Third Packages:  The analysis has in-build third packages in the environment, like axios and moment.js, but you may want to use others. With combination with the Tago-Builder, you can use any third package you like and build an even more powerful script for TagoIO.

So, let's start with the instructions you need to get your analysis working in an external environment.

1. Install Node.js and NPM

Node.js is a powerful and relatively new programing language developed using JavaScript. It is a non-blocking and event-driven language that has been adopted for several developers and companies to deal with data-intensive real-time applications. You can learn about node.js here.

Open Node.js Installation Guide for instructions on how to install NPM and Node.js.

2. Create your Environment

In order to start writing your code, you first must setup the environment with Node.JS and NPM.

2-1. Open your favorite command-line tool like the Windows Command Prompt, PowerShell, Cygwin, Bash or the Git shell (which is installed along with Github for Windows).  Then create or navigate to your new project folder.

2-2. If the folder is empty, you must write in the command-line npm init and fill all prompted requests. If this is your first time, you can leave all default by just pressing enter.

2-3. Now you must install Tago sdk and Tago-Builder SDK. Enter in your command-line npm install --save tago tago-builder. This will start the installation of the TagoIO SDK and the Tago-Builder if you wish to upload your script later at TagoIO.

To know how to use the SDK for coding an Analysis, use our SDK documentation.

 2-4. Now you can create your analysis archive. For this instruction, let's call it analysis.js. Open it with your favorite editor, like Visual Studio Code or even Notepad, You can write the code exactly as you would do on TagoIO editor. 

You can get the Hello World analysis example by clicking here.

3. Running your Analysis

After the code and the environment set, you only need to make sure you put the right Analysis token into your analysis file.

In order to do that, every analysis has the following line below. You must replace  MY-ANALYSIS-TOKEN-HERE by your analysis token.

module.exports = new Analysis(myAnalysis, 'MY-ANALYSIS-TOKEN-HERE');

You can get the analysis token by accessing your analysis page at TagoIO and selecting  External for 'Run the scripts from'. Create a new analysis if you don't have any.

Now all you have to do is write at your command-line tool node ./analysis.js. You should see the following prompt at your command-line tool:

4. Use Tago-Builder to Upload the Script

If you only want to run the scripts on your machine, this step is not required. But if you want to build powerful scripts to upload at TagoIO, with several folders, imports, and third-party packages, you must use the tago-builder to compile the scripts.

To do that is simple, just enter your command line tool and follow these instructions:

  1. Type in your terminal tago-builder my_script.js new_name.tago.js(the last parameter is optional).
  2. Upload the generated new_name.tago.js file to your analysis at TagoIO.

More instructions on how Tago-Builder works and what you're able to do can be found clicking here.

More Examples

You can check our analysis examples with the full environment already set up for you below:

Now you have everything you need to know about running analysis in your machine and can start to creating full applications and powerful analysis using TagoIO.