## Installation and Usage
npm install @attraqt/activity``bash`
npm install --save @attraqt/activity
`js
import {activity} from @attraqt/activity
activity.init({
trackerKey: "YOUR_TRACKER_KEY",
region: "WEBSITE_REGION" // optional, set to EU by default
});
activity.setUser({
identities: {
sessionid: "YOUR_SESSION_ID"
},
traits: {
birthday: "2020-04-01"
},
segments: ["segment1"]
});
activity.send({
action: "view",
target: {
product: "YOUR_PRODUCT_ID"
}
});
`
| Method | Argument(s) | Result | Description |
| ----------------- | ---------------------------------------------------------------------------------------------------------------- | ------------------- | ----------------------------------------------------- |
| init | options: ActivityInitOptions | void | Initializes the activity client |Activity \| Activity[]
| send | activity: [](src/models/activity.ts), options?: SendActivityOptions | Promise | Sends the activity |User
| setUser | user: | void | Sets the user to be sent along with future activities |void
| clearUser | | | Clears the previously set user |string
| addUserIdentity | identityRepository: , identity: string | void | Sets a user identity |{[identityRepository: string]: string}
| setUserIdentities | identities: | void | Sets user identities |string
| addUserSegment | segment: | void | Adds a segment to the user |string[]
| setUserSegments | segments: | void | Sets user segments |string
| addUserTrait | trait: , traitValue: string | void | Adds a trait to the user |{[trait: string]: string}
| setUserTraits | traits: | void | Sets user traits |Promise<
| getUserClusters | | Clusters>` | get the user clusters |