Giter VIP home page Giter VIP logo

stripe-plugin's Introduction

Stripe Plugin

Get customer and invoice data from Stripe into PostHog.

This plugin will:

  • Associate your Stripe customers with PostHog users
  • Create a PostHog user from a Stripe customer if it doesn't exist
  • Emit events for every new customer
  • Set the Stripe customer data as user properties in PostHog
  • Notify you of upcoming invoices above a certain threshold

stripe-plugin's People

Contributors

hazzadous avatar kpthatsme avatar pjhul avatar timgl avatar yakkomajuri avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

isabella232

stripe-plugin's Issues

Support backfill of paid invoice data

We should be able to support capturing historical paid invoices.

How this would work:

  1. Allow users to set a backfill date in config

  2. When calculating Paid Invoices, query all invoices starting with backfill date โ€“ send backdated events to PostHog with the amount paid per month

This should give users a pretty good view of all income month over month

rebuilding plugin spec

Planning on rebuilding this plugin as it currently times out and doesn't work well.

Current usage of this plugin

  • No-one on cloud
  • No recent usage on self hosted

What we want out of this

  • person/group properties
    • What plan and product they're on
    • Current status (paid/cancelled)
    • How much they spent in the last month
    • How much they spent cumulatively
    • How much they paid cumulatively
    • When they subscribed
  • Events
    • Subscribed
    • invoice paid
    • cancelled

How to identify stripe customers with posthog persons

  1. metadata on the Stripe Customer: posthog_distinct_id
  2. email on the stripe customer
  3. stripe customer_id

How it works:

every 10 minute, get 100 new invoices (paginate until we find new ones, from storage)

  • if customer doesn't exist
    • call api/person and grab user by email to get distinct_id. WARN if > 1 result or 0 results
    • if group_type_id is set, also call groups/related to find related groups
    • send subscribed invoice
    • store distinct_id mapping into storage
  • grab customer from storage, increment "total_spend" amount and update dict with dates and amounts
  • send invoice paid event, with $set for all properties
  • (if group_type_id is set) send $groupidentify event
  • set invoice id in storage

Plugin Improvements List

  • Better testing
  • Filter relevant information better
  • Check a hash of the customer data before sending event to update it
  • Support a daily MRR event
  • Support more of Stripe's endpoints

make it possible to associate stripe data with group

In our case the billable entity is an "organization" as such we would want to associate f.e. the turnover generated with the organization and not (only) the person, even though stripe of course associates turnover to a person.

On our "organization" group type we store the person ID of the "owner" and of course the person is also associated with the "organization" via group identify.

What I guess I would like to see added is the ability to specify a group type and then relevant properties would also be added there. what I am unsure about is how to best handle cases where the "owner" changes. in that case it should ideall sum up f.e. the turnover from the previous and the current owner on the "organization".

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.