Javscript SDK for your app to communicate with Got It Analytics Platform
npm install @gotitinc/giap_javascript
import giap from '@gotitinc/giap_javascript';
Use this method to initialize and setup the SDK. All other SDK methods must be called after this one
giap.initialize('YOUR_PROJECT_TOKEN', 'THE_GIAP_SERVER_URL');
Parameters
projectToken
: String - required - your project tokenserverUrl
: String - required - GIAP server urlenableLog
: Boolean - optional - set totrue
to enable development log
Use this method with a string representing user id (required) right after user has just signed up
giap.alias('INSERT THE USER ID');
Use this method with a string representing user id (required) right after user has just logged in
giap.identify('INSERT THE USER ID');
Use a string to represent the event name (required) and a object (optional) to represent the event properties.
giap.track('Visit', { economyGroup });
At any moment after initializing the lib, you can set custom properties for current tracking profile
giap.setProfileProperties({ fullName: 'YOUR FULL NAME' });
giap.increase('propertyName', 100);
giap.append('propertyName', ['one', 'two']);
giap.remove('propertyName', ['two']);
Use this method right after user has just logged out
giap.reset();
GIAP Javascript SDK handles everything asynchronously. Your app can be notified about important tasks done by the SDK.
Implement the following methods for your library:
giap.notification.didResetWithDistinctId = (distinctId) => {
console.log(`GIAP didResetWithDistinctId: ${distinctId}`);
};
giap.notification.didEmitEvents = (events, responseData) => {
console.log('GIAP didEmitEvent: ', events);
console.log(' Response: ', responseData);
};
giap.notification.didUpdateProfile = ({ id, props }, responseData) => {
console.log(`GIAP didUpdateProfile: ${id} with withProperties: `, props);
console.log(' Response: ', responseData);
};
giap.notification.didCreateAliasForUserId = (
{ userId, distinctId },
responseData,
) => {
console.log(
`GIAP didCreateAliasForUserId: ${userId} withDistinctId ${distinctId}`,
);
console.log(' Response: ', responseData);
};
giap.notification.didIdentifyUserId = (
{ userId, distinctId },
responseData,
) => {
console.log(
`GIAP didIdentifyUserId: ${userId} withCurrentDistinctId ${distinctId}`,
);
console.log(' Response: ', responseData);
};
- Install Node.js at least version 14 on your machine
-
Clone this repository
git clone https://github.com/tutoruniverse/giap_javascript.git
-
Install dependencies
cd giap_javascript npm install
npm test
- Edit config in
demo/src/constants/app.js
if needed - Run
npm run start-demo
npm run build