@tracelog/lib 0.0.5 → 0.0.7
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.
|
@@ -88,10 +88,12 @@ class SenderManager extends state_manager_1.StateManager {
|
|
|
88
88
|
method: 'POST',
|
|
89
89
|
mode: 'cors',
|
|
90
90
|
credentials: 'omit',
|
|
91
|
+
body: payload,
|
|
91
92
|
headers: {
|
|
92
93
|
'Content-Type': 'application/json',
|
|
94
|
+
Origin: window.location.origin,
|
|
95
|
+
Referer: window.location.href,
|
|
93
96
|
},
|
|
94
|
-
body: payload,
|
|
95
97
|
});
|
|
96
98
|
return response.ok;
|
|
97
99
|
}
|
|
@@ -108,7 +110,8 @@ class SenderManager extends state_manager_1.StateManager {
|
|
|
108
110
|
}
|
|
109
111
|
sendQueueSync(body) {
|
|
110
112
|
const { url, payload } = this.prepareRequest(body);
|
|
111
|
-
|
|
113
|
+
const blob = new Blob([payload], { type: 'application/json' });
|
|
114
|
+
if (this.isSendBeaconAvailable() && navigator.sendBeacon(url, blob)) {
|
|
112
115
|
return true;
|
|
113
116
|
}
|
|
114
117
|
return this.sendSyncXHR(url, payload);
|
|
@@ -118,13 +121,16 @@ class SenderManager extends state_manager_1.StateManager {
|
|
|
118
121
|
return false;
|
|
119
122
|
}
|
|
120
123
|
const { url, payload } = this.prepareRequest(body);
|
|
121
|
-
|
|
124
|
+
const blob = new Blob([payload], { type: 'application/json' });
|
|
125
|
+
return navigator.sendBeacon(url, blob);
|
|
122
126
|
}
|
|
123
127
|
sendSyncXHR(url, payload) {
|
|
124
128
|
const xhr = new XMLHttpRequest();
|
|
125
129
|
try {
|
|
126
130
|
xhr.open('POST', url, false);
|
|
127
131
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
132
|
+
xhr.setRequestHeader('Origin', window.location.origin);
|
|
133
|
+
xhr.setRequestHeader('Referer', window.location.href);
|
|
128
134
|
xhr.withCredentials = false;
|
|
129
135
|
xhr.timeout = constants_1.SYNC_XHR_TIMEOUT_MS;
|
|
130
136
|
xhr.send(payload);
|
|
@@ -85,10 +85,12 @@ export class SenderManager extends StateManager {
|
|
|
85
85
|
method: 'POST',
|
|
86
86
|
mode: 'cors',
|
|
87
87
|
credentials: 'omit',
|
|
88
|
+
body: payload,
|
|
88
89
|
headers: {
|
|
89
90
|
'Content-Type': 'application/json',
|
|
91
|
+
Origin: window.location.origin,
|
|
92
|
+
Referer: window.location.href,
|
|
90
93
|
},
|
|
91
|
-
body: payload,
|
|
92
94
|
});
|
|
93
95
|
return response.ok;
|
|
94
96
|
}
|
|
@@ -105,7 +107,8 @@ export class SenderManager extends StateManager {
|
|
|
105
107
|
}
|
|
106
108
|
sendQueueSync(body) {
|
|
107
109
|
const { url, payload } = this.prepareRequest(body);
|
|
108
|
-
|
|
110
|
+
const blob = new Blob([payload], { type: 'application/json' });
|
|
111
|
+
if (this.isSendBeaconAvailable() && navigator.sendBeacon(url, blob)) {
|
|
109
112
|
return true;
|
|
110
113
|
}
|
|
111
114
|
return this.sendSyncXHR(url, payload);
|
|
@@ -115,13 +118,16 @@ export class SenderManager extends StateManager {
|
|
|
115
118
|
return false;
|
|
116
119
|
}
|
|
117
120
|
const { url, payload } = this.prepareRequest(body);
|
|
118
|
-
|
|
121
|
+
const blob = new Blob([payload], { type: 'application/json' });
|
|
122
|
+
return navigator.sendBeacon(url, blob);
|
|
119
123
|
}
|
|
120
124
|
sendSyncXHR(url, payload) {
|
|
121
125
|
const xhr = new XMLHttpRequest();
|
|
122
126
|
try {
|
|
123
127
|
xhr.open('POST', url, false);
|
|
124
128
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
|
129
|
+
xhr.setRequestHeader('Origin', window.location.origin);
|
|
130
|
+
xhr.setRequestHeader('Referer', window.location.href);
|
|
125
131
|
xhr.withCredentials = false;
|
|
126
132
|
xhr.timeout = SYNC_XHR_TIMEOUT_MS;
|
|
127
133
|
xhr.send(payload);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tracelog/lib",
|
|
3
3
|
"description": "JavaScript library for web analytics and real-time event tracking",
|
|
4
4
|
"license": "MIT",
|
|
5
|
-
"version": "0.0.
|
|
5
|
+
"version": "0.0.7",
|
|
6
6
|
"main": "./dist/cjs/public-api.js",
|
|
7
7
|
"module": "./dist/esm/public-api.js",
|
|
8
8
|
"types": "./dist/esm/public-api.d.ts",
|