Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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.
8 changes: 5 additions & 3 deletions packages/react-grab/src/core/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,12 @@ 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;
// eslint-disable-next-line @typescript-eslint/no-unused-vars -- need to omit init-only options from settableOptions to avoid circular dependency
const { enabled: _enabled, silent: _silent, ...settableOptions } = initialOptions;

return createRoot((dispose) => {
let disposed = false;
Expand Down
8 changes: 8 additions & 0 deletions packages/react-grab/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,18 @@ 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 {
enabled?: never;
silent?: never;
}

export interface SourceInfo {
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