| | |
| | | import { clearOrderTripStorage, reportEvent } from '../../../../../utils/Robotaxi-public-method'; |
| | | import { getOrderId } from '../../../../utils/order'; |
| | | import { TripStatus, toTripStatus } from '../../constants/trip-status'; |
| | | import { ARRIVED_DROPOFF_PAGE_VIEW_EVENT_ID, TRIP_IN_PROGRESS_COMPLETE_TRIP_BUTTON_EVENT_ID } from '../../constants/report-events'; |
| | | import { ARRIVED_DROPOFF_PAGE_VIEW_EVENT_ID, PICKUP_ARRIVED_PAGE_VIEW_EVENT_ID, TRIP_IN_PROGRESS_PAGE_VIEW_EVENT_ID, TRIP_IN_PROGRESS_COMPLETE_TRIP_BUTTON_EVENT_ID } from '../../constants/report-events'; |
| | | import { createTripInProgressCompleteTripReportPayload } from '../../constants/confirm-ride-report'; |
| | | import { clearPassedRouteCache } from '../passed-route-cache'; |
| | | import { PENDING_CANCEL_CONTEXT_TTL_MS, type PendingCancelContext } from '../use-order-actions.shared'; |
| | |
| | | }; |
| | | |
| | | /** |
| | | * 行程中(状态为 6)上报页面浏览埋点。 |
| | | */ |
| | | const reportTripInProgressEventIfNeeded = ( |
| | | mappedTripStatus: TripStatus | null, |
| | | changeStatusOld: TripStatus, |
| | | effectiveOrderId: string, |
| | | deps: UseWebSocketEventsDeps |
| | | ) => { |
| | | const shouldReportTripInProgress = ( |
| | | mappedTripStatus === TripStatus.InService |
| | | && changeStatusOld !== TripStatus.InService |
| | | && Boolean(effectiveOrderId) |
| | | ); |
| | | if (!shouldReportTripInProgress) { |
| | | return; |
| | | } |
| | | if (deps.tripInProgressReportedOrderIdRef.current === effectiveOrderId) { |
| | | return; |
| | | } |
| | | deps.tripInProgressReportedOrderIdRef.current = effectiveOrderId; |
| | | getOrderDetail(effectiveOrderId) |
| | | .then((orderDetail: any) => { |
| | | const payload = createTripInProgressCompleteTripReportPayload({ |
| | | startSite: deps.startSite, |
| | | endSite: deps.endSite, |
| | | vehicleInfo: deps.vehicleInfo, |
| | | vehicleLocation: deps.vehicleLocation, |
| | | fareEstimate: deps.fareEstimate, |
| | | routeDurationSeconds: deps.routeDuration, |
| | | routeDistanceMeters: deps.orderRouteMetrics?.distanceMeters, |
| | | orderDetail |
| | | }); |
| | | reportEvent(TRIP_IN_PROGRESS_PAGE_VIEW_EVENT_ID, payload, 'pageView'); |
| | | }) |
| | | .catch(() => { |
| | | deps.tripInProgressReportedOrderIdRef.current = ''; |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * 车辆到达上车点后上报页面浏览埋点。 |
| | | */ |
| | | const reportPickupArrivedEventIfNeeded = ( |
| | | mappedTripStatus: TripStatus | null, |
| | | changeStatusOld: TripStatus, |
| | | effectiveOrderId: string, |
| | | deps: UseWebSocketEventsDeps |
| | | ) => { |
| | | const shouldReportPickupArrived = ( |
| | | mappedTripStatus === TripStatus.VehicleArrivedPickup |
| | | && changeStatusOld !== TripStatus.VehicleArrivedPickup |
| | | && Boolean(effectiveOrderId) |
| | | ); |
| | | if (!shouldReportPickupArrived) { |
| | | return; |
| | | } |
| | | if (deps.pickupArrivedReportedOrderIdRef.current === effectiveOrderId) { |
| | | return; |
| | | } |
| | | deps.pickupArrivedReportedOrderIdRef.current = effectiveOrderId; |
| | | getOrderDetail(effectiveOrderId) |
| | | .then((orderDetail: any) => { |
| | | const payload = createTripInProgressCompleteTripReportPayload({ |
| | | startSite: deps.startSite, |
| | | endSite: deps.endSite, |
| | | vehicleInfo: deps.vehicleInfo, |
| | | vehicleLocation: deps.vehicleLocation, |
| | | fareEstimate: deps.fareEstimate, |
| | | routeDurationSeconds: deps.routeDuration, |
| | | routeDistanceMeters: deps.orderRouteMetrics?.distanceMeters, |
| | | orderDetail |
| | | }); |
| | | reportEvent(PICKUP_ARRIVED_PAGE_VIEW_EVENT_ID, payload, 'pageView'); |
| | | }) |
| | | .catch(() => { |
| | | deps.pickupArrivedReportedOrderIdRef.current = ''; |
| | | }); |
| | | }; |
| | | |
| | | /** |
| | | * 到达目的地后上报完成行程埋点。 |
| | | */ |
| | | const reportTripCompleteEventIfNeeded = ( |
| | |
| | | const mappedTripStatus = syncTripStatus(payload, currentDeps); |
| | | const effectiveOrderId = resolveEffectiveOrderId(payload, currentOrderId); |
| | | syncVehicleInfo(effectiveOrderId, currentDeps, lastFetchedVehicleOrderIdRef); |
| | | reportPickupArrivedEventIfNeeded(mappedTripStatus, changeStatusOld, effectiveOrderId, currentDeps); |
| | | reportTripInProgressEventIfNeeded(mappedTripStatus, changeStatusOld, effectiveOrderId, currentDeps); |
| | | reportTripCompleteEventIfNeeded(mappedTripStatus, changeStatusOld, effectiveOrderId, currentDeps); |
| | | handleStatusSideEffects(mappedTripStatus, changeStatusOld, currentDeps); |
| | | handleCancelPopupPush(payload, changeStatusOld, currentDeps, pendingCancelContext); |