-
Notifications
You must be signed in to change notification settings - Fork 514
Replace Web3Forms with internal feedback emails #1244
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
0b9f5b6
Replace Web3Forms with internal feedback emails
mantrakp04 9500d5c
Merge branch 'dev' into codex/native-internal-feedback-emails
mantrakp04 afdb77b
Refactor internal feedback email handling and improve featurebase use…
mantrakp04 11c5e9b
Merge remote-tracking branch 'origin/dev' into codex/native-internal-…
mantrakp04 25d59e5
Merge branch 'dev' into codex/native-internal-feedback-emails
mantrakp04 76bb7d9
Merge branch 'dev' into codex/native-internal-feedback-emails
mantrakp04 9f6dce9
Merge branch 'dev' into codex/native-internal-feedback-emails
mantrakp04 2e2b717
Refactor feature request handling and feedback form validation
mantrakp04 5524d87
Merge branch 'dev' into codex/native-internal-feedback-emails
mantrakp04 853ef41
Update feedback endpoint test to reflect schema validation changes
mantrakp04 a9f90d0
Refactor feature request handling and improve error handling
mantrakp04 98cb134
Merge branch 'dev' into codex/native-internal-feedback-emails
mantrakp04 d752e53
Enhance internal feedback email configuration and improve loading sta…
mantrakp04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
apps/backend/src/app/api/latest/internal/feedback/route.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| import { sendSupportFeedbackEmail } from "@/lib/internal-feedback-emails"; | ||
| import { createSmartRouteHandler } from "@/route-handlers/smart-route-handler"; | ||
| import { adaptSchema, clientOrHigherAuthTypeSchema, emailSchema, yupBoolean, yupNumber, yupObject, yupString } from "@stackframe/stack-shared/dist/schema-fields"; | ||
|
|
||
| export const POST = createSmartRouteHandler({ | ||
| metadata: { | ||
| summary: "Submit support feedback", | ||
| description: "Send a support feedback message to the internal Stack Auth inbox", | ||
| tags: ["Internal"], | ||
| }, | ||
| request: yupObject({ | ||
| auth: yupObject({ | ||
| type: clientOrHigherAuthTypeSchema, | ||
| tenancy: adaptSchema.defined(), | ||
| user: adaptSchema.defined(), | ||
| project: yupObject({ | ||
| id: yupString().oneOf(["internal"]).defined(), | ||
| }).defined(), | ||
| }).defined(), | ||
| body: yupObject({ | ||
| name: yupString().optional().max(100), | ||
| email: emailSchema.defined().nonEmpty(), | ||
| message: yupString().defined().nonEmpty().max(5000), | ||
| }).defined(), | ||
|
mantrakp04 marked this conversation as resolved.
|
||
| method: yupString().oneOf(["POST"]).defined(), | ||
| }), | ||
| response: yupObject({ | ||
| statusCode: yupNumber().oneOf([200]).defined(), | ||
| bodyType: yupString().oneOf(["json"]).defined(), | ||
| body: yupObject({ | ||
| success: yupBoolean().oneOf([true]).defined(), | ||
| }).defined(), | ||
| }), | ||
| async handler({ auth, body }) { | ||
| await sendSupportFeedbackEmail({ | ||
| tenancy: auth.tenancy, | ||
| user: auth.user, | ||
| name: body.name ?? null, | ||
| email: body.email, | ||
| message: body.message, | ||
| }); | ||
|
|
||
| return { | ||
| statusCode: 200, | ||
| bodyType: "json", | ||
| body: { | ||
| success: true, | ||
| }, | ||
| }; | ||
| }, | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { UsersCrud } from "@stackframe/stack-shared/dist/interface/crud/users"; | ||
| import { getEnvVariable } from "@stackframe/stack-shared/dist/utils/env"; | ||
| import { StackAssertionError } from "@stackframe/stack-shared/dist/utils/errors"; | ||
| import { getOrCreateFeaturebaseUser as getOrCreateFeaturebaseUserShared, StackAuthUser } from "@stackframe/stack-shared/dist/utils/featurebase"; | ||
|
|
||
| export function getFeaturebaseApiKey(): string { | ||
| return getEnvVariable("STACK_FEATUREBASE_API_KEY", ""); | ||
| } | ||
|
|
||
| export function requireFeaturebaseApiKey(): string { | ||
| const key = getFeaturebaseApiKey(); | ||
| if (!key) { | ||
| throw new StackAssertionError("STACK_FEATUREBASE_API_KEY environment variable is not set"); | ||
| } | ||
| return key; | ||
| } | ||
|
|
||
| export function toFeaturebaseUserArgs(user: UsersCrud["Admin"]["Read"]): StackAuthUser { | ||
| return { | ||
| id: user.id, | ||
| primaryEmail: user.primary_email, | ||
| displayName: user.display_name, | ||
| profileImageUrl: user.profile_image_url, | ||
| }; | ||
| } | ||
|
|
||
| export async function getOrCreateFeaturebaseUserFromAuth(user: UsersCrud["Admin"]["Read"]) { | ||
| return await getOrCreateFeaturebaseUserShared(toFeaturebaseUserArgs(user)); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.