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

feat(TMD-463): Tracking for View more comments #4023

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ Array [
"spot-im-clicked-settings",
"spot-im-user-notifications-click",
"spot-im-open-user-profile",
"spot-im-show-more-comments-clicked",
"spot-im-share-type",
"spot-im-renew-sso",
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,11 @@ Object {
"component": "spot im : username clicked",
}
`;

exports[`should track when user clicks view more comments 1`] = `
Object {
"action": "navigation",
"attrs": Object {},
"component": "spot im : view more comments clicked",
}
`;
14 changes: 14 additions & 0 deletions packages/article-comments/__tests__/web/tracking.web.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,17 @@ it("should track when user clicks on their username", () => {
const [[callParams]] = analyticsStream.mock.calls;
expect(callParams).toMatchSnapshot();
});

it("should track when user clicks view more comments", () => {
const analyticsStream = jest.fn();

const testInstance = TestRenderer.create(
<WithTrackingContext analyticsStream={analyticsStream} />
);
const [commentsContainer] = testInstance.root.findAllByType(CommentContainer);

commentsContainer.props.viewMoreComments();

const [[callParams]] = analyticsStream.mock.calls;
expect(callParams).toMatchSnapshot();
});
13 changes: 11 additions & 2 deletions packages/article-comments/src/comments.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Comments extends Component {
onCommentNotificationClicked,
onCommentUsernameClicked,
onCommentSettingsClicked,
viewMoreComments,
domainSpecificUrl
} = this.props;

Expand Down Expand Up @@ -108,6 +109,10 @@ class Comments extends Component {
"spot-im-open-user-profile",
onCommentUsernameClicked
);
document.addEventListener(
"spot-im-show-more-comments-clicked",
viewMoreComments
);
document.addEventListener("spot-im-share-type", event =>
getShareEvent(event)
);
Expand Down Expand Up @@ -167,7 +172,8 @@ class Comments extends Component {
onCommentRecommend,
onCommentNotificationClicked,
onCommentUsernameClicked,
onCommentSettingsClicked
onCommentSettingsClicked,
viewMoreComments
} = this.props;

return (
Expand All @@ -188,6 +194,7 @@ class Comments extends Component {
onCommentNotificationClicked={onCommentNotificationClicked}
onCommentUsernameClicked={onCommentUsernameClicked}
onCommentSettingsClicked={onCommentSettingsClicked}
viewMoreComments={viewMoreComments}
>
<div
ref={el => {
Expand Down Expand Up @@ -220,6 +227,7 @@ Comments.propTypes = {
onCommentNotificationClicked: PropTypes.func,
onCommentUsernameClicked: PropTypes.func,
onCommentSettingsClicked: PropTypes.func,
viewMoreComments: PropTypes.func,
domainSpecificUrl: PropTypes.string.isRequired
};

Expand All @@ -239,7 +247,8 @@ Comments.defaultProps = {
onCommentRecommend: () => {},
onCommentNotificationClicked: () => {},
onCommentUsernameClicked: () => {},
onCommentSettingsClicked: () => {}
onCommentSettingsClicked: () => {},
viewMoreComments: () => {}
};

export default withTrackEvents(Comments);
5 changes: 5 additions & 0 deletions packages/article-comments/src/tracking/with-track-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export default Component =>
actionName: "navigation",
eventName: "onCommentNotificationClicked",
trackingName: "spot im : notification clicked"
},
{
actionName: "navigation",
eventName: "viewMoreComments",
trackingName: "spot im : view more comments clicked"
}
]
});