Skip to content

feat: payments through trackEvent, capturePayment removed (5.0.0) - #45

Open
ChetanBhosale wants to merge 6 commits into
mainfrom
chetan/lin-3231-trackevent-payments
Open

ChetanBhosale wants to merge 6 commits into
mainfrom
chetan/lin-3231-trackevent-payments

Conversation

@ChetanBhosale

@ChetanBhosale ChetanBhosale commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

Payments now go through trackEvent. Put amount, paymentId and currency (plus userId and optional status) in eventData and the SDK sends it as a payment; anything else stays a custom event. capturePayment, removePayment and trackPayment are removed. Version 5.0.0.

await LinkRunner().trackEvent(
  eventName: 'FIRST_PAYMENT',
  eventData: {'amount': 1200, 'paymentId': 'bk_10231', 'currency': 'INR', 'userId': 'playo_u_8842'},
);

Migration: rename capturePayment to trackEvent, pass the old type as the event name with the same spelling, and move the fields into eventData (currency is new and required). Refunds: same paymentId with PAYMENT_CANCELLED.

Rules

  • A call is a payment only when eventData has amount, paymentId and currency (camelCase). They are moved to the top level of the capture-event request (amount, payment_id, currency, user_id, status); every other key stays in event_data.
  • amount and/or currency without paymentId is a normal custom event, sent exactly as before.
  • paymentId with amount or currency missing fails with amount, paymentId and currency must be sent together, nothing is sent.
  • For a payment: amount is a number, 0 or more (negative fails); paymentId not blank; currency 3 letters, sent uppercase; userId required ("" uses the user saved by signup/setUserData); status optional (PaymentStatus value or its name), default PAYMENT_COMPLETED.
  • The event name is sent exactly as typed. Old payment types must keep their uppercase spelling (FIRST_PAYMENT) to match existing dashboard mappings.

Changes

  • Removed trackPayment, the payment param, EventPayment / LRCapturePayment / LRRemovePayment and their Dart validation. Native 5.0.0 does the payment check.
  • PaymentStatus moved to lr_payment_status.dart; a PaymentStatus in eventData['status'] is sent as its name.
  • Android/iOS bridges pass eventData to native trackEvent unchanged. Native Android 5.0.0, LinkrunnerKit 5.0.0.

Testing

  • flutter test 13/13 pass; dart analyze lib test 7 info-level naming notes only. Android debug APK and iOS simulator builds compile against native 5.0.0.
  • End to end on the Android emulator against a local hazelnut gateway: custom events stored unchanged (incl. amount+currency without paymentId); FIRST_PAYMENT 1200 (PaymentStatus enum sent as its name, userId: "" used the saved user, product keys kept in event_data) and amount 0 stored as revenue; lowercase first_payment kept as its own type; PAYMENT_FAILED stored; partial payment and -5 threw PlatformException(TRACK_EVENT_FAILED, …) and never reached the gateway.
  • Not run: Flutter on iOS end to end (on iOS an invalid payment is dropped and logged, like native).

Backend: https://github.com/linkrunner-labs/hazelnut/pull/884 (no change needed for this design). Docs: linkrunner-labs/docs#265

Linear: https://linear.app/linkrunner/issue/LIN-3231/in-app-events-trackevent-with-amount-becomes-the-payment-api

🤖 Generated with Claude Code

ChetanBhosale and others added 3 commits October 11, 2026 23:25
…ovePayment

trackEvent takes an optional EventPayment (amount, paymentId, currency,
optional status), validated in Dart and passed to the native 5.0.0
trackEvent. capturePayment, removePayment, LRCapturePayment,
LRRemovePayment and PaymentType are removed. Native SDKs and the package
version move to 5.0.0.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
trackPayment(eventName, paymentId, userId, amount, currency, status, eventData)
replaces capturePayment and sends through trackEvent with an EventPayment.
EventPayment now takes a required userId and status defaults to
PAYMENT_COMPLETED and is always sent. Android and iOS bridges pass userId
to the native 5.0.0 EventPayment.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 11, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 877ca915-3b5d-437a-8461-376321d92e32
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

ChetanBhosale and others added 3 commits October 23, 2026 13:38
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
… old types

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ChetanBhosale ChetanBhosale changed the title feat: trackPayment replaces capturePayment (5.0.0) feat: payments through trackEvent, capturePayment removed (5.0.0) Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant