-
Notifications
You must be signed in to change notification settings - Fork 1
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
#86c0b8vp3: Impement Sentry generator using ast #50
Open
RuslanAktaev
wants to merge
25
commits into
main
Choose a base branch
from
86c0b8vp3-sentry-generator-with-ast
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
110600c
feat: implemented sentry generator
rbd2q 99b7a5f
feat: updated expo-app and next-app generators
rbd2q d7b7633
refactor: refactored sentry generator
rbd2q 743e548
feat: updated next and expo generators
rbd2q 81221c4
Merge branch 'main' into 86byre0hx-implement-sentry-generator
rbd2q 5f0234c
feat: Integrated tsquery
RuslanAktaev 17e75c7
feat: Resolved conflicts
RuslanAktaev 5647f01
feat: Integrated AST
RuslanAktaev e555fb9
feat: Added TODO
RuslanAktaev 434cb11
feat: Generator
RuslanAktaev f6fe466
feat: Resolved conflicts
RuslanAktaev 5ecf230
feat: Refactored functions
RuslanAktaev def2b0c
feat: Implemented sentry config for expo app
RuslanAktaev 2bc58a5
feat: Added dsn
RuslanAktaev fea129e
feat: Refactored generators
RuslanAktaev 14ac7ec
feat: Fixed for expo sentry generator
RuslanAktaev c7b5671
feat: Removed apps
RuslanAktaev 1c53262
feat: Clean trash
RuslanAktaev 789f624
feat: Removed test lib
RuslanAktaev aa84ee1
feat: Removed libs
RuslanAktaev 02fa500
deps: Fixed deps
RuslanAktaev 9cd39bc
feat: Removed extra scripts
RuslanAktaev 655cfb0
Merge branch 'main' into 86c0b8vp3-sentry-generator-with-ast
RuslanAktaev a5c7c6b
refactor: Created updateFile util function
RuslanAktaev 14b8ff3
fix: Fixed dsn name
RuslanAktaev 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 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 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export interface ExpoAppGeneratorSchema { | ||
name: string; | ||
directory: string; | ||
withSentry: boolean; | ||
} |
This file contains 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 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 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 |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export interface NextAppGeneratorSchema { | ||
name: string; | ||
directory: string; | ||
withSentry: boolean; | ||
} |
This file contains 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
23 changes: 23 additions & 0 deletions
23
plugin/src/generators/sentry/files/app/[locale]/global-error.tsx.template
This file contains 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,23 @@ | ||
'use client'; | ||
|
||
import * as Sentry from '@sentry/nextjs'; | ||
import NextError from 'next/error'; | ||
import { ReactElement, useEffect } from 'react'; | ||
|
||
interface GlobalErrorProps { | ||
error: Error & { digest?: string }; | ||
} | ||
|
||
export default function GlobalError({ error }: GlobalErrorProps): ReactElement { | ||
useEffect(() => { | ||
Sentry.captureException(error); | ||
}, [error]); | ||
|
||
return ( | ||
<html> | ||
<body> | ||
<NextError statusCode={undefined as any} /> | ||
</body> | ||
</html> | ||
); | ||
} |
22 changes: 22 additions & 0 deletions
22
plugin/src/generators/sentry/files/sentry.client.config.ts.template
This file contains 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,22 @@ | ||
import * as Sentry from '@sentry/nextjs'; | ||
|
||
Sentry.init({ | ||
dsn: '<%= dsn %>', | ||
|
||
// Adjust this value in production, or use tracesSampler for greater control | ||
tracesSampleRate: 1, | ||
|
||
debug: false, | ||
replaysOnErrorSampleRate: 1.0, | ||
|
||
// This sets the sample rate to be 10%. You may want this to be 100% while | ||
// in development and sample at a lower rate in production | ||
replaysSessionSampleRate: 0.1, | ||
|
||
// You can remove this option if you're not planning to use the Sentry Session Replay feature: | ||
integrations: [ | ||
Sentry.replayIntegration(), | ||
Sentry.inboundFiltersIntegration(), | ||
], | ||
denyUrls: ['localhost'], | ||
}); |
12 changes: 12 additions & 0 deletions
12
plugin/src/generators/sentry/files/sentry.edge.config.ts.template
This file contains 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,12 @@ | ||
import * as Sentry from '@sentry/nextjs'; | ||
|
||
Sentry.init({ | ||
dsn: '<%= dsn %>', | ||
|
||
// Adjust this value in production, or use tracesSampler for greater control | ||
tracesSampleRate: 1, | ||
|
||
debug: false, | ||
integrations: [Sentry.inboundFiltersIntegration()], | ||
denyUrls: ['localhost'] | ||
}); |
12 changes: 12 additions & 0 deletions
12
plugin/src/generators/sentry/files/sentry.server.config.ts.template
This file contains 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,12 @@ | ||
import * as Sentry from '@sentry/nextjs'; | ||
|
||
Sentry.init({ | ||
dsn: '<%= dsn %>', | ||
|
||
// Adjust this value in production, or use tracesSampler for greater control | ||
tracesSampleRate: 1, | ||
|
||
debug: false, | ||
integrations: [Sentry.inboundFiltersIntegration()], | ||
denyUrls: ['localhost'], | ||
}); |
This file contains 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,21 @@ | ||
import { formatFiles, Tree } from '@nx/devkit'; | ||
import { SentryGeneratorSchema } from './schema'; | ||
import { isExpoApp, isNextApp } from '../../shared/utils'; | ||
import { generateSentryNext, generateSentryExpo } from './utils'; | ||
|
||
export async function sentryGenerator( | ||
tree: Tree, | ||
options: SentryGeneratorSchema, | ||
) { | ||
const projectRoot = `apps/${options.directory}`; | ||
|
||
if (isNextApp(tree, projectRoot)) { | ||
generateSentryNext(tree, options, projectRoot); | ||
} else if (isExpoApp(tree, projectRoot)) { | ||
generateSentryExpo(tree, options, projectRoot); | ||
} | ||
|
||
await formatFiles(tree); | ||
} | ||
|
||
export default sentryGenerator; |
This file contains 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,5 @@ | ||
export interface SentryGeneratorSchema { | ||
name: string; | ||
directory: string; | ||
dsn: string; | ||
} |
This file contains 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,23 @@ | ||
{ | ||
"$schema": "https://json-schema.org/schema", | ||
"$id": "Sentry", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"directory": { | ||
"type": "string", | ||
"description": "", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "Enter the name of the directory in the 'apps/' folder (e.g: web)" | ||
}, | ||
"dsn": { | ||
"type": "string", | ||
"description": "", | ||
"x-prompt": "What is your Sentry DSN?" | ||
} | ||
}, | ||
"required": ["directory", "dsn"] | ||
} |
This file contains 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 @@ | ||
export * from './property-assignment-data'; |
7 changes: 7 additions & 0 deletions
7
plugin/src/generators/sentry/types/property-assignment-data.ts
This file contains 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,7 @@ | ||
import { Expression } from 'typescript'; | ||
|
||
export type PropertyAssignmentData = { | ||
key: string; | ||
initializer: Expression; | ||
comment?: string; | ||
}; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use selectProject from utils? So we can remove
x-prompt
for directory.Example: https://github.com/RonasIT/nx-generators/blob/main/plugin/src/generators/react-lib/generator.ts#L22