1.0.1 • Published 2 years ago
@cxsense/admin v1.0.1
CXSense Admin SDK
CXSense NodeJs Admin SDK.
Learn more about API endpoint definitions here https://cxsense.io/docs
Installation
npm install @cxsense/admin
Getting started guide
const CxAdmin = require('@cxsense/admin');
CxAdmin.Auth.set({
clientId: 'your_client_id',
clientSecret: 'your_client_secret'
}
Create a simple journey
Create your simple journey with an event.
const Journey = new CxAdmin.Journey('projectId');
await Journey.create(
[
{
event_id: 'login',
},
]
)
Track user interactions
Your user will be created in a segment with the given properties. In this instance, our team will receive a Slack message after a the user's login.
const Profile = new CxAdmin.Profile('user_id');
const profile = await Profile.identify({user_properties: {name: 'Foo'}})
const Interaction = new CxAdmin.Interaction(profile._id);
await Interaction.track('login')
Subscribe to a destination
You can implement your own destination or utilse destinations in the marketplace. All secrets are encrypted at rest using he Advanced Encryption Standard (AES) algorithm, AES-256 and this API always communicates over a secure HTTP(s) connection.
const details = {
url: "https://slack.com/api/chat.postMessage",
data: {
channel: "C04BJK2GYT1",
text: "{user.fullName} has logged in!"
},
auth: {
bearer_token: 'slack-auth-token'
}
method: "post"
}
const Destination = new CxAdmin.Destination('Slack')
await Destination.subscribe('journeyId', details)
Realtime achievement listener
const Achievement = new CXSense.Achievement('profileId')
Achievement.onGain(data => {
console.log(data)
})