SDK For Data Streaming
React-Native
6min
install peer dependencies $ npm install @react native async storage/async storage save $ npm install react native native mqtt save install sdk $ npm install @deerden/qualetics react native sdk save usage import qualeticsservice from "@deerden/qualetics react native sdk"; const qualetics = new qualeticsservice("qualeticstest", "supersecretpassword", "nlp", false, { host 'tcp\ //api qualetics com', port 1883, defaultactor { type "user", id "1234", } }); qualetics init(); / / \<button onpress={() => { qualetics send({ "actor" { "type" "user", "id" "js1234" }, "action" { "type" "buttonclick" }, "context" { "type" "button", "name" "button1" } }); }} title="press" /> options var qualetics = new qualetics service("your application id", "your application secret", "session prefix" / , false (optional, currently always false since automatic page tracking is not supported on react native, options (optional) object containing additional options ) /) init(); the following options can be provided when constructing the tracker instance { host string, // host that tracker will connect to, defaults to ws\ //api qualetics com port number, // port that tracker will connect to, defaults to 8083 defaultactor actor object // default actor for all the messages stickysessionid boolean, // store sessionid as cookie, defaults to true, only usable on browser // if stored sessionid has different session prefix than what is configured // new session id will be generated and it will be stored storedefaultactorfromapicall boolean, // store default actor from api call, defaults to true, only usable on browser // this setting will have no effect if default actor setting is set trackusergeolocation boolean // currently not supported on react native trackpagevisibilitychanges boolean //currently not supported on react native } sending events after the tracker has been initialized you can start sending events data format in the event should be { "actor" { "type" "user", // required "id" "js1234", // optional, id of the user "attributes" { //optional, key value pairs that can provide more data about the actor "name" "john doe", "age" "31", "address" { "street" "test street 1", "zip" "50100" } } }, "action" { "type" "new user", // required "attributes" { // optional, key value pairs that can provide more data about the action "referrer" "facebook", "coupon" "kihsk123fs" } }, "context" { "type" "course", // require "id" "12321123", // optional, identifier for the context "attributes" { // optional, key value pairs that can provide more data about the context "speaker" "jane doe" } } } events can be sent either by sending the complete json object qualetics send({ "actor" { "type" "user", "id" "js1234" }, "action" { "type" "buttonclick" }, "context" { "type" "button", "name" "button1" } }); or by using the message builder let message = qualetics createmessage(); message setaction({ type "buttonclick" }) setactor({ type "user", id "js1234" }) setcontext({ type "button", name "button2" }) send();