# JR四国非公式アプリ データ取得経路マップ 作成日: 2026-07-07 ## 目的 Sentryで観測している `endpoint=positions / operation_info / train_operation / timetable` が、実際にどのURL、hook、画面、バックエンド、外部取得元に対応するかを整理する。 この文書は調査結果のみ。既存コードの変更案は含めるが、実装変更は行っていない。 ## 対象範囲 - React Native / Expo アプリ側の `fetch`, `observedFetchJson`, `observedFetchText` - WebViewに注入しているJavaScript内の `fetch` - WebView内の公式サイトXHR、およびmock XHR interceptor - `lib/mockApi` - `stateBox` 配下のfetch - n8n webhook - Google Apps Script fallback - `jr-shikoku-backend-api-v1.haruk.in` - `jr-shikoku-backend-mock-api-v1.haruk.in` - `jr-shikoku-api-data-storage.haruk.in` - JR四国公式走行位置 `https://train.jr-shikoku.co.jp/sp.html` - JR四国公式運行情報 `https://www.jr-shikoku.co.jp/info/` - 鉄道運用Hub / えれサイトの集約JSON ## Sentry観測対象の取得一覧 | 論理endpoint | 呼び出し元ファイル | 関数/hook | 実URL/host | path | root_tab/screen | 取得タイミング | 更新間隔 | timeout | retry | cache | fallback | Sentry tag endpoint | 備考 | |---|---|---|---|---|---|---|---|---:|---|---|---|---|---| | positions current mock | `lib/mockApi/positionMasters.ts` | `fetchMockTrainPositions` | `jr-shikoku-backend-mock-api-v1.haruk.in` | `/train-positions/current` | positions / startup provider | mock API有効時、`useCurrentTrain` と `useTrainMenu` から呼ばれる | 15秒 | 8000ms | 最大1回 | module memory last-good | 前回成功データを返す | `positions_current` / source=`mock_api` / user_visible=`true` / preload=`false` / fetch_priority=`high` | Sentryでtimeout確認済みの主対象。バックエンド側計測が必要。 | | positions master mock | `lib/mockApi/positionMasters.ts` | `fetchPositionMasters` | `jr-shikoku-backend-mock-api-v1.haruk.in` | `/position-masters` | positions / settings-dependent | mock API有効化時、または起動時にmock有効なら取得 | 基本1回 | 8000ms | 最大1回 | module memory `_cache` | なし | `positions_master` / source=`mock_api` / user_visible=`false` / preload=`true` / fetch_priority=`medium` | PosNum+LineからPos文字列を補完。頻度は低い。 | | positions n8n | `stateBox/useCurrentTrain.tsx` | `getCurrentTrain` | `n8n.haruk.in` | `/webhook/c501550c-7d1b-4e50-927b-4429fe18931a` | positions | 起動時、mock切替時、interval | 15秒 | 8000ms | 最大1回 | なし | Google Apps Script fallback | `positions_current` / source=`n8n` / user_visible=`true` / preload=`false` / fetch_priority=`high` | mock API無効時の主経路。成功時は録画snapshotにも使う。 | | positions GAS fallback | `stateBox/useCurrentTrain.tsx` | `getCurrentTrain` catch内 | `script.google.com` | `/macros/s/AKfyc.../exec` | positions | n8n走行位置取得失敗時のみ | n8n失敗時のみ | 8000ms | 最大1回 | 既存データとmerge | 前回表示データ維持 | `positions_gas_fallback` / source=`gas` / user_visible=`true` / preload=`false` / fetch_priority=`high` | Direction等が欠けるため既存データとmerge。 | | timetable today | `stateBox/useAllTrainDiagram.tsx` | `getTrainDiagram` | `jr-shikoku-api-data-storage.haruk.in` | `/tmp/diagram-today.json` または `/tmp/diagram-today-beta.json` | provider全体 / timetable consumers | provider mount直後 | 30秒、background継続指定あり。ただしobservedFetch側はbackground開始を抑制 | 15000ms | 最大1回 | AsyncStorage `ALL_TRAIN_DIAGRAM` | cache失敗時はalert | `timetable_today` / source=`static_storage` / user_visible=`false` / preload=`true` / fetch_priority=`medium` | ダイヤ・発車標・列車詳細で広く使用。 | | train operation data | `stateBox/useAllTrainDiagram.tsx` | `getCustomTrainData` | `jr-shikoku-backend-api-v1.haruk.in` または beta | `/train-data` | provider全体 / train detail / diagram | provider mount直後 | 30秒、background継続指定あり。ただしobservedFetch側はbackground開始を抑制 | 15000ms | 最大1回 | なし | 失敗は握りつぶし | `train_operation_data` / source=`backend_api` / user_visible=`false` / preload=`true` / fetch_priority=`medium` | 約1MB級。WebView内でも別途取得される。 | | operation logs | `stateBox/useAllTrainDiagram.tsx` | `getTodayOperation` | `jr-shikoku-backend-api-v1.haruk.in` または beta | `/operation-logs` | provider全体 / topMenu / train detail | provider mount直後 | 30秒、background継続指定あり。ただしobservedFetch側はbackground開始を抑制 | 15000ms | 最大1回 | なし | 失敗は握りつぶし | `operation_logs` / source=`backend_api` / user_visible=`false` / preload=`true` / fetch_priority=`medium` | 列車別運行ログ。WebView内でも別途取得される。 | | operation flag | `stateBox/useAreaInfo.tsx` | `getAreaData` | `n8n.haruk.in` | `/webhook/jr-shikoku-trainfo-flag` | topMenu / information / provider全体 | mount後、InteractionManager後に1200ms遅延 | 60秒 | 10000ms | 最大1回 | なし | 失敗は握りつぶし | `operation_info_flag` / source=`n8n` / user_visible=`true` / preload=`true` / fetch_priority=`medium` | topMenuのバッジ・対象エリア判定。 | | operation text GAS | `stateBox/useAreaInfo.tsx` | `fetchAreaDescription` | `script.google.com` | `/macros/s/AKfycbz80.../exec` | topMenu / information | operation flagで対象駅ありの場合だけ800ms遅延 | flag結果依存 | 15000ms | なし | なし | 失敗は握りつぶし | `operation_info_text` / source=`gas` / user_visible=`true` / preload=`false` / fetch_priority=`medium` | 第1回観測でtimeout。現在は通常時の実行を抑制。 | ## WebView内の取得一覧 | 論理endpoint | 呼び出し元ファイル | 関数/hook | 実URL/host | path | root_tab/screen | 取得タイミング | 更新間隔 | timeout | retry | cache | fallback | Sentry tag endpoint | 備考 | |---|---|---|---|---|---|---|---|---:|---|---|---|---|---| | positions official page | `components/Apps/WebView.tsx` | `AppsWebView` | `train.jr-shikoku.co.jp` | `/sp.html` | positions | 走行位置root初回activate時 | WebView lifecycle依存 | WebView標準 | WebView標準 | WebView page cache / OS依存 | remount watchdog | 未計測 | RN SentryではWebView navigation breadcrumbのみ。 | | positions official XHR live | JR四国公式ページ内 | 公式サイトXHR | `train.jr-shikoku.co.jp` | `/g?arg1=train&arg2=train` | positions WebView | 公式ページロード後、公式サイト側ポーリング | 公式サイト実装依存。概ね数秒単位 | 公式サイト/ブラウザ依存 | 不明 | 公式サイト/ブラウザ依存 | mock interceptor可能 | 未計測 / 候補 `positions_webview` | RN wrapperを通らない。現状Sentryで通信詳細が見えない。 | | positions official XHR static | JR四国公式ページ内 | 公式サイトXHR | `train.jr-shikoku.co.jp` | `/g?arg1=lang...`, `/g?arg1=station...`, etc | positions WebView | 公式ページロード時 | 基本初回 | 公式サイト/ブラウザ依存 | 不明 | 公式サイト/ブラウザ依存 | mock static intercept optional | 未計測 | `lib/mockApi/webviewXhrInterceptor.ts` に一覧コメントあり。 | | positions WebView injected train-data | `lib/webViewInjectjavascript.ts` | `startPolling/DatalistUpdate` | `jr-shikoku-backend-api-v1.haruk.in` | `/train-data` | positions WebView | Phase 2後、polling開始 | 30秒 | なし | なし | WebView localStorage 1日 | 失敗は無視 | 未計測 / RN側は `train_operation` | RN側Providerと重複取得。WebView内なのでRN Sentryにspanなし。 | | positions WebView injected operation-logs | `lib/webViewInjectjavascript.ts` | `operationListUpdate` | `jr-shikoku-backend-api-v1.haruk.in` | `/operation-logs` | positions WebView | Phase 1、Phase 3 polling、visibility復帰 | 30秒 | なし | なし | WebView localStorage 1日 | 失敗は無視 | 未計測 / RN側は `operation_info` | RN側Providerと重複取得。 | | positions WebView injected diagram | `lib/webViewInjectjavascript.ts` | `TrainDiagramData2Update` | `jr-shikoku-api-data-storage.haruk.in` | `/tmp/diagram-today.json` | positions WebView | Phase 2、polling | 30秒 | なし | なし | WebView localStorage 1時間 | 失敗は無視 | 未計測 / RN側は `timetable` | RN側Providerと重複取得。環境切替URLが注入optionにあるが、現コード内fetch文字列は定数参照。 | | positions WebView injected station-list | `lib/webViewInjectjavascript.ts` | Phase 1 | `n8n.haruk.in` | `/webhook/jr-shikoku-station-list` | positions WebView | WebView注入script起動時 | 初回中心 | なし | なし | WebView localStorage 1週間 | 失敗は無視 | 未計測 / 候補 `station_info` | 走行位置WebView表示の補助データ。 | | positions WebView injected problems | `lib/webViewInjectjavascript.ts` | `getProblemsData` | `n8n.haruk.in` | `/webhook/jrshikoku-position-problems` | positions WebView | Phase 1、polling、visibility復帰 | 30秒 | なし | なし | WebView localStorage 1分 | 失敗は無視 | 未計測 / 候補 `positions_problem` | 位置情報問題データ。 | | positions WebView unyohub | `lib/webViewInjectjavascript.ts` | `unyohubDataUpdate` | `jr-shikoku-api-data-storage.haruk.in` | `/thirdparty/unyohub-unyo.json` | positions WebView | 設定ON時、Phase 3 | 30秒 | なし | なし | WebView localStorage 1時間 | 失敗はconsole | 未計測 / 候補 `thirdparty_unyohub` | 鉄道運用Hub由来の集約JSON。 | | positions WebView elesite | `lib/webViewInjectjavascript.ts` | `elesiteDataUpdate` | `jr-shikoku-api-data-storage.haruk.in` | `/thirdparty/elesite-unyo.json` | positions WebView | 設定ON時、Phase 3 | 30秒 | なし | なし | WebView localStorage 1時間 | 失敗はconsole | 未計測 / 候補 `thirdparty_elesite` | えれサイト由来の集約JSON。 | | operation official page | `ndView.tsx` | operation WebView | `www.jr-shikoku.co.jp` | `/info/` | information | 運行情報root初回activate時 | WebView lifecycle依存 | WebView標準 | WebView標準 | OS/WebView依存 | remount watchdog | 未計測 | injected scriptでページ内容を加工し、画像生成結果をpostMessage。 | | operation hidden preload | `Apps.tsx` | `HiddenStartupPreloadWebViews` | `www.jr-shikoku.co.jp` | `/info/` | startup hidden preload | 起動時preload条件成立時 | 1回 | WebView標準 | なし | OS/WebView依存 | なし | 未計測 | Sentry breadcrumb/contextのみ。 | | positions hidden preload | `Apps.tsx` | `HiddenStartupPreloadWebViews` | `train.jr-shikoku.co.jp` | `/` | startup hidden preload | 起動時preload条件成立時 | 1回 | WebView標準 | なし | OS/WebView依存 | なし | 未計測 | 走行位置WebViewの事前ウォームアップ。 | ## Sentry endpoint対象外だが存在するRN fetch | 用途 | 呼び出し元ファイル | 実URL/host | path | タイミング | 更新間隔 | cache | 備考 | |---|---|---|---|---|---|---|---| | update権限 / 外部データ利用権限 | `stateBox/useTrainMenu.tsx` | `jr-shikoku-backend-api-v1.haruk.in` または beta | `/check-permission?user_id=...` | push token取得後 | token/backend変更時 | なし | Sentry未計測。queryにuser_idあり。 | | バス・列車データ | `stateBox/useBusAndTrainData.tsx` | `script.google.com` | GAS | mount時、AsyncStorage miss時 | 基本1回 | AsyncStorage `BUS_AND_TRAIN` | Sentry未計測。 | | train pair data | `stateBox/useBusAndTrainData.tsx` | `script.google.com` | GAS | mount時 | 基本1回 | なし | Sentry未計測。 | | 遅延速報EX | `stateBox/useTrainDelayData.tsx` | `script.google.com` | GAS | `loadingDelayData`変化時 | 手動/状態依存 | なし | Sentry未計測。Android widgetにも同URLあり。 | | 特急列車情報 | `components/Menu/SpecialTrainInfoBox.tsx` | `n8n.haruk.in` | `/webhook/sptrainfo` | component mount | 1回 | なし | Sentry未計測。 | | 位置ID補助情報 GET | `components/発車時刻表/LED_inside_Component/TrainPosition.tsx`, `components/ActionSheetComponents/EachTrainInfo/TrainDataView.tsx` | `n8n.haruk.in` | `/webhook/JR-shikoku-PosID-v3?PosId=...` | 列車詳細/LED表示時 | 表示対象変更ごと | なし | Sentry未計測。UI細部表示用。 | | 位置ID補助情報 POST/DELETE | `TrainPositionDataPush.tsx`, `TrainPositionDataDelete.tsx` | `n8n.haruk.in` | `/webhook/JR-shikoku-PosID-v3` | ユーザー投稿/削除要求 | 操作時 | なし | Sentry未計測。mutating request。 | | 通知設定登録 | `components/Settings/NotificationSettings.tsx` | `n8n.haruk.in` | `/webhook/jr-shikoku-notification-configurations` | 設定保存操作時 | 操作時 | AsyncStorageに設定保存 | Sentry未計測。tokenを送る。 | | unyohub RN hook | `stateBox/useUnyohub.tsx` | `jr-shikoku-api-data-storage.haruk.in` | `/thirdparty/unyohub-unyo.json` | 設定ON時 | 10分 | AsyncStorage | WebView内でも別取得あり。 | | elesite RN hook | `stateBox/useElesite.tsx` | `jr-shikoku-api-data-storage.haruk.in` | `/thirdparty/elesite-unyo.json` | 設定ON時 | 10分 | AsyncStorage | WebView内でも別取得あり。 | | 駅住所LOD | `components/駅名表/AddressText.tsx` | station別 `jslodApi` | `.json` | 駅名標表示時 | 表示対象変更ごと | なし | 外部LOD。Sentry未計測。 | | Anpanman列車状態 | `components/ActionSheetComponents/EachTrainInfoCore/trainIconStatus.tsx` | `n8n.haruk.in` | `/webhook/{anpanmanApiPath}?trainNum=...` | 対象列車詳細表示時 | 対象変更ごと | なし | Sentry未計測。 | | Android operation widget | `components/AndroidWidget/InfoWidget.tsx` | `script.google.com` | operation info GAS | widget更新時 | widget runtime依存 | なし | RN画面外。 | | Android delay widget | `components/AndroidWidget/TraInfoEXWidget.tsx` | `script.google.com` | delay GAS | widget更新時 | widget runtime依存 | なし | RN画面外。 | | GeneralWebView recording import | `GeneralWebView.tsx` | arbitrary / blob / resolvedUri内 | download URL | 録画importリンク操作時 | 操作時 | なし | 任意URL由来。Sentry endpoint化すべきではない。 | ## endpoint別依存関係 ### positions ```text positions screen ├─ RN provider: useCurrentTrain │ ├─ mock ON: jr-shikoku-backend-mock-api-v1 /train-positions/current │ │ └─ fallback: module memory last-good cache │ └─ mock OFF: n8n /webhook/c501550c... │ └─ fallback: Google Apps Script positions fallback │ └─ fallback: currentTrain previous state if present ├─ RN provider: useTrainMenu │ ├─ mock ON: /position-masters │ └─ mock ON: /train-positions/current, then inject to WebView mock XHR └─ WebView: train.jr-shikoku.co.jp/sp.html ├─ official XHR /g?arg1=train&arg2=train ├─ official XHR static /g?... station/lang/etc └─ injected enhancement fetches backend/storage/n8n auxiliary data ``` 表示対象: - 走行位置画面 - 列車詳細ActionSheet - 発車標/LED系 - fixed position box 現Sentry tag: - `endpoint=positions` - WebView公式XHRは未計測。候補は `positions_webview`。 ### operation_info ```text topMenu / information / train detail ├─ useAreaInfo │ ├─ n8n /webhook/jr-shikoku-trainfo-flag │ └─ if active area exists: Google Apps Script operation text ├─ useAllTrainDiagram │ └─ jr-shikoku-backend-api-v1 /operation-logs ├─ information WebView │ └─ www.jr-shikoku.co.jp/info/ official page │ └─ injected script parses/captures page and postMessage to RN └─ widgets / delay providers ├─ operation info GAS └─ delay GAS ``` 表示対象: - topMenuバッジ・運行情報カード - informationタブ - 列車詳細内の運行ログ表示 - Android widgets 現Sentry tag: - `endpoint=operation_info` - WebView公式ページは未計測。 ### train_operation ```text train detail / diagram / WebView enhancement ├─ RN: useAllTrainDiagram -> backend /train-data └─ WebView injected JS -> backend /train-data └─ localStorage cache 1 day ``` 表示対象: - 列車詳細 - ダイヤ/発車標 - 走行位置WebViewの列車アイコン・編成/運用装飾 現Sentry tag: - RN fetch: `endpoint=train_operation` - WebView fetch: 未計測 ### timetable ```text timetable / station diagram / train detail ├─ RN: useAllTrainDiagram -> data-storage /tmp/diagram-today.json │ └─ fallback: AsyncStorage ALL_TRAIN_DIAGRAM └─ WebView injected JS -> data-storage /tmp/diagram-today.json └─ localStorage cache 1 hour ``` 表示対象: - 時刻表 - 発車標 - 列車詳細停車駅/通過駅 - 走行位置WebView内の補助表示 現Sentry tag: - RN fetch: `endpoint=timetable` - WebView fetch: 未計測 ## 画面別fetch一覧 ### アプリ起動直後 Providerがmountされるため、現在の構成では表示タブに関係なく以下が走り得る。 | 取得 | 起動時挙動 | 備考 | |---|---|---| | `useCurrentTrain.getCurrentTrain` | 即時1回、その後15秒interval | positions。mock ON/OFFで経路が変わる。 | | `useAllTrainDiagram.getTrainDiagram` | 即時1回、その後30秒interval | timetable。AsyncStorage fallbackあり。 | | `useAllTrainDiagram.getCustomTrainData` | 即時1回、その後30秒interval | train_operation。 | | `useAllTrainDiagram.getTodayOperation` | 即時1回、その後30秒interval | operation_info。 | | `useAreaInfo.getAreaData` | InteractionManager後 + 1200ms遅延。その後60秒interval | operation_info flag。対象ありならGAS textも800ms遅延。 | | `useTrainMenu.check-permission` | push token取得後 | Sentry未計測。 | | hidden preload WebViews | preload条件成立時 | positions公式/operation公式を不可視WebViewでロード。 | ### topMenu表示中 | 取得 | 発生源 | 備考 | |---|---|---| | positions RN polling | `useCurrentTrain` provider | 表示タブに関係なく継続。ただしbackgroundではinterval停止。 | | timetable / train_operation / operation_logs | `useAllTrainDiagram` provider | 表示タブに関係なく30秒ごと。 | | operation flag / text | `useAreaInfo` | topMenu表示内容に直結。 | | special train info | `SpecialTrainInfoBox` | 該当Sheet表示時のみ。 | ### positions表示中 | 取得 | 発生源 | 備考 | |---|---|---| | positions RN polling | `useCurrentTrain` | 15秒。画面表示に必須。 | | train.jr-shikoku公式WebView | `AppsWebView` | 公式XHRはRN Sentry不可視。 | | WebView injected train-data / operation-logs / diagram / station-list / problems | `webViewInjectjavascript` | RN providerと重複取得あり。WebView localStorage cacheあり。 | | unyohub / elesite | WebView injected JS、またはRN hooks | 設定ON時のみ。 | ### information表示中 | 取得 | 発生源 | 備考 | |---|---|---| | JR四国公式運行情報WebView | `ndView.tsx` | `https://www.jr-shikoku.co.jp/info/`。RN Sentryではpage load breadcrumb中心。 | | operation flag/text | `useAreaInfo` | バッジ/本文補助。 | | operation logs | `useAllTrainDiagram` | 列車別運行ログ。 | ### バックグラウンド復帰時 | 取得 | 発生源 | 備考 | |---|---|---| | `useInterval` | AppState active復帰時に即時実行 | userStoppedでなければ即時fetch。observedFetch側はbackground開始を抑制。 | | positions WebView | `useWebViewRemount` / WebView lifecycle | iOSはunfocused時watchdog pause設定あり。 | | WebView injected `refreshAllData` | document visibilitychange/pageshow | WebView内で train-data / operation-logs / position-problems を再取得。RN Sentry不可視。 | | GeneralWebView | background 10秒超でremount | 汎用WebViewのみ。 | ## 起動時/タブ切替時fetchタイムライン ```text T+0ms app providers mount ├─ useCurrentTrain -> positions current fetch ├─ useAllTrainDiagram -> timetable fetch ├─ useAllTrainDiagram -> train_operation fetch ├─ useAllTrainDiagram -> operation_logs fetch └─ useTrainMenu -> settings/env load, maybe check-permission after token T+after interactions + 1200ms └─ useAreaInfo -> operation_info_flag └─ if active area exists: +800ms -> operation_info_text GAS TopMenu first screen └─ no page-specific heavy WebView, but provider fetches above continue positions first activation ├─ AppsWebView loads train.jr-shikoku.co.jp/sp.html ├─ official site starts /g?... XHRs ├─ injected JS Phase 0: WebView localStorage cache read ├─ injected JS Phase 1: station-list, operation-logs, position-problems ├─ injected JS Phase 2: train-data, diagram-today └─ injected JS Phase 3: 30s polling, optional unyohub/elesite information first activation ├─ ndView WebView loads www.jr-shikoku.co.jp/info/ └─ injected script parses/captures page and postMessage to RN when user capture actions occur Tab switch back to positions/information ├─ root component is kept after activation ├─ WebView retention depends on current navigation/root gating and OS WebView process └─ provider-level RN fetches generally continue independent of active tab ``` ## 危険度・制御方針 ### High priority | 取得 | 分類理由 | 推奨方針 | |---|---|---| | `/train-positions/current` | 表示中timeoutがユーザー体感に直結。Sentryで実測済み。 | server-side duration/upstream/cacheログ、backend last-known-good、app persistent stale cache。 | | `useCurrentTrain` n8n positions | mock OFF時の主経路。走行位置画面に必須。 | stale cache導入、失敗時UI全体error回避、endpoint細分化。 | | JR公式WebView `/g?arg1=train&arg2=train` | 走行位置WebViewの本体だがRN Sentry不可視。 | WebView postMessage計測、またはRN側 proxy/cache化を検討。 | | `/operation-logs` | WebView/RNで重複、列車詳細表示に影響。 | backend span/cache hit/miss、WebView側計測。 | | `/train-data` | 大きいレスポンス、RN/WebViewで重複。 | stale cache、conditional fetch、WebView/RN共有設計。 | ### Medium priority | 取得 | 分類理由 | 推奨方針 | |---|---|---| | `diagram-today.json` | 広範囲で使うがAsyncStorage fallbackあり。 | stale cache明示、WebView側との重複削減。 | | `operation_info_flag` | topMenuバッジ/運行情報表示に影響。 | endpoint細分化、失敗時は前回状態維持。 | | `operation_info_text` GAS | 遅延/timeout履歴あり。必須ではない詳細本文。 | preloadではなく遅延維持、stale cache、cellular抑制候補。 | | station-list / position-problems WebView | 表示補助。WebView内でのみ見えにくい。 | WebView breadcrumb/postMessage計測。 | | unyohub / elesite | 設定ON時のみだがWebView内は30秒polling。 | cellular抑制、10分程度へ間引き、Sentry breadcrumb。 | ### Low priority | 取得 | 分類理由 | 推奨方針 | |---|---|---| | bus/train GAS | 初回またはcache miss中心。 | observedFetch化は後回し。 | | train pair GAS | 補助データ。 | cache導入候補。 | | special train info | Sheet表示時のみ。 | 失敗UIだけ整備。 | | notification config | ユーザー操作時のみ。 | mutationとして個別エラーハンドリング。 | | station LOD address | 駅名標詳細のみ。 | 失敗しても無表示でよい。 | | Anpanman status | 装飾表示。 | 失敗してもUI全体に影響させない。 | ## stale cacheを入れるべき取得 | 優先度 | 取得 | 理由 | 推奨cache | |---|---|---|---| | High | `/train-positions/current` | 走行位置表示が直接壊れる | backend last-known-good + app persistent cache。TTL 30-120秒。 | | High | n8n positions | mock OFF時の主経路 | app persistent last-good。TTL 30-120秒。 | | High | JR公式WebView train XHR | WebView表示本体 | 公式XHRをRN/proxy化できるならstale。難しければWebView localStorage/postMessage。 | | Medium | `/operation-logs` | 列車詳細/運行情報補助 | backend/app cache。TTL 1-5分。 | | Medium | `/train-data` | 大容量かつ重複取得 | app/WebView共有cache。TTL 1日でも許容しやすい。 | | Medium | `diagram-today.json` | 既にAsyncStorage fallbackあり | 既存cacheをstale表示として明示。TTL 1日。 | | Medium | `operation_info_flag` | バッジ/エリア判定 | 前回状態維持。TTL 1-5分。 | | Medium | `operation_info_text` | GAS遅延に弱い | 前回本文保持。TTL 5-30分。 | | Low | unyohub / elesite | 設定ON時の補助 | 既存AsyncStorage/WebView localStorageを活用。TTL 10-60分。 | ## バックエンド側に計測を入れるべきAPI | API | host | 理由 | 必要な計測 | |---|---|---|---| | `/train-positions/current` | `jr-shikoku-backend-mock-api-v1.haruk.in` | Sentryでforeground timeout確認済み。 | handler duration, upstream duration, cache hit/miss, stale served, status, bytes, upstream error kind。 | | `/position-masters` | `jr-shikoku-backend-mock-api-v1.haruk.in` | mock経路の基礎データ。頻度低いが失敗時mock表示品質に影響。 | handler duration, cache hit/miss, db/storage duration。 | | `/train-data` | `jr-shikoku-backend-api-v1.haruk.in` | 大容量・RN/WebView重複取得。 | handler duration, data source duration, response bytes, compression, cache status。 | | `/operation-logs` | `jr-shikoku-backend-api-v1.haruk.in` | operation_infoとしてRN/WebView重複取得。 | handler duration, query/upstream duration, cache status, filtered count。 | | `/check-permission` | `jr-shikoku-backend-api-v1.haruk.in` | user_id queryあり、失敗しても表示は続くが権限UIに影響。 | duration, auth/lookup duration, no PII logging。 | | `diagram-today.json` publish pipeline | `jr-shikoku-api-data-storage.haruk.in` | 静的配信だが生成元障害は広範囲影響。 | CDN/storage access log, generation timestamp, object age, size。 | | `thirdparty/unyohub-unyo.json` | `jr-shikoku-api-data-storage.haruk.in` | 外部由来の集約結果。 | generation timestamp, upstream scrape duration, source error count。 | | `thirdparty/elesite-unyo.json` | `jr-shikoku-api-data-storage.haruk.in` | 外部由来の集約結果。 | generation timestamp, upstream scrape duration, source error count。 | ## Sentry endpoint tag改善案 RN側observedFetchについては、4分類から以下の低カーディナリティな論理endpointへ細分化済み。`area=data_fetch`, `result`, `root_tab`, `status` は維持し、`source`, `user_visible`, `preload`, `fetch_priority` を追加した。 ### 現在のRN側endpoint分類 低カーディナリティを維持するため、URL単位ではなく論理単位で増やす。 | 旧endpoint | 現endpoint | 対象 | |---|---|---| | `positions` | `positions_current` | 現在位置本体。n8n current / mock currentを含めるかは要検討。 | | `positions` | `positions_master` | `/position-masters`。 | | `positions` | `positions_gas_fallback` | Google Apps Script fallback。 | | 未計測 | `positions_webview` | JR公式WebView XHR / postMessage計測。 | | `operation_info` | `operation_info_flag` | n8n flag。 | | `operation_info` | `operation_info_text` | Google Apps Script text。 | | `operation_info` | `operation_logs` | backend `/operation-logs`。 | | `train_operation` | `train_operation_data` | backend `/train-data`。 | | `timetable` | `timetable_today` | `diagram-today.json`。 | | 未計測 | `thirdparty_unyohub` | unyohub集約JSON。 | | 未計測 | `thirdparty_elesite` | elesite集約JSON。 | ### 追加tag - `source=rn_fetch|mock_api|n8n|gas|backend_api|static_storage|webview_fetch` - `user_visible=true|false` - `preload=true|false` - `fetch_priority=high|medium|low` ### 注意 - `endpoint` tagにURL全文やID入りpathは入れない。 - `urlHost` と `urlPathTemplate` はcontextに維持する。 - `positions_current` をn8n/mock/GASで分けすぎるとissue数は追いやすいが、全体のpositions失敗率は見にくくなる。`source` tagまたはcontextで `mock_api / n8n / gas` を分ける案も有効。 ## 変更案の優先順位 ### High 1. `positions_current` のendpoint細分化、または `source=mock_api|n8n|gas` 追加。 2. WebView公式XHR `/g?arg1=train&arg2=train` のpostMessage計測。 3. backend mock API `/train-positions/current` にserver-side span/cache/upstream durationを追加。 4. positionsのpersistent stale cache。 ### Medium 1. `operation_info` を `operation_info_flag / operation_info_text / operation_logs` に分離。 2. WebView injected JS fetchの軽量postMessage計測。 3. `/train-data` と `diagram-today.json` のRN/WebView重複取得を整理。 4. unyohub/elesiteのWebView polling間隔を30秒から設定/TTLベースへ見直し。 ### Low 1. LED/駅詳細/通知/Widget系の直接fetchをobservedFetch化。 2. 任意URLを扱うGeneralWebView importはSentry endpoint化せず、操作エラーとして別分類。 3. station LOD address fetchの失敗をUI非表示に統一。 ## 現時点の結論 - Sentryで見えている `positions` のtimeoutは、RN側のmock currentまたはn8n/GAS経路のどれかに紐づく。今回観測された `urlHost=jr-shikoku-backend-mock-api-v1.haruk.in`, `urlPathTemplate=/train-positions/current` はmock currentで確定。 - 走行位置画面ではRN provider fetchとWebView公式XHR、さらにWebView injected fetchが並行して走る。見えているSentry spanはRN provider側だけで、WebView内の公式取得は不可視。 - `operation_info` はflag、GAS text、backend operation logs、公式WebViewの4系統が混在しているため、細分化した方が原因追跡しやすい。 - `train_operation` と `timetable` はRNとWebViewで重複取得している。ユーザー体感の安定化には、stale cacheと重複削減が効きやすい。 - バックエンド側で最優先に計測すべきは `/train-positions/current`。次点で `/train-data` と `/operation-logs`。