Documentation ¶
Index ¶
- Constants
- Variables
- func FillProducts(stripeClient *client.API, subscriptions []*stripe.Subscription)
- func FromPriceID(priceID string) backend.PlanType
- func GetBaseLookupKey(productTier backend.PlanType, interval model.PricingSubscriptionInterval, ...) (result string)
- func GetEntitlements(ctx context.Context, customer *marketplacemetering.ResolveCustomerOutput) ([]mpeTypes.Entitlement, error)
- func GetErrors7DayAverage(ctx context.Context, DB *gorm.DB, ccClient *clickhouse.Client, ...) (float64, error)
- func GetLimitAmount(limitCostCents *int, productType model.PricingProductType, ...) *int64
- func GetLogs7DayAverage(ctx context.Context, DB *gorm.DB, ccClient *clickhouse.Client, ...) (float64, error)
- func GetOverageKey(productType model.PricingProductType, retentionPeriod backend.RetentionPeriod, ...) string
- func GetProductMetadata(price *stripe.Price) (*model.PricingProductType, *backend.PlanType, bool, ...)
- func GetSessions7DayAverage(ctx context.Context, DB *gorm.DB, ccClient *clickhouse.Client, ...) (float64, error)
- func GetStripePrices(stripeClient *client.API, workspace *model.Workspace, ...) (map[model.PricingProductType]*stripe.Price, error)
- func GetTraces7DayAverage(ctx context.Context, DB *gorm.DB, ccClient *clickhouse.Client, ...) (float64, error)
- func GetWorkspaceErrorsMeter(ctx context.Context, DB *gorm.DB, ccClient *clickhouse.Client, ...) (int64, error)
- func GetWorkspaceLogsMeter(ctx context.Context, DB *gorm.DB, ccClient *clickhouse.Client, ...) (int64, error)
- func GetWorkspaceSessionsMeter(ctx context.Context, DB *gorm.DB, ccClient *clickhouse.Client, ...) (int64, error)
- func GetWorkspaceTracesMeter(ctx context.Context, DB *gorm.DB, ccClient *clickhouse.Client, ...) (int64, error)
- func IncludedAmount(planType backend.PlanType, productType model.PricingProductType) int64
- func MustUpgradeForClearbit(tier string) bool
- func ProductToBasePriceCents(productType model.PricingProductType, planType backend.PlanType, meter int64) float64
- func RetentionMultiplier(retentionPeriod backend.RetentionPeriod) float64
- func TypeToMemberLimit(planType backend.PlanType, unlimitedMembers bool) *int64
- type AWSCustomerUsage
- type AWSCustomerUsages
- type AWSMPProductCode
- type GraduatedPriceItem
- type PaymentIssueType
- type ProductPricing
- type Worker
- func (w *Worker) AddOrUpdateOverageItem(newPrice *stripe.Price, invoiceLine *stripe.InvoiceLineItem, ...) error
- func (w *Worker) CalculateOverages(ctx context.Context, workspaceID int) (WorkspaceOverages, error)
- func (w *Worker) GetBillingIssue(ctx context.Context, workspace *model.Workspace, customer *stripe.Customer, ...) (PaymentIssueType, error)
- func (w *Worker) ProcessBillingIssue(ctx context.Context, workspace *model.Workspace, status PaymentIssueType)
- func (w *Worker) ReportAWSMPUsages(ctx context.Context, usages AWSCustomerUsages)
- func (w *Worker) ReportAllUsage(ctx context.Context)
- func (w *Worker) ReportStripeUsageForWorkspace(ctx context.Context, workspaceID int) error
- type WorkspaceOverages
Constants ¶
View Source
const BillingWarningPeriod = 7 * 24 * time.Hour
Variables ¶
View Source
var AWSMPProducts = map[AWSMPProductCode]backend.PlanType{ AWSMPProductCodeUsageBased: backend.PlanTypeUsageBased, }
View Source
var ProductPrices = map[backend.PlanType]map[model.PricingProductType]ProductPricing{ backend.PlanTypeGraduated: { model.PricingProductTypeSessions: { Included: 500, Items: []GraduatedPriceItem{{ Rate: 20. / 1_000, Count: 15_000, }, { Rate: 15. / 1_000, Count: 50_000, }, { Rate: 12. / 1_000, Count: 150_000, }, { Rate: 6.5 / 1_000, Count: 500_000, }, { Rate: 3.5 / 1_000, Count: 1_000_000, }, { Rate: 2.5 / 1_000, }}, }, model.PricingProductTypeErrors: { Included: 1_000, Items: []GraduatedPriceItem{{ Rate: 2. / 1_000, Count: 50_000, }, { Rate: 0.5 / 1_000, Count: 100_000, }, { Rate: 0.25 / 1_000, Count: 200_000, }, { Rate: 0.2 / 1_000, Count: 500_000, }, { Rate: 0.1 / 1_000, Count: 5_000_000, }, { Rate: 0.05 / 1_000, }}, }, model.PricingProductTypeLogs: { Included: 1_000_000, Items: []GraduatedPriceItem{{ Rate: 2.5 / 1_000_000, Count: 1_000_000, }, { Rate: 2. / 1_000_000, Count: 10_000_000, }, { Rate: 1.5 / 1_000_000, Count: 100_000_000, }, { Rate: 1. / 1_000_000, Count: 1_000_000_000, }, { Rate: 0.5 / 1_000_000, }}, }, model.PricingProductTypeTraces: { Included: 25_000_000, Items: []GraduatedPriceItem{{ Rate: 2.5 / 1_000_000, Count: 1_000_000, }, { Rate: 2. / 1_000_000, Count: 10_000_000, }, { Rate: 1.5 / 1_000_000, Count: 100_000_000, }, { Rate: 1. / 1_000_000, Count: 1_000_000_000, }, { Rate: 0.5 / 1_000_000, }}, }, }, backend.PlanTypeUsageBased: { model.PricingProductTypeSessions: { Included: 500, Items: []GraduatedPriceItem{{ Rate: 20. / 1_000, }}, }, model.PricingProductTypeErrors: { Included: 1_000, Items: []GraduatedPriceItem{{ Rate: 2. / 1_000, }}, }, model.PricingProductTypeLogs: { Included: 1_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, model.PricingProductTypeTraces: { Included: 1_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, }, backend.PlanTypeLite: { model.PricingProductTypeSessions: { Included: 2_000, Items: []GraduatedPriceItem{{ Rate: 5. / 1_000, }}, }, model.PricingProductTypeErrors: { Included: 4_000, Items: []GraduatedPriceItem{{ Rate: 0.2 / 1_000, }}, }, model.PricingProductTypeLogs: { Included: 4_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, model.PricingProductTypeTraces: { Included: 4_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, }, backend.PlanTypeBasic: { model.PricingProductTypeSessions: { Included: 10_000, Items: []GraduatedPriceItem{{ Rate: 5. / 1_000, }}, }, model.PricingProductTypeErrors: { Included: 20_000, Items: []GraduatedPriceItem{{ Rate: 0.2 / 1_000, }}, }, model.PricingProductTypeLogs: { Included: 20_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, model.PricingProductTypeTraces: { Included: 20_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, }, backend.PlanTypeStartup: { model.PricingProductTypeSessions: { Included: 80_000, Items: []GraduatedPriceItem{{ Rate: 5. / 1_000, }}, }, model.PricingProductTypeErrors: { Included: 160_000, Items: []GraduatedPriceItem{{ Rate: 0.2 / 1_000, }}, }, model.PricingProductTypeLogs: { Included: 160_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, model.PricingProductTypeTraces: { Included: 160_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, }, backend.PlanTypeEnterprise: { model.PricingProductTypeSessions: { Included: 300_000, Items: []GraduatedPriceItem{{ Rate: 5. / 1_000, }}, }, model.PricingProductTypeErrors: { Included: 600_000, Items: []GraduatedPriceItem{{ Rate: 0.2 / 1_000, }}, }, model.PricingProductTypeLogs: { Included: 600_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, model.PricingProductTypeTraces: { Included: 600_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, }, backend.PlanTypeFree: { model.PricingProductTypeSessions: { Included: 500, Items: []GraduatedPriceItem{{ Rate: 5. / 1_000, }}, }, model.PricingProductTypeErrors: { Included: 1_000, Items: []GraduatedPriceItem{{ Rate: 0.2 / 1_000, }}, }, model.PricingProductTypeLogs: { Included: 1_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, model.PricingProductTypeTraces: { Included: 25_000_000, Items: []GraduatedPriceItem{{ Rate: 1.5 / 1_000_000, }}, }, }, }
Functions ¶
func FillProducts ¶
Products are too nested in the Subscription model to be added through the API This method calls the Stripe ListProducts API and replaces each product id in the subscriptions with the full product data.
func FromPriceID ¶
func GetBaseLookupKey ¶
func GetBaseLookupKey(productTier backend.PlanType, interval model.PricingSubscriptionInterval, unlimitedMembers bool, retentionPeriod backend.RetentionPeriod) (result string)
Returns a Stripe lookup key which maps to a single Stripe Price
func GetEntitlements ¶
func GetEntitlements(ctx context.Context, customer *marketplacemetering.ResolveCustomerOutput) ([]mpeTypes.Entitlement, error)
func GetErrors7DayAverage ¶
func GetLimitAmount ¶
func GetLimitAmount(limitCostCents *int, productType model.PricingProductType, planType backend.PlanType, retentionPeriod backend.RetentionPeriod) *int64
func GetLogs7DayAverage ¶
func GetOverageKey ¶
func GetOverageKey(productType model.PricingProductType, retentionPeriod backend.RetentionPeriod, planType backend.PlanType) string
func GetProductMetadata ¶
func GetProductMetadata(price *stripe.Price) (*model.PricingProductType, *backend.PlanType, bool, model.PricingSubscriptionInterval, backend.RetentionPeriod)
Returns the Highlight model.PricingProductType, Tier, and Interval for the Stripe Price
func GetSessions7DayAverage ¶
func GetStripePrices ¶
func GetStripePrices(stripeClient *client.API, workspace *model.Workspace, productTier backend.PlanType, interval model.PricingSubscriptionInterval, unlimitedMembers bool, sessionsRetention *backend.RetentionPeriod, errorsRetention *backend.RetentionPeriod) (map[model.PricingProductType]*stripe.Price, error)
Returns the Stripe Prices for the associated tier and interval
func GetTraces7DayAverage ¶
func GetWorkspaceErrorsMeter ¶
func GetWorkspaceLogsMeter ¶
func GetWorkspaceTracesMeter ¶
func IncludedAmount ¶
func IncludedAmount(planType backend.PlanType, productType model.PricingProductType) int64
func MustUpgradeForClearbit ¶
MustUpgradeForClearbit shows when tier is insufficient for Clearbit.
func ProductToBasePriceCents ¶
func RetentionMultiplier ¶
func RetentionMultiplier(retentionPeriod backend.RetentionPeriod) float64
Types ¶
type AWSCustomerUsage ¶
type AWSCustomerUsage struct { Customer *model.AWSMarketplaceCustomer Usage WorkspaceOverages }
type AWSCustomerUsages ¶
type AWSCustomerUsages = map[int]AWSCustomerUsage
type AWSMPProductCode ¶
type AWSMPProductCode = string
const AWSMPProductCodeUsageBased AWSMPProductCode = "24dmmonsy3i8lrvjcct8mq07y"
type GraduatedPriceItem ¶
type PaymentIssueType ¶
type PaymentIssueType = string
const PaymentIssueTypeCardCheckFail PaymentIssueType = "payment_method_check_failed"
const PaymentIssueTypeInvoiceOpenAttempted PaymentIssueType = "invoice_open_attempted"
const PaymentIssueTypeInvoiceUncollectible PaymentIssueType = "invoice_uncollectible"
const PaymentIssueTypeNoPaymentMethod PaymentIssueType = "no_payment_method"
const PaymentIssueTypeSubscriptionDue PaymentIssueType = "subscription_due"
type ProductPricing ¶
type ProductPricing struct { Included int64 Items []GraduatedPriceItem }
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
func (*Worker) AddOrUpdateOverageItem ¶
func (*Worker) CalculateOverages ¶
func (*Worker) GetBillingIssue ¶
func (*Worker) ProcessBillingIssue ¶
func (*Worker) ReportAWSMPUsages ¶
func (w *Worker) ReportAWSMPUsages(ctx context.Context, usages AWSCustomerUsages)
func (*Worker) ReportAllUsage ¶
type WorkspaceOverages ¶
type WorkspaceOverages = map[model.PricingProductType]int64
Click to show internal directories.
Click to hide internal directories.