Repository navigation
最大許容精度と精度超過時の到着強制をFirebase Remote Config参照に変更し従来値をフォールバックに使用 - #6131
Conversation
📝 WalkthroughWalkthroughFirebase Remote Config を導入して、GPS精度関連の許容値と強制未到着フラグをアプリ起動時に取得し、複数のコンポーネント・ユーティリティで固定定数から動的値へ切り替える変更を実施。到着判定・精度警告・グラフ正規化など各機能に反映。 ChangesRemote Config 統合による精度判定の動的化
Sequence DiagramsequenceDiagram
participant App as App
participant Index as index.js
participant Setup as setupRemoteConfig
participant Firebase as FirebaseRemoteConfig
participant Components as DevOverlay/Track/useRefreshStation
participant Sentry as Sentry
App->>Index: 起動
Index->>Setup: setupRemoteConfig()
Setup->>Firebase: setConfigSettings / setDefaults / fetchAndActivate
Firebase-->>Setup: 成功/値
Setup-->>Index: Promise resolves
Setup--xIndex: エラー -> Sentry.captureException
Components->>Firebase: getValue(max_permit_accuracy / force_not_arrived...)
Firebase-->>Components: 値 or static (フォールバック)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@jest.setup.js`:
- Around line 58-78: モックの module-scoped "store" がテスト間で保持されリークするので、jest.mock
の返り値に store をクリアするメソッドを追加してテストごとにリセットできるようにしてください:jest.mock(...) 内の store(現在の
store 変数)、setDefaults、getValue に影響を与えるので、例えば resetRemoteConfigMock() をエクスポートして
store を {} に再代入する実装を追加し、各テストの beforeEach でその resetRemoteConfigMock()
を呼ぶようにテスト側で運用してください。
In `@src/utils/accuracyChart.ts`:
- Around line 74-78: normalizeAccuracy can produce NaN when logSpan <= 0; guard
the ceiling/logSpan computed from getAccuracyChartCeiling() so it never falls at
or below the floor: compute const ceiling = Math.max(getAccuracyChartCeiling(),
ACCURACY_CHART_FLOOR_M + Number.EPSILON) or clamp logSpan to a small positive
value (e.g. Math.max(Math.log(ceiling) - LOG_FLOOR, 1e-12)) before using it in
the division; update the code paths in normalizeAccuracy that reference
getAccuracyChartCeiling, LOG_FLOOR and ACCURACY_CHART_FLOOR_M and add a unit
test asserting correct behavior when getAccuracyChartCeiling() returns values at
or below the floor.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9d10b9fc-73f6-44e2-9b01-e165c8b82eb0
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (12)
index.jsjest.setup.jspackage.jsonsrc/components/DevOverlay.tsxsrc/constants/location.tssrc/hooks/useRefreshStation.test.tsxsrc/hooks/useRefreshStation.tssrc/lib/remoteConfig.test.tssrc/lib/remoteConfig.tssrc/utils/accuracyChart.test.tssrc/utils/accuracyChart.tssrc/utils/handleTrackingLocation.ts
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/utils/accuracyChart.test.ts`:
- Around line 48-62: Add a global test teardown that calls jest.clearAllMocks()
after each test to prevent mock leakage; specifically, add an afterEach hook
(adjacent to the existing tests that use spy.mockRestore(), e.g. in
src/utils/accuracyChart.test.ts) which invokes jest.clearAllMocks() so all
spies/mocks are cleared between tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 076a1b42-3b50-4e6a-88e3-868c0774dfbe
📒 Files selected for processing (3)
jest.setup.jssrc/utils/accuracyChart.test.tssrc/utils/accuracyChart.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- jest.setup.js
- src/utils/accuracyChart.ts
概要
最大許容精度(継続測位で受理する測位精度の上限)と、精度超過時に到着判定を強制的に未到着へ倒す挙動を Firebase Remote Config から参照するように変更しました。リモート値が未取得・不正な場合は従来挙動(最大許容精度 1.5km / 強制未到着は有効)にフォールバックします。
変更の種類
変更内容
src/lib/remoteConfig.tsを新設し、setupRemoteConfig()(起動時に既定値登録+fetchAndActivate)と同期 gettergetMaxPermitAccuracy()/isForceNotArrivedOnLowAccuracyEnabled()を実装max_permit_accuracy(数値, フォールバック 1500m)とforce_not_arrived_on_low_accuracy(真偽, フォールバックtrue)を追加。MAX_PERMIT_ACCURACY定数はフォールバック既定値として残置handleTrackingLocationの測位棄却フィルタ、useRefreshStationの到着判定、accuracyChart/DevOverlayの診断表示の色・スケール)useRefreshStationの精度超過時arrived: false強制をフィーチャートグルで切り替え可能化(無効時は精度に依らず通常の到着判定を行う)index.jsの起動時にsetupRemoteConfig()を実行(フォアグラウンド/ヘッドレスのバックグラウンド測位タスク両経路をカバー、失敗時は Sentry 報告のみでアプリ起動はブロックしない)@react-native-firebase/remote-configを依存追加、jest.setup.jsに Remote Config のモックを追加、src/lib/remoteConfig.test.ts新設および関連テストを追加・更新回帰リスクと緩和
falseを正規値と区別できないため、未設定(getSource() === 'static')判定でフォールバックを発火させ、誤って無効化されないようにしている。pod install(iOS)等のネイティブ依存再取得が必要。テスト
npm run lintが通ることnpm testが通ることnpm run typecheckが通ることnpm testは 162 suites / 1766 tests 全パス。関連Issue
スクリーンショット(任意)
Generated by Claude Code
Summary by CodeRabbit
新機能
テスト
雑務