Skip to content

Conversation

@adelrodriguez
Copy link
Collaborator

@adelrodriguez adelrodriguez commented Jan 30, 2026

Summary

  • migrate environment checks to std-env with browser/mobile overrides via import.meta.env and DEV
  • remove NODE_ENV preset/pass-through and delete utils environment shim
  • update url builder defaults and add std-env dependencies across apps/packages
  • update @init/error faultier integration and version

Testing

  • bun run format
  • bun run check (fails: faultier default export + no-unsafe-call lint in existing files)
  • bun run typecheck (fails: faultier default export in packages/error/src/fault.ts)
  • bun run test (fails: faultier default export)
  • bun run analyze

Greptile Overview

Greptile Summary

Replaces custom environment detection utilities with std-env library and removes NODE_ENV preset management across the monorepo.

Key Changes

  • Deleted packages/utils/src/environment.ts containing custom isDevelopment(), isProduction(), isCI() helpers
  • Migrated all environment checks to std-env constants (isDevelopment, isProduction, isCI, isTest)
  • Removed node() preset from env configurations (no longer validates NODE_ENV)
  • Updated createUrlBuilder default protocol from environment-based (http in dev, https in prod) to always https
  • Added isDevelopment override parameter to logger configuration for browser/mobile contexts where std-env may not auto-detect correctly
  • Changed function calls like isCI() to direct constant access isCI throughout codebase
  • Removed NODE_ENV from turbo.json globalPassThroughEnv

Migration Pattern

Apps using bundlers (Vite, Webpack) now use import.meta.env.DEV/import.meta.env.PROD for runtime environment checks, while packages use std-env constants. The logger accepts an explicit override to handle edge cases where auto-detection fails.

Confidence Score: 4/5

  • Safe to merge with awareness of protocol default change
  • The refactor is well-executed with comprehensive test updates and consistent migration pattern. Score reduced by one point due to the breaking change in createUrlBuilder default protocol behavior (now always defaults to https instead of environment-based). The PR author acknowledged this in testing notes, and previous thread confirms awareness, but requires verification that all call sites handle development http correctly.
  • Verify that all createUrlBuilder call sites explicitly pass protocol when http is needed in development

Important Files Changed

Filename Overview
packages/utils/src/environment.ts removed custom environment detection helpers in favor of std-env
packages/env/src/presets.ts replaced isCI() calls with isCI constant from std-env, removed node() preset
packages/utils/src/url.ts changed protocol default from environment-based to always https
packages/observability/src/logger/index.ts added isDevelopment override option, uses std-env import
turbo.json removed NODE_ENV from globalPassThroughEnv

Sequence Diagram

sequenceDiagram
    participant App as Application Code
    participant ImportMeta as import.meta.env
    participant StdEnv as std-env
    participant Logger as Logger Config
    participant Monitoring as Monitoring Setup
    
    Note over App,Monitoring: Environment Detection Flow
    
    App->>ImportMeta: Check import.meta.env.DEV
    ImportMeta-->>App: Boolean (dev mode)
    App->>ImportMeta: Check import.meta.env.PROD
    ImportMeta-->>App: Boolean (prod mode)
    
    App->>Logger: configureLogger({ isDevelopment })
    Logger->>StdEnv: import { isDevelopment }
    StdEnv-->>Logger: Boolean constant
    Logger->>Logger: Use override or std-env default
    Logger-->>App: Logger configured
    
    App->>Monitoring: initializeErrorMonitoring()
    Monitoring->>StdEnv: import { isProduction }
    StdEnv-->>Monitoring: Boolean constant
    Monitoring->>Monitoring: Set sample rate based on env
    Monitoring-->>App: Monitoring initialized
    
    App->>App: createUrlBuilder(url, protocol)
    Note over App: Protocol defaults to 'https'<br/>Override with import.meta.env.PROD check
Loading

@coderabbitai
Copy link

coderabbitai bot commented Jan 30, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • 🔍 Trigger a full review
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/std-env

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@adelrodriguez adelrodriguez changed the base branch from main to graphite-base/80 January 30, 2026 04:39
@adelrodriguez adelrodriguez changed the base branch from graphite-base/80 to refactor_replace_faultier_with_better-result_for_error_handling January 30, 2026 04:39
Copy link
Collaborator Author

adelrodriguez commented Jan 30, 2026

Base automatically changed from refactor_replace_faultier_with_better-result_for_error_handling to main January 30, 2026 04:39
@adelrodriguez adelrodriguez force-pushed the refactor/std-env branch 3 times, most recently from 19b338e to 749a555 Compare January 30, 2026 04:44
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@adelrodriguez adelrodriguez merged commit 7bb6c13 into main Jan 30, 2026
8 checks passed
@adelrodriguez adelrodriguez deleted the refactor/std-env branch January 30, 2026 04:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants