releasebird-javascript-sdk 1.0.24 → 1.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -117,37 +117,37 @@ export default class RbirdSessionManager {
117
117
  }
118
118
 
119
119
  trackEvent(name, data) {
120
+ if (window.localStorage.getItem('rbird_state')) {
121
+ let state = JSON.parse(window.localStorage.getItem('rbird_state'));
120
122
 
121
- let state = window.localStorage.getItem('rbird_state');
122
-
123
- let request = {}
124
- request.name = name;
125
- request.peopleId = state?.identify?.people;
126
- request.data = data || {};
127
- const http = new XMLHttpRequest();
128
- http.open("POST", `${API}/events`);
129
- http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
130
- http.setRequestHeader("timezone", Intl.DateTimeFormat().resolvedOptions().timeZone);
131
- http.setRequestHeader("apiKey", this.apiKey);
132
- http.onerror = (error) => {
133
- //handle error
134
- };
135
- let self = this;
136
- http.onreadystatechange = function (e) {
137
- if (http.readyState === 4) {
138
- if (http.status === 200 || http.status === 201) {
139
- try {
140
- //handle success
141
- } catch (exp) {
123
+ let request = {}
124
+ request.name = name;
125
+ request.peopleId = state?.identify?.people;
126
+ request.data = data || {};
127
+ const http = new XMLHttpRequest();
128
+ http.open("POST", `${API}/events`);
129
+ http.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
130
+ http.setRequestHeader("timezone", Intl.DateTimeFormat().resolvedOptions().timeZone);
131
+ http.setRequestHeader("apiKey", this.apiKey);
132
+ http.onerror = (error) => {
133
+ //handle error
134
+ };
135
+ let self = this;
136
+ http.onreadystatechange = function (e) {
137
+ if (http.readyState === 4) {
138
+ if (http.status === 200 || http.status === 201) {
139
+ try {
140
+ //handle success
141
+ } catch (exp) {
142
+ //handle error
143
+ }
144
+ } else {
142
145
  //handle error
143
146
  }
144
- } else {
145
- //handle error
146
147
  }
147
- }
148
- };
149
- http.send(JSON.stringify(request));
150
-
148
+ };
149
+ http.send(JSON.stringify(request));
150
+ }
151
151
  }
152
152
 
153
153
  identifyUser(identify, hash) {