Skip to content

Commit d20d005

Browse files
committed
πŸ“ˆ Set PostHog $insert_id on transactional events for backend dedupe
Auto-assign $insert_id = {event}_{transaction_id} inside useLogEvent so frontend-fired purchase/subscribe/start_trial/begin_checkout events dedupe against the backend posthog-node counterpart that tracks the same txn. Also rename the stray payment_id key in the book-list begin_checkout call so it actually carries transaction_id and picks up the new behavior.
1 parent de7f11b commit d20d005

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

β€Žcomposables/use-logger.tsβ€Ž

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ export function useLogEvent(eventName: string, eventParams: EventParams = {}) {
167167
posthogParams.nft_class_ids = classIds.join(',')
168168
}
169169
}
170+
// Dedupe against the backend-fired counterpart (posthog-node) for the same transaction.
171+
if (typeof eventParams.transaction_id === 'string' && eventParams.transaction_id) {
172+
posthogParams.$insert_id = `${eventName}_${eventParams.transaction_id}`
173+
}
170174
posthog.capture(eventName, { app: '3ook', ...posthogParams })
171175
}
172176
catch (error) {

β€Žpages/list.vueβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ async function handleCheckoutButtonClick() {
177177
...getAnalyticsParameters({ utmSource: '3ook-list' }),
178178
},
179179
)
180-
useLogEvent('begin_checkout', { payment_id: paymentId })
180+
useLogEvent('begin_checkout', { transaction_id: paymentId })
181181
await navigateTo(url, { external: true })
182182
}
183183
catch (error) {

0 commit comments

Comments
Β (0)