Skip to content

Commit

Permalink
Forward canary state to error reporting.
Browse files Browse the repository at this point in the history
And explicitly include non-CDN-state in version for easier filtering.
  • Loading branch information
cramforce committed Feb 17, 2016
1 parent 2b165f9 commit 1941eec
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions src/error.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ export function getErrorReportUrl(message, filename, line, col, error) {
if (window.context && window.context.location) {
url += '&3p=1';
}
if (window.AMP_CONFIG && window.AMP_CONFIG.canary) {
url += '&ca=1';
}

if (error) {
const tagName = error && error.associatedElement
Expand Down
14 changes: 14 additions & 0 deletions test/functional/test-error.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,20 @@ describe('reportErrorToServer', () => {
expect(query['3p']).to.equal('1');
});

it('reportError marks canary', () => {
window.AMP_CONFIG = {
canary: true,
};
const e = new Error('XYZ');
e.fromAssert = true;
const url = parseUrl(
getErrorReportUrl(undefined, undefined, undefined, undefined, e));
const query = parseQueryString(url.search);

expect(query.m).to.equal('XYZ');
expect(query['ca']).to.equal('1');
});

it('reportError without error object', () => {
const url = parseUrl(
getErrorReportUrl('foo bar', 'foo.js', '11', '22', undefined));
Expand Down
2 changes: 1 addition & 1 deletion tools/errortracker/app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
application: amp-error-reporting
version: 6
version: 7
runtime: go
api_version: go1

Expand Down
9 changes: 8 additions & 1 deletion tools/errortracker/errortracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,16 @@ func handle(w http.ResponseWriter, r *http.Request) {
severity = "ERROR"
level = logging.Error
errorType += "-cdn"
} else {
errorType += "-origin"
}
if r.URL.Query().Get("3p") == "1" {
errorType = "-3p"
errorType += "-3p"
} else {
errorType += "-1p"
}
if r.URL.Query().Get("ca") == "1" {
errorType += "-canary"
}

if level != logging.Error && rand.Float32() > 0.01 {
Expand Down

0 comments on commit 1941eec

Please sign in to comment.