1
Prerequisites
Before installing the TakeProfit Widget SDK, ensure that you meet the following requirements:
- Package Manager: The SDK is distributed via npm, so you should have either npm (comes with Node.js) or yarn installed.
-
Project Setup: Ensure you have an existing project directory with a basic configuration, such as a
package.jsonfile. If not, you can create one with:
2
Install the SDK
The TakeProfit Widget SDK is available as an npm package. To install it, run the following command in your project directory:If you prefer using This command will add the SDK as a dependency in your Note: Replace
yarn, you can install it with:package.json file and download it to the node_modules directory.Verifying Installation
After installation, you should seetakeprofit-widget-sdk listed under "dependencies" in your package.json file, like this:^0.2.3 with the version number you have installed.3
Initialize the SDK in Your Project
Once installed, you can begin using the SDK by importing it into your project files. Here’s a simple setup example:
-
Import the SDK: Open the main file where you intend to initialize the SDK (e.g.,
index.js,app.js, ormain.ts) and import the SDK: -
Basic Initialization: To ensure the SDK is correctly initialized, call the
connectmethod when your widget is ready to communicate with the platform: -
Hiding the Loader: To let the TakeProfit platform know your widget is ready, use the
hideLoaderfunction after initialization:
4
Verify Installation
After setting up the SDK in your project, follow these steps to verify that it’s working correctly:
-
Test Initialization:
- Run your project (typically with
npm startoryarn start). - Check the browser’s developer console to ensure there are no errors related to
takeprofit-widget-sdk.
- Run your project (typically with
-
Local Storage Configuration (for local widget testing):
- Open Take Profit Platform in your browser.
- Open your browser’s console and set up a local storage entry for your widget to test it on the TakeProfit platform interface.
-
Run this command in the browser console:
-
Replace
<your iframe URL>and<icon URL>with the actual URLs for testing. - Reload the page and verify that your widget appears in the TakeProfit widget panel.
Common Issues & Troubleshooting
Here are some common issues you may encounter during installation, along with solutions:Cannot find module 'takeprofit-widget-sdk'
Cannot find module 'takeprofit-widget-sdk'
Ensure you’ve installed the SDK in the correct directory. Run
npm install
again to confirm all dependencies are correctly installed.Error: Version compatibility with Node.js
Error: Version compatibility with Node.js
The SDK requires Node.js version 12 or later. Check your Node.js version
with
node -v. Update if necessary.Widget Doesn’t Load in TakeProfit Platform
Widget Doesn’t Load in TakeProfit Platform
Ensure that your
iframeUrl in the local storage configuration points to a
live or local server. - Clear the browser cache and try reloading the page.