Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/pages/Carrier.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ function JourneyParcels({ state, save, carrierName, journeyId, onPick }) {
save(newState)
if (posthogEnabled) {
posthog.capture('delivery_request_created', {
shipment_ref: shipment.id,
initiated_by: 'carrier',
item_type: shipment.itemType,
weight_kg: shipment.weightKg,
Expand Down
12 changes: 7 additions & 5 deletions src/pages/Delivery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export default function Delivery({ state, save, id, profile, setProfile }) {

if (posthogEnabled) {
posthog.capture('delivery_acceptance_recorded', {
shipment_ref: shipment.id,
accepted_by: who,
match_confirmed: senderAccepted && carrierAccepted,
})
Expand Down Expand Up @@ -170,7 +171,7 @@ export default function Delivery({ state, save, id, profile, setProfile }) {
{ status: DELIVERY.DECLINED },
{ status: STATUS.RETRYING, rejectedJourneyIds: [...shipment.rejectedJourneyIds, journey.id] },
)
if (posthogEnabled) posthog.capture('delivery_request_declined')
if (posthogEnabled) posthog.capture('delivery_request_declined', { shipment_ref: shipment.id })
goTo(`matches/${shipment.id}`)
}

Expand All @@ -193,6 +194,7 @@ export default function Delivery({ state, save, id, profile, setProfile }) {
`Request withdrawn by ${shipment.senderName}: ${shipment.origin} to ${shipment.destination}, carrier ${journey.carrierName}`)
if (posthogEnabled) {
posthog.capture('delivery_request_withdrawn', {
shipment_ref: shipment.id,
carrier_had_accepted: delivery.carrierAccepted,
})
}
Expand Down Expand Up @@ -227,7 +229,7 @@ export default function Delivery({ state, save, id, profile, setProfile }) {
function handlePickup(code) {
if (code === delivery.pickupOtp) {
update({ status: DELIVERY.IN_TRANSIT })
if (posthogEnabled) posthog.capture('pickup_confirmed')
if (posthogEnabled) posthog.capture('pickup_confirmed', { shipment_ref: shipment.id })
setMessage({ ok: true, text: 'Pickup confirmed. The parcel is on its way.' })
} else {
setMessage({ ok: false, text: `Wrong pickup code. The parcel has not been handed over. Ask ${isolate(shipment.senderName)} to read the code again.` })
Expand All @@ -244,7 +246,7 @@ export default function Delivery({ state, save, id, profile, setProfile }) {
{ status: STATUS.DELIVERED },
)
setMessage({ ok: true, text: `Delivery confirmed. ${amount} released to ${isolate(journey.carrierName)}.` })
if (posthogEnabled) posthog.capture('delivery_confirmed')
if (posthogEnabled) posthog.capture('delivery_confirmed', { shipment_ref: shipment.id })
sendToWebhook('delivery', { ...record, escrow: ESCROW.RELEASED, deliveredAt },
`Delivery completed: ${amount} released to ${journey.carrierName}`)
} else {
Expand All @@ -259,7 +261,7 @@ export default function Delivery({ state, save, id, profile, setProfile }) {
{ status: STATUS.DISPUTED },
)
setMessage({ ok: false, text: `Wrong delivery code again. After ${MAX_CODE_TRIES} wrong codes, ${amount} is frozen and an admin will check this delivery.` })
if (posthogEnabled) posthog.capture('delivery_disputed', { dispute_source: 'maximum_delivery_code_attempts' })
if (posthogEnabled) posthog.capture('delivery_disputed', { shipment_ref: shipment.id, dispute_source: 'maximum_delivery_code_attempts' })
sendToWebhook('dispute', { ...record, escrow: ESCROW.FROZEN },
`Dispute raised: ${reason}, ${shipment.origin} to ${shipment.destination}`)
} else {
Expand All @@ -279,7 +281,7 @@ export default function Delivery({ state, save, id, profile, setProfile }) {
{ status: STATUS.DISPUTED },
)
setMessage({ ok: false, text: `Problem reported. ${amount} is frozen until an admin reviews it.` })
if (posthogEnabled) posthog.capture('delivery_disputed', { dispute_source: 'reported_problem', problem_category: problem })
if (posthogEnabled) posthog.capture('delivery_disputed', { shipment_ref: shipment.id, dispute_source: 'reported_problem', problem_category: problem })
sendToWebhook('dispute', { ...record, escrow: ESCROW.FROZEN },
`Dispute raised: ${shipment.origin} to ${shipment.destination}`)
}
Expand Down
1 change: 1 addition & 0 deletions src/pages/Matches.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ export default function Matches({ state, save, id }) {
save(newState)
if (posthogEnabled) {
posthog.capture('delivery_request_created', {
shipment_ref: shipment.id,
initiated_by: 'sender',
item_type: shipment.itemType,
weight_kg: shipment.weightKg,
Expand Down
1 change: 1 addition & 0 deletions src/pages/Sender.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export default function Sender({ state, save, profile, setProfile }) {
save({ ...state, shipments: [...state.shipments, shipment] })
if (posthogEnabled) {
posthog.capture('shipment_posted', {
shipment_ref: shipment.id,
origin_city: origin,
destination_city: destination,
item_type: type,
Expand Down