Skip to content

Commit a3074cf

Browse files
Add cdn to error reporting function, and update amp-errors.md (ampproject#39635)
1 parent 17437ba commit a3074cf

File tree

3 files changed

+32
-14
lines changed

3 files changed

+32
-14
lines changed

Diff for: docs/spec/amp-errors.md

+27-13
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,37 @@ the `betaErrorReportingUrl` config. E.g. for `cdn.ampproject.org`
1010
The following fields are reported:
1111

1212
- `v=string` - AMP version
13+
- `noamp={0,1}` - whether the document contains non-AMP JavaScript
1314
- `m=string` - the error message
14-
- `a=1` - whether the error is labeled as "user" error (as opposed to a "dev" error).
15-
- `ex=1` - whether the error is labeled as "expected".
16-
- `3p=1` - whether the error occurred in the 3p context.
17-
- `ca=1` - whether this is a canary version of AMP.
18-
- `or=string` - the ancestor origin if available.
19-
- `iem=1` - whether this document is iframed.
20-
- `rvu=string` - the viewer URL, provided by the viewer.
21-
- `mso=string` - the messaging origin for viewer communication.
22-
- `el=string` - the identifier/information on the associated DOM element.
23-
- `s=string` - the error stack.
24-
- `f=string` - the error's file name.
25-
- `l=number` - the error's line number.
26-
- `c=number` - the error's column number.
15+
- `a={0,1}` - whether the error is labeled as "user" error (as opposed to a "dev" error).
16+
- `ex={0,1}` - whether the error is labeled as "expected".
17+
- `dw={0,1}` - whether the document is presented in a detached window (e.g., inside an iframe)
18+
- `3p={0,1}` - whether the error occurred in the 3p context.
19+
- At most one of the following:
20+
- `sxg=1` - the runtime was build with the `--sxg` (Signed Exchanges) flag.
21+
- `esm=1` - the runtime was build with the `--esm` (JavaScript Modules) flag.
22+
- `3p=1` - the runtime is served from a third party.
23+
- `rt=string` - the runtime type.
24+
- `cdn=string` - the value of `cdnUrl` in the runtime configuration, or the value of the `runtime-host` meta tag if the former is undefined.
25+
- `adid=string` - _(`rt=inabox` only)_ the A4A ID.
26+
- `ca=1` - _(deprecated)_ whether this is a canary version of AMP.
27+
- `bt=string` - runtime release channel type.
28+
- `or=string` - _(optional)_ the ancestor origin if available.
29+
- `vs=string` - _(optional)_ the viewer's state.
30+
- `iem=1` - _(optional)_ whether this document is iframed.
31+
- `rvu=string` - _(optional)_ the viewer URL, provided by the viewer.
32+
- `mso=string` - _(optional)_ the messaging origin for viewer communication.
33+
- `exps=string` - _(optional)_ the defined experiments and whether they are turned on, in the format `expname=1,expname=0,expname=1`...
34+
- `el=string` - _(optional)_ the identifier/information on the associated DOM element.
35+
- `args=string` - _(optional)_ JSON.Stringified arguments associated with the error object.
36+
- `s=string` - _(optional)_ the error stack.
37+
- `f=string` - _(optional)_ the error's file name.
38+
- `l=number` - _(optional)_ the error's line number.
39+
- `c=number` - _(optional)_ the error's column number.
2740
- `r=string` - the document's referrer.
2841
- `ae=string` - accumulated/correlated error messages.
2942
- `fr=string` - the document's location fragment.
43+
- `pt=1` - _(optional)_ _internal implementation detail_
3044

3145
## "Expected" errors
3246

Diff for: src/error-reporting.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -550,14 +550,17 @@ export function getErrorReportData(
550550
runtime = 'esm';
551551
data['esm'] = '1';
552552
} else if (self.context && self.context.location) {
553-
data['3p'] = '1';
554553
runtime = '3p';
554+
data['3p'] = '1';
555555
} else if (getMode().runtime) {
556556
runtime = getMode().runtime;
557557
}
558558

559559
data['rt'] = runtime;
560560

561+
// The value of urls.cdn.
562+
data['cdn'] = urls.cdn;
563+
561564
// Add our a4a id if we are inabox
562565
if (runtime === 'inabox') {
563566
data['adid'] = getMode().a4aId;

Diff for: test/unit/test-error-reporting.js

+1
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ describes.sandboxed('getErrorReportData', {}, (env) => {
227227
expect(data.r).to.contain('http://localhost');
228228
expect(data.noAmp).to.equal('1');
229229
expect(data.args).to.be.undefined;
230+
expect(data.cdn).to.equal('https://cdn.ampproject.org');
230231
});
231232

232233
it('reportError with error and ignore stack', () => {

0 commit comments

Comments
 (0)