@reportportal/client-javascript 5.0.13 → 5.0.14

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/VERSION CHANGED
@@ -1 +1 @@
1
- 5.0.14-SNAPSHOT
1
+ 5.0.15-SNAPSHOT
@@ -0,0 +1,19 @@
1
+ //! Was added to support NodeJS 10.
2
+ if (!Promise.allSettled) {
3
+ Promise.allSettled = function (promises) {
4
+ return Promise.all(
5
+ promises.map((p) =>
6
+ Promise.resolve(p).then(
7
+ (value) => ({
8
+ status: 'fulfilled',
9
+ value,
10
+ }),
11
+ (error) => ({
12
+ status: 'rejected',
13
+ reason: error,
14
+ }),
15
+ ),
16
+ ),
17
+ );
18
+ };
19
+ }
@@ -7,6 +7,7 @@ const { getClientConfig } = require('./commons/config');
7
7
  const Statistics = require('../statistics/statistics');
8
8
  const { EVENT_NAME } = require('../statistics/constants');
9
9
  const { RP_STATUSES } = require('./constants/statuses');
10
+ require('./polyfills');
10
11
 
11
12
  const MULTIPART_BOUNDARY = Math.floor(Math.random() * 10000000000).toString();
12
13
 
@@ -115,11 +116,11 @@ class RPClient {
115
116
  return RestClient.request('GET', url, {}, { headers: this.headers });
116
117
  }
117
118
 
118
- triggerStatisticsEvent() {
119
+ async triggerStatisticsEvent() {
119
120
  if (process.env.REPORTPORTAL_CLIENT_JS_NO_ANALYTICS) {
120
121
  return;
121
122
  }
122
- this.statistics.trackEvent();
123
+ await this.statistics.trackEvent();
123
124
  }
124
125
 
125
126
  /**
@@ -206,7 +207,7 @@ class RPClient {
206
207
  );
207
208
  });
208
209
  }
209
- this.triggerStatisticsEvent();
210
+ this.triggerStatisticsEvent().catch(console.error);
210
211
  return {
211
212
  tempId,
212
213
  promise: this.map[tempId].promiseStart,
@@ -581,32 +582,38 @@ class RPClient {
581
582
 
582
583
  itemObj.finishSend = true;
583
584
  this.logDebug(`Finish all children for test item with tempId ${itemTempId}`);
584
- Promise.all(
585
+ Promise.allSettled(
585
586
  itemObj.children.map((itemId) => this.map[itemId] && this.map[itemId].promiseFinish),
586
- ).then(
587
- () => {
587
+ )
588
+ .then((results) => {
589
+ if (this.debug) {
590
+ results.forEach((result, index) => {
591
+ if (result.status === 'fulfilled') {
592
+ this.logDebug(
593
+ `Successfully finish child with tempId ${itemObj.children[index]}
594
+ of test item with tempId ${itemTempId}`,
595
+ );
596
+ } else {
597
+ this.logDebug(
598
+ `Failed to finish child with tempId ${itemObj.children[index]}
599
+ of test item with tempId ${itemTempId}`,
600
+ );
601
+ }
602
+ });
603
+ }
604
+
588
605
  this.cleanMap(itemObj.children);
589
- this.logDebug(
590
- `All children for test item with tempId ${itemTempId} successfully finished.`,
591
- );
606
+
592
607
  this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
593
608
  this.finishTestItemPromiseStart(
594
609
  itemObj,
595
610
  itemTempId,
596
611
  Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
597
612
  );
598
- },
599
- () => {
600
- this.cleanMap(itemObj.children);
613
+ })
614
+ .catch(() => {
601
615
  this.logDebug(`Error finish children of test item with tempId ${itemTempId}`);
602
- this.logDebug(`Finish test item with tempId ${itemTempId}`, finishTestItemRQ);
603
- this.finishTestItemPromiseStart(
604
- itemObj,
605
- itemTempId,
606
- Object.assign(finishTestItemData, { launchUuid: this.launchUuid }),
607
- );
608
- },
609
- );
616
+ });
610
617
 
611
618
  return {
612
619
  tempId: itemTempId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reportportal/client-javascript",
3
- "version": "5.0.13",
3
+ "version": "5.0.14",
4
4
  "description": "ReportPortal client for Node.js",
5
5
  "author": "ReportPortal.io",
6
6
  "scripts": {
@@ -28,20 +28,24 @@ class Statistics {
28
28
  }
29
29
 
30
30
  async trackEvent() {
31
- const requestBody = {
32
- client_id: await getClientId(),
33
- events: [
34
- {
35
- name: this.eventName,
36
- params: this.eventParams,
37
- },
38
- ],
39
- };
31
+ try {
32
+ const requestBody = {
33
+ client_id: await getClientId(),
34
+ events: [
35
+ {
36
+ name: this.eventName,
37
+ params: this.eventParams,
38
+ },
39
+ ],
40
+ };
40
41
 
41
- await axios.post(
42
- `https://www.google-analytics.com/mp/collect?measurement_id=${MEASUREMENT_ID}&api_secret=${API_KEY}`,
43
- requestBody,
44
- );
42
+ await axios.post(
43
+ `https://www.google-analytics.com/mp/collect?measurement_id=${MEASUREMENT_ID}&api_secret=${API_KEY}`,
44
+ requestBody,
45
+ );
46
+ } catch (error) {
47
+ console.error(error.message);
48
+ }
45
49
  }
46
50
  }
47
51