Support tracking events on standard hyperlinks
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- html, javascript
调研方向
首先定位 Segment 的实现,以及现有的 sendTrackEvent 和 sendTrackingLogEvent 入口点。检查 analytics helper 的导出方式,以及消费者中如何处理链接点击。当消费者可以导入并使用一个用于原生超链接的 helper,并且该 helper 会在整页刷新前发送事件时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Context
@edx/frontend-platform provides an analytics service interface and a Segment implementation for tracking events (custom events, page events, identify events). The Segment implementation relies on helper functions from Segment.js, including:
global.analytics.track(viasendTrackEvent)global.analytics.page(viasendPageEvent)global.analytics.identify(viaidentifyAuthenticatedUser)
@edx/frontend-platform also exports a sendTrackingLogEvent function to send events to the tracking log, which includes event that are sent to our partners as part of our data share agreements (e.g., for their research purposes). These events are sent via a POST request to the configured trackingLogApiUrl (i.e., ${config.LMS_BASE_URL}/event)
Problem
We occasionally run into use cases where we need to dispatch an event when a user clicks on a native HTML hyperlink that triggers a full page refresh. However, using sendTrackEvent and/or sendTrackingLogEvent in this situation is not possible because the browser navigates away from the current page without giving the asynchronous event enough time to fire.
Segment provides a trackLink method that is not currently utilized by @edx/frontend-platform. However, its implementation relies on event listeners on a DOM element (i.e., hyperlink), which isn't compatible in a React world with frequent component re-rendering. For example, on component mount, an event listener might get set, but then on a component re-render, the underlying DOM element with the aforementioned event listener got re-rendered so its effectively a new DOM element that would need an event listener added again. Similarly, when a component unmounts, there's no way to clear the event listener with trackLink which leads to potentially unwanted behavior.
As such, for tracking events of native HTML hyperlinks that trigger a full page refresh, consumers have had to implement their own workarounds, e.g.:
- Preventing default link behavior (i.e.,
event.preventDefault()), dispatching the event, and then awaiting aPromiseto resolve after an intentional delay before forcing navigation withglobal.location.href. - Preventing default link behavior (i.e.,
event.preventDefault()) dispatching the event, then waiting for asetTimeoutto execute after an intentional delay before forcing navigation withglobal.location.href.
Acceptance Criteria
- Ensure consumers of
@edx/frontend-platformcan import/use a helper function to track events asynchronously when clicking on a native HTML hyperlink that triggers a full page refresh.
- 主要语言
- JavaScript
- 星标
- 38
- 派生
- 90
- 平均合并
- 3 分钟
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
openedx/frontend-platform 的其他 Issue
-
a11y
难度 2/5 1-3 小时 新手友好度 76/100
openedx/frontend-platform#745 · 3 条评论 ·
-
难度 5/5 一周以上 新手友好度 45/100
openedx/frontend-platform#892 · 4 条评论 ·
-
难度 3/5 1-2 天 新手友好度 48/100
openedx/frontend-platform#837 ·
-
难度 4/5 3-5 天 新手友好度 35/100
openedx/frontend-platform#835 · 1 条评论 ·
-
难度 5/5 一周以上 新手友好度 25/100
openedx/frontend-platform#833 ·
查看 openedx/frontend-platform 的全部 Issue
相似的 Issue
-
Client execution contract accepts a grant the code never takes可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area: client enhancement priority: medium
难度 2/5 1-3 小时 新手友好度 78/100
opensro-dev/opensro#3808 ·
维护者通常 1 天内回复
-
luciano_blocktronics: sysop chat status views are both keyed TL10 and use itemFormat, which a TextView ignores可能已有人在做 @Z3NMA 今天认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 82/100
NuSkooler/enigma-bbs#1058 ·
维护者通常 1 天内回复
-
marketing
难度 2/5 1-3 小时 新手友好度 76/100
维护者通常 1 天内回复
-
enhancement good first issue help wanted
难度 2/5 1-3 小时 新手友好度 88/100
-
enhancement good first issue severity: low
难度 2/5 1-3 小时 新手友好度 78/100
TMHSDigital/Static_Chess#163 ·
维护者通常 1 天内回复