-
Notifications
You must be signed in to change notification settings - Fork 3.7k
feat(favicon): environment-distinct favicon (dev/staging), same wordmark #5588
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
Open
waleedlatif1
wants to merge
7
commits into
staging
Choose a base branch
from
feat/env-differentiated-favicons
base: staging
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
7 commits
Select commit
Hold shift + click to select a range
f21eb25
feat(favicon): environment-distinct favicon (dev/staging), same wordmark
waleedlatif1 1682470
fix(favicon): lighter pink/yellow hues, fix CI env-flags naming check
waleedlatif1 944c5e4
fix(favicon): resolve deployment tier at request time, not build time
waleedlatif1 1833d92
fix(favicon): resolve metadata at request time, fully honor whitelabe…
waleedlatif1 5412f70
refactor(favicon): eliminate duplicate icon-set map, add getDeploymen…
waleedlatif1 37a3b05
fix(favicon): close static/ISR bake-in gap, fix manifest whitelabel leak
waleedlatif1 1e42a73
fix(favicon): revert marketing-ISR-breaking force-dynamic, fix manife…
waleedlatif1 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| import { type NextRequest, NextResponse } from 'next/server' | ||
| import { getDeploymentEnv } from '@/lib/core/config/env-flags' | ||
| import { withRouteHandler } from '@/lib/core/utils/with-route-handler' | ||
| import { getBrandConfig, ICON_SETS } from '@/ee/whitelabeling' | ||
|
|
||
| export const dynamic = 'force-dynamic' | ||
|
|
||
| /** | ||
| * Redirect target for the legacy `/favicon.ico` path (rewritten here in | ||
| * `next.config.ts`), resolved per-request rather than baked into | ||
| * `next.config.ts`'s `rewrites()` directly. This app's Docker image is built | ||
| * once with dummy env values and promoted through dev/staging/production — | ||
| * `bootstrap.ts` hydrates `process.env` from AWS Secrets Manager at container | ||
| * boot, after the build already ran (`docker/app.Dockerfile`) — so a | ||
| * same-process-lifetime decision like `getDeploymentEnv()` must be evaluated | ||
| * here, at request time, not in `next.config.ts`, which only runs once during | ||
| * that shared build and would freeze whichever tier happened to be active | ||
| * then (never the tier the container actually ends up running as). | ||
| * | ||
| * Reuses {@link ICON_SETS} from `ee/whitelabeling/metadata.ts` rather than | ||
| * maintaining a second env-to-path map here, so the two can't drift apart. A | ||
| * whitelabeled deployment's own favicon always wins here too, matching | ||
| * `generateBrandedMetadata()` — a tenant on a dev/staging environment should | ||
| * never see Sim's internal tinted mark. | ||
| */ | ||
| export const GET = withRouteHandler(async (request: NextRequest) => { | ||
| const brand = getBrandConfig() | ||
| const destination = brand.faviconUrl || ICON_SETS[getDeploymentEnv()].svg | ||
| return NextResponse.redirect(new URL(destination, request.url)) | ||
| }) | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| /** | ||
| * @vitest-environment node | ||
| */ | ||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' | ||
|
|
||
| const { envRef } = vi.hoisted(() => ({ | ||
| envRef: { NODE_ENV: 'development' as string | undefined }, | ||
| })) | ||
|
|
||
| vi.mock('@/lib/core/config/env', () => ({ | ||
| get env() { | ||
| return envRef | ||
| }, | ||
| getEnv: (key: string) => process.env[key], | ||
| isFalsy: (v: unknown) => v === false || v === 'false' || v === '0', | ||
| isTruthy: (v: unknown) => v === true || v === 'true' || v === '1', | ||
| })) | ||
|
|
||
| import { getDeploymentEnv } from '@/lib/core/config/env-flags' | ||
|
|
||
| describe('getDeploymentEnv', () => { | ||
| const ENV_KEYS = [ | ||
| 'OTEL_DEPLOYMENT_ENVIRONMENT', | ||
| 'DEPLOYMENT_ENVIRONMENT', | ||
| 'APPCONFIG_ENVIRONMENT', | ||
| ] | ||
|
|
||
| beforeEach(() => { | ||
| for (const key of ENV_KEYS) delete process.env[key] | ||
| envRef.NODE_ENV = 'development' | ||
| }) | ||
|
|
||
| afterEach(() => { | ||
| for (const key of ENV_KEYS) delete process.env[key] | ||
| }) | ||
|
|
||
| it('resolves the dev tier from OTEL_DEPLOYMENT_ENVIRONMENT=dev', () => { | ||
| process.env.OTEL_DEPLOYMENT_ENVIRONMENT = 'dev' | ||
| expect(getDeploymentEnv()).toBe('development') | ||
| }) | ||
|
|
||
| it('resolves the staging tier from OTEL_DEPLOYMENT_ENVIRONMENT=staging', () => { | ||
| process.env.OTEL_DEPLOYMENT_ENVIRONMENT = 'staging' | ||
| expect(getDeploymentEnv()).toBe('staging') | ||
| }) | ||
|
|
||
| it('resolves the production tier from OTEL_DEPLOYMENT_ENVIRONMENT=prod', () => { | ||
| process.env.OTEL_DEPLOYMENT_ENVIRONMENT = 'prod' | ||
| expect(getDeploymentEnv()).toBe('production') | ||
| }) | ||
|
|
||
| it('maps APPCONFIG_ENVIRONMENT=production to the production tier when OTEL var is unset', () => { | ||
| process.env.APPCONFIG_ENVIRONMENT = 'production' | ||
| expect(getDeploymentEnv()).toBe('production') | ||
| }) | ||
|
|
||
| it('falls back to NODE_ENV when no deployment-tier env var is set', () => { | ||
| envRef.NODE_ENV = 'production' | ||
| expect(getDeploymentEnv()).toBe('production') | ||
| }) | ||
|
|
||
| it('defaults to development when nothing is set at all', () => { | ||
| envRef.NODE_ENV = undefined | ||
| expect(getDeploymentEnv()).toBe('development') | ||
| }) | ||
|
|
||
| it('prefers OTEL_DEPLOYMENT_ENVIRONMENT over DEPLOYMENT_ENVIRONMENT and APPCONFIG_ENVIRONMENT', () => { | ||
| process.env.OTEL_DEPLOYMENT_ENVIRONMENT = 'staging' | ||
| process.env.DEPLOYMENT_ENVIRONMENT = 'prod' | ||
| process.env.APPCONFIG_ENVIRONMENT = 'production' | ||
| expect(getDeploymentEnv()).toBe('staging') | ||
| }) | ||
|
|
||
| it('buckets an unrecognized tier value to development rather than throwing', () => { | ||
| process.env.OTEL_DEPLOYMENT_ENVIRONMENT = 'some-future-tier' | ||
| expect(getDeploymentEnv()).toBe('development') | ||
| }) | ||
| }) |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
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.