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

📈 AmpStoryEventTracker & Integration tests #24548

Merged
merged 11 commits into from Sep 18, 2019

Conversation

Enriqe
Copy link
Contributor

@Enriqe Enriqe commented Sep 16, 2019

Partial rollforward of #23030

Doesn't include:

  • Configurable options (StorySpec) e.g. repeat: false option. This will come in a follow up

Does include:

  • Integration tests
  • New tracker AmpStoryEventTracker which inherits from CustomEventTracker. This will make it possible for us to build story-specific features in analytics (e.g. storySpec).

@Enriqe Enriqe changed the title 📈 AmpStoryEventTracker and integration tests 📈 AmpStoryEventTracker & Integration tests Sep 16, 2019
@Enriqe Enriqe marked this pull request as ready for review September 16, 2019 19:26

* @param {function(!AnalyticsEvent)} listener
*/
fireListener_(event, rootTarget, config, listener) {
Copy link
Contributor

Choose a reason for hiding this comment

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

To make sure I understand: we're adding a "fireListener" method to be able to maybe not fire duplicate events depending on the configuration?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, that's right. This is going to make it easier for when we introduce the configurable options and control when we fire events or not.

test/integration/test-amp-story-analytics.js Show resolved Hide resolved
test/integration/test-amp-story-analytics.js Outdated Show resolved Hide resolved
Copy link
Contributor

@gmajoulet gmajoulet left a comment

Choose a reason for hiding this comment

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

LGTM, but let's consider copy/pasting the CustomEventTracker unit tests to the new story tracker, since it should be low effort :)

@Enriqe
Copy link
Contributor Author

Enriqe commented Sep 16, 2019

Good idea, I added the relevant unit tests 👍.

Skipped the ones that included sandbox events since they're not relevant for stories, but feel free to correct me if I'm wrong. /cc @zhouyx

extensions/amp-analytics/0.1/events.js Outdated Show resolved Hide resolved
extensions/amp-analytics/0.1/events.js Outdated Show resolved Hide resolved
extensions/amp-analytics/0.1/events.js Outdated Show resolved Hide resolved
if (observables) {
observables.fire(event);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

sandboxEvent is added if an analytics event is added by an AMP component dynamically, in the format of sandbox-xxx.
In those case, the event won't be recognized as a story event because the name doesn't start with story-. Would that be an issue?
Code wise, it's fine extending the CustomEventTracker class, as no event would ever fall into the this.sandboxBuffer_ here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To make sure I understand: sandboxEvent is emitted by an arbitrary AMP component?

If that's the case then it should still go to the CustomEventTracker, right? So not intercepting sandbox-* events here seems like the right behavior.

Let me know if I'm missing something.

Copy link
Contributor

Choose a reason for hiding this comment

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

That's right. All sandbox events will be handled by the CustomEventTracker.
It won't be an issue for now, but it could be an issue if a component trigger a sandbox story event in the future. sandbox-story-xxx. It would be great to keep that in mind by adding a comment.

@Enriqe
Copy link
Contributor Author

Enriqe commented Sep 18, 2019

@zhouyx this is ready for another review 👍

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.

One comment. LGTM

if (observables) {
observables.fire(event);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

That's right. All sandbox events will be handled by the CustomEventTracker.
It won't be an issue for now, but it could be an issue if a component trigger a sandbox story event in the future. sandbox-story-xxx. It would be great to keep that in mind by adding a comment.

@Enriqe
Copy link
Contributor Author

Enriqe commented Sep 18, 2019

Thanks all!

@Enriqe Enriqe merged commit 4c92129 into ampproject:master Sep 18, 2019
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.

None yet

4 participants