Support tracking events on standard hyperlinks
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- html, javascript
調査の方向性
まず Segment の実装と、既存のエントリポイントである sendTrackEvent および sendTrackingLogEvent を見つけます。analytics ヘルパーがどのようにエクスポートされているか、またコンシューマーでリンククリックがどのように処理されているかを確認します。ネイティブハイパーリンク用のヘルパーをコンシューマーがインポートして使用でき、そのヘルパーがページ全体のリフレッシュ前にイベントを送信できれば完了です。
索引モデルが 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分
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
openedx/frontend-platform のほかの issue
-
a11y
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
openedx/frontend-platform#745 · コメント 3 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 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 1週間以上 初心者へのやさしさ 25/100
openedx/frontend-platform#833 ·
openedx/frontend-platform の issue をすべて見る
似ている issue
-
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 日以内に返信
-
[Bug] Account menu (footer ⚙) doesn't dismiss on outside click — stays open and covers the Bot listオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
Fei2411/DeepSeek-Bot#1693 ·
-
area-templates triage:bot-seen triage:needs-human
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
microsoft/aspire#22356 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信