@wdio/sumologic-reporter 9.0.0-alpha.9 → 9.0.4

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/build/index.js CHANGED
@@ -1,142 +1,123 @@
1
- import dateFormat from 'dateformat';
2
- import stringify from 'json-stringify-safe';
3
- import WDIOReporter from '@wdio/reporter';
4
- import logger from '@wdio/logger';
5
- const log = logger('@wdio/sumologic-reporter');
6
- const MAX_LINES = 100;
7
- const DATE_FORMAT = 'yyyy-mm-dd HH:mm:ss,l o';
8
- /**
9
- * Initialize a new sumologic test reporter.
10
- */
11
- export default class SumoLogicReporter extends WDIOReporter {
12
- _options;
13
- _interval;
14
- _unsynced = [];
15
- _isSynchronising = false;
16
- _hasRunnerEnd = false;
17
- constructor(options) {
18
- super(options);
19
- this._options = Object.assign({
20
- // don't create a log file
21
- stdout: true,
22
- // define sync interval how often logs get pushed to Sumologic
23
- syncInterval: 100,
24
- // endpoint of collector source
25
- sourceAddress: process.env.SUMO_SOURCE_ADDRESS
26
- }, options);
27
- if (typeof this._options.sourceAddress !== 'string') {
28
- log.error('Sumo Logic requires "sourceAddress" paramater');
29
- }
30
- this._interval = global.setInterval(this.sync.bind(this), this._options.syncInterval);
1
+ // src/index.ts
2
+ import dateFormat from "dateformat";
3
+ import stringify from "json-stringify-safe";
4
+ import WDIOReporter from "@wdio/reporter";
5
+ import logger from "@wdio/logger";
6
+ var log = logger("@wdio/sumologic-reporter");
7
+ var MAX_LINES = 100;
8
+ var DATE_FORMAT = "yyyy-mm-dd HH:mm:ss,l o";
9
+ var SumoLogicReporter = class extends WDIOReporter {
10
+ _options;
11
+ _interval;
12
+ _unsynced = [];
13
+ _isSynchronising = false;
14
+ _hasRunnerEnd = false;
15
+ constructor(options) {
16
+ super(options);
17
+ this._options = Object.assign({
18
+ // don't create a log file
19
+ stdout: true,
20
+ // define sync interval how often logs get pushed to Sumologic
21
+ syncInterval: 100,
22
+ // endpoint of collector source
23
+ sourceAddress: process.env.SUMO_SOURCE_ADDRESS
24
+ }, options);
25
+ if (typeof this._options.sourceAddress !== "string") {
26
+ log.error('Sumo Logic requires "sourceAddress" paramater');
31
27
  }
32
- // @ts-ignore
33
- get isSynchronised() {
34
- return this._unsynced.length === 0;
28
+ this._interval = global.setInterval(this.sync.bind(this), this._options.syncInterval);
29
+ }
30
+ // @ts-ignore
31
+ get isSynchronised() {
32
+ return this._unsynced.length === 0;
33
+ }
34
+ onRunnerStart(runner) {
35
+ this._unsynced.push(stringify({
36
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
37
+ event: "runner:start",
38
+ data: runner
39
+ }));
40
+ }
41
+ onSuiteStart(suite) {
42
+ this._unsynced.push(stringify({
43
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
44
+ event: "suite:start",
45
+ data: suite
46
+ }));
47
+ }
48
+ onTestStart(test) {
49
+ this._unsynced.push(stringify({
50
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
51
+ event: "test:start",
52
+ data: test
53
+ }));
54
+ }
55
+ onTestSkip(test) {
56
+ this._unsynced.push(stringify({
57
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
58
+ event: "test:skip",
59
+ data: test
60
+ }));
61
+ }
62
+ onTestPass(test) {
63
+ this._unsynced.push(stringify({
64
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
65
+ event: "test:pass",
66
+ data: test
67
+ }));
68
+ }
69
+ onTestFail(test) {
70
+ this._unsynced.push(stringify({
71
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
72
+ event: "test:fail",
73
+ data: test
74
+ }));
75
+ }
76
+ onTestEnd(test) {
77
+ this._unsynced.push(stringify({
78
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
79
+ event: "test:end",
80
+ data: test
81
+ }));
82
+ }
83
+ onSuiteEnd(suite) {
84
+ this._unsynced.push(stringify({
85
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
86
+ event: "suite:end",
87
+ data: suite
88
+ }));
89
+ }
90
+ onRunnerEnd(runner) {
91
+ this._hasRunnerEnd = true;
92
+ this._unsynced.push(stringify({
93
+ time: dateFormat(/* @__PURE__ */ new Date(), DATE_FORMAT),
94
+ event: "runner:end",
95
+ data: runner
96
+ }));
97
+ }
98
+ async sync() {
99
+ if (this._hasRunnerEnd && this._unsynced.length === 0) {
100
+ clearInterval(this._interval);
35
101
  }
36
- onRunnerStart(runner) {
37
- this._unsynced.push(stringify({
38
- time: dateFormat(new Date(), DATE_FORMAT),
39
- event: 'runner:start',
40
- data: runner
41
- }));
102
+ if (this._isSynchronising || this._unsynced.length === 0 || typeof this._options.sourceAddress !== "string") {
103
+ return;
42
104
  }
43
- onSuiteStart(suite) {
44
- this._unsynced.push(stringify({
45
- time: dateFormat(new Date(), DATE_FORMAT),
46
- event: 'suite:start',
47
- data: suite
48
- }));
105
+ const logLines = this._unsynced.slice(0, MAX_LINES).join("\n");
106
+ this._isSynchronising = true;
107
+ log.debug("start synchronization");
108
+ try {
109
+ const resp = await fetch(this._options.sourceAddress, {
110
+ method: "POST",
111
+ body: JSON.stringify(logLines)
112
+ });
113
+ this._unsynced.splice(0, MAX_LINES);
114
+ this._isSynchronising = false;
115
+ return log.debug(`synchronised collector data, server status: ${resp.status}`);
116
+ } catch (err) {
117
+ return log.error("failed send data to Sumo Logic:\n", err.stack);
49
118
  }
50
- onTestStart(test) {
51
- this._unsynced.push(stringify({
52
- time: dateFormat(new Date(), DATE_FORMAT),
53
- event: 'test:start',
54
- data: test
55
- }));
56
- }
57
- onTestSkip(test) {
58
- this._unsynced.push(stringify({
59
- time: dateFormat(new Date(), DATE_FORMAT),
60
- event: 'test:skip',
61
- data: test
62
- }));
63
- }
64
- onTestPass(test) {
65
- this._unsynced.push(stringify({
66
- time: dateFormat(new Date(), DATE_FORMAT),
67
- event: 'test:pass',
68
- data: test
69
- }));
70
- }
71
- onTestFail(test) {
72
- this._unsynced.push(stringify({
73
- time: dateFormat(new Date(), DATE_FORMAT),
74
- event: 'test:fail',
75
- data: test
76
- }));
77
- }
78
- onTestEnd(test) {
79
- this._unsynced.push(stringify({
80
- time: dateFormat(new Date(), DATE_FORMAT),
81
- event: 'test:end',
82
- data: test
83
- }));
84
- }
85
- onSuiteEnd(suite) {
86
- this._unsynced.push(stringify({
87
- time: dateFormat(new Date(), DATE_FORMAT),
88
- event: 'suite:end',
89
- data: suite
90
- }));
91
- }
92
- onRunnerEnd(runner) {
93
- this._hasRunnerEnd = true;
94
- this._unsynced.push(stringify({
95
- time: dateFormat(new Date(), DATE_FORMAT),
96
- event: 'runner:end',
97
- data: runner
98
- }));
99
- }
100
- async sync() {
101
- /**
102
- * clear intervall if everything was synced
103
- */
104
- if (this._hasRunnerEnd && this._unsynced.length === 0) {
105
- clearInterval(this._interval);
106
- }
107
- /**
108
- * don't synchronise logs if
109
- * - we've already send out a request and are waiting for the successful response
110
- * - we have nothing to synchronise
111
- * - there is an invalid source address
112
- */
113
- if (this._isSynchronising || this._unsynced.length === 0 || typeof this._options.sourceAddress !== 'string') {
114
- return;
115
- }
116
- const logLines = this._unsynced.slice(0, MAX_LINES).join('\n');
117
- /**
118
- * set `isSynchronising` to true so we don't sync when a request is being made
119
- */
120
- this._isSynchronising = true;
121
- log.debug('start synchronization');
122
- try {
123
- const resp = await fetch(this._options.sourceAddress, {
124
- method: 'POST',
125
- body: JSON.stringify(logLines)
126
- });
127
- /**
128
- * remove transfered logs from log bucket
129
- */
130
- this._unsynced.splice(0, MAX_LINES);
131
- /**
132
- * reset sync flag so we can sync again
133
- */
134
- this._isSynchronising = false;
135
- return log.debug(`synchronised collector data, server status: ${resp.status}`);
136
- }
137
- catch (err) {
138
- return log.error('failed send data to Sumo Logic:\n', err.stack);
139
- }
140
- }
141
- }
142
- export * from './types.js';
119
+ }
120
+ };
121
+ export {
122
+ SumoLogicReporter as default
123
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wdio/sumologic-reporter",
3
- "version": "9.0.0-alpha.9+9220932b7",
3
+ "version": "9.0.4",
4
4
  "description": "A WebdriverIO reporter that sends test results to Sumologic for data analyses",
5
5
  "author": "Christian Bromann <mail@bromann.dev>",
6
6
  "homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-sumologic-reporter",
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "repository": {
12
12
  "type": "git",
13
- "url": "git://github.com/webdriverio/webdriverio.git",
13
+ "url": "git+https://github.com/webdriverio/webdriverio.git",
14
14
  "directory": "packages/wdio-sumologic-service"
15
15
  },
16
16
  "keywords": [
@@ -25,14 +25,16 @@
25
25
  "module": "./build/index.js",
26
26
  "types": "./build/index.d.ts",
27
27
  "exports": {
28
- ".": "./build/index.js",
29
- "./package.json": "./package.json"
28
+ ".": {
29
+ "types": "./build/index.d.ts",
30
+ "import": "./build/index.js"
31
+ }
30
32
  },
31
33
  "typeScriptVersion": "3.8.3",
32
34
  "dependencies": {
33
- "@wdio/logger": "9.0.0-alpha.9+9220932b7",
34
- "@wdio/reporter": "9.0.0-alpha.9+9220932b7",
35
- "@wdio/types": "9.0.0-alpha.9+9220932b7",
35
+ "@wdio/logger": "9.0.4",
36
+ "@wdio/reporter": "9.0.4",
37
+ "@wdio/types": "9.0.4",
36
38
  "dateformat": "4.5.1",
37
39
  "json-stringify-safe": "^5.0.1"
38
40
  },
@@ -43,5 +45,5 @@
43
45
  "publishConfig": {
44
46
  "access": "public"
45
47
  },
46
- "gitHead": "9220932b7048d9b5b6c8397dda54842625be7ef2"
48
+ "gitHead": "1f3d6f781391548e8672e768e72b3d5c499a3aa7"
47
49
  }
package/build/types.js DELETED
@@ -1 +0,0 @@
1
- export {};
File without changes