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

Sidebar nav #2634

Closed
wants to merge 34 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
6ebe039
pricing fixes
chitalian Sep 11, 2024
f3629b9
sidebar stuff
chitalian Sep 12, 2024
66438a7
Merge branch 'main' into pricing-updates-everything
chitalian Sep 12, 2024
f39ee6d
rev
chitalian Sep 12, 2024
82d4172
rev
chitalian Sep 12, 2024
241c898
moving settings to their own pages
chitalian Sep 13, 2024
49e5070
side bar cleaning
chitalian Sep 13, 2024
99d109c
pricing stuff
chitalian Sep 13, 2024
1d30e03
stripe stuff
chitalian Sep 14, 2024
babbfba
more billing page
chitalian Sep 14, 2024
8b88674
stripe
chitalian Sep 16, 2024
f62bdfb
minor fixes
chitalian Sep 16, 2024
c3c2db0
I am a frontend god
chitalian Sep 17, 2024
7380049
be god too
chitalian Sep 17, 2024
42bdf9d
billing i am a god
chitalian Sep 17, 2024
0d26abf
ui touch ups and blocks
chitalian Sep 18, 2024
9d886ef
lint
chitalian Sep 18, 2024
896c554
Merge branch 'main' into sidebar-nav
chitalian Sep 18, 2024
91895a1
Merge branch 'main' into sidebar-nav
chitalian Sep 18, 2024
f44149f
merge types
chitalian Sep 18, 2024
31fbe1e
fix types and build
chitalian Sep 18, 2024
c5eb371
fix types and build
chitalian Sep 18, 2024
b976f9a
fix build completely
chitalian Sep 18, 2024
08bed53
stripe manager
chitalian Sep 18, 2024
87602f3
Merge branch 'main' into sidebar-nav
chitalian Sep 18, 2024
c88f085
minor UI updates
chitalian Sep 18, 2024
4a9617b
coupon
chitalian Sep 18, 2024
2cacf47
types
chitalian Sep 18, 2024
6126038
enable growth users
chitalian Sep 18, 2024
102c241
enable growth users
chitalian Sep 18, 2024
b4d0f3e
fix logic for link building
chitalian Sep 18, 2024
8600a4d
filter out helicone users
chitalian Sep 18, 2024
12e6c1c
filter out helicone users on add user
chitalian Sep 18, 2024
b5f27da
move is pro tag
chitalian Sep 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
174 changes: 172 additions & 2 deletions docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -11987,7 +11987,105 @@
"description": "Ok",
"content": {
"application/json": {
"schema": {}
"schema": {
"properties": {
"total": {
"type": "number",
"format": "double"
},
"tax": {
"type": "number",
"format": "double",
"nullable": true
},
"subtotal": {
"type": "number",
"format": "double"
},
"discount": {
"properties": {
"coupon": {
"properties": {
"percent_off": {
"type": "number",
"format": "double",
"nullable": true
},
"name": {
"type": "string",
"nullable": true
}
},
"required": [
"percent_off",
"name"
],
"type": "object"
}
},
"required": [
"coupon"
],
"type": "object",
"nullable": true
},
"lines": {
"properties": {
"data": {
"items": {
"properties": {
"description": {
"type": "string",
"nullable": true
},
"amount": {
"type": "number",
"format": "double",
"nullable": true
},
"id": {
"type": "string",
"nullable": true
}
},
"required": [
"description",
"amount",
"id"
],
"type": "object"
},
"type": "array"
}
},
"required": [
"data"
],
"type": "object",
"nullable": true
},
"next_payment_attempt": {
"type": "number",
"format": "double",
"nullable": true
},
"currency": {
"type": "string",
"nullable": true
}
},
"required": [
"total",
"tax",
"subtotal",
"discount",
"lines",
"next_payment_attempt",
"currency"
],
"type": "object",
"nullable": true
}
}
}
}
Expand Down Expand Up @@ -12060,7 +12158,79 @@
"description": "Ok",
"content": {
"application/json": {
"schema": {}
"schema": {
"properties": {
"items": {
"items": {
"properties": {
"price": {
"properties": {
"product": {
"properties": {
"name": {
"type": "string",
"nullable": true
}
},
"required": [
"name"
],
"type": "object",
"nullable": true
}
},
"required": [
"product"
],
"type": "object"
},
"quantity": {
"type": "number",
"format": "double"
}
},
"required": [
"price"
],
"type": "object"
},
"type": "array"
},
"trial_end": {
"type": "number",
"format": "double",
"nullable": true
},
"id": {
"type": "string"
},
"current_period_start": {
"type": "number",
"format": "double"
},
"current_period_end": {
"type": "number",
"format": "double"
},
"cancel_at_period_end": {
"type": "boolean"
},
"status": {
"type": "string"
}
},
"required": [
"items",
"trial_end",
"id",
"current_period_start",
"current_period_end",
"cancel_at_period_end",
"status"
],
"type": "object",
"nullable": true
}
}
}
}
Expand Down
48 changes: 46 additions & 2 deletions helicone-node/api/generatedTypes/public.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4322,7 +4322,32 @@ export interface operations {
/** @description Ok */
200: {
content: {
"application/json": unknown;
"application/json": ({
/** Format: double */
total: number;
/** Format: double */
tax: number | null;
/** Format: double */
subtotal: number;
discount: ({
coupon: {
/** Format: double */
percent_off: number | null;
name: string | null;
};
}) | null;
lines: ({
data: ({
description: string | null;
/** Format: double */
amount: number | null;
id: string | null;
})[];
}) | null;
/** Format: double */
next_payment_attempt: number | null;
currency: string | null;
}) | null;
};
};
};
Expand Down Expand Up @@ -4350,7 +4375,26 @@ export interface operations {
/** @description Ok */
200: {
content: {
"application/json": unknown;
"application/json": ({
items: ({
price: {
product: ({
name: string | null;
}) | null;
};
/** Format: double */
quantity?: number;
})[];
/** Format: double */
trial_end: number | null;
id: string;
/** Format: double */
current_period_start: number;
/** Format: double */
current_period_end: number;
cancel_at_period_end: boolean;
status: string;
}) | null;
};
};
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class OrganizationController extends Controller {
@Request() request: JawnAuthenticatedRequest
): Promise<Result<null, string>> {
const organizationManager = new OrganizationManager(request.authParams);
const memberCount = await organizationManager.getMemberCount();
const memberCount = await organizationManager.getMemberCount(true);
if (memberCount.error || !memberCount.data) {
return err(memberCount.error ?? "Error getting member count");
}
Expand Down Expand Up @@ -281,7 +281,7 @@ export class OrganizationController extends Controller {
const stripeManager = new StripeManager(request.authParams);
const organizationManager = new OrganizationManager(request.authParams);

const memberCount = await organizationManager.getMemberCount();
const memberCount = await organizationManager.getMemberCount(true);
if (memberCount.error || !memberCount.data) {
return err(memberCount.error ?? "Error getting member count");
}
Expand Down
68 changes: 64 additions & 4 deletions valhalla/jawn/src/controllers/public/stripeController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import Stripe from "stripe";
import { JawnAuthenticatedRequest } from "../../types/request";
import { StripeManager } from "../../managers/stripe/StripeManager";
import { Result } from "../../lib/shared/result";

export interface UpgradeToProRequest {
addons?: {
Expand Down Expand Up @@ -148,7 +149,26 @@ export class StripeController extends Controller {
@Get("/subscription/preview-invoice")
public async previewInvoice(
@Request() request: JawnAuthenticatedRequest
): Promise<any> {
): Promise<{
currency: string | null;
next_payment_attempt: number | null;
lines: {
data: {
id: string | null;
amount: number | null;
description: string | null;
}[];
} | null;
discount: {
coupon: {
name: string | null;
percent_off: number | null;
};
} | null;
subtotal: number;
tax: number | null;
total: number;
} | null> {
const stripeManager = new StripeManager(request.authParams);
const result = await stripeManager.getUpcomingInvoice();

Expand All @@ -157,7 +177,15 @@ export class StripeController extends Controller {
throw new Error(result.error);
}

return result.data;
return {
currency: result.data?.currency ?? null,
next_payment_attempt: result.data?.next_payment_attempt ?? null,
lines: result.data?.lines ?? null,
discount: result.data?.discount ?? null,
subtotal: result.data?.subtotal ?? 0,
tax: result.data?.tax ?? null,
total: result.data?.total ?? 0,
};
}

@Post("/subscription/cancel-subscription")
Expand All @@ -184,7 +212,22 @@ export class StripeController extends Controller {
@Get("/subscription")
public async getSubscription(
@Request() request: JawnAuthenticatedRequest
): Promise<any> {
): Promise<{
status: string;
cancel_at_period_end: boolean;
current_period_end: number;
current_period_start: number;
id: string;
trial_end: number | null;
items: {
quantity?: number;
price: {
product: {
name: string | null;
} | null;
};
}[];
} | null> {
const stripeManager = new StripeManager(request.authParams);
const result = await stripeManager.getSubscription();

Expand All @@ -193,7 +236,24 @@ export class StripeController extends Controller {
throw new Error(result.error);
}

return result.data;
if (!result.data) return null;

return {
status: result.data.status,
cancel_at_period_end: result.data.cancel_at_period_end,
current_period_end: result.data.current_period_end,
current_period_start: result.data.current_period_start,
id: result.data.id,
trial_end: result.data.trial_end,
items: result.data.items.data.map((item) => ({
quantity: item.quantity,
price: {
product: {
name: ((item.price.product as any)?.name ?? null) as string | null,
},
},
})),
};
}

@Post("/webhook")
Expand Down
11 changes: 9 additions & 2 deletions valhalla/jawn/src/managers/organization/OrganizationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ export class OrganizationManager extends BaseManager {
return ok(layout);
}

async getMemberCount(): Promise<Result<number, string>> {
async getMemberCount(
filterHeliconeEmails: boolean = false
): Promise<Result<number, string>> {
const { data: members, error: membersError } =
await this.organizationStore.getOrganizationMembers(
this.authParams.organizationId
Expand All @@ -367,7 +369,12 @@ export class OrganizationManager extends BaseManager {
if (membersError !== null) {
return err(membersError);
}
return ok(members.length);
return ok(
members.filter(
(member) =>
!filterHeliconeEmails || !member.email.endsWith("@helicone.ai")
).length
);
}

async getOrganizationMembers(
Expand Down
Loading
Loading