Skip to content
Merged
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
17 changes: 17 additions & 0 deletions src/actions/utils/environment/__tests__/environmentActions.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { afterEach, describe, expect, it } from 'vitest'
import { getPrivacyPolicyVersion } from '../environmentActions'

const testEnv = import.meta.env as unknown as Record<string, string | undefined>
const originalPrivacyPolicyVersion = testEnv['PRIVACY_POLICY_VERSION']

describe('environmentActions.getPrivacyPolicyVersion', () => {
afterEach(() => {
testEnv['PRIVACY_POLICY_VERSION'] = originalPrivacyPolicyVersion
})

it('returns the integration-injected privacy policy version', () => {
testEnv['PRIVACY_POLICY_VERSION'] = '2026-04-21'

expect(getPrivacyPolicyVersion()).toBe('2026-04-21')
})
})
7 changes: 4 additions & 3 deletions src/actions/utils/environment/environmentActions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ActionsFunctionError } from '../errors/ActionsFunctionError'
import {
DEV_SERVER_PORT,
PRIVACY_POLICY_VERSION,
PUBLIC_SENTRY_DSN,
PUBLIC_UPSTASH_SEARCH_READONLY_TOKEN,
PUBLIC_UPSTASH_SEARCH_REST_URL,
Expand Down Expand Up @@ -35,12 +34,14 @@ export function getDevServerPort(): number {
}

export function getPrivacyPolicyVersion(): string {
if (!PRIVACY_POLICY_VERSION) {
const privacyPolicyVersion = import.meta.env['PRIVACY_POLICY_VERSION']

if (!privacyPolicyVersion) {
throw new ActionsFunctionError(
'PRIVACY_POLICY_VERSION environment variable is not set. This should be injected by the PrivacyPolicyVersion integration.'
)
}
return PRIVACY_POLICY_VERSION
return privacyPolicyVersion
}

export function getPackageRelease(): string {
Expand Down
7 changes: 4 additions & 3 deletions src/components/scripts/utils/environmentClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* src/lib/config/environmentServer.ts for details.
*/
import {
PRIVACY_POLICY_VERSION,
PUBLIC_GOOGLE_MAPS_API_KEY,
PUBLIC_GOOGLE_MAP_ID,
PUBLIC_SENTRY_DSN,
Expand Down Expand Up @@ -90,12 +89,14 @@ export function getPackageRelease(): string {
* @throws {ClientScriptError} If PRIVACY_POLICY_VERSION is missing
*/
export function getPrivacyPolicyVersion(): string {
if (!PRIVACY_POLICY_VERSION) {
const privacyPolicyVersion = import.meta.env['PRIVACY_POLICY_VERSION']

if (!privacyPolicyVersion) {
throw new ClientScriptError(
'PRIVACY_POLICY_VERSION environment variable is not set. This should be injected by the PrivacyPolicyVersion integration.'
)
}
return PRIVACY_POLICY_VERSION
return privacyPolicyVersion
}

/**
Expand Down
Loading