feat(analytics): 共有導線に share イベントを計装 - #6
Merged
Merged
Conversation
ShareBar の共有導線が一切計測されていなかった。events.ts の export は
trackCalculate / trackCopyResult / trackPresetClick の3本のみで share は
関数すら存在せず、nativeShare() と SNS 5件(X / Facebook / LINE /
WhatsApp / Reddit)は無計装。クリップボードの copy_result だけが計測され
ていたため、共有施策の効果判定が原理的に不可能だった。
- events.ts: trackShare を既存の emit/toParams 形に合わせて追加
- useToolEvents.ts: share を返す。calculate と違い間引かない
(共有先ごとの内訳が目的で、複数先への共有は正当な行動のため)
- ShareBar.tsx: navigator.share 成功時と各 SNS リンクの onClick で送出
nativeShare() のフォールバックは copy() が copy_result("link") を送るため
share は送らない(1操作を2イベントで数えると共有率が二重計上になる)。
ShareBar は ToolFrame からのみ使われるため全ツールへ一括で効く。
GA4 Admin > Custom definitions への label 登録が別途必要
(未登録だと Data API 側が空になる)。
npm run typecheck / audit:i18n ともに PASS。
Claude-Session: https://claude.ai/code/session_01ENHPNZ5ngcdrTHJ2H6oAFd
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
ShareBar の共有導線が 一切計測されていなかった。
events.tsにはtrackCalculate/trackCopyResult/trackPresetClick/trackFavoriteToggle/trackToolSearchと 5本の tracker があるが、share に相当するものだけが存在しなかった。結果として:
nativeShare()(navigator.share)copy()共有ボタンは押されているのに GA4 では常にゼロで、共有施策の効果判定が原理的に不可能だった。
お気に入りや検索まで計測されている中で、共有だけが漏れていた形。
変更 (3ファイル・28行)
events.ts—trackShareを既存のemit/toParams形に合わせて追加useToolEvents.ts—shareを返す。calculateと違い 間引かない(共有先ごとの内訳が目的で、同一着地で複数先へ共有するのは正当な行動のため)
ShareBar.tsx—navigator.share成功時にshare("native")、各 SNS の<a>にonClick二重計上を避けた箇所
nativeShare()のフォールバックはcopy()を呼び、その中で既にcopy_result("link")が送られる。ここで
shareも送ると 1操作が 2イベントになり共有率が水増しされるため、送出は
navigator.share成功パスだけに限定した。キャンセルは reject されるので成功パスには来ない。適用範囲
ShareBarはToolFrame.tsx:52の 1箇所からのみ使われ、ToolFrameは全ツール共通。この 1ファイルの修正で全ツールの共有計装が有効になる (個別ツールの改修は不要)。
events.tsのヘッダコメントの通り、GA4 Admin > カスタム定義に event-scoped のcustom dimension として
labelを登録しないと Data API 側が空になる。コードだけでは集計に出ない。登録対象の値:
native/X/Facebook/LINE/WhatsApp/Redditなお GA4 のカスタムディメンションは 登録時点以降のデータにしか適用されず遡及しない。
本 PR は未マージ=まだ share イベントが飛んでいないため、先に登録しておけば取りこぼしはゼロ。
検証
npm run typecheck→ exit 0 (origin/main ベースで cherry-pick 後に再確認済み)npm run audit:i18n→ ✓ i18n consistency OK (17言語)https://claude.ai/code/session_01ENHPNZ5ngcdrTHJ2H6oAFd