Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
7 changes: 7 additions & 0 deletions .changeset/silent-intro-option.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"react-grab": minor
"grab": minor
"@react-grab/cli": minor
---

Add `silent` option to suppress the React Grab intro banner and version-check log. Useful when console output is forwarded to error tracking services like Sentry.
4 changes: 3 additions & 1 deletion packages/react-grab/src/core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,9 @@ export const init = (rawOptions?: Options): ReactGrabAPI => {
}
hasInited = true;

logIntro();
if (!initialOptions.silent) {
logIntro();
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars -- need to omit enabled from settableOptions to avoid circular dependency
const { enabled: _enabled, ...settableOptions } = initialOptions;
Expand Down
7 changes: 7 additions & 0 deletions packages/react-grab/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,13 @@ export interface Options {
* @default true
*/
freezeReactUpdates?: boolean;
/**
* Suppress the React Grab intro banner and version-check log.
* Useful when console output is forwarded to error tracking
* services like Sentry.
* @default false
*/
silent?: boolean;
Comment thread
cursor[bot] marked this conversation as resolved.
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Comment thread
vercel[bot] marked this conversation as resolved.
}

export interface SettableOptions extends Options {
Expand Down
3 changes: 3 additions & 0 deletions packages/react-grab/src/utils/get-script-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const parseOptionsFromJson = (rawValue: unknown): Partial<Options> | null => {
if (typeof rawValue.freezeReactUpdates === "boolean") {
parsedOptions.freezeReactUpdates = rawValue.freezeReactUpdates;
}
if (typeof rawValue.silent === "boolean") {
parsedOptions.silent = rawValue.silent;
}

if (Object.keys(parsedOptions).length === 0) return null;
return parsedOptions;
Expand Down