Skip to content

Conversation

bradfrizzell
Copy link
Contributor

With this change, vendors and publishers will be able to get some simple error reporting.

if (isObject(urlObj)) {
url = urlObj['url'];
errorReportingUrl = urlObj['errorReportingUrl'];
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

else if (typeof urlObj == 'string') url = urlObj;
else /* warn and ignore */

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

};
Services.urlReplacementsForDoc(ampDoc).expandUrlAsync(
errorReportingUrl, macros, whitelist).then(url => {
Services.xhrFor(win).fetch(url);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to send as an XHR? I was thinking we would use an image (see https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/0.1/transport.js#L66)

ERROR_TYPE: errorType,
HREF: win.location.href
};
Services.urlReplacementsForDoc(ampDoc).expandUrlAsync(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you use expandUrlSync?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

* @param {!Window} win
*/
function sendErrorMessage(errorType, errorReportingUrl, win, ampDoc) {
if (Math.random() < RTC_ERROR_REPORTING_FREQUENCY) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this determined per page instead of per error report? Put the following as a static field:

const ERROR_REPORTING_ENABLED = Math.random() < 0.01;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -17,7 +17,7 @@
<body>
<h2> NOTE: Must disable check that isSecureUrl for testing </h2>
<h2>Doubleclick with RTC</h2>
<amp-ad width="320" height="50"
<!-- <amp-ad width="320" height="50"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -32,6 +34,9 @@ const MAX_RTC_CALLOUTS = 5;
/** @type {number} */
const MAX_URL_LENGTH = 16384;

/** @type {boolean} */
export const ERROR_REPORTING_ENABLED = Math.random() < 0.01;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why export?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

@@ -511,12 +513,14 @@ describes.realWin('real-time-config-manager', {amp: true}, env => {

// Test various misconfigurations that are missing vendors or urls.
[{'timeoutMillis': 500}, {'vendors': {}}, {'urls': []},
{'vendors': {}, 'urls': []},
{'vendors': 'incorrect', 'urls': 'incorrect'}].forEach(rtcConfig => {
/*{'vendors': {}, 'urls': []},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove commented out portion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

dev().warn(TAG, `Insecure RTC errorReportingUrl: ${errorReportingUrl}`);
return;
}
const whitelist = {ERROR_TYPE: true, HREF: true};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably include the timeout macro set by the pub if the errorType is timeout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed offline

Copy link
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My biggest concern is that this change adds size to v0.js. ping @choumx and @jridgewell for better ideas.

src/transport.js Outdated
@@ -14,27 +14,27 @@
* limitations under the License.
*/

import {Services} from '../../../src/services';
import {Services} from './services';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ping @jridgewell @choumx
What would be a better approach to share code between two extensions.

* @param {!Window} win
* @param {!../../../src/service/ampdoc-impl.AmpDoc} ampDoc
*/
export function sendErrorMessage(errorType, errorReportingUrl, win, ampDoc) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<amp-analytics> supports sending user error, that could be another way to support this.
Is error collecting temporary? or is this a feature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a feature of RTC. We wanted a way to do this outside of requiring pubs setup amp-analytics ideally

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we insert analytics like what we do with activeView?

};
const url = Services.urlReplacementsForDoc(ampDoc).expandUrlSync(
errorReportingUrl, macros, whitelist);
sendRequest(win, url, {image: true});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand this correct, this will always send a request with image. Then why importing from transport.js, we can simply create new Image() with src equals to url. Let me know if that works. Thanks.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Contributor

@zhouyx zhouyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with one comment

* @param {!Window} win
* @param {!../../../src/service/ampdoc-impl.AmpDoc} ampDoc
*/
export function sendErrorMessage(errorType, errorReportingUrl, win, ampDoc) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

win is not required, can get it from ampdoc.win.
nit: We usually put ampdoc as the first param.

@keithwrightbos keithwrightbos merged commit 88eb095 into master Apr 17, 2018
glevitzky pushed a commit that referenced this pull request Apr 27, 2018
* Add pingback

* Change fraction

* Allow HREF as macro

* Responding to feedback

* Respond to feedback

* Fix lint

* Respond to feedback

* Update whitelist

* Unmove transport.js

* Respond to feedback

* Fix mistakes

* More responding

* Undo class change

* Fix tests
@bradfrizzell bradfrizzell deleted the frizz-rtc-pingback branch May 31, 2018 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants