Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

source-stripe-native: fix streams' incremental replications #1976

Merged
merged 2 commits into from
Sep 24, 2024

Conversation

Alex-Bair
Copy link
Contributor

@Alex-Bair Alex-Bair commented Sep 23, 2024

Description:

There were various issues preventing some streams from incrementally replicating:

  • The incorrect event types were being listened to (ex: ApplicationFees)
  • The Stripe API does not generate certain events (ex: Payouts).

The connector has been updated to let us check for multiple different event types with the EVENT_TYPES class variable. This variable references a dictionary whose keys are Stripe API event types and whose values are the appropriate meta_.op value. EVENT_TYPES can be different between parent and child streams, enabling "split" streams - streams that backfill like child streams but incrementally replicate like standard streams with associated events.

Notes:

  • There are a number of streams whose events I couldn't confirm are actually generated by Stripe. These are noted in the code with comments. I still have these streams using events for incremental replication, and we can reassess a different strategy later if we discover that these events aren't generated by Stripe.
  • The Payouts stream was switched over to be a no-events stream since the associated events aren't generated by Stripe. It seems like most payout docs aren't updated after they are created, so this should work for most use cases. But if that assumption doesn't hold & we need to capture updated payouts, we'll need to rethink this strategy.

Closes #1965.

Workflow steps:

(How does one use this feature, and how has it changed)

Documentation links affected:

(list any documentation links that you created, or existing ones that you've identified as needing updates, along with a brief description)

Notes for reviewers:

Tested on a local stack. Confirmed what streams I could access are now performing incremental replication.

Discover snapshot changes are expected due to description updates and the addition of the object attribute to all Stripe documents' schemas.


This change is Reviewable

…ication.

Switch to passing an array of event types for most streams' incremental
replications. This lets us listen to more than one type of event (like
both `.created`, `.updated`. and `.deleted` events) as well as provide
more accurate `meta_.op` information based on specific events.

As a result of this switch, some child streams are now listening to
events that return the child document directly in the event API
response. This means they behave like child streams during backfills but
like non-child streams during incremental replication. These streams are
listed in the `SPLIT_CHILD_STREAM_NAMES` array, which is used to help
determine whether this a standard child stream or a split child stream.

Some streams' associated events are not generated by Stripe
(ex: `Accounts`, `Persons`, `Payouts`), and determining how to address
these is left for a later commit.

Discover snapshot changes are expected due to adding `object` to each
document's schema.
No `payout.*` events are generated by Stripe despite being detailed in their docs, so we can't rely on those events to do incremental replication. Instead, we can treat `Payouts` as a no event stream. It seems like most payouts aren't updated after creation, so this strategy should work fine most of the time.
@Alex-Bair Alex-Bair added the change:planned This is a planned change label Sep 23, 2024
Copy link
Member

@williamhbaker williamhbaker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Lots of little nuances to the Stripe API to work through, nice job!

@Alex-Bair Alex-Bair merged commit 911128f into main Sep 24, 2024
69 of 76 checks passed
@Alex-Bair Alex-Bair deleted the bair/source-stripe-native-incremental-events branch September 24, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
change:planned This is a planned change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

source-stripe-native: some streams' incremental replications aren't happening
2 participants