@elastic/synthetics 1.0.0-beta.3 → 1.0.0-beta.32
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/README.md +4 -3
- package/dist/cli.js +123 -161
- package/dist/cli.js.map +1 -1
- package/dist/common_types.d.ts +159 -34
- package/dist/common_types.d.ts.map +1 -1
- package/dist/config.d.ts +2 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +5 -5
- package/dist/config.js.map +1 -1
- package/dist/core/browser-service.js +5 -5
- package/dist/core/browser-service.js.map +1 -1
- package/dist/core/expect.d.ts +25 -25
- package/dist/core/expect.d.ts.map +1 -1
- package/dist/core/expect.js.map +1 -1
- package/dist/core/gatherer.d.ts +4 -8
- package/dist/core/gatherer.d.ts.map +1 -1
- package/dist/core/gatherer.js +49 -15
- package/dist/core/gatherer.js.map +1 -1
- package/dist/core/index.d.ts +5 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +23 -11
- package/dist/core/index.js.map +1 -1
- package/dist/core/logger.d.ts +0 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +3 -16
- package/dist/core/logger.js.map +1 -1
- package/dist/core/runner.d.ts +21 -65
- package/dist/core/runner.d.ts.map +1 -1
- package/dist/core/runner.js +212 -93
- package/dist/core/runner.js.map +1 -1
- package/dist/dsl/index.js +5 -1
- package/dist/dsl/index.js.map +1 -1
- package/dist/dsl/journey.d.ts +9 -4
- package/dist/dsl/journey.d.ts.map +1 -1
- package/dist/dsl/journey.js +27 -7
- package/dist/dsl/journey.js.map +1 -1
- package/dist/dsl/monitor.d.ts +66 -0
- package/dist/dsl/monitor.d.ts.map +1 -0
- package/dist/dsl/monitor.js +63 -0
- package/dist/dsl/monitor.js.map +1 -0
- package/dist/dsl/step.d.ts +3 -2
- package/dist/dsl/step.d.ts.map +1 -1
- package/dist/dsl/step.js +2 -1
- package/dist/dsl/step.js.map +1 -1
- package/dist/formatter/javascript.d.ts +98 -0
- package/dist/formatter/javascript.d.ts.map +1 -0
- package/dist/formatter/javascript.js +295 -0
- package/dist/formatter/javascript.js.map +1 -0
- package/dist/generator/index.d.ts +29 -0
- package/dist/generator/index.d.ts.map +1 -0
- package/dist/generator/index.js +240 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/{reporters/reporter.js → generator/utils.d.ts} +5 -3
- package/dist/generator/utils.d.ts.map +1 -0
- package/dist/generator/utils.js +80 -0
- package/dist/generator/utils.js.map +1 -0
- package/dist/helpers.d.ts +24 -1
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.js +126 -19
- package/dist/helpers.js.map +1 -1
- package/dist/index.d.ts +6 -7
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -26
- package/dist/index.js.map +1 -1
- package/dist/{parse_args.d.ts → loader.d.ts} +2 -5
- package/dist/loader.d.ts.map +1 -0
- package/dist/loader.js +152 -0
- package/dist/loader.js.map +1 -0
- package/dist/locations/index.d.ts +45 -0
- package/dist/locations/index.d.ts.map +1 -0
- package/dist/locations/index.js +90 -0
- package/dist/locations/index.js.map +1 -0
- package/dist/{reporters/reporter.d.ts → locations/public-locations.d.ts} +12 -8
- package/dist/locations/public-locations.d.ts.map +1 -0
- package/dist/locations/public-locations.js +41 -0
- package/dist/locations/public-locations.js.map +1 -0
- package/dist/options.d.ts +41 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/options.js +182 -0
- package/dist/options.js.map +1 -0
- package/dist/plugins/browser-console.d.ts +5 -4
- package/dist/plugins/browser-console.d.ts.map +1 -1
- package/dist/plugins/browser-console.js +27 -8
- package/dist/plugins/browser-console.js.map +1 -1
- package/dist/plugins/index.js +5 -1
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/network.d.ts +20 -33
- package/dist/plugins/network.d.ts.map +1 -1
- package/dist/plugins/network.js +173 -214
- package/dist/plugins/network.js.map +1 -1
- package/dist/plugins/performance.d.ts +4 -19
- package/dist/plugins/performance.d.ts.map +1 -1
- package/dist/plugins/performance.js +5 -5
- package/dist/plugins/performance.js.map +1 -1
- package/dist/plugins/plugin-manager.d.ts +9 -5
- package/dist/plugins/plugin-manager.d.ts.map +1 -1
- package/dist/plugins/plugin-manager.js +44 -29
- package/dist/plugins/plugin-manager.js.map +1 -1
- package/dist/plugins/tracing.d.ts +6 -6
- package/dist/plugins/tracing.d.ts.map +1 -1
- package/dist/plugins/tracing.js +8 -7
- package/dist/plugins/tracing.js.map +1 -1
- package/dist/push/bundler.d.ts +34 -0
- package/dist/push/bundler.d.ts.map +1 -0
- package/dist/push/bundler.js +123 -0
- package/dist/push/bundler.js.map +1 -0
- package/dist/push/index.d.ts +33 -0
- package/dist/push/index.d.ts.map +1 -0
- package/dist/push/index.js +174 -0
- package/dist/push/index.js.map +1 -0
- package/dist/push/monitor.d.ts +34 -0
- package/dist/push/monitor.d.ts.map +1 -0
- package/dist/push/monitor.js +78 -0
- package/dist/push/monitor.js.map +1 -0
- package/{src/reporters/reporter.ts → dist/push/plugin.d.ts} +8 -10
- package/dist/push/plugin.d.ts.map +1 -0
- package/dist/push/plugin.js +133 -0
- package/dist/push/plugin.js.map +1 -0
- package/dist/push/request.d.ts +43 -0
- package/dist/push/request.d.ts.map +1 -0
- package/dist/push/request.js +83 -0
- package/dist/push/request.js.map +1 -0
- package/dist/reporters/base.d.ts +14 -6
- package/dist/reporters/base.d.ts.map +1 -1
- package/dist/reporters/base.js +54 -48
- package/dist/reporters/base.js.map +1 -1
- package/dist/reporters/index.d.ts +18 -8
- package/dist/reporters/index.d.ts.map +1 -1
- package/dist/reporters/index.js.map +1 -1
- package/dist/reporters/json.d.ts +18 -67
- package/dist/reporters/json.d.ts.map +1 -1
- package/dist/reporters/json.js +153 -175
- package/dist/reporters/json.js.map +1 -1
- package/dist/reporters/junit.d.ts +7 -1
- package/dist/reporters/junit.d.ts.map +1 -1
- package/dist/reporters/junit.js +94 -89
- package/dist/reporters/junit.js.map +1 -1
- package/dist/sdk/lh-trace-processor.d.ts +35 -9
- package/dist/sdk/lh-trace-processor.d.ts.map +1 -1
- package/dist/sdk/lh-trace-processor.js +114 -53
- package/dist/sdk/lh-trace-processor.js.map +1 -1
- package/dist/sdk/trace-metrics.d.ts +4 -4
- package/dist/sdk/trace-metrics.d.ts.map +1 -1
- package/dist/sdk/trace-metrics.js +5 -6
- package/dist/sdk/trace-metrics.js.map +1 -1
- package/dist/sdk/trace-processor.d.ts +11 -3
- package/dist/sdk/trace-processor.d.ts.map +1 -1
- package/dist/sdk/trace-processor.js +17 -9
- package/dist/sdk/trace-processor.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1888
- package/package.json +32 -20
- package/src/cli.ts +205 -152
- package/src/common_types.ts +192 -34
- package/src/config.ts +2 -5
- package/src/core/expect.ts +58 -24
- package/src/core/gatherer.ts +59 -24
- package/src/core/index.ts +36 -15
- package/src/core/logger.ts +1 -12
- package/src/core/runner.ts +215 -152
- package/src/dsl/journey.ts +37 -6
- package/src/dsl/monitor.ts +88 -0
- package/src/dsl/step.ts +9 -2
- package/src/formatter/javascript.ts +367 -0
- package/src/generator/index.ts +316 -0
- package/src/generator/utils.ts +80 -0
- package/src/helpers.ts +132 -12
- package/src/index.ts +22 -22
- package/src/loader.ts +171 -0
- package/src/locations/index.ts +108 -0
- package/src/locations/public-locations.ts +38 -0
- package/src/options.ts +211 -0
- package/src/plugins/browser-console.ts +30 -8
- package/src/plugins/network.ts +208 -267
- package/src/plugins/performance.ts +6 -22
- package/src/plugins/plugin-manager.ts +49 -31
- package/src/plugins/tracing.ts +8 -9
- package/src/push/bundler.ts +100 -0
- package/src/push/index.ts +202 -0
- package/src/push/monitor.ts +96 -0
- package/src/push/plugin.ts +119 -0
- package/src/push/request.ts +103 -0
- package/src/reporters/base.ts +63 -52
- package/src/reporters/index.ts +26 -3
- package/src/reporters/json.ts +203 -206
- package/src/reporters/junit.ts +98 -93
- package/src/sdk/lh-trace-processor.ts +132 -68
- package/src/sdk/trace-metrics.ts +10 -6
- package/src/sdk/trace-processor.ts +28 -13
- package/templates/.github/workflows/run-synthetics.yml +26 -0
- package/templates/README.md +21 -0
- package/templates/journeys/advanced-example-helpers.ts +54 -0
- package/templates/journeys/advanced-example.journey.ts +43 -0
- package/templates/journeys/example.journey.ts +18 -0
- package/templates/synthetics.config.ts +27 -0
- package/CHANGELOG.md +0 -102
- package/NOTICE.txt +0 -221
- package/dist/parse_args.d.ts.map +0 -1
- package/dist/parse_args.js +0 -89
- package/dist/parse_args.js.map +0 -1
- package/dist/reporters/reporter.d.ts.map +0 -1
- package/dist/reporters/reporter.js.map +0 -1
- package/src/parse_args.ts +0 -127
package/dist/reporters/json.d.ts
CHANGED
|
@@ -25,21 +25,20 @@
|
|
|
25
25
|
/// <reference types="node" />
|
|
26
26
|
import BaseReporter from './base';
|
|
27
27
|
import { Journey, Step } from '../dsl';
|
|
28
|
-
import { NetworkInfo, TraceOutput, StatusValue, PerfMetrics } from '../common_types';
|
|
29
|
-
|
|
30
|
-
import { Metrics } from '../plugins';
|
|
31
|
-
declare type OutputType = 'synthetics/metadata' | 'journey/register' | 'journey/start' | 'screenshot/block' | 'step/screenshot_ref' | 'step/screenshot' | 'step/end' | 'journey/network_info' | 'journey/filmstrips' | 'journey/browserconsole' | 'journey/metrics' | 'journey/end';
|
|
28
|
+
import { NetworkInfo, NetworkConditions, TraceOutput, StatusValue, PerfMetrics, Params, Screenshot, StartEvent, JourneyStartResult, StepEndResult, JourneyEndResult, PageMetrics } from '../common_types';
|
|
29
|
+
declare type OutputType = 'synthetics/metadata' | 'journey/register' | 'journey/start' | 'screenshot/block' | 'step/screenshot_ref' | 'step/screenshot' | 'step/metrics' | 'step/filmstrips' | 'step/end' | 'journey/network_info' | 'journey/browserconsole' | 'journey/end';
|
|
32
30
|
declare type Payload = {
|
|
33
31
|
source?: string;
|
|
34
32
|
start?: number;
|
|
35
33
|
end?: number;
|
|
36
34
|
url?: string;
|
|
37
|
-
status?: StatusValue
|
|
38
|
-
|
|
39
|
-
params?:
|
|
35
|
+
status?: StatusValue;
|
|
36
|
+
pagemetrics?: PageMetrics;
|
|
37
|
+
params?: Params;
|
|
40
38
|
type?: OutputType;
|
|
41
39
|
text?: string;
|
|
42
40
|
index?: number;
|
|
41
|
+
network_conditions?: NetworkConditions;
|
|
43
42
|
};
|
|
44
43
|
declare type OutputFields = {
|
|
45
44
|
type: OutputType;
|
|
@@ -54,7 +53,7 @@ declare type OutputFields = {
|
|
|
54
53
|
};
|
|
55
54
|
error?: Error;
|
|
56
55
|
root_fields?: Record<string, unknown>;
|
|
57
|
-
payload?: Payload
|
|
56
|
+
payload?: Payload;
|
|
58
57
|
blob?: string;
|
|
59
58
|
blob_mime?: string;
|
|
60
59
|
};
|
|
@@ -73,12 +72,6 @@ declare type ScreenshotReference = {
|
|
|
73
72
|
height: number;
|
|
74
73
|
}>;
|
|
75
74
|
};
|
|
76
|
-
declare type ScreenshotOutput = {
|
|
77
|
-
step: Step;
|
|
78
|
-
blob_mime: string;
|
|
79
|
-
blocks: Array<ScreenshotBlob>;
|
|
80
|
-
reference: ScreenshotReference;
|
|
81
|
-
};
|
|
82
75
|
export declare function formatNetworkFields(network: NetworkInfo): {
|
|
83
76
|
ecs: {
|
|
84
77
|
url: string;
|
|
@@ -88,58 +81,10 @@ export declare function formatNetworkFields(network: NetworkInfo): {
|
|
|
88
81
|
original: string;
|
|
89
82
|
};
|
|
90
83
|
http: {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
body: {
|
|
94
|
-
bytes: number;
|
|
95
|
-
content: string;
|
|
96
|
-
};
|
|
97
|
-
referrer: string;
|
|
98
|
-
url: string;
|
|
99
|
-
urlFragment?: string;
|
|
100
|
-
method: string;
|
|
101
|
-
headers: Protocol.Network.Headers;
|
|
102
|
-
postData?: string;
|
|
103
|
-
hasPostData?: boolean;
|
|
104
|
-
postDataEntries?: Protocol.Network.PostDataEntry[];
|
|
105
|
-
mixedContentType?: Protocol.Security.MixedContentType;
|
|
106
|
-
initialPriority: Protocol.Network.ResourcePriority;
|
|
107
|
-
referrerPolicy: "unsafe-url" | "no-referrer-when-downgrade" | "no-referrer" | "origin" | "origin-when-cross-origin" | "same-origin" | "strict-origin" | "strict-origin-when-cross-origin";
|
|
108
|
-
isLinkPreload?: boolean;
|
|
109
|
-
trustTokenParams?: Protocol.Network.TrustTokenParams;
|
|
110
|
-
};
|
|
111
|
-
response: {
|
|
112
|
-
body: {
|
|
113
|
-
bytes: number;
|
|
114
|
-
};
|
|
115
|
-
status_code: number;
|
|
116
|
-
url: string;
|
|
117
|
-
status: number;
|
|
118
|
-
statusText: string;
|
|
119
|
-
headers: Protocol.Network.Headers;
|
|
120
|
-
headersText?: string;
|
|
121
|
-
mimeType: string;
|
|
122
|
-
requestHeaders?: Protocol.Network.Headers;
|
|
123
|
-
requestHeadersText?: string;
|
|
124
|
-
connectionReused: boolean;
|
|
125
|
-
connectionId: number;
|
|
126
|
-
remoteIPAddress?: string;
|
|
127
|
-
remotePort?: number;
|
|
128
|
-
fromDiskCache?: boolean;
|
|
129
|
-
fromServiceWorker?: boolean;
|
|
130
|
-
fromPrefetchCache?: boolean;
|
|
131
|
-
encodedDataLength: number;
|
|
132
|
-
timing?: Protocol.Network.ResourceTiming;
|
|
133
|
-
serviceWorkerResponseSource?: Protocol.Network.ServiceWorkerResponseSource;
|
|
134
|
-
responseTime?: number;
|
|
135
|
-
cacheStorageCacheName?: string;
|
|
136
|
-
protocol?: string;
|
|
137
|
-
securityState: Protocol.Security.SecurityState;
|
|
138
|
-
securityDetails?: Protocol.Network.SecurityDetails;
|
|
139
|
-
};
|
|
84
|
+
request: import("../common_types").Request;
|
|
85
|
+
response: import("../common_types").Response;
|
|
140
86
|
};
|
|
141
87
|
tls: {
|
|
142
|
-
cipher: string;
|
|
143
88
|
server: {
|
|
144
89
|
x509: {
|
|
145
90
|
issuer: {
|
|
@@ -168,10 +113,16 @@ export declare function getScreenshotBlocks(screenshot: Buffer): Promise<{
|
|
|
168
113
|
* at the end of each journey and construct equally sized blocks out
|
|
169
114
|
* of the individual screenshot image.
|
|
170
115
|
*/
|
|
171
|
-
export declare function gatherScreenshots(screenshotsPath: string, callback: (
|
|
116
|
+
export declare function gatherScreenshots(screenshotsPath: string, callback: (data: Screenshot) => Promise<void>): Promise<void>;
|
|
172
117
|
export default class JSONReporter extends BaseReporter {
|
|
173
|
-
|
|
174
|
-
|
|
118
|
+
onStart(params: StartEvent): void;
|
|
119
|
+
onJourneyRegister(journey: Journey): void;
|
|
120
|
+
onJourneyStart(journey: Journey, { timestamp, params }: JourneyStartResult): void;
|
|
121
|
+
onStepEnd(journey: Journey, step: Step, { start, end, error, url, status, pagemetrics, traces, metrics, filmstrips, }: StepEndResult): void;
|
|
122
|
+
onJourneyEnd(journey: Journey, { timestamp, start, end, networkinfo, browserconsole, status, error, options, }: JourneyEndResult): Promise<void>;
|
|
123
|
+
onEnd(): void;
|
|
124
|
+
writeScreenshotBlocks(journey: Journey, screenshot: Screenshot): Promise<void>;
|
|
125
|
+
writeMetrics(journey: Journey, step: Step, type: string, events: Array<TraceOutput> | PerfMetrics): void;
|
|
175
126
|
writeJSON({ _id, journey, type, timestamp, step, root_fields, error, payload, blob, blob_mime, url, }: OutputFields): void;
|
|
176
127
|
}
|
|
177
128
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/reporters/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAMH,OAAO,YAAY,MAAM,QAAQ,CAAC;AASlC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAEvC,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../src/reporters/json.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;;AAMH,OAAO,YAAY,MAAM,QAAQ,CAAC;AASlC,OAAO,EAAE,OAAO,EAAE,I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H,YAAY,CACzB,OAAO,EAAE,OAAO,EAChB,EACE,SAAS,EACT,KAAK,EACL,GAAG,EACH,WAAW,EACX,cAAc,EACd,MAAM,EACN,KAAK,EACL,OAAO,GACR,EAAE,gBAAgB;IAyEZ,KAAK;IAIR,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU;IAyBpE,YAAY,CACV,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,IAAI,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,KAAK,CAAC,WAAW,CAAC,GAAG,WAAW;IAuB1C,SAAS,CAAC,EACR,GAAG,EACH,OAAO,EACP,IAAI,EACJ,SAAS,EACT,IAAI,EACJ,WAAW,EACX,KAAK,EACL,OAAO,EACP,IAAI,EACJ,SAAS,EACT,GAAG,GACJ,EAAE,YAAY;CAgBhB"}
|
package/dist/reporters/json.js
CHANGED
|
@@ -48,55 +48,12 @@ function getMetadata() {
|
|
|
48
48
|
},
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
function formatVersion(protocol) {
|
|
52
|
-
if (!protocol) {
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (protocol === 'h2') {
|
|
56
|
-
return 2;
|
|
57
|
-
}
|
|
58
|
-
else if (protocol === 'http/1.1') {
|
|
59
|
-
return 1.1;
|
|
60
|
-
}
|
|
61
|
-
else if (protocol === 'http/1.0') {
|
|
62
|
-
return 1.0;
|
|
63
|
-
}
|
|
64
|
-
else if (protocol.startsWith('h3')) {
|
|
65
|
-
return 3;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function formatRequest(request) {
|
|
69
|
-
var _a;
|
|
70
|
-
const postData = request.postData ? request.postData : '';
|
|
71
|
-
return {
|
|
72
|
-
...request,
|
|
73
|
-
body: {
|
|
74
|
-
bytes: postData.length,
|
|
75
|
-
content: postData,
|
|
76
|
-
},
|
|
77
|
-
referrer: (_a = request.headers) === null || _a === void 0 ? void 0 : _a.Referer,
|
|
78
|
-
};
|
|
79
|
-
}
|
|
80
|
-
function formatResponse(response) {
|
|
81
|
-
if (!response) {
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
return {
|
|
85
|
-
...response,
|
|
86
|
-
body: {
|
|
87
|
-
bytes: response.encodedDataLength,
|
|
88
|
-
},
|
|
89
|
-
status_code: response.status,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
51
|
function formatTLS(tls) {
|
|
93
|
-
if (!tls) {
|
|
52
|
+
if (!tls || !tls.protocol) {
|
|
94
53
|
return;
|
|
95
54
|
}
|
|
96
|
-
const cipher = `${tls.keyExchange ? tls.keyExchange + '_' : ''}${tls.cipher}_${tls.keyExchangeGroup}`;
|
|
97
55
|
const [name, version] = tls.protocol.toLowerCase().split(' ');
|
|
98
56
|
return {
|
|
99
|
-
cipher,
|
|
100
57
|
server: {
|
|
101
58
|
x509: {
|
|
102
59
|
issuer: {
|
|
@@ -110,11 +67,10 @@ function formatTLS(tls) {
|
|
|
110
67
|
},
|
|
111
68
|
},
|
|
112
69
|
version_protocol: name,
|
|
113
|
-
version
|
|
70
|
+
version,
|
|
114
71
|
};
|
|
115
72
|
}
|
|
116
73
|
function formatNetworkFields(network) {
|
|
117
|
-
var _a;
|
|
118
74
|
const { request, response, url, browser } = network;
|
|
119
75
|
const ecs = {
|
|
120
76
|
// URL would be parsed and mapped by heartbeat
|
|
@@ -122,19 +78,16 @@ function formatNetworkFields(network) {
|
|
|
122
78
|
user_agent: {
|
|
123
79
|
name: browser.name,
|
|
124
80
|
version: browser.version,
|
|
125
|
-
original:
|
|
81
|
+
original: request.headers?.['User-Agent'],
|
|
126
82
|
},
|
|
127
83
|
http: {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
response: formatResponse(response),
|
|
84
|
+
request,
|
|
85
|
+
response,
|
|
131
86
|
},
|
|
132
|
-
tls: formatTLS(response
|
|
87
|
+
tls: formatTLS(response?.securityDetails),
|
|
133
88
|
};
|
|
134
89
|
const pickItems = [
|
|
135
90
|
'browser',
|
|
136
|
-
'status',
|
|
137
|
-
'method',
|
|
138
91
|
'type',
|
|
139
92
|
'isNavigationRequest',
|
|
140
93
|
'requestSentTime',
|
|
@@ -174,7 +127,7 @@ function stepInfo(step, type, status) {
|
|
|
174
127
|
};
|
|
175
128
|
}
|
|
176
129
|
async function getScreenshotBlocks(screenshot) {
|
|
177
|
-
const img = sharp_1.default(screenshot, { sequentialRead: true });
|
|
130
|
+
const img = (0, sharp_1.default)(screenshot, { sequentialRead: true });
|
|
178
131
|
const { width, height } = await img.metadata();
|
|
179
132
|
/**
|
|
180
133
|
* Chop the screenshot image (1280*720) which is the default
|
|
@@ -185,8 +138,8 @@ async function getScreenshotBlocks(screenshot) {
|
|
|
185
138
|
* optimal for caching in the ES and proved out to be bad, so we stick to 8
|
|
186
139
|
*/
|
|
187
140
|
const divisions = 8;
|
|
188
|
-
const blockWidth = width / divisions;
|
|
189
|
-
const blockHeight = height / divisions;
|
|
141
|
+
const blockWidth = Math.floor(width / divisions);
|
|
142
|
+
const blockHeight = Math.floor(height / divisions);
|
|
190
143
|
const reference = {
|
|
191
144
|
width,
|
|
192
145
|
height,
|
|
@@ -201,7 +154,7 @@ async function getScreenshotBlocks(screenshot) {
|
|
|
201
154
|
.extract({ top, left, width: blockWidth, height: blockHeight })
|
|
202
155
|
.jpeg()
|
|
203
156
|
.toBuffer();
|
|
204
|
-
const hash = crypto_1.createHash('sha1').update(buf).digest('hex');
|
|
157
|
+
const hash = (0, crypto_1.createHash)('sha1').update(buf).digest('hex');
|
|
205
158
|
blocks.push({
|
|
206
159
|
blob: buf.toString('base64'),
|
|
207
160
|
id: hash,
|
|
@@ -230,95 +183,107 @@ exports.getScreenshotBlocks = getScreenshotBlocks;
|
|
|
230
183
|
* of the individual screenshot image.
|
|
231
184
|
*/
|
|
232
185
|
async function gatherScreenshots(screenshotsPath, callback) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
await helpers_1.totalist(screenshotsPath, async (_, absPath) => {
|
|
186
|
+
if ((0, helpers_1.isDirectory)(screenshotsPath)) {
|
|
187
|
+
await (0, helpers_1.totalist)(screenshotsPath, async (_, absPath) => {
|
|
236
188
|
try {
|
|
237
|
-
const content = fs_1.readFileSync(absPath, 'utf8');
|
|
238
|
-
const
|
|
239
|
-
await callback(
|
|
189
|
+
const content = (0, fs_1.readFileSync)(absPath, 'utf8');
|
|
190
|
+
const screenshot = JSON.parse(content);
|
|
191
|
+
await callback(screenshot);
|
|
240
192
|
}
|
|
241
193
|
catch (_) {
|
|
242
194
|
// TODO: capture progarammatic synthetic errors under different type
|
|
243
195
|
}
|
|
244
196
|
});
|
|
245
197
|
}
|
|
246
|
-
return screenshots;
|
|
247
198
|
}
|
|
248
199
|
exports.gatherScreenshots = gatherScreenshots;
|
|
249
200
|
class JSONReporter extends base_1.default {
|
|
250
|
-
|
|
201
|
+
onStart(params) {
|
|
251
202
|
/**
|
|
252
203
|
* report the number of journeys that exists on a suite which
|
|
253
204
|
* could be used for better sharding
|
|
254
205
|
*/
|
|
255
|
-
this.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
206
|
+
this.writeJSON({
|
|
207
|
+
type: 'synthetics/metadata',
|
|
208
|
+
root_fields: {
|
|
209
|
+
num_journeys: params.numJourneys,
|
|
210
|
+
},
|
|
211
|
+
payload: params.networkConditions
|
|
212
|
+
? {
|
|
213
|
+
network_conditions: params.networkConditions,
|
|
214
|
+
}
|
|
215
|
+
: undefined,
|
|
262
216
|
});
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
217
|
+
}
|
|
218
|
+
onJourneyRegister(journey) {
|
|
219
|
+
this.writeJSON({
|
|
220
|
+
type: 'journey/register',
|
|
221
|
+
journey,
|
|
268
222
|
});
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
}
|
|
223
|
+
}
|
|
224
|
+
onJourneyStart(journey, { timestamp, params }) {
|
|
225
|
+
this.writeJSON({
|
|
226
|
+
type: 'journey/start',
|
|
227
|
+
journey,
|
|
228
|
+
timestamp,
|
|
229
|
+
payload: { params, source: journey.callback.toString() },
|
|
276
230
|
});
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
231
|
+
}
|
|
232
|
+
onStepEnd(journey, step, { start, end, error, url, status, pagemetrics, traces, metrics, filmstrips, }) {
|
|
233
|
+
this.writeMetrics(journey, step, 'relative_trace', traces);
|
|
234
|
+
this.writeMetrics(journey, step, 'experience', metrics);
|
|
235
|
+
if (filmstrips) {
|
|
236
|
+
// Write each filmstrip separately so that we don't get documents that are too large
|
|
237
|
+
filmstrips.forEach((strip, index) => {
|
|
238
|
+
this.writeJSON({
|
|
239
|
+
type: 'step/filmstrips',
|
|
240
|
+
journey,
|
|
241
|
+
step,
|
|
242
|
+
payload: { index },
|
|
243
|
+
root_fields: {
|
|
244
|
+
browser: { relative_trace: { start: strip.start } },
|
|
285
245
|
},
|
|
246
|
+
blob: strip.blob,
|
|
247
|
+
blob_mime: strip.mime,
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
this.writeJSON({
|
|
252
|
+
type: 'step/end',
|
|
253
|
+
journey,
|
|
254
|
+
step: {
|
|
255
|
+
...step,
|
|
256
|
+
duration: {
|
|
257
|
+
us: (0, helpers_1.getDurationInUs)(end - start),
|
|
286
258
|
},
|
|
259
|
+
},
|
|
260
|
+
url,
|
|
261
|
+
error,
|
|
262
|
+
payload: {
|
|
263
|
+
source: step.callback.toString(),
|
|
287
264
|
url,
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
url,
|
|
292
|
-
status,
|
|
293
|
-
metrics,
|
|
294
|
-
},
|
|
295
|
-
});
|
|
265
|
+
status,
|
|
266
|
+
pagemetrics,
|
|
267
|
+
},
|
|
296
268
|
});
|
|
297
|
-
|
|
298
|
-
|
|
269
|
+
}
|
|
270
|
+
async onJourneyEnd(journey, { timestamp, start, end, networkinfo, browserconsole, status, error, options, }) {
|
|
271
|
+
const { ssblocks, screenshots } = options;
|
|
272
|
+
const writeScreenshots = screenshots === 'on' ||
|
|
273
|
+
(screenshots === 'only-on-failure' && status === 'failed');
|
|
274
|
+
if (writeScreenshots) {
|
|
275
|
+
await gatherScreenshots((0, path_1.join)(helpers_1.CACHE_PATH, 'screenshots'), async (screenshot) => {
|
|
276
|
+
const { data, timestamp, step } = screenshot;
|
|
277
|
+
if (!data) {
|
|
278
|
+
return;
|
|
279
|
+
}
|
|
299
280
|
if (ssblocks) {
|
|
300
|
-
|
|
301
|
-
for (let i = 0; i < blocks.length; i++) {
|
|
302
|
-
const block = blocks[i];
|
|
303
|
-
this.writeJSON({
|
|
304
|
-
type: 'screenshot/block',
|
|
305
|
-
_id: block.id,
|
|
306
|
-
blob: block.blob,
|
|
307
|
-
blob_mime,
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
this.writeJSON({
|
|
311
|
-
type: 'step/screenshot_ref',
|
|
312
|
-
journey,
|
|
313
|
-
step,
|
|
314
|
-
root_fields: {
|
|
315
|
-
screenshot_ref: reference,
|
|
316
|
-
},
|
|
317
|
-
});
|
|
281
|
+
await this.writeScreenshotBlocks(journey, screenshot);
|
|
318
282
|
}
|
|
319
283
|
else {
|
|
320
284
|
this.writeJSON({
|
|
321
285
|
type: 'step/screenshot',
|
|
286
|
+
timestamp,
|
|
322
287
|
journey,
|
|
323
288
|
step,
|
|
324
289
|
blob: data,
|
|
@@ -326,67 +291,80 @@ class JSONReporter extends base_1.default {
|
|
|
326
291
|
});
|
|
327
292
|
}
|
|
328
293
|
});
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
});
|
|
341
|
-
}
|
|
342
|
-
if (filmstrips) {
|
|
343
|
-
// Write each filmstrip separately so that we don't get documents that are too large
|
|
344
|
-
filmstrips.forEach((strip, index) => {
|
|
345
|
-
this.writeJSON({
|
|
346
|
-
type: 'journey/filmstrips',
|
|
347
|
-
journey,
|
|
348
|
-
payload: { index },
|
|
349
|
-
root_fields: {
|
|
350
|
-
browser: { relative_trace: { start: strip.start } },
|
|
351
|
-
},
|
|
352
|
-
blob: strip.blob,
|
|
353
|
-
blob_mime: strip.mime,
|
|
354
|
-
});
|
|
294
|
+
}
|
|
295
|
+
if (networkinfo) {
|
|
296
|
+
networkinfo.forEach(ni => {
|
|
297
|
+
const { ecs, payload } = formatNetworkFields(ni);
|
|
298
|
+
this.writeJSON({
|
|
299
|
+
type: 'journey/network_info',
|
|
300
|
+
journey,
|
|
301
|
+
timestamp: ni.timestamp,
|
|
302
|
+
root_fields: (0, snakecase_keys_1.default)(ecs),
|
|
303
|
+
step: ni.step,
|
|
304
|
+
payload: (0, snakecase_keys_1.default)(payload),
|
|
355
305
|
});
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
if (browserconsole) {
|
|
309
|
+
browserconsole.forEach(({ timestamp, text, type, step, error }) => {
|
|
310
|
+
this.writeJSON({
|
|
311
|
+
type: 'journey/browserconsole',
|
|
312
|
+
journey,
|
|
313
|
+
timestamp,
|
|
314
|
+
step,
|
|
315
|
+
error,
|
|
316
|
+
payload: {
|
|
317
|
+
text,
|
|
318
|
+
type,
|
|
319
|
+
},
|
|
366
320
|
});
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
this.writeJSON({
|
|
324
|
+
type: 'journey/end',
|
|
325
|
+
journey,
|
|
326
|
+
timestamp,
|
|
327
|
+
error,
|
|
328
|
+
payload: {
|
|
329
|
+
start,
|
|
330
|
+
end,
|
|
331
|
+
status,
|
|
332
|
+
},
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
onEnd() {
|
|
336
|
+
this.stream.flushSync();
|
|
337
|
+
}
|
|
338
|
+
async writeScreenshotBlocks(journey, screenshot) {
|
|
339
|
+
const { blob_mime, blocks, reference } = await getScreenshotBlocks(Buffer.from(screenshot.data, 'base64'));
|
|
340
|
+
for (let i = 0; i < blocks.length; i++) {
|
|
341
|
+
const block = blocks[i];
|
|
370
342
|
this.writeJSON({
|
|
371
|
-
type: '
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
end,
|
|
377
|
-
status,
|
|
378
|
-
},
|
|
343
|
+
type: 'screenshot/block',
|
|
344
|
+
timestamp: screenshot.timestamp,
|
|
345
|
+
_id: block.id,
|
|
346
|
+
blob: block.blob,
|
|
347
|
+
blob_mime,
|
|
379
348
|
});
|
|
380
|
-
|
|
349
|
+
}
|
|
350
|
+
this.writeJSON({
|
|
351
|
+
type: 'step/screenshot_ref',
|
|
352
|
+
timestamp: screenshot.timestamp,
|
|
353
|
+
journey,
|
|
354
|
+
step: screenshot.step,
|
|
355
|
+
root_fields: {
|
|
356
|
+
screenshot_ref: reference,
|
|
357
|
+
},
|
|
381
358
|
});
|
|
382
359
|
}
|
|
383
|
-
writeMetrics(journey, type, events) {
|
|
360
|
+
writeMetrics(journey, step, type, events) {
|
|
384
361
|
const metrics = Array.isArray(events) ? events : [events];
|
|
385
362
|
metrics.forEach(event => {
|
|
386
363
|
event &&
|
|
387
364
|
this.writeJSON({
|
|
388
|
-
type: '
|
|
365
|
+
type: 'step/metrics',
|
|
389
366
|
journey,
|
|
367
|
+
step,
|
|
390
368
|
root_fields: {
|
|
391
369
|
browser: {
|
|
392
370
|
[type]: event,
|
|
@@ -395,7 +373,7 @@ class JSONReporter extends base_1.default {
|
|
|
395
373
|
});
|
|
396
374
|
});
|
|
397
375
|
}
|
|
398
|
-
// Writes a
|
|
376
|
+
// Writes a structured synthetics event
|
|
399
377
|
// Note that blob is ultimately stored in ES as a base64 encoded string. You must base 64 encode
|
|
400
378
|
// it before passing it into this function!
|
|
401
379
|
// The payload field is an un-indexed field with no ES mapping, so users can put arbitary structured
|
|
@@ -404,14 +382,14 @@ class JSONReporter extends base_1.default {
|
|
|
404
382
|
this.write({
|
|
405
383
|
type,
|
|
406
384
|
_id,
|
|
407
|
-
'@timestamp': timestamp || helpers_1.getTimestamp(),
|
|
408
|
-
journey: journeyInfo(journey, type, payload
|
|
409
|
-
step: stepInfo(step, type, payload
|
|
385
|
+
'@timestamp': timestamp || (0, helpers_1.getTimestamp)(),
|
|
386
|
+
journey: journeyInfo(journey, type, payload?.status),
|
|
387
|
+
step: stepInfo(step, type, payload?.status),
|
|
410
388
|
root_fields: { ...(root_fields || {}), ...getMetadata() },
|
|
411
389
|
payload,
|
|
412
390
|
blob,
|
|
413
391
|
blob_mime,
|
|
414
|
-
error: helpers_1.formatError(error),
|
|
392
|
+
error: (0, helpers_1.formatError)(error),
|
|
415
393
|
url,
|
|
416
394
|
package_version: version,
|
|
417
395
|
});
|