index.tsx 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932
  1. import type {DATA_CATEGORY_INFO} from 'sentry/constants';
  2. import type {DataCategoryExact} from 'sentry/types/core';
  3. import type {User} from 'sentry/types/user';
  4. declare global {
  5. interface Window {
  6. /**
  7. * Stripe SDK
  8. */
  9. Stripe: stripe.Stripe;
  10. /**
  11. * Used in admin
  12. */
  13. __sendGridApiKey: string;
  14. /**
  15. * Google analytics
  16. */
  17. ga: any;
  18. /**
  19. * Reload agent
  20. */
  21. ra: any;
  22. /**
  23. * Bing
  24. */
  25. uetq: any;
  26. /**
  27. * Zendesk widget
  28. */
  29. zE: any;
  30. /**
  31. * Pendo which is used to render guides
  32. */
  33. pendo?: any; // TODO: use types package
  34. }
  35. }
  36. /**
  37. * Allows for declaration merging, so getsentry can add additional properties
  38. * to Sentry interfaces.
  39. */
  40. declare module 'sentry/types/system' {
  41. interface Config {
  42. 'getsentry.amplitudeApiKey'?: string;
  43. 'getsentry.googleMapsApiKey'?: string;
  44. 'getsentry.sendgridApiKey'?: string;
  45. 'getsentry.stripePublishKey'?: string;
  46. }
  47. }
  48. export type EventBucket = {
  49. events: number;
  50. price: number;
  51. onDemandPrice?: number;
  52. /**
  53. * Available in performance plans
  54. */
  55. unitPrice?: number;
  56. };
  57. export enum PlanName {
  58. DEVELOPER = 'Developer',
  59. TEAM = 'Team',
  60. BUSINESS = 'Business',
  61. TEAM_BUNDLE = 'Team Bundle',
  62. BUSINESS_BUNDLE = 'Business Bundle',
  63. TEAM_SPONSORED = 'Sponsored Team',
  64. BUSINESS_SPONSORED = 'Sponsored Business',
  65. }
  66. export enum CheckoutType {
  67. STANDARD = 'standard',
  68. BUNDLE = 'bundle',
  69. }
  70. export type DataCategories = (typeof DATA_CATEGORY_INFO)[DataCategoryExact]['plural'];
  71. export type Plan = {
  72. allowAdditionalReservedEvents: boolean;
  73. allowOnDemand: boolean;
  74. /**
  75. * All available data categories on the current plan tier.
  76. * Can be used for category upsells.
  77. */
  78. availableCategories: string[];
  79. basePrice: number;
  80. billingInterval: 'monthly' | 'annual';
  81. /**
  82. * Data categories on the plan (errors, transactions, etc.)
  83. */
  84. categories: string[];
  85. checkoutCategories: string[];
  86. contractInterval: 'monthly' | 'annual';
  87. description: string;
  88. features: string[];
  89. hasOnDemandModes: boolean;
  90. id: string;
  91. maxMembers: number | null;
  92. name: string;
  93. onDemandCategories: string[];
  94. onDemandEventPrice: number;
  95. planCategories: {
  96. [categoryKey in DataCategories]?: EventBucket[];
  97. };
  98. price: number;
  99. reservedMinimum: number;
  100. retentionDays: number;
  101. totalPrice: number;
  102. trialPlan: string | null;
  103. userSelectable: boolean;
  104. categoryDisplayNames?: {
  105. [categoryKey in DataCategories]?: {plural: string; singular: string};
  106. };
  107. checkoutType?: CheckoutType;
  108. };
  109. type PendingChanges = {
  110. customPrice: number | null;
  111. customPriceAttachments: number | null;
  112. customPriceErrors: number | null;
  113. customPricePcss: number | null;
  114. customPriceTransactions: number | null;
  115. // TODO:categories remove customPrice{Categories}
  116. customPrices: {[categoryKey in DataCategories]?: number | null};
  117. effectiveDate: string;
  118. onDemandBudgets: PendingOnDemandBudgets | null;
  119. onDemandEffectiveDate: string;
  120. onDemandMaxSpend: number;
  121. plan: string;
  122. planDetails: Plan;
  123. planName: string;
  124. // TODO:categories remove reserved{Categories}
  125. reserved: {[categoryKey in DataCategories]?: number | null};
  126. reservedAttachments: number | null;
  127. reservedBudgets: PendingReservedBudget[];
  128. reservedCpe: {[categoryKey in DataCategories]?: number | null};
  129. reservedErrors: number | null;
  130. reservedEvents: number;
  131. reservedTransactions: number | null;
  132. };
  133. enum VatStatus {
  134. UNKNOWN = 'unknown',
  135. PERSONAL = 'personal',
  136. BUSINESS = 'business',
  137. BUSINESS_NOVAT = 'business_novat',
  138. OTHER = 'other',
  139. }
  140. export type GDPRDetails = {
  141. dpoAddress: string;
  142. dpoEmail: string;
  143. dpoName: string;
  144. dpoPhone: string;
  145. euRepAddress: string;
  146. euRepEmail: string;
  147. euRepName: string;
  148. euRepPhone: string;
  149. };
  150. type Partner = {
  151. externalId: string;
  152. isActive: boolean;
  153. name: string;
  154. partnership: {
  155. displayName: string;
  156. id: string;
  157. supportNote: string;
  158. };
  159. };
  160. export enum BillingType {
  161. CREDIT_CARD = 'credit card',
  162. INVOICED = 'invoiced',
  163. PARTNER = 'partner',
  164. }
  165. export enum OnDemandBudgetMode {
  166. SHARED = 'shared',
  167. PER_CATEGORY = 'per_category',
  168. }
  169. type SharedOnDemandBudget = {
  170. budgetMode: OnDemandBudgetMode.SHARED;
  171. sharedMaxBudget: number;
  172. };
  173. type SharedOnDemandBudgetWithSpends = SharedOnDemandBudget & {
  174. onDemandSpendUsed: number;
  175. };
  176. export type PerCategoryOnDemandBudget = {
  177. attachmentsBudget: number;
  178. budgetMode: OnDemandBudgetMode.PER_CATEGORY;
  179. // TODO:categories remove {categories}Budget
  180. budgets: {[categoryKey in DataCategories]?: number};
  181. errorsBudget: number;
  182. replaysBudget: number;
  183. transactionsBudget: number;
  184. monitorSeatsBudget?: number;
  185. uptimeBudget?: number;
  186. };
  187. type PerCategoryOnDemandBudgetWithSpends = PerCategoryOnDemandBudget & {
  188. attachmentSpendUsed: number;
  189. errorSpendUsed: number;
  190. transactionSpendUsed: number;
  191. // TODO:categories remove {categories}SpendUsed
  192. usedSpends: {[categoryKey in DataCategories]?: number};
  193. };
  194. export type OnDemandBudgets = SharedOnDemandBudget | PerCategoryOnDemandBudget;
  195. type OnDemandBudgetsEnabled = {
  196. enabled: boolean;
  197. };
  198. type OnDemandBudgetsWithSpends =
  199. | SharedOnDemandBudgetWithSpends
  200. | PerCategoryOnDemandBudgetWithSpends;
  201. export type SubscriptionOnDemandBudgets = OnDemandBudgetsEnabled &
  202. OnDemandBudgetsWithSpends;
  203. export type PendingOnDemandBudgets = OnDemandBudgetsEnabled & OnDemandBudgets;
  204. export type ProductTrial = {
  205. category: DataCategories;
  206. isStarted: boolean;
  207. reasonCode: number;
  208. betaOptInStatus?: boolean;
  209. endDate?: string;
  210. lengthDays?: number;
  211. startDate?: string;
  212. };
  213. export type Subscription = {
  214. accountBalance: number;
  215. billingInterval: 'monthly' | 'annual';
  216. // billingPeriod varies between 1-12 months. if you're looking for the monthly usage interval, use onDemandPeriodStart
  217. billingPeriodEnd: string;
  218. billingPeriodStart: string;
  219. canCancel: boolean;
  220. canGracePeriod: boolean;
  221. canSelfServe: boolean;
  222. canTrial: boolean;
  223. cancelAtPeriodEnd: boolean;
  224. /**
  225. * Current history per data category
  226. */
  227. categories: {
  228. [categoryKey in DataCategories]?: BillingMetricHistory;
  229. };
  230. contractInterval: 'monthly' | 'annual';
  231. contractPeriodEnd: string;
  232. contractPeriodStart: string;
  233. customPrice: number | null;
  234. customPriceAttachments: number | null;
  235. customPriceErrors: number | null;
  236. customPricePcss: number | null;
  237. customPriceTransactions: number | null;
  238. dataRetention: string | null;
  239. // Event details
  240. dateJoined: string;
  241. // GDPR Info
  242. gdprDetails: GDPRDetails | null;
  243. gracePeriodEnd: string | null;
  244. gracePeriodStart: string | null;
  245. hadCustomDynamicSampling: boolean;
  246. hasDismissedForcedTrialNotice: boolean;
  247. hasDismissedTrialEndingNotice: boolean;
  248. hasOverageNotificationsDisabled: boolean;
  249. hasReservedBudgets: boolean;
  250. hasRestrictedIntegration: boolean | null;
  251. hasSoftCap: boolean;
  252. id: string;
  253. isBundleEligible: boolean;
  254. // Added by SubscriptionStore to show/hide a UI element
  255. isEnterpriseTrial: boolean;
  256. // was the trial forced on to the org to rectify access to premium features
  257. isExemptFromForcedTrial: boolean;
  258. isForcedTrial: boolean;
  259. isFree: boolean;
  260. // Subscription flags
  261. isGracePeriod: boolean;
  262. isHeroku: boolean;
  263. isManaged: boolean;
  264. isOverMemberLimit: boolean;
  265. isPartner: boolean;
  266. isPastDue: boolean;
  267. isPerformancePlanTrial: boolean;
  268. isSelfServePartner: boolean;
  269. isSponsored: boolean;
  270. isSuspended: boolean;
  271. isTrial: boolean;
  272. lastTrialEnd: string | null;
  273. membersDeactivatedFromLimit: number;
  274. name: string;
  275. onDemandDisabled: boolean;
  276. onDemandInvoiced: boolean;
  277. onDemandMaxSpend: number;
  278. onDemandPeriodEnd: string;
  279. onDemandPeriodStart: string;
  280. onDemandSpendUsed: number;
  281. partner: Partner | null;
  282. paymentSource: {
  283. countryCode: string;
  284. expMonth: number;
  285. expYear: number;
  286. last4: string;
  287. zipCode: string;
  288. } | null;
  289. pendingChanges: PendingChanges | null;
  290. // Subscription details
  291. plan: string;
  292. planDetails: Plan;
  293. planTier: string;
  294. /**
  295. * Total events allowed for the current usage period including gifted
  296. */
  297. prepaidEventsAllowed: number | null;
  298. renewalDate: string;
  299. reservedAttachments: number | null;
  300. reservedBudgetCategories: string[] | null;
  301. /**
  302. * For am1 plan tier, null for previous tiers
  303. */
  304. reservedErrors: number | null;
  305. /**
  306. * Reserved events on a recurring subscription
  307. * For plan tiers previous to am1
  308. */
  309. reservedEvents: number;
  310. reservedTransactions: number | null;
  311. slug: string;
  312. spendAllocationEnabled: boolean;
  313. sponsoredType: string | null;
  314. status: 'active' | 'trialing' | 'closed' | 'past_due';
  315. supportsOnDemand: boolean;
  316. suspensionReason: string | null;
  317. totalLicenses: number;
  318. totalMembers: number | null;
  319. totalProjects: number | null;
  320. trialEnd: string | null;
  321. trialPlan: string | null;
  322. trialTier: string | null;
  323. type: BillingType;
  324. /**
  325. * All quotas available on the plan are exceeded
  326. */
  327. usageExceeded: boolean;
  328. // Seats
  329. usedLicenses: number;
  330. acv?: number;
  331. // Billing information
  332. billingEmail?: string | null;
  333. channel?: string;
  334. /**
  335. * Optional without access, and possibly null with access
  336. */
  337. companyName?: string | null;
  338. contactInfo?: string | null;
  339. countryCode?: string | null;
  340. // Refetch usage data if Subscription is updated
  341. isDeleted?: boolean;
  342. isTrialStarted?: boolean;
  343. msaUpdatedForDataConsent?: boolean;
  344. onDemandBudgets?: SubscriptionOnDemandBudgets;
  345. onDemandInvoicedManual?: boolean | null;
  346. orgStatus?: {
  347. id: string;
  348. name: string;
  349. };
  350. owner?: {email: string; name: string};
  351. previousPaidPlans?: string[];
  352. productTrials?: ProductTrial[];
  353. reservedBudgets?: ReservedBudget[];
  354. // Added by SubscriptionStore
  355. setAt?: number;
  356. stats?: {
  357. events24h: number;
  358. events30d: number;
  359. eventsPrev24h: number;
  360. eventsPrev30d: number;
  361. };
  362. stripeCustomerID?: string;
  363. trueForward?: {attachment: boolean; error: boolean; transaction: boolean};
  364. /**
  365. * Optional without access, and possibly null with access
  366. */
  367. vatID?: string | null;
  368. vatStatus?: VatStatus | null;
  369. };
  370. export type DiscountInfo = {
  371. amount: number;
  372. billingInterval: 'monthly' | 'annual';
  373. billingPeriods: number;
  374. // TODO: better typing
  375. creditCategory: string;
  376. disclaimerText: string;
  377. discountType: 'percentPoints' | 'events';
  378. durationText: string;
  379. maxCentsPerPeriod: number;
  380. modalDisclaimerText: string;
  381. planRequirement: 'business' | 'paid' | null;
  382. reminderText: string;
  383. };
  384. export type Promotion = {
  385. autoOptIn: boolean;
  386. discountInfo: DiscountInfo;
  387. endDate: string;
  388. name: string;
  389. promptActivityTrigger: string | null;
  390. showDiscountInfo: boolean;
  391. slug: string;
  392. startDate: string;
  393. timeLimit: string;
  394. };
  395. export type PromotionClaimed = {
  396. dateClaimed: string;
  397. dateCompleted: string;
  398. dateExpired: string;
  399. freeEventCreditDaysLeft: number;
  400. isLastCycleForFreeEvents: boolean;
  401. promotion: Promotion;
  402. claimant?: User;
  403. };
  404. export type PromotionData = {
  405. activePromotions: PromotionClaimed[];
  406. availablePromotions: Promotion[];
  407. completedPromotions: PromotionClaimed[];
  408. };
  409. /** @internal exported for tests only */
  410. export type Feature = {
  411. description: string;
  412. name: string;
  413. };
  414. export type BillingConfig = {
  415. annualDiscount: number;
  416. defaultPlan: string;
  417. defaultReserved: {
  418. [categoryKey in DataCategories]?: number;
  419. };
  420. featureList: Record<string, Feature>;
  421. freePlan: string;
  422. id: string;
  423. planList: Plan[];
  424. };
  425. export type BillingStat = {
  426. accepted: number;
  427. date: string;
  428. dropped: {
  429. total: number;
  430. other?: number;
  431. overQuota?: number;
  432. spikeProtection?: number; // Calculated in UsageDetailItem
  433. };
  434. filtered: number;
  435. total: number;
  436. ts: string;
  437. // TODO(chart-cleanup): Used by v1 only
  438. isProjected?: boolean;
  439. /**
  440. * Not present when user does not have the correct role
  441. */
  442. onDemandCostRunningTotal?: number;
  443. };
  444. export type BillingStats = BillingStat[];
  445. export type BillingStatTotal = {
  446. accepted: number;
  447. dropped: number;
  448. droppedOther: number;
  449. droppedOverQuota: number;
  450. droppedSpikeProtection: number;
  451. filtered: number;
  452. projected: number;
  453. };
  454. export type CustomerUsage = {
  455. onDemandEventsAllowed: number;
  456. onDemandMaxSpend: number;
  457. periodEnd: string;
  458. periodStart: string;
  459. stats: {[key: string]: BillingStats};
  460. totals: {[key: string]: BillingStatTotal};
  461. eventTotals?: {[key: string]: {[key: string]: BillingStatTotal}};
  462. };
  463. type StructuredAddress = {
  464. addressLine1: string | null;
  465. addressLine2: string | null;
  466. city: string | null;
  467. countryCode: string | null;
  468. postalCode: string | null;
  469. region: string | null;
  470. };
  471. type TaxNumberName = {
  472. taxId: string;
  473. taxIdName: string;
  474. };
  475. type SentryTaxIds = TaxNumberName & {
  476. region?: TaxNumberName & {
  477. code: string;
  478. };
  479. };
  480. export type InvoiceBase = StructuredAddress & {
  481. amount: number;
  482. amountBilled: number | null;
  483. amountRefunded: number;
  484. channel: string | null;
  485. chargeAttempts: number | null;
  486. creditApplied: number | null;
  487. dateCreated: string;
  488. displayAddress: string | null;
  489. id: string;
  490. isClosed: boolean;
  491. // guid
  492. isPaid: boolean;
  493. isRefunded: boolean;
  494. nextChargeAttempt: string | null;
  495. receipt: {
  496. url: string;
  497. };
  498. sentryTaxIds: SentryTaxIds | null;
  499. taxNumber: string | null;
  500. type: string | null;
  501. };
  502. export type Invoice = InvoiceBase & {
  503. charges: any[];
  504. customer:
  505. | Subscription
  506. | {
  507. id: string;
  508. isDeleted: boolean;
  509. slug: string;
  510. name?: string;
  511. };
  512. defaultTaxName: string | null;
  513. effectiveAt: string | null;
  514. isReverseCharge: boolean;
  515. items: InvoiceItem[];
  516. periodEnd: string | null;
  517. periodStart: string | null;
  518. sender: {
  519. address: string[];
  520. name: string;
  521. };
  522. stripeInvoiceID: string | null;
  523. };
  524. type BaseInvoiceItem = {
  525. amount: number;
  526. data: {period?: any; plan?: any; quantity?: any};
  527. description: string;
  528. type: InvoiceItemType;
  529. };
  530. export type InvoiceItem = BaseInvoiceItem & {
  531. periodEnd: string;
  532. periodStart: string;
  533. };
  534. export enum InvoiceItemType {
  535. UNKOWN = '',
  536. SUBSCRIPTION = 'subscription',
  537. ONDEMAND = 'ondemand',
  538. RESERVED_EVENTS = 'reserved',
  539. DAILY_EVENTS = 'daily_events',
  540. BALANCE_CHANGE = 'balance_change',
  541. CANCELLATION_FEE = 'cancellation_fee',
  542. SUBSCRIPTION_CREDIT = 'subscription_credit',
  543. CREDIT_APPLIED = 'credit_applied',
  544. /**
  545. * Used for am1 plans
  546. */
  547. ATTACHMENTS = 'attachments',
  548. TRANSACTIONS = 'transactions',
  549. ONDEMAND_ATTACHMENTS = 'ondemand_attachments',
  550. ONDEMAND_ERRORS = 'ondemand_errors',
  551. ONDEMAND_TRANSACTIONS = 'ondemand_transactions',
  552. ONDEMAND_REPLAYS = 'ondemand_replays',
  553. ONDEMAND_SPANS = 'ondemand_spans',
  554. ONDEMAND_SPANS_INDEXED = 'ondemand_spans_indexed',
  555. ONDEMAND_MONITOR_SEATS = 'ondemand_monitor_seats',
  556. ONDEMAND_UPTIME = 'ondemand_uptime',
  557. ONDEMAND_PROFILE_DURATION = 'ondemand_profile_duration',
  558. RESERVED_ATTACHMENTS = 'reserved_attachments',
  559. RESERVED_ERRORS = 'reserved_errors',
  560. RESERVED_TRANSACTIONS = 'reserved_transactions',
  561. RESERVED_REPLAYS = 'reserved_replays',
  562. RESERVED_SPANS = 'reserved_spans',
  563. RESERVED_SPANS_INDEXED = 'reserved_spans_indexed',
  564. RESERVED_MONITOR_SEATS = 'reserved_monitor_seats',
  565. RESERVED_UPTIME = 'reserved_uptime',
  566. RESERVED_PROFILE_DURATION = 'reserved_profile_duration',
  567. }
  568. export enum InvoiceStatus {
  569. PAID = 'paid',
  570. CLOSED = 'closed',
  571. AWAITING_PAYMENT = 'awaiting payment',
  572. }
  573. export type BillingMetricHistory = {
  574. /**
  575. * Category name (e.g. "errors")
  576. */
  577. category: string;
  578. customPrice: number | null;
  579. free: number;
  580. onDemandBudget: number;
  581. onDemandCpe: number | null;
  582. onDemandQuantity: number;
  583. onDemandSpendUsed: number;
  584. /**
  585. * List order for billing metrics
  586. */
  587. order: number;
  588. prepaid: number;
  589. reserved: number | null;
  590. sentUsageWarning: boolean;
  591. softCapType: 'ON_DEMAND' | 'TRUE_FORWARD' | null;
  592. trueForward: boolean;
  593. usage: number;
  594. usageExceeded: boolean;
  595. };
  596. export type BillingHistory = {
  597. categories: {[key: string]: BillingMetricHistory};
  598. hadCustomDynamicSampling: boolean;
  599. hasReservedBudgets: boolean;
  600. id: string;
  601. isCurrent: boolean;
  602. links: {
  603. csv: string;
  604. csvPerProject: string;
  605. };
  606. onDemandBudgetMode: OnDemandBudgetMode;
  607. onDemandMaxSpend: number;
  608. onDemandSpend: number;
  609. periodEnd: string;
  610. // is today between periodStart/periodEnd?
  611. periodStart: string;
  612. plan: string;
  613. planName: string;
  614. reserved: {
  615. [categoryKey in DataCategories]?: number | null;
  616. };
  617. reservedBudgetCategories: string[];
  618. usage: {
  619. [categoryKey in DataCategories]?: number;
  620. };
  621. planDetails?: Plan;
  622. reservedBudgets?: ReservedBudget[];
  623. };
  624. export type PreviewData = {
  625. atPeriodEnd: boolean;
  626. balanceChange: number;
  627. billedAmount: number;
  628. creditApplied: number;
  629. effectiveAt: string;
  630. invoiceItems: PreviewInvoiceItem[];
  631. newBalance: number;
  632. previewToken: string;
  633. proratedAmount: number;
  634. paymentIntent?: string;
  635. paymentSecret?: string;
  636. };
  637. type PreviewInvoiceItem = BaseInvoiceItem & {
  638. period_end: string;
  639. period_start: string;
  640. };
  641. export enum CreditType {
  642. ERROR = 'error',
  643. TRANSACTION = 'transaction',
  644. SPAN = 'span',
  645. SPAN_INDEXED = 'spanIndexed',
  646. PROFILE_DURATION = 'profileDuration',
  647. ATTACHMENT = 'attachment',
  648. REPLAY = 'replay',
  649. MONITOR_SEAT = 'monitorSeat',
  650. DISCOUNT = 'discount',
  651. PERCENT = 'percent',
  652. UPTIME = 'uptime',
  653. }
  654. type BaseRecurringCredit = {
  655. amount: number;
  656. id: number;
  657. periodEnd: string;
  658. periodStart: string;
  659. };
  660. interface RecurringDiscount extends BaseRecurringCredit {
  661. totalAmountRemaining: number;
  662. type: CreditType.DISCOUNT;
  663. }
  664. interface RecurringPercentDiscount extends BaseRecurringCredit {
  665. percentPoints: number;
  666. totalAmountRemaining: number;
  667. type: CreditType.PERCENT;
  668. }
  669. interface RecurringEventCredit extends BaseRecurringCredit {
  670. totalAmountRemaining: null;
  671. type:
  672. | CreditType.ERROR
  673. | CreditType.TRANSACTION
  674. | CreditType.SPAN
  675. | CreditType.PROFILE_DURATION
  676. | CreditType.ATTACHMENT
  677. | CreditType.REPLAY;
  678. }
  679. export type RecurringCredit =
  680. | RecurringDiscount
  681. | RecurringPercentDiscount
  682. | RecurringEventCredit;
  683. export enum CohortId {
  684. SECOND = 2,
  685. THIRD = 3,
  686. FOURTH = 4,
  687. FIFTH = 5,
  688. SIXTH = 6,
  689. SEVENTH = 7,
  690. EIGHTH = 8,
  691. NINTH = 9,
  692. TENTH = 10,
  693. }
  694. /** @internal exported for tests only */
  695. export type Cohort = {
  696. cohortId: CohortId;
  697. nextPlan: NextPlanInfo | null;
  698. secondDiscount: number;
  699. };
  700. export type NextPlanInfo = {
  701. contractPeriod: string;
  702. discountAmount: number;
  703. discountMonths: number;
  704. errorCredits: number;
  705. errorCreditsMonths: number;
  706. id: string;
  707. name: string;
  708. reserved: {
  709. [categoryKey in DataCategories]?: number;
  710. };
  711. reservedAttachments: number;
  712. reservedErrors: number;
  713. totalPrice: number;
  714. categoryCredits?: {
  715. [categoryKey in DataCategories]?: {
  716. credits: number;
  717. months: number;
  718. };
  719. };
  720. reservedTransactions?: number;
  721. };
  722. export type PlanMigration = {
  723. cohort: Cohort | null;
  724. dateApplied: string | null;
  725. effectiveAt: string | null;
  726. id: number | string;
  727. planTier: string;
  728. recurringCredits: RecurringCredit[];
  729. scheduled: boolean;
  730. };
  731. export enum PlanTier {
  732. /**
  733. * Performance plans with continuous profiling
  734. * and dynamic sampling for spans.
  735. */
  736. AM3 = 'am3',
  737. /**
  738. * Performance plans with continuous profiling
  739. * and dynamic sampling for transactions.
  740. */
  741. AM2 = 'am2',
  742. /**
  743. * First generation of application monitoring plans.
  744. * Includes performance features.
  745. */
  746. AM1 = 'am1',
  747. /**
  748. * Monthly metered plans with variable data options.
  749. */
  750. MM2 = 'mm2',
  751. /**
  752. * First generation of monthly metered plans.
  753. * Features and data volumes are tightly coupled.
  754. */
  755. MM1 = 'mm1',
  756. }
  757. // Response from /organizations/:orgSlug/payments/:invoiceId/new/
  758. export type PaymentCreateResponse = {
  759. amount: string;
  760. clientSecret: string;
  761. currency: string;
  762. returnUrl: string;
  763. };
  764. // Response from /organizations/:orgSlug/payments/setup/
  765. export type PaymentSetupCreateResponse = {
  766. clientSecret: string;
  767. id: string;
  768. lastError: string | null;
  769. status: string;
  770. };
  771. export enum AddressType {
  772. STRUCTURED = 'structured',
  773. UNSTRUCTURED = 'unstructured',
  774. }
  775. export type BillingDetails = StructuredAddress & {
  776. addressType: AddressType | null;
  777. billingEmail: string | null;
  778. companyName: string | null;
  779. displayAddress: string | null;
  780. taxNumber: string | null;
  781. };
  782. export interface MonitorCountResponse {
  783. disabledMonitorCount: number;
  784. enabledMonitorCount: number;
  785. overQuotaMonitorCount: number;
  786. }
  787. export type PendingReservedBudget = {
  788. categories: {[categoryKey in DataCategories]?: boolean | null};
  789. reservedBudget: number;
  790. };
  791. export type ReservedBudget = {
  792. categories: {
  793. [categoryKey in DataCategories]?: ReservedBudgetMetricHistory;
  794. };
  795. freeBudget: number;
  796. id: string;
  797. percentUsed: number;
  798. reservedBudget: number;
  799. totalReservedSpend: number;
  800. };
  801. export type ReservedBudgetMetricHistory = {
  802. reservedCpe: number; // in cents
  803. reservedSpend: number;
  804. };
  805. export type ReservedBudgetForCategory = {
  806. freeBudget: number;
  807. prepaidBudget: number;
  808. reservedCpe: number; // in cents
  809. reservedSpend: number;
  810. totalReservedBudget: number;
  811. };
  812. type PolicyConsent = {
  813. acceptedVersion: string;
  814. createdAt: string;
  815. userEmail: string;
  816. userName: string;
  817. };
  818. export type Policy = {
  819. active: boolean;
  820. /** Policy consent signature data if policy has been signed. Null if not signed or hasSignature is false. */
  821. consent: PolicyConsent | null;
  822. /** True if the policy can be signed. */
  823. hasSignature: boolean;
  824. /** Readable policy name */
  825. name: string;
  826. /** Slug of a parent policy that needs consent before this policy */
  827. parent: string | null;
  828. slug: string;
  829. /** True if no parent policies */
  830. standalone: boolean;
  831. /** The date of the current version */
  832. updatedAt: string | null;
  833. url: string | null;
  834. /** The current version */
  835. version: string | null;
  836. };
  837. type PolicyFile = {
  838. checksum: string;
  839. name: string;
  840. size: number;
  841. };
  842. export type PolicyRevision = {
  843. createdAt: string;
  844. current: boolean;
  845. file: PolicyFile | null;
  846. url: string | null;
  847. version: string;
  848. };