@mparticle/web-sdk 2.26.10 → 2.28.0
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.
- package/dist/mparticle.common.js +28 -27
- package/dist/mparticle.esm.js +28 -27
- package/dist/mparticle.js +109 -58
- package/package.json +1 -1
- package/src/configAPIClient.ts +85 -72
- package/src/ecommerce.js +2 -1
- package/src/events.js +2 -1
- package/src/identity.js +8 -7
- package/src/mp-instance.js +11 -2
- package/src/sdkRuntimeModels.ts +1 -1
- package/src/store.ts +12 -1
- package/src/uploaders.ts +17 -4
package/src/uploaders.ts
CHANGED
|
@@ -33,12 +33,25 @@ export class XHRUploader extends AsyncUploader {
|
|
|
33
33
|
public async upload(fetchPayload: fetchPayload): Promise<Response> {
|
|
34
34
|
const response: Response = await this.makeRequest(
|
|
35
35
|
this.url,
|
|
36
|
-
fetchPayload.body
|
|
36
|
+
fetchPayload.body,
|
|
37
|
+
fetchPayload.method as 'post' | 'get'
|
|
37
38
|
);
|
|
38
39
|
return response;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
// XHR Ready States
|
|
43
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/readyState
|
|
44
|
+
// 0 UNSENT open() has not been called yet.
|
|
45
|
+
// 1 OPENED send() has been called.
|
|
46
|
+
// 2 HEADERS_RECEIVED send() has been called, and headers and status are available.
|
|
47
|
+
// 3 LOADING Downloading; responseText holds partial data.
|
|
48
|
+
// 4 DONE The operation is complete.
|
|
49
|
+
|
|
50
|
+
private async makeRequest(
|
|
51
|
+
url: string,
|
|
52
|
+
data: string,
|
|
53
|
+
method: 'post' | 'get' = 'post'
|
|
54
|
+
): Promise<Response> {
|
|
42
55
|
const xhr: XMLHttpRequest = new XMLHttpRequest();
|
|
43
56
|
return new Promise((resolve, reject) => {
|
|
44
57
|
xhr.onreadystatechange = () => {
|
|
@@ -46,13 +59,13 @@ export class XHRUploader extends AsyncUploader {
|
|
|
46
59
|
|
|
47
60
|
// Process the response
|
|
48
61
|
if (xhr.status >= 200 && xhr.status < 300) {
|
|
49
|
-
resolve(
|
|
62
|
+
resolve(xhr as unknown as Response);
|
|
50
63
|
} else {
|
|
51
64
|
reject(xhr);
|
|
52
65
|
}
|
|
53
66
|
};
|
|
54
67
|
|
|
55
|
-
xhr.open(
|
|
68
|
+
xhr.open(method, url);
|
|
56
69
|
xhr.send(data);
|
|
57
70
|
});
|
|
58
71
|
}
|