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
Conversation
|
||
* @param {function(!AnalyticsEvent)} listener | ||
*/ | ||
fireListener_(event, rootTarget, config, listener) { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this 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 :)
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 |
if (observables) { | ||
observables.fire(event); | ||
} | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
c653e6e
to
22d3d99
Compare
93e7cf2
to
e22f15f
Compare
@zhouyx this is ready for another review 👍 |
There was a problem hiding this 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); | ||
} | ||
|
There was a problem hiding this comment.
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.
Thanks all! |
Partial rollforward of #23030
Doesn't include:
repeat: false
option. This will come in a follow upDoes include:
AmpStoryEventTracker
which inherits fromCustomEventTracker
. This will make it possible for us to build story-specific features in analytics (e.g.storySpec
).