Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update comment to customEventReporterBuilder #10632

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/extension-analytics.js
Expand Up @@ -122,7 +122,9 @@ class CustomEventReporter {


/**
* A builder class that enable extension elements to easily build a CustomEventReporter instance
* A builder class that enable extension elements to easily build and get a CustomEventReporter instance.
* Its constructor requires the parent AMP element.
* It provides two methods #track() and #build() to build the CustomEventReporter instance.
*/
export class CustomEventReporterBuilder {
/** @param {!AmpElement} parent */
Expand All @@ -139,6 +141,8 @@ export class CustomEventReporterBuilder {
}

/**
* The #track() method takes in a unique custom-event name, and the corresponding request url (or an array of request urls).
* One can call #track() multiple times with different eventType name (order doesn't matter) before #build() is called.
* @param {string} eventType
* @param {string|!Array<string>} request
*/
Expand All @@ -160,8 +164,9 @@ export class CustomEventReporterBuilder {
}

/**
* Call to build the CustomEventReporter instance.
* Should only be called after all eventType added.
* Call the #build() method to build and get the CustomEventReporter instance.
* One CustomEventReporterBuilder instance can only build one reporter,
* which means #build() should only be called once after all eventType are added.
*/
build() {
dev().assert(this.config_, 'CustomEventReporter already built');
Expand Down