mirror of
https://github.com/formbricks/formbricks.git
synced 2026-05-13 19:38:37 -05:00
Compare commits
138 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5330477678 | |||
| f654ba6f83 | |||
| 4e3dcae02d | |||
| f141c53c68 | |||
| 0622407772 | |||
| a6c0b6bbfc | |||
| 527f8fd0d5 | |||
| 7a0da3a3e4 | |||
| 1ce8595bfd | |||
| 5113a4bd2c | |||
| 4430ed0d8d | |||
| ca15d9645d | |||
| 7306f60aff | |||
| 322a1b4e57 | |||
| cd40401ace | |||
| 86cc8fb8ff | |||
| 9bb487ab57 | |||
| 39064f9d2c | |||
| 6a6e213b3e | |||
| ee56cc10e7 | |||
| 7c47299775 | |||
| 92f4f04f7c | |||
| e072a0e889 | |||
| 4723a428e7 | |||
| d7692a1b76 | |||
| a08f2db40c | |||
| 48eb4fe705 | |||
| 26a2d50d45 | |||
| da5d9e27e1 | |||
| 8e2934d7bb | |||
| 799b86801d | |||
| 9d77b808d0 | |||
| 007d996870 | |||
| 9f59d7a967 | |||
| b9c647ef62 | |||
| 7770d43f9a | |||
| 615aa6aaad | |||
| f57ca755f4 | |||
| fd37b978c0 | |||
| d40ce9ce84 | |||
| 21c63bc400 | |||
| 77722aa638 | |||
| 2a9897370e | |||
| 5e85347bf5 | |||
| e4a9d28b4b | |||
| b79703f87e | |||
| 567cc4b893 | |||
| d9b37496fc | |||
| 87a06c846a | |||
| c5e02a597d | |||
| 1fec0ca7a6 | |||
| ae165eac87 | |||
| 7de5fdc383 | |||
| 3e61d31041 | |||
| d7e537f699 | |||
| 1e6c7609b6 | |||
| 59438d9afe | |||
| e234ed78cf | |||
| 74b168d727 | |||
| 2ed2da61cd | |||
| 729f269d4e | |||
| 41776d0001 | |||
| a2a6870a21 | |||
| 3ab62968e5 | |||
| d4f7f0f35d | |||
| a10cd0cb47 | |||
| 45100673f1 | |||
| 35f53769a5 | |||
| 22ad78a187 | |||
| 67076c4b4c | |||
| 74bfeb132e | |||
| 562b4047ae | |||
| 4791018546 | |||
| be1e546729 | |||
| 5bad0da477 | |||
| 9c776c5e4e | |||
| c50b46f715 | |||
| ce0a0573be | |||
| 3e27143ab1 | |||
| 018e2883ff | |||
| 85fb7ca956 | |||
| 2258699156 | |||
| b1a7b929bd | |||
| fded9a3bad | |||
| 4d84468269 | |||
| e6e010e801 | |||
| 8ced882406 | |||
| f7d462cc7f | |||
| f3d679d087 | |||
| c79a600efc | |||
| 7a8da3b84b | |||
| 4b2d48397d | |||
| 3ea81dc7c1 | |||
| d9b6b550a9 | |||
| 56a6ba08ba | |||
| 1ba55ff66c | |||
| 0cf621d76c | |||
| 3dc615fdc0 | |||
| 7157b17901 | |||
| 82c26941e4 | |||
| 591d5fa3d4 | |||
| 211bca1bd8 | |||
| 5a20839c5b | |||
| 85743bd3d0 | |||
| 335ec02361 | |||
| 7918523957 | |||
| 3b5fe4cb94 | |||
| 6bbd5ec7ef | |||
| c9542dcf79 | |||
| 4277a9dc34 | |||
| b1da63e47d | |||
| 8c05154a86 | |||
| 45122de652 | |||
| 2180bf98ba | |||
| 2d4a94721b | |||
| b2b97c8bed | |||
| f349f7199d | |||
| e7d8803a13 | |||
| 53a9b218bc | |||
| c618e7d473 | |||
| 3d0f703ae1 | |||
| 33eadaaa7b | |||
| 452617529c | |||
| 5951eea618 | |||
| e314feb416 | |||
| 0910b0f1a7 | |||
| 10ba42eb31 | |||
| 04f1e17e23 | |||
| 4642cc60c9 | |||
| 49fa5c587c | |||
| 4f9b48b5e5 | |||
| 80789327d0 | |||
| 38108a32d1 | |||
| ce4b64da0e | |||
| 9790b071d7 | |||
| 1f5ba0e60e | |||
| b502bbc91e | |||
| 6772ac7c20 |
@@ -1,272 +0,0 @@
|
||||
import { IntegrationType } from "@prisma/client";
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
||||
import { getCacheService } from "@formbricks/cache";
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { logger } from "@formbricks/logger";
|
||||
import { sendTelemetryEvents } from "./telemetry";
|
||||
|
||||
// Mock dependencies
|
||||
vi.mock("@formbricks/cache");
|
||||
vi.mock("@formbricks/database", () => ({
|
||||
prisma: {
|
||||
organization: {
|
||||
findFirst: vi.fn(),
|
||||
count: vi.fn(),
|
||||
},
|
||||
user: { count: vi.fn() },
|
||||
team: { count: vi.fn() },
|
||||
project: { count: vi.fn() },
|
||||
survey: { count: vi.fn() },
|
||||
response: {
|
||||
count: vi.fn(),
|
||||
findFirst: vi.fn(),
|
||||
},
|
||||
display: { count: vi.fn() },
|
||||
contact: { count: vi.fn() },
|
||||
segment: { count: vi.fn() },
|
||||
integration: { findMany: vi.fn() },
|
||||
account: { findMany: vi.fn() },
|
||||
$queryRaw: vi.fn(),
|
||||
},
|
||||
}));
|
||||
vi.mock("@formbricks/logger", () => ({
|
||||
logger: {
|
||||
error: vi.fn(),
|
||||
info: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
debug: vi.fn(),
|
||||
},
|
||||
}));
|
||||
vi.mock("@/lib/env", () => ({
|
||||
env: {
|
||||
SMTP_HOST: "smtp.example.com",
|
||||
S3_BUCKET_NAME: "my-bucket",
|
||||
PROMETHEUS_ENABLED: true,
|
||||
RECAPTCHA_SITE_KEY: "site-key",
|
||||
RECAPTCHA_SECRET_KEY: "secret-key",
|
||||
GITHUB_ID: "github-id",
|
||||
},
|
||||
}));
|
||||
|
||||
// Mock fetch
|
||||
const fetchMock = vi.fn();
|
||||
globalThis.fetch = fetchMock;
|
||||
|
||||
const mockCacheService = {
|
||||
get: vi.fn(),
|
||||
set: vi.fn(),
|
||||
tryLock: vi.fn(),
|
||||
del: vi.fn(),
|
||||
};
|
||||
|
||||
describe("sendTelemetryEvents", () => {
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
vi.useFakeTimers();
|
||||
// Set a fixed time far in the past to ensure we can always send telemetry
|
||||
vi.setSystemTime(new Date("2024-01-01T00:00:00.000Z"));
|
||||
|
||||
// Setup default cache behavior
|
||||
vi.mocked(getCacheService).mockResolvedValue({
|
||||
ok: true,
|
||||
data: mockCacheService as any,
|
||||
});
|
||||
mockCacheService.tryLock.mockResolvedValue({ ok: true, data: true }); // Lock acquired
|
||||
mockCacheService.del.mockResolvedValue({ ok: true, data: undefined });
|
||||
mockCacheService.get.mockResolvedValue({ ok: true, data: null }); // No last sent time
|
||||
mockCacheService.set.mockResolvedValue({ ok: true, data: undefined });
|
||||
|
||||
// Setup default prisma behavior
|
||||
vi.mocked(prisma.organization.findFirst).mockResolvedValue({
|
||||
id: "org-123",
|
||||
createdAt: new Date("2023-01-01"),
|
||||
} as any);
|
||||
|
||||
// Mock raw SQL query for counts (batched query)
|
||||
vi.mocked(prisma.$queryRaw).mockResolvedValue([
|
||||
{
|
||||
organizationCount: BigInt(1),
|
||||
userCount: BigInt(5),
|
||||
teamCount: BigInt(2),
|
||||
projectCount: BigInt(3),
|
||||
surveyCount: BigInt(10),
|
||||
inProgressSurveyCount: BigInt(4),
|
||||
completedSurveyCount: BigInt(6),
|
||||
responseCountAllTime: BigInt(100),
|
||||
responseCountSinceLastUpdate: BigInt(10),
|
||||
displayCount: BigInt(50),
|
||||
contactCount: BigInt(20),
|
||||
segmentCount: BigInt(4),
|
||||
newestResponseAt: new Date("2024-01-01T00:00:00.000Z"),
|
||||
},
|
||||
] as any);
|
||||
|
||||
// Mock other queries
|
||||
vi.mocked(prisma.integration.findMany).mockResolvedValue([{ type: IntegrationType.notion }] as any);
|
||||
vi.mocked(prisma.account.findMany).mockResolvedValue([{ provider: "github" }] as any);
|
||||
|
||||
fetchMock.mockResolvedValue({ ok: true });
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
test("should send telemetry successfully when conditions are met", async () => {
|
||||
await sendTelemetryEvents();
|
||||
|
||||
// Check lock acquisition
|
||||
expect(mockCacheService.tryLock).toHaveBeenCalledWith(
|
||||
"telemetry_lock",
|
||||
"locked",
|
||||
60 * 1000 // 1 minute TTL
|
||||
);
|
||||
|
||||
// Check data gathering
|
||||
expect(prisma.organization.findFirst).toHaveBeenCalled();
|
||||
expect(prisma.$queryRaw).toHaveBeenCalled();
|
||||
|
||||
// Check fetch call
|
||||
expect(fetchMock).toHaveBeenCalledTimes(1);
|
||||
const payload = JSON.parse(fetchMock.mock.calls[0][1].body);
|
||||
expect(payload.organizationCount).toBe(1);
|
||||
expect(payload.userCount).toBe(5);
|
||||
expect(payload.integrations.notion).toBe(true);
|
||||
expect(payload.sso.github).toBe(true);
|
||||
|
||||
// Check cache update (no TTL parameter)
|
||||
expect(mockCacheService.set).toHaveBeenCalledWith("telemetry_last_sent_ts", expect.any(String));
|
||||
|
||||
// Check lock release
|
||||
expect(mockCacheService.del).toHaveBeenCalledWith(["telemetry_lock"]);
|
||||
});
|
||||
|
||||
test("should skip if in-memory check fails", async () => {
|
||||
// Run once to set nextTelemetryCheck
|
||||
await sendTelemetryEvents();
|
||||
vi.clearAllMocks();
|
||||
|
||||
// Run again immediately (should fail in-memory check)
|
||||
await sendTelemetryEvents();
|
||||
|
||||
expect(getCacheService).not.toHaveBeenCalled();
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("should skip if Redis last sent time is recent", async () => {
|
||||
// Mock last sent time as recent
|
||||
const recentTime = Date.now() - 1000 * 60 * 60; // 1 hour ago
|
||||
mockCacheService.get.mockResolvedValue({ ok: true, data: String(recentTime) });
|
||||
|
||||
await sendTelemetryEvents();
|
||||
|
||||
expect(mockCacheService.tryLock).not.toHaveBeenCalled(); // No lock attempt
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("should skip if lock cannot be acquired", async () => {
|
||||
mockCacheService.tryLock.mockResolvedValue({ ok: true, data: false }); // Lock not acquired
|
||||
|
||||
await sendTelemetryEvents();
|
||||
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
expect(mockCacheService.del).not.toHaveBeenCalled(); // Shouldn't try to delete lock we didn't acquire
|
||||
});
|
||||
|
||||
test("should handle cache service failure gracefully", async () => {
|
||||
vi.mocked(getCacheService).mockResolvedValue({
|
||||
ok: false,
|
||||
error: new Error("Cache error"),
|
||||
} as any);
|
||||
|
||||
await sendTelemetryEvents();
|
||||
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
// Should verify that nextTelemetryCheck was updated, but it's a module variable.
|
||||
// We can infer it by running again and checking calls
|
||||
vi.clearAllMocks();
|
||||
await sendTelemetryEvents();
|
||||
expect(getCacheService).not.toHaveBeenCalled(); // Should be blocked by in-memory check
|
||||
});
|
||||
|
||||
test("should handle telemetry send failure and apply cooldown", async () => {
|
||||
// Reset module to clear nextTelemetryCheck state from previous tests
|
||||
vi.resetModules();
|
||||
const { sendTelemetryEvents: freshSendTelemetryEvents } = await import("./telemetry");
|
||||
|
||||
// Ensure we can acquire lock by setting last sent time far in the past
|
||||
const oldTime = Date.now() - 25 * 60 * 60 * 1000; // 25 hours ago
|
||||
mockCacheService.get.mockResolvedValue({ ok: true, data: String(oldTime) });
|
||||
mockCacheService.tryLock.mockResolvedValue({ ok: true, data: true }); // Lock acquired
|
||||
|
||||
// Make fetch fail to trigger the catch block
|
||||
const networkError = new Error("Network error");
|
||||
fetchMock.mockRejectedValue(networkError);
|
||||
|
||||
await freshSendTelemetryEvents();
|
||||
|
||||
// Verify lock was acquired
|
||||
expect(mockCacheService.tryLock).toHaveBeenCalledWith("telemetry_lock", "locked", 60 * 1000);
|
||||
|
||||
// The error should be caught in the inner catch block
|
||||
// The actual implementation logs as warning, not error
|
||||
expect(logger.warn).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
error: networkError,
|
||||
message: "Network error",
|
||||
}),
|
||||
"Failed to send telemetry - applying 1h cooldown"
|
||||
);
|
||||
|
||||
// Lock should be released in finally block
|
||||
expect(mockCacheService.del).toHaveBeenCalledWith(["telemetry_lock"]);
|
||||
|
||||
// Cache should not be updated on failure
|
||||
expect(mockCacheService.set).not.toHaveBeenCalled();
|
||||
|
||||
// Verify cooldown: run again immediately (should be blocked by in-memory check)
|
||||
vi.clearAllMocks();
|
||||
mockCacheService.get.mockResolvedValue({ ok: true, data: null });
|
||||
mockCacheService.tryLock.mockResolvedValue({ ok: true, data: true });
|
||||
await freshSendTelemetryEvents();
|
||||
expect(getCacheService).not.toHaveBeenCalled(); // Should be blocked by in-memory check
|
||||
});
|
||||
|
||||
test("should skip if no organization exists", async () => {
|
||||
// Reset module to clear nextTelemetryCheck state from previous tests
|
||||
vi.resetModules();
|
||||
const { sendTelemetryEvents: freshSendTelemetryEvents } = await import("./telemetry");
|
||||
|
||||
// Ensure we can acquire lock by setting last sent time far in the past
|
||||
const oldTime = Date.now() - 25 * 60 * 60 * 1000; // 25 hours ago
|
||||
|
||||
// Re-setup mocks after resetModules
|
||||
vi.mocked(getCacheService).mockResolvedValue({
|
||||
ok: true,
|
||||
data: mockCacheService as any,
|
||||
});
|
||||
mockCacheService.tryLock.mockResolvedValue({ ok: true, data: true }); // Lock acquired
|
||||
mockCacheService.del.mockResolvedValue({ ok: true, data: undefined });
|
||||
mockCacheService.get.mockResolvedValue({ ok: true, data: String(oldTime) });
|
||||
mockCacheService.set.mockResolvedValue({ ok: true, data: undefined });
|
||||
|
||||
vi.mocked(prisma.organization.findFirst).mockResolvedValue(null);
|
||||
|
||||
await freshSendTelemetryEvents();
|
||||
|
||||
// sendTelemetry returns early when no org exists
|
||||
// Since it returns (not throws), the try block completes successfully
|
||||
// Then cache.set is called, and finally block executes
|
||||
expect(fetchMock).not.toHaveBeenCalled();
|
||||
|
||||
// Verify lock was acquired (prerequisite for finally block to execute)
|
||||
expect(mockCacheService.tryLock).toHaveBeenCalledWith("telemetry_lock", "locked", 60 * 1000);
|
||||
|
||||
// Lock should be released in finally block
|
||||
expect(mockCacheService.del).toHaveBeenCalledWith(["telemetry_lock"]);
|
||||
|
||||
// Note: The current implementation calls cache.set even when no org exists
|
||||
// This might be a bug, but we test the actual behavior
|
||||
expect(mockCacheService.set).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,270 +0,0 @@
|
||||
import { IntegrationType } from "@prisma/client";
|
||||
import { type CacheKey, getCacheService } from "@formbricks/cache";
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { logger } from "@formbricks/logger";
|
||||
import { env } from "@/lib/env";
|
||||
import { getInstanceInfo } from "@/lib/instance";
|
||||
import packageJson from "@/package.json";
|
||||
|
||||
const TELEMETRY_INTERVAL_MS = 24 * 60 * 60 * 1000; // 24 hours
|
||||
const TELEMETRY_LOCK_KEY = "telemetry_lock" as CacheKey;
|
||||
const TELEMETRY_LAST_SENT_KEY = "telemetry_last_sent_ts" as CacheKey;
|
||||
|
||||
/**
|
||||
* In-memory timestamp for the next telemetry check.
|
||||
* This is a fast, process-local check to avoid unnecessary Redis calls.
|
||||
* Updated after each check to prevent redundant executions.
|
||||
*/
|
||||
let nextTelemetryCheck = 0;
|
||||
|
||||
/**
|
||||
* Sends telemetry events to Formbricks Enterprise endpoint.
|
||||
* Uses a three-layer check system to prevent duplicate submissions:
|
||||
* 1. In-memory check (fast, process-local)
|
||||
* 2. Redis check (shared across instances, persists across restarts)
|
||||
* 3. Distributed lock (prevents concurrent execution in multi-instance deployments)
|
||||
*/
|
||||
export const sendTelemetryEvents = async () => {
|
||||
try {
|
||||
const now = Date.now();
|
||||
|
||||
// ============================================================
|
||||
// CHECK 1: In-Memory Check (Fast Path)
|
||||
// ============================================================
|
||||
// Purpose: Quick process-local check to avoid Redis calls if we recently checked.
|
||||
// How it works: If current time is before nextTelemetryCheck, skip entirely.
|
||||
// This is updated after each successful check or failure to prevent spam.
|
||||
if (now < nextTelemetryCheck) {
|
||||
return;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// CHECK 2: Redis Check (Shared State)
|
||||
// ============================================================
|
||||
// Purpose: Check if telemetry was sent recently by ANY instance (shared across cluster).
|
||||
// This persists across restarts and works in multi-instance deployments.
|
||||
|
||||
const cacheServiceResult = await getCacheService();
|
||||
if (!cacheServiceResult.ok) {
|
||||
// Redis unavailable: Fallback to in-memory cooldown to avoid spamming.
|
||||
// Wait 1 hour before trying again. This prevents hammering Redis when it's down.
|
||||
nextTelemetryCheck = now + 60 * 60 * 1000;
|
||||
return;
|
||||
}
|
||||
const cache = cacheServiceResult.data;
|
||||
|
||||
// Get the timestamp of when telemetry was last sent (from any instance).
|
||||
const lastSentResult = await cache.get(TELEMETRY_LAST_SENT_KEY);
|
||||
const lastSentStr = lastSentResult.ok && lastSentResult.data ? (lastSentResult.data as string) : null;
|
||||
const lastSent = lastSentStr ? Number.parseInt(lastSentStr, 10) : 0;
|
||||
|
||||
// If less than 24 hours have passed since last telemetry, skip.
|
||||
// Update in-memory check to match remaining time for fast-path optimization.
|
||||
if (now - lastSent < TELEMETRY_INTERVAL_MS) {
|
||||
nextTelemetryCheck = lastSent + TELEMETRY_INTERVAL_MS;
|
||||
return;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// CHECK 3: Distributed Lock (Prevent Concurrent Execution)
|
||||
// ============================================================
|
||||
// Purpose: Ensure only ONE instance executes telemetry at a time in a cluster.
|
||||
// How it works:
|
||||
// - Uses Redis SET NX (only set if not exists) for atomic lock acquisition
|
||||
// - Lock expires after 1 minute (TTL) to prevent deadlocks if instance crashes
|
||||
// - If lock exists, another instance is already running telemetry, so we exit
|
||||
// - Lock is released in finally block after telemetry completes or fails
|
||||
const lockResult = await cache.tryLock(TELEMETRY_LOCK_KEY, "locked", 60 * 1000); // 1 minute TTL
|
||||
|
||||
if (!lockResult.ok || !lockResult.data) {
|
||||
// Lock acquisition failed or already held by another instance.
|
||||
// Exit silently - the other instance will handle telemetry.
|
||||
// No need to update nextTelemetryCheck here since we didn't execute.
|
||||
return;
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// EXECUTION: Send Telemetry
|
||||
// ============================================================
|
||||
// We've passed all checks and acquired the lock. Now execute telemetry.
|
||||
try {
|
||||
await sendTelemetry(lastSent);
|
||||
|
||||
// Success: Update Redis with current timestamp so other instances know telemetry was sent.
|
||||
// No TTL - persists indefinitely to support low-volume instances (responses every few days/weeks).
|
||||
await cache.set(TELEMETRY_LAST_SENT_KEY, now.toString());
|
||||
|
||||
// Update in-memory check to prevent this instance from checking again for 24h.
|
||||
nextTelemetryCheck = now + TELEMETRY_INTERVAL_MS;
|
||||
} catch (e) {
|
||||
// Log as warning since telemetry is non-essential
|
||||
const errorMessage = e instanceof Error ? e.message : String(e);
|
||||
logger.warn(
|
||||
{ error: e, message: errorMessage, lastSent, now },
|
||||
"Failed to send telemetry - applying 1h cooldown"
|
||||
);
|
||||
|
||||
// Failure cooldown: Prevent retrying immediately to avoid hammering the endpoint.
|
||||
// Wait 1 hour before allowing this instance to try again.
|
||||
// Note: Other instances can still try (they'll hit the lock or Redis check).
|
||||
nextTelemetryCheck = now + 60 * 60 * 1000;
|
||||
} finally {
|
||||
// Always release the lock, even if telemetry failed.
|
||||
// This allows other instances to retry if this one failed.
|
||||
await cache.del([TELEMETRY_LOCK_KEY]);
|
||||
}
|
||||
} catch (error) {
|
||||
// Catch-all for any unexpected errors in the wrapper logic (cache failures, lock issues, etc.)
|
||||
// Log as warning since telemetry is non-essential functionality
|
||||
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||
logger.warn(
|
||||
{ error, message: errorMessage, timestamp: Date.now() },
|
||||
"Unexpected error in sendTelemetryEvents wrapper - telemetry check skipped"
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Gathers telemetry data and sends it to Formbricks Enterprise endpoint.
|
||||
* @param lastSent - Timestamp of last telemetry send (used to calculate incremental metrics)
|
||||
*/
|
||||
const sendTelemetry = async (lastSent: number) => {
|
||||
// Get the instance info (hashed oldest organization ID and creation date).
|
||||
// Using the oldest org ensures the ID doesn't change over time.
|
||||
const instanceInfo = await getInstanceInfo();
|
||||
if (!instanceInfo) return; // No organization exists, nothing to report
|
||||
|
||||
const { instanceId, createdAt: instanceCreatedAt } = instanceInfo;
|
||||
|
||||
// Optimize database queries to reduce connection pool usage:
|
||||
// Instead of 15 parallel queries (which could exhaust the connection pool),
|
||||
// we batch all count queries into a single raw SQL query.
|
||||
// This reduces connection usage from 15 → 3 (batch counts + integrations + accounts).
|
||||
const [countsResult, integrations, ssoProviders] = await Promise.all([
|
||||
// Single query for all counts (13 metrics in one round-trip)
|
||||
prisma.$queryRaw<
|
||||
[
|
||||
{
|
||||
organizationCount: bigint;
|
||||
userCount: bigint;
|
||||
teamCount: bigint;
|
||||
projectCount: bigint;
|
||||
surveyCount: bigint;
|
||||
inProgressSurveyCount: bigint;
|
||||
completedSurveyCount: bigint;
|
||||
responseCountAllTime: bigint;
|
||||
responseCountSinceLastUpdate: bigint;
|
||||
displayCount: bigint;
|
||||
contactCount: bigint;
|
||||
segmentCount: bigint;
|
||||
newestResponseAt: Date | null;
|
||||
},
|
||||
]
|
||||
>`
|
||||
SELECT
|
||||
(SELECT COUNT(*) FROM "Organization") as "organizationCount",
|
||||
(SELECT COUNT(*) FROM "User") as "userCount",
|
||||
(SELECT COUNT(*) FROM "Team") as "teamCount",
|
||||
(SELECT COUNT(*) FROM "Project") as "projectCount",
|
||||
(SELECT COUNT(*) FROM "Survey") as "surveyCount",
|
||||
(SELECT COUNT(*) FROM "Survey" WHERE status = 'inProgress') as "inProgressSurveyCount",
|
||||
(SELECT COUNT(*) FROM "Survey" WHERE status = 'completed') as "completedSurveyCount",
|
||||
(SELECT COUNT(*) FROM "Response") as "responseCountAllTime",
|
||||
(SELECT COUNT(*) FROM "Response" WHERE "created_at" > ${new Date(lastSent || 0)}) as "responseCountSinceLastUpdate",
|
||||
(SELECT COUNT(*) FROM "Display") as "displayCount",
|
||||
(SELECT COUNT(*) FROM "Contact") as "contactCount",
|
||||
(SELECT COUNT(*) FROM "Segment") as "segmentCount",
|
||||
(SELECT MAX("created_at") FROM "Response") as "newestResponseAt"
|
||||
`,
|
||||
// Keep these as separate queries since they need DISTINCT which is harder to optimize
|
||||
prisma.integration.findMany({ select: { type: true }, distinct: ["type"] }),
|
||||
prisma.account.findMany({ select: { provider: true }, distinct: ["provider"] }),
|
||||
]);
|
||||
|
||||
// Extract metrics from the batched query result and convert bigints to numbers
|
||||
const counts = countsResult[0];
|
||||
const organizationCount = Number(counts.organizationCount);
|
||||
const userCount = Number(counts.userCount);
|
||||
const teamCount = Number(counts.teamCount);
|
||||
const projectCount = Number(counts.projectCount);
|
||||
const surveyCount = Number(counts.surveyCount);
|
||||
const inProgressSurveyCount = Number(counts.inProgressSurveyCount);
|
||||
const completedSurveyCount = Number(counts.completedSurveyCount);
|
||||
const responseCountAllTime = Number(counts.responseCountAllTime);
|
||||
const responseCountSinceLastUpdate = Number(counts.responseCountSinceLastUpdate);
|
||||
const displayCount = Number(counts.displayCount);
|
||||
const contactCount = Number(counts.contactCount);
|
||||
const segmentCount = Number(counts.segmentCount);
|
||||
const newestResponse = counts.newestResponseAt ? { createdAt: counts.newestResponseAt } : null;
|
||||
|
||||
// Convert integration array to boolean map indicating which integrations are configured.
|
||||
const integrationMap = {
|
||||
notion: integrations.some((i) => i.type === IntegrationType.notion),
|
||||
googleSheets: integrations.some((i) => i.type === IntegrationType.googleSheets),
|
||||
airtable: integrations.some((i) => i.type === IntegrationType.airtable),
|
||||
slack: integrations.some((i) => i.type === IntegrationType.slack),
|
||||
};
|
||||
|
||||
// Check SSO configuration: either via environment variables or database records.
|
||||
// This detects which SSO providers are available/configured.
|
||||
const ssoMap = {
|
||||
github: !!env.GITHUB_ID || ssoProviders.some((p) => p.provider === "github"),
|
||||
google: !!env.GOOGLE_CLIENT_ID || ssoProviders.some((p) => p.provider === "google"),
|
||||
azureAd: !!env.AZUREAD_CLIENT_ID || ssoProviders.some((p) => p.provider === "azuread"),
|
||||
oidc: !!env.OIDC_CLIENT_ID || ssoProviders.some((p) => p.provider === "openid"),
|
||||
};
|
||||
|
||||
// Construct telemetry payload with usage statistics and configuration.
|
||||
const payload = {
|
||||
schemaVersion: 1, // Schema version for future compatibility
|
||||
// Core entity counts
|
||||
organizationCount,
|
||||
userCount,
|
||||
teamCount,
|
||||
projectCount,
|
||||
surveyCount,
|
||||
inProgressSurveyCount,
|
||||
completedSurveyCount,
|
||||
// Response metrics
|
||||
responseCountAllTime,
|
||||
responseCountSinceLastUsageUpdate: responseCountSinceLastUpdate, // Incremental since last telemetry
|
||||
displayCount,
|
||||
contactCount,
|
||||
segmentCount,
|
||||
integrations: integrationMap,
|
||||
infrastructure: {
|
||||
smtp: !!env.SMTP_HOST,
|
||||
s3: !!env.S3_BUCKET_NAME,
|
||||
prometheus: !!env.PROMETHEUS_ENABLED,
|
||||
},
|
||||
security: {
|
||||
recaptcha: !!(env.RECAPTCHA_SITE_KEY && env.RECAPTCHA_SECRET_KEY),
|
||||
},
|
||||
sso: ssoMap,
|
||||
meta: {
|
||||
version: packageJson.version, // Formbricks version for compatibility tracking
|
||||
},
|
||||
temporal: {
|
||||
instanceCreatedAt: instanceCreatedAt.toISOString(), // When instance was first created
|
||||
newestResponseAt: newestResponse?.createdAt.toISOString() || null, // Most recent activity
|
||||
},
|
||||
};
|
||||
|
||||
// Send telemetry to Formbricks Enterprise endpoint.
|
||||
// This endpoint collects usage statistics for enterprise license validation and analytics.
|
||||
const url = `https://ee.formbricks.com/api/v1/instances/${instanceId}/usage-updates`;
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeout = setTimeout(() => controller.abort(), 10000); // 10 second timeout
|
||||
|
||||
await fetch(url, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
clearTimeout(timeout);
|
||||
};
|
||||
@@ -3,7 +3,6 @@ import { headers } from "next/headers";
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { logger } from "@formbricks/logger";
|
||||
import { ResourceNotFoundError } from "@formbricks/types/errors";
|
||||
import { sendTelemetryEvents } from "@/app/api/(internal)/pipeline/lib/telemetry";
|
||||
import { ZPipelineInput } from "@/app/api/(internal)/pipeline/types/pipelines";
|
||||
import { responses } from "@/app/lib/api/response";
|
||||
import { transformErrorToDetails } from "@/app/lib/api/validator";
|
||||
@@ -51,22 +50,6 @@ export const POST = async (request: Request) => {
|
||||
throw new ResourceNotFoundError("Organization", "Organization not found");
|
||||
}
|
||||
|
||||
// Fetch survey for webhook payload
|
||||
const survey = await getSurvey(surveyId);
|
||||
if (!survey) {
|
||||
logger.error({ url: request.url, surveyId }, `Survey with id ${surveyId} not found`);
|
||||
|
||||
return responses.notFoundResponse("Survey", surveyId, true);
|
||||
}
|
||||
|
||||
if (survey.environmentId !== environmentId) {
|
||||
logger.error(
|
||||
{ url: request.url, surveyId, environmentId, surveyEnvironmentId: survey.environmentId },
|
||||
`Survey ${surveyId} does not belong to environment ${environmentId}`
|
||||
);
|
||||
return responses.badRequestResponse("Survey not found in this environment");
|
||||
}
|
||||
|
||||
// Fetch webhooks
|
||||
const getWebhooksForPipeline = async (environmentId: string, event: PipelineTriggers, surveyId: string) => {
|
||||
const webhooks = await prisma.webhook.findMany({
|
||||
@@ -97,16 +80,7 @@ export const POST = async (request: Request) => {
|
||||
body: JSON.stringify({
|
||||
webhookId: webhook.id,
|
||||
event,
|
||||
data: {
|
||||
...response,
|
||||
survey: {
|
||||
title: survey.name,
|
||||
type: survey.type,
|
||||
status: survey.status,
|
||||
createdAt: survey.createdAt,
|
||||
updatedAt: survey.updatedAt,
|
||||
},
|
||||
},
|
||||
data: response,
|
||||
}),
|
||||
}).catch((error) => {
|
||||
logger.error({ error, url: request.url }, `Webhook call to ${webhook.url} failed`);
|
||||
@@ -114,12 +88,18 @@ export const POST = async (request: Request) => {
|
||||
);
|
||||
|
||||
if (event === "responseFinished") {
|
||||
// Fetch integrations and responseCount in parallel
|
||||
const [integrations, responseCount] = await Promise.all([
|
||||
// Fetch integrations, survey, and responseCount in parallel
|
||||
const [integrations, survey, responseCount] = await Promise.all([
|
||||
getIntegrations(environmentId),
|
||||
getSurvey(surveyId),
|
||||
getResponseCountBySurveyId(surveyId),
|
||||
]);
|
||||
|
||||
if (!survey) {
|
||||
logger.error({ url: request.url, surveyId }, `Survey with id ${surveyId} not found`);
|
||||
return new Response("Survey not found", { status: 404 });
|
||||
}
|
||||
|
||||
if (integrations.length > 0) {
|
||||
await handleIntegrations(integrations, inputValidation.data, survey);
|
||||
}
|
||||
@@ -246,10 +226,6 @@ export const POST = async (request: Request) => {
|
||||
}
|
||||
});
|
||||
}
|
||||
if (event === "responseCreated") {
|
||||
// Send telemetry events
|
||||
await sendTelemetryEvents();
|
||||
}
|
||||
|
||||
return Response.json({ data: {} });
|
||||
};
|
||||
|
||||
@@ -1109,11 +1109,10 @@ const reviewPrompt = (t: TFunction): TTemplate => {
|
||||
required: false,
|
||||
buttonUrl: "https://formbricks.com/github",
|
||||
buttonExternal: true,
|
||||
ctaButtonLabel: t("templates.review_prompt_question_2_button_label"),
|
||||
}),
|
||||
],
|
||||
logic: [createBlockJumpLogic(reusableElementIds[1], localSurvey.endings[0].id, "isClicked")],
|
||||
buttonLabel: t("templates.next"),
|
||||
buttonLabel: t("templates.review_prompt_question_2_button_label"),
|
||||
backButtonLabel: t("templates.back"),
|
||||
t,
|
||||
}),
|
||||
@@ -1160,10 +1159,9 @@ const interviewPrompt = (t: TFunction): TTemplate => {
|
||||
buttonUrl: "https://cal.com/johannes",
|
||||
buttonExternal: true,
|
||||
required: false,
|
||||
ctaButtonLabel: t("templates.interview_prompt_question_1_button_label"),
|
||||
}),
|
||||
],
|
||||
buttonLabel: t("templates.next"),
|
||||
buttonLabel: t("templates.interview_prompt_question_1_button_label"),
|
||||
t,
|
||||
}),
|
||||
],
|
||||
@@ -2696,10 +2694,9 @@ const marketSiteClarity = (t: TFunction): TTemplate => {
|
||||
required: false,
|
||||
buttonUrl: "https://app.formbricks.com/auth/signup",
|
||||
buttonExternal: true,
|
||||
ctaButtonLabel: t("templates.market_site_clarity_question_3_button_label"),
|
||||
}),
|
||||
],
|
||||
buttonLabel: t("templates.next"),
|
||||
buttonLabel: t("templates.market_site_clarity_question_3_button_label"),
|
||||
t,
|
||||
}),
|
||||
],
|
||||
|
||||
+1
-2
@@ -17,8 +17,7 @@
|
||||
"zh-Hans-CN",
|
||||
"zh-Hant-TW",
|
||||
"nl-NL",
|
||||
"es-ES",
|
||||
"sv-SE"
|
||||
"es-ES"
|
||||
]
|
||||
},
|
||||
"version": 1.8
|
||||
|
||||
+4
-7
@@ -395,7 +395,6 @@ checksums:
|
||||
common/updated: 8aa8ff2dc2977ca4b269e80a513100b4
|
||||
common/updated_at: 8fdb85248e591254973403755dcc3724
|
||||
common/upload: 4a6c84aa16db0f4e5697f49b45257bc7
|
||||
common/upload_failed: d4dd7b6ee4c1572e4136659f74d9632b
|
||||
common/upload_input_description: 64f59bc339568d52b8464b82546b70ea
|
||||
common/url: ca97457614226960d41dd18c3c29c86b
|
||||
common/user: 61073457a5c3901084b557d065f876be
|
||||
@@ -1171,7 +1170,8 @@ checksums:
|
||||
environments/surveys/edit/automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds: 1be3819ffa1db67385357ae933d69a7b
|
||||
environments/surveys/edit/automatically_mark_the_survey_as_complete_after: c6ede2a5515a4ca72b36aec2583f43aa
|
||||
environments/surveys/edit/back_button_label: 25af945e77336724b5276de291cc92d9
|
||||
environments/surveys/edit/background_styling: eb4a06cf54a7271b493fab625d930570
|
||||
environments/surveys/edit/background_styling: 4e1e6fd2ec767bbff8767f6c0f68a731
|
||||
environments/surveys/edit/block_deleted: c682259eb138ad84f8b4441abfd9b572
|
||||
environments/surveys/edit/block_duplicated: dc9e9fab2b1cd91f6c265324b34c6376
|
||||
environments/surveys/edit/bold: 4d7306bc355ed2befd6a9237c5452ee6
|
||||
environments/surveys/edit/brand_color: 84ddb5736deb9f5c081ffe4962a6c63e
|
||||
@@ -1187,7 +1187,7 @@ checksums:
|
||||
environments/surveys/edit/card_arrangement_for_survey_type_derived: c06b9aaebcc11bc16e57a445b62361fc
|
||||
environments/surveys/edit/card_background_color: acd5d023e1d1a4471b053dce504c7a83
|
||||
environments/surveys/edit/card_border_color: 8d7c7f4cbd99f154ce892dfa258eb504
|
||||
environments/surveys/edit/card_styling: 47137a7e809b060ca94418202a8fd3c5
|
||||
environments/surveys/edit/card_styling: 01e88d58219539fb831e79f0bb3ce88e
|
||||
environments/surveys/edit/casual: 6534fe68718fade470a9031f7390409e
|
||||
environments/surveys/edit/caution_edit_duplicate: ee93bccb34fcd707e1ef4735f1c2fc31
|
||||
environments/surveys/edit/caution_edit_published_survey: faf7fc57c776f2a9104d143e20044486
|
||||
@@ -1243,7 +1243,6 @@ checksums:
|
||||
environments/surveys/edit/css_selector: 615e9f1b74622df29de28a5b5614c6fe
|
||||
environments/surveys/edit/cta_button_label: ec070ffba38eae24751bb3a4c1e14c81
|
||||
environments/surveys/edit/custom_hostname: bc2b1c8de3f9b8ef145b45aeba6ab429
|
||||
environments/surveys/edit/customize_survey_logo: 7f7e26026c88a727228f2d7a00d914e2
|
||||
environments/surveys/edit/darken_or_lighten_background_of_your_choice: 304a64a8050ebf501d195e948cd25b6f
|
||||
environments/surveys/edit/date_format: e95dfc41ac944874868487457ddc057a
|
||||
environments/surveys/edit/days_before_showing_this_survey_again: 354fb28c5ff076f022d82a20c749ee46
|
||||
@@ -1344,9 +1343,9 @@ checksums:
|
||||
environments/surveys/edit/hide_back_button_description: caaa30cf43c5611577933a1c9f44b9ee
|
||||
environments/surveys/edit/hide_block_settings: c24c3d3892c251792e297cdc036d2fde
|
||||
environments/surveys/edit/hide_logo: eef4de2e3fffe8cbe32bff4f6f7250d8
|
||||
environments/surveys/edit/hide_logo_from_survey: 9d44321539cc2b397376a35bb8b3d1cd
|
||||
environments/surveys/edit/hide_progress_bar: 7eefe7db6a051105bded521d94204933
|
||||
environments/surveys/edit/hide_question_settings: 99127cd016db2f7fc80333b36473c0ef
|
||||
environments/surveys/edit/hide_the_logo_in_this_specific_survey: 29d4c6c714886e57bc29ad292d0f5a00
|
||||
environments/surveys/edit/hostname: 9bdaa7692869999df51bb60d58d9ef62
|
||||
environments/surveys/edit/how_funky_do_you_want_your_cards_in_survey_type_derived_surveys: 3cb16b37510c01af20a80f51b598346e
|
||||
environments/surveys/edit/if_you_need_more_please: a7d208c283caf6b93800b809fca80768
|
||||
@@ -1393,7 +1392,6 @@ checksums:
|
||||
environments/surveys/edit/load_segment: 5341d3de37ff10f7526152e38e25e3c5
|
||||
environments/surveys/edit/logic_error_warning: 542fbb918ffdb29e6f9a4a6196ffb558
|
||||
environments/surveys/edit/logic_error_warning_text: f2afad8852a95ed169a39959efbf592c
|
||||
environments/surveys/edit/logo_settings: 9f54ca6684e989cc38bf177425b6d366
|
||||
environments/surveys/edit/long_answer: 3a97f8d2e90aba6e679917a0c5670c53
|
||||
environments/surveys/edit/long_answer_toggle_description: 86bcdfeb74d9825c2f2d5a215e92d111
|
||||
environments/surveys/edit/lower_label: 45985bca022d4370bd6e013af75d5160
|
||||
@@ -1426,7 +1424,6 @@ checksums:
|
||||
environments/surveys/edit/overwrite_global_waiting_time: 7bc23bd502b6bd048356b67acd956d9d
|
||||
environments/surveys/edit/overwrite_global_waiting_time_description: 795cf6e93d4c01d2e43aa0ebab601c6e
|
||||
environments/surveys/edit/overwrite_placement: d7278be243e52c5091974e0fc4a7c342
|
||||
environments/surveys/edit/overwrite_survey_logo: a89cb566dfcc1559446abd8b830c84ed
|
||||
environments/surveys/edit/overwrite_the_global_placement_of_the_survey: 874075712254b1ce92e099d89f675a48
|
||||
environments/surveys/edit/pick_a_background_from_our_library_or_upload_your_own: b83bcbdc8131fc9524d272ff5dede754
|
||||
environments/surveys/edit/picture_idx: 55e053ad1ade5d17c582406706036028
|
||||
|
||||
@@ -176,7 +176,6 @@ export const AVAILABLE_LOCALES: TUserLocale[] = [
|
||||
"ja-JP",
|
||||
"zh-Hans-CN",
|
||||
"es-ES",
|
||||
"sv-SE",
|
||||
];
|
||||
|
||||
// Billing constants
|
||||
|
||||
@@ -140,7 +140,6 @@ export const appLanguages = [
|
||||
"zh-Hans-CN": "英语(美国)",
|
||||
"nl-NL": "Engels (VS)",
|
||||
"es-ES": "Inglés (EE.UU.)",
|
||||
"sv-SE": "Engelska (USA)",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -157,7 +156,6 @@ export const appLanguages = [
|
||||
"zh-Hans-CN": "德语",
|
||||
"nl-NL": "Duits",
|
||||
"es-ES": "Alemán",
|
||||
"sv-SE": "Tyska",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -174,7 +172,6 @@ export const appLanguages = [
|
||||
"zh-Hans-CN": "葡萄牙语(巴西)",
|
||||
"nl-NL": "Portugees (Brazilië)",
|
||||
"es-ES": "Portugués (Brasil)",
|
||||
"sv-SE": "Portugisiska (Brasilien)",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -191,7 +188,6 @@ export const appLanguages = [
|
||||
"zh-Hans-CN": "法语",
|
||||
"nl-NL": "Frans",
|
||||
"es-ES": "Francés",
|
||||
"sv-SE": "Franska",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -203,12 +199,11 @@ export const appLanguages = [
|
||||
"fr-FR": "Chinois (Traditionnel)",
|
||||
"zh-Hant-TW": "繁體中文",
|
||||
"pt-PT": "Chinês (Tradicional)",
|
||||
"ro-RO": "Chineza (Tradițională)",
|
||||
"ro-RO": "Chineză (Tradicională)",
|
||||
"ja-JP": "中国語(繁体字)",
|
||||
"zh-Hans-CN": "繁体中文",
|
||||
"nl-NL": "Chinees (Traditioneel)",
|
||||
"es-ES": "Chino (Tradicional)",
|
||||
"sv-SE": "Kinesiska (traditionell)",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -225,7 +220,6 @@ export const appLanguages = [
|
||||
"zh-Hans-CN": "葡萄牙语(葡萄牙)",
|
||||
"nl-NL": "Portugees (Portugal)",
|
||||
"es-ES": "Portugués (Portugal)",
|
||||
"sv-SE": "Portugisiska (Portugal)",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -242,7 +236,6 @@ export const appLanguages = [
|
||||
"zh-Hans-CN": "罗马尼亚语",
|
||||
"nl-NL": "Roemeens",
|
||||
"es-ES": "Rumano",
|
||||
"sv-SE": "Rumänska",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -259,7 +252,6 @@ export const appLanguages = [
|
||||
"zh-Hans-CN": "日语",
|
||||
"nl-NL": "Japans",
|
||||
"es-ES": "Japonés",
|
||||
"sv-SE": "Japanska",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -271,12 +263,11 @@ export const appLanguages = [
|
||||
"fr-FR": "Chinois (Simplifié)",
|
||||
"zh-Hant-TW": "簡體中文",
|
||||
"pt-PT": "Chinês (Simplificado)",
|
||||
"ro-RO": "Chineza (Simplificată)",
|
||||
"ro-RO": "Chineză (Simplificată)",
|
||||
"ja-JP": "中国語(簡体字)",
|
||||
"zh-Hans-CN": "简体中文",
|
||||
"nl-NL": "Chinees (Vereenvoudigd)",
|
||||
"es-ES": "Chino (Simplificado)",
|
||||
"sv-SE": "Kinesiska (förenklad)",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -288,12 +279,11 @@ export const appLanguages = [
|
||||
"fr-FR": "Néerlandais",
|
||||
"zh-Hant-TW": "荷蘭語",
|
||||
"pt-PT": "Holandês",
|
||||
"ro-RO": "Olandeza",
|
||||
"ro-RO": "Olandeză",
|
||||
"ja-JP": "オランダ語",
|
||||
"zh-Hans-CN": "荷兰语",
|
||||
"nl-NL": "Nederlands",
|
||||
"es-ES": "Neerlandés",
|
||||
"sv-SE": "Nederländska",
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -310,24 +300,6 @@ export const appLanguages = [
|
||||
"zh-Hans-CN": "西班牙语",
|
||||
"nl-NL": "Spaans",
|
||||
"es-ES": "Español",
|
||||
"sv-SE": "Spanska",
|
||||
},
|
||||
},
|
||||
{
|
||||
code: "sv-SE",
|
||||
label: {
|
||||
"en-US": "Swedish",
|
||||
"de-DE": "Schwedisch",
|
||||
"pt-BR": "Sueco",
|
||||
"fr-FR": "Suédois",
|
||||
"zh-Hant-TW": "瑞典語",
|
||||
"pt-PT": "Sueco",
|
||||
"ro-RO": "Suedeză",
|
||||
"ja-JP": "スウェーデン語",
|
||||
"zh-Hans-CN": "瑞典语",
|
||||
"nl-NL": "Zweeds",
|
||||
"es-ES": "Sueco",
|
||||
"sv-SE": "Svenska",
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
import "server-only";
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { createHash } from "node:crypto";
|
||||
import { cache as reactCache } from "react";
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { DatabaseError } from "@formbricks/types/errors";
|
||||
|
||||
export type TInstanceInfo = {
|
||||
instanceId: string;
|
||||
createdAt: Date;
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns instance info including the anonymized instance ID and creation date.
|
||||
*
|
||||
* The instance ID is a SHA-256 hash of the oldest organization's ID, ensuring
|
||||
* it remains stable over time. Used for telemetry and license checks.
|
||||
*
|
||||
* @returns Instance info with hashed ID and creation date, or `null` if no organizations exist
|
||||
*/
|
||||
export const getInstanceInfo = reactCache(async (): Promise<TInstanceInfo | null> => {
|
||||
try {
|
||||
const oldestOrg = await prisma.organization.findFirst({
|
||||
orderBy: { createdAt: "asc" },
|
||||
select: { id: true, createdAt: true },
|
||||
});
|
||||
|
||||
if (!oldestOrg) return null;
|
||||
|
||||
return {
|
||||
instanceId: createHash("sha256").update(oldestOrg.id).digest("hex"),
|
||||
createdAt: oldestOrg.createdAt,
|
||||
};
|
||||
} catch (error) {
|
||||
if (error instanceof Prisma.PrismaClientKnownRequestError) {
|
||||
throw new DatabaseError(error.message);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Convenience function that returns just the instance ID.
|
||||
*
|
||||
* @returns Hashed instance ID, or `null` if no organizations exist
|
||||
*/
|
||||
export const getInstanceId = async (): Promise<string | null> => {
|
||||
const info = await getInstanceInfo();
|
||||
return info?.instanceId ?? null;
|
||||
};
|
||||
@@ -69,12 +69,6 @@ describe("Time Utilities", () => {
|
||||
const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000);
|
||||
expect(timeSince(oneHourAgo.toISOString(), "de-DE")).toBe("vor etwa 1 Stunde");
|
||||
});
|
||||
|
||||
test("should format time since in Swedish", () => {
|
||||
const now = new Date();
|
||||
const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000);
|
||||
expect(timeSince(oneHourAgo.toISOString(), "sv-SE")).toBe("ungefär en timme sedan");
|
||||
});
|
||||
});
|
||||
|
||||
describe("timeSinceDate", () => {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { formatDistance, intlFormat } from "date-fns";
|
||||
import { de, enUS, es, fr, ja, nl, pt, ptBR, ro, sv, zhCN, zhTW } from "date-fns/locale";
|
||||
import { de, enUS, es, fr, ja, nl, pt, ptBR, ro, zhCN, zhTW } from "date-fns/locale";
|
||||
import { TUserLocale } from "@formbricks/types/user";
|
||||
|
||||
export const convertDateString = (dateString: string | null) => {
|
||||
@@ -93,8 +93,6 @@ const getLocaleForTimeSince = (locale: TUserLocale) => {
|
||||
return fr;
|
||||
case "nl-NL":
|
||||
return nl;
|
||||
case "sv-SE":
|
||||
return sv;
|
||||
case "zh-Hant-TW":
|
||||
return zhTW;
|
||||
case "pt-PT":
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import * as nextHeaders from "next/headers";
|
||||
import { describe, expect, test, vi } from "vitest";
|
||||
import { AVAILABLE_LOCALES, DEFAULT_LOCALE } from "@/lib/constants";
|
||||
import { appLanguages } from "@/lib/i18n/utils";
|
||||
import { findMatchingLocale } from "./locale";
|
||||
|
||||
// Mock the Next.js headers function
|
||||
@@ -85,25 +84,4 @@ describe("locale", () => {
|
||||
expect(result).toBe(germanLocale);
|
||||
expect(nextHeaders.headers).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test("Swedish locale (sv-SE) is available and selectable", async () => {
|
||||
// Verify sv-SE is in AVAILABLE_LOCALES
|
||||
expect(AVAILABLE_LOCALES).toContain("sv-SE");
|
||||
|
||||
// Verify Swedish has a language entry with proper labels
|
||||
const swedishLanguage = appLanguages.find((lang) => lang.code === "sv-SE");
|
||||
expect(swedishLanguage).toBeDefined();
|
||||
expect(swedishLanguage?.label["en-US"]).toBe("Swedish");
|
||||
expect(swedishLanguage?.label["sv-SE"]).toBe("Svenska");
|
||||
|
||||
// Verify the locale can be matched from Accept-Language header
|
||||
vi.mocked(nextHeaders.headers).mockReturnValue({
|
||||
get: vi.fn().mockReturnValue("sv-SE,en-US"),
|
||||
} as any);
|
||||
|
||||
const result = await findMatchingLocale();
|
||||
|
||||
expect(result).toBe("sv-SE");
|
||||
expect(nextHeaders.headers).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "Aktualisiert",
|
||||
"updated_at": "Aktualisiert am",
|
||||
"upload": "Hochladen",
|
||||
"upload_failed": "Upload fehlgeschlagen. Bitte versuche es erneut.",
|
||||
"upload_input_description": "Klicke oder ziehe, um Dateien hochzuladen.",
|
||||
"url": "URL",
|
||||
"user": "Benutzer",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "Schließe die Umfrage automatisch, wenn der Benutzer nach einer bestimmten Anzahl von Sekunden nicht antwortet.",
|
||||
"automatically_mark_the_survey_as_complete_after": "Umfrage automatisch als abgeschlossen markieren nach",
|
||||
"back_button_label": "Zurück\"- Button ",
|
||||
"background_styling": "Hintergrundgestaltung",
|
||||
"background_styling": "Hintergründe",
|
||||
"block_duplicated": "Block dupliziert.",
|
||||
"bold": "Fett",
|
||||
"brand_color": "Markenfarbe",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "Kartenanordnung für {surveyTypeDerived} Umfragen",
|
||||
"card_background_color": "Hintergrundfarbe der Karte",
|
||||
"card_border_color": "Farbe des Kartenrandes",
|
||||
"card_styling": "Kartengestaltung",
|
||||
"card_styling": "Kartenstil",
|
||||
"casual": "Lässig",
|
||||
"caution_edit_duplicate": "Duplizieren & bearbeiten",
|
||||
"caution_edit_published_survey": "Eine veröffentlichte Umfrage bearbeiten?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "CSS-Selektor",
|
||||
"cta_button_label": "\"CTA\"-Schaltflächen-Beschriftung",
|
||||
"custom_hostname": "Benutzerdefinierter Hostname",
|
||||
"customize_survey_logo": "Umfragelogo anpassen",
|
||||
"darken_or_lighten_background_of_your_choice": "Hintergrund deiner Wahl abdunkeln oder aufhellen.",
|
||||
"date_format": "Datumsformat",
|
||||
"days_before_showing_this_survey_again": "Tage nachdem eine beliebige Umfrage angezeigt wurde, bevor diese Umfrage erscheinen kann.",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "Den Zurück-Button in der Umfrage nicht anzeigen",
|
||||
"hide_block_settings": "Block-Einstellungen ausblenden",
|
||||
"hide_logo": "Logo verstecken",
|
||||
"hide_logo_from_survey": "Logo in dieser Umfrage ausblenden",
|
||||
"hide_progress_bar": "Fortschrittsbalken ausblenden",
|
||||
"hide_question_settings": "Frageeinstellungen ausblenden",
|
||||
"hide_the_logo_in_this_specific_survey": "Logo in dieser speziellen Umfrage verstecken",
|
||||
"hostname": "Hostname",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "Wie funky sollen deine Karten in {surveyTypeDerived} Umfragen sein",
|
||||
"if_you_need_more_please": "Wenn Du mehr brauchst, bitte",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "Segment laden",
|
||||
"logic_error_warning": "Änderungen werden zu Logikfehlern führen",
|
||||
"logic_error_warning_text": "Das Ändern des Fragetypen entfernt die Logikbedingungen von dieser Frage",
|
||||
"logo_settings": "Logo-Einstellungen",
|
||||
"long_answer": "Lange Antwort",
|
||||
"long_answer_toggle_description": "Ermöglichen Sie den Befragten, längere Antworten über mehrere Zeilen zu schreiben.",
|
||||
"lower_label": "Unteres Label",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "Benutzerdefinierte Wartezeit festlegen",
|
||||
"overwrite_global_waiting_time_description": "Die Projektkonfiguration nur für diese Umfrage überschreiben.",
|
||||
"overwrite_placement": "Platzierung überschreiben",
|
||||
"overwrite_survey_logo": "Benutzerdefiniertes Umfragelogo festlegen",
|
||||
"overwrite_the_global_placement_of_the_survey": "Platzierung für diese Umfrage überschreiben",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "Wähle einen Hintergrund aus oder lade deinen eigenen hoch.",
|
||||
"picture_idx": "Bild {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "Updated",
|
||||
"updated_at": "Updated at",
|
||||
"upload": "Upload",
|
||||
"upload_failed": "Upload failed. Please try again.",
|
||||
"upload_input_description": "Click or drag to upload files.",
|
||||
"url": "URL",
|
||||
"user": "User",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "Automatically close the survey if the user does not respond after certain number of seconds.",
|
||||
"automatically_mark_the_survey_as_complete_after": "Automatically mark the survey as complete after",
|
||||
"back_button_label": "\"Back\" Button Label",
|
||||
"background_styling": "Background styling",
|
||||
"background_styling": "Background Styling",
|
||||
"block_duplicated": "Block duplicated.",
|
||||
"bold": "Bold",
|
||||
"brand_color": "Brand color",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "Card Arrangement for {surveyTypeDerived} Surveys",
|
||||
"card_background_color": "Card background color",
|
||||
"card_border_color": "Card border color",
|
||||
"card_styling": "Card styling",
|
||||
"card_styling": "Card Styling",
|
||||
"casual": "Casual",
|
||||
"caution_edit_duplicate": "Duplicate & edit",
|
||||
"caution_edit_published_survey": "Edit a published survey?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "CSS Selector",
|
||||
"cta_button_label": "\"CTA\" button label",
|
||||
"custom_hostname": "Custom hostname",
|
||||
"customize_survey_logo": "Customize the survey logo",
|
||||
"darken_or_lighten_background_of_your_choice": "Darken or lighten background of your choice.",
|
||||
"date_format": "Date format",
|
||||
"days_before_showing_this_survey_again": "days after any survey is shown before this survey can appear.",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "Do not display the back button in the survey",
|
||||
"hide_block_settings": "Hide Block settings",
|
||||
"hide_logo": "Hide logo",
|
||||
"hide_logo_from_survey": "Hide logo from this survey",
|
||||
"hide_progress_bar": "Hide progress bar",
|
||||
"hide_question_settings": "Hide Question settings",
|
||||
"hide_the_logo_in_this_specific_survey": "Hide the logo in this specific survey",
|
||||
"hostname": "Hostname",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "How funky do you want your cards in {surveyTypeDerived} Surveys",
|
||||
"if_you_need_more_please": "If you need more, please",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "Load segment",
|
||||
"logic_error_warning": "Changing will cause logic errors",
|
||||
"logic_error_warning_text": "Changing the question type will remove the logic conditions from this question",
|
||||
"logo_settings": "Logo settings",
|
||||
"long_answer": "Long answer",
|
||||
"long_answer_toggle_description": "Allow respondents to write longer, multi-line answers.",
|
||||
"lower_label": "Lower Label",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "Set custom waiting time",
|
||||
"overwrite_global_waiting_time_description": "Override the project configuration for this survey only.",
|
||||
"overwrite_placement": "Overwrite placement",
|
||||
"overwrite_survey_logo": "Set custom survey logo",
|
||||
"overwrite_the_global_placement_of_the_survey": "Overwrite the global placement of the survey",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "Pick a background from our library or upload your own.",
|
||||
"picture_idx": "Picture {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "Actualizado",
|
||||
"updated_at": "Actualizado el",
|
||||
"upload": "Subir",
|
||||
"upload_failed": "La subida ha fallado. Por favor, inténtalo de nuevo.",
|
||||
"upload_input_description": "Haz clic o arrastra para subir archivos.",
|
||||
"url": "URL",
|
||||
"user": "Usuario",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "Cerrar automáticamente la encuesta si el usuario no responde después de cierto número de segundos.",
|
||||
"automatically_mark_the_survey_as_complete_after": "Marcar automáticamente la encuesta como completa después de",
|
||||
"back_button_label": "Etiqueta del botón \"Atrás\"",
|
||||
"background_styling": "Estilo del fondo",
|
||||
"background_styling": "Estilo de fondo",
|
||||
"block_duplicated": "Bloque duplicado.",
|
||||
"bold": "Negrita",
|
||||
"brand_color": "Color de marca",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "Disposición de tarjetas para encuestas de tipo {surveyTypeDerived}",
|
||||
"card_background_color": "Color de fondo de la tarjeta",
|
||||
"card_border_color": "Color del borde de la tarjeta",
|
||||
"card_styling": "Estilo de la tarjeta",
|
||||
"card_styling": "Estilo de tarjeta",
|
||||
"casual": "Informal",
|
||||
"caution_edit_duplicate": "Duplicar y editar",
|
||||
"caution_edit_published_survey": "¿Editar una encuesta publicada?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "Selector CSS",
|
||||
"cta_button_label": "Etiqueta del botón \"CTA\"",
|
||||
"custom_hostname": "Nombre de host personalizado",
|
||||
"customize_survey_logo": "Personalizar el logotipo de la encuesta",
|
||||
"darken_or_lighten_background_of_your_choice": "Oscurece o aclara el fondo de tu elección.",
|
||||
"date_format": "Formato de fecha",
|
||||
"days_before_showing_this_survey_again": "días después de que se muestre cualquier encuesta antes de que esta encuesta pueda aparecer.",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "No mostrar el botón de retroceso en la encuesta",
|
||||
"hide_block_settings": "Ocultar ajustes del bloque",
|
||||
"hide_logo": "Ocultar logotipo",
|
||||
"hide_logo_from_survey": "Ocultar logotipo de esta encuesta",
|
||||
"hide_progress_bar": "Ocultar barra de progreso",
|
||||
"hide_question_settings": "Ocultar ajustes de la pregunta",
|
||||
"hide_the_logo_in_this_specific_survey": "Ocultar el logotipo en esta encuesta específica",
|
||||
"hostname": "Nombre de host",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "¿Cuánto estilo quieres darle a tus tarjetas en las encuestas de tipo {surveyTypeDerived}?",
|
||||
"if_you_need_more_please": "Si necesitas más, por favor",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "Cargar segmento",
|
||||
"logic_error_warning": "El cambio causará errores lógicos",
|
||||
"logic_error_warning_text": "Cambiar el tipo de pregunta eliminará las condiciones lógicas de esta pregunta",
|
||||
"logo_settings": "Ajustes del logotipo",
|
||||
"long_answer": "Respuesta larga",
|
||||
"long_answer_toggle_description": "Permitir a los encuestados escribir respuestas más largas y de varias líneas.",
|
||||
"lower_label": "Etiqueta inferior",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "Establecer tiempo de espera personalizado",
|
||||
"overwrite_global_waiting_time_description": "Anular la configuración del proyecto solo para esta encuesta.",
|
||||
"overwrite_placement": "Sobrescribir ubicación",
|
||||
"overwrite_survey_logo": "Establecer logotipo personalizado para la encuesta",
|
||||
"overwrite_the_global_placement_of_the_survey": "Sobrescribir la ubicación global de la encuesta",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "Elige un fondo de nuestra biblioteca o sube el tuyo propio.",
|
||||
"picture_idx": "Imagen {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "Mise à jour",
|
||||
"updated_at": "Mis à jour à",
|
||||
"upload": "Télécharger",
|
||||
"upload_failed": "Échec du téléchargement. Veuillez réessayer.",
|
||||
"upload_input_description": "Cliquez ou faites glisser pour charger un fichier.",
|
||||
"url": "URL",
|
||||
"user": "Utilisateur",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "Fermer automatiquement l'enquête si l'utilisateur ne répond pas après un certain nombre de secondes.",
|
||||
"automatically_mark_the_survey_as_complete_after": "Marquer automatiquement l'enquête comme terminée après",
|
||||
"back_button_label": "Label du bouton \"Retour''",
|
||||
"background_styling": "Style d'arrière-plan",
|
||||
"background_styling": "Style de fond",
|
||||
"block_duplicated": "Bloc dupliqué.",
|
||||
"bold": "Gras",
|
||||
"brand_color": "Couleur de marque",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "Sélecteur CSS",
|
||||
"cta_button_label": "Libellé du bouton « CTA »",
|
||||
"custom_hostname": "Nom d'hôte personnalisé",
|
||||
"customize_survey_logo": "Personnaliser le logo de l'enquête",
|
||||
"darken_or_lighten_background_of_your_choice": "Assombrir ou éclaircir l'arrière-plan de votre choix.",
|
||||
"date_format": "Format de date",
|
||||
"days_before_showing_this_survey_again": "jours après qu'une enquête soit affichée avant que cette enquête puisse apparaître.",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "Ne pas afficher le bouton retour dans l'enquête",
|
||||
"hide_block_settings": "Masquer les paramètres du bloc",
|
||||
"hide_logo": "Cacher le logo",
|
||||
"hide_logo_from_survey": "Masquer le logo de cette enquête",
|
||||
"hide_progress_bar": "Cacher la barre de progression",
|
||||
"hide_question_settings": "Masquer les paramètres de la question",
|
||||
"hide_the_logo_in_this_specific_survey": "Cacher le logo dans cette enquête spécifique",
|
||||
"hostname": "Nom d'hôte",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "À quel point voulez-vous que vos cartes soient funky dans les enquêtes {surveyTypeDerived}",
|
||||
"if_you_need_more_please": "Si vous en avez besoin de plus, s'il vous plaît",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "Segment de chargement",
|
||||
"logic_error_warning": "Changer causera des erreurs logiques",
|
||||
"logic_error_warning_text": "Changer le type de question supprimera les conditions logiques de cette question.",
|
||||
"logo_settings": "Paramètres du logo",
|
||||
"long_answer": "Longue réponse",
|
||||
"long_answer_toggle_description": "Permettre aux répondants d'écrire des réponses plus longues et sur plusieurs lignes.",
|
||||
"lower_label": "Étiquette inférieure",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "Définir un temps d'attente personnalisé",
|
||||
"overwrite_global_waiting_time_description": "Remplacer la configuration du projet pour cette enquête uniquement.",
|
||||
"overwrite_placement": "Surcharge de placement",
|
||||
"overwrite_survey_logo": "Définir un logo d'enquête personnalisé",
|
||||
"overwrite_the_global_placement_of_the_survey": "Surcharger le placement global de l'enquête",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "Choisissez un arrière-plan dans notre bibliothèque ou téléchargez le vôtre.",
|
||||
"picture_idx": "Image {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "更新済み",
|
||||
"updated_at": "更新日時",
|
||||
"upload": "アップロード",
|
||||
"upload_failed": "アップロードに失敗しました。もう一度お試しください。",
|
||||
"upload_input_description": "クリックまたはドラッグしてファイルをアップロードしてください。",
|
||||
"url": "URL",
|
||||
"user": "ユーザー",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "ユーザーが一定秒数応答しない場合、フォームを自動的に閉じます。",
|
||||
"automatically_mark_the_survey_as_complete_after": "フォームを自動的に完了としてマークする",
|
||||
"back_button_label": "「戻る」ボタンのラベル",
|
||||
"background_styling": "背景のスタイル設定",
|
||||
"background_styling": "背景のスタイル",
|
||||
"block_duplicated": "ブロックが複製されました。",
|
||||
"bold": "太字",
|
||||
"brand_color": "ブランドカラー",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "{surveyTypeDerived} フォームのカード配置",
|
||||
"card_background_color": "カードの背景色",
|
||||
"card_border_color": "カードの枠線の色",
|
||||
"card_styling": "カードのスタイル設定",
|
||||
"card_styling": "カードのスタイル",
|
||||
"casual": "カジュアル",
|
||||
"caution_edit_duplicate": "複製して編集",
|
||||
"caution_edit_published_survey": "公開済みのフォームを編集しますか?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "CSSセレクター",
|
||||
"cta_button_label": "\"CTA\"ボタンのラベル",
|
||||
"custom_hostname": "カスタムホスト名",
|
||||
"customize_survey_logo": "アンケートのロゴをカスタマイズする",
|
||||
"darken_or_lighten_background_of_your_choice": "お好みの背景を暗くしたり明るくしたりします。",
|
||||
"date_format": "日付形式",
|
||||
"days_before_showing_this_survey_again": "任意のフォームが表示された後、このフォームが再表示されるまでの日数。",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "フォームに「戻る」ボタンを表示しない",
|
||||
"hide_block_settings": "ブロック設定を非表示",
|
||||
"hide_logo": "ロゴを非表示",
|
||||
"hide_logo_from_survey": "このアンケートからロゴを非表示にする",
|
||||
"hide_progress_bar": "プログレスバーを非表示",
|
||||
"hide_question_settings": "質問設定を非表示",
|
||||
"hide_the_logo_in_this_specific_survey": "この特定のフォームでロゴを非表示にする",
|
||||
"hostname": "ホスト名",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "{surveyTypeDerived} フォームのカードをどれくらいユニークにしますか",
|
||||
"if_you_need_more_please": "さらに必要な場合は、",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "セグメントを読み込み",
|
||||
"logic_error_warning": "変更するとロジックエラーが発生します",
|
||||
"logic_error_warning_text": "質問の種類を変更すると、この質問のロジック条件が削除されます",
|
||||
"logo_settings": "ロゴ設定",
|
||||
"long_answer": "長文回答",
|
||||
"long_answer_toggle_description": "回答者が長文の複数行の回答を書けるようにします。",
|
||||
"lower_label": "下限ラベル",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "カスタム待機時間を設定する",
|
||||
"overwrite_global_waiting_time_description": "このフォームのみプロジェクト設定を上書きします。",
|
||||
"overwrite_placement": "配置を上書き",
|
||||
"overwrite_survey_logo": "カスタムアンケートロゴを設定する",
|
||||
"overwrite_the_global_placement_of_the_survey": "フォームのグローバルな配置を上書き",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "ライブラリから背景を選択するか、独自にアップロードしてください。",
|
||||
"picture_idx": "写真 {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "Bijgewerkt",
|
||||
"updated_at": "Bijgewerkt op",
|
||||
"upload": "Uploaden",
|
||||
"upload_failed": "Upload mislukt. Probeer het opnieuw.",
|
||||
"upload_input_description": "Klik of sleep om bestanden te uploaden.",
|
||||
"url": "URL",
|
||||
"user": "Gebruiker",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "Sluit de enquête automatisch af als de gebruiker na een bepaald aantal seconden niet reageert.",
|
||||
"automatically_mark_the_survey_as_complete_after": "Markeer de enquête daarna automatisch als voltooid",
|
||||
"back_button_label": "Knoplabel 'Terug'",
|
||||
"background_styling": "Achtergrondstijl",
|
||||
"background_styling": "Achtergrondstyling",
|
||||
"block_duplicated": "Blok gedupliceerd.",
|
||||
"bold": "Vetgedrukt",
|
||||
"brand_color": "Merk kleur",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "Kaartarrangement voor {surveyTypeDerived} enquêtes",
|
||||
"card_background_color": "Achtergrondkleur van de kaart",
|
||||
"card_border_color": "Randkleur kaart",
|
||||
"card_styling": "Kaartstijl",
|
||||
"card_styling": "Kaartstyling",
|
||||
"casual": "Casual",
|
||||
"caution_edit_duplicate": "Dupliceren en bewerken",
|
||||
"caution_edit_published_survey": "Een gepubliceerde enquête bewerken?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "CSS-kiezer",
|
||||
"cta_button_label": "\"CTA\" knoplabel",
|
||||
"custom_hostname": "Aangepaste hostnaam",
|
||||
"customize_survey_logo": "Pas het enquêtelogo aan",
|
||||
"darken_or_lighten_background_of_your_choice": "Maak de achtergrond naar keuze donkerder of lichter.",
|
||||
"date_format": "Datumformaat",
|
||||
"days_before_showing_this_survey_again": "dagen nadat een enquête is getoond voordat deze enquête kan verschijnen.",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "Geef de terugknop niet weer in de enquête",
|
||||
"hide_block_settings": "Blokinstellingen verbergen",
|
||||
"hide_logo": "Logo verbergen",
|
||||
"hide_logo_from_survey": "Verberg logo van deze enquête",
|
||||
"hide_progress_bar": "Voortgangsbalk verbergen",
|
||||
"hide_question_settings": "Vraaginstellingen verbergen",
|
||||
"hide_the_logo_in_this_specific_survey": "Verberg het logo in deze specifieke enquête",
|
||||
"hostname": "Hostnaam",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "Hoe funky wil je je kaarten hebben in {surveyTypeDerived} Enquêtes",
|
||||
"if_you_need_more_please": "Als u meer nodig heeft, alstublieft",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "Laadsegment",
|
||||
"logic_error_warning": "Wijzigen zal logische fouten veroorzaken",
|
||||
"logic_error_warning_text": "Als u het vraagtype wijzigt, worden de logische voorwaarden van deze vraag verwijderd",
|
||||
"logo_settings": "Logo-instellingen",
|
||||
"long_answer": "Lang antwoord",
|
||||
"long_answer_toggle_description": "Sta respondenten toe om langere antwoorden met meerdere regels te schrijven.",
|
||||
"lower_label": "Lager etiket",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "Stel aangepaste wachttijd in",
|
||||
"overwrite_global_waiting_time_description": "Overschrijf de projectconfiguratie alleen voor deze enquête.",
|
||||
"overwrite_placement": "Plaatsing overschrijven",
|
||||
"overwrite_survey_logo": "Stel aangepast enquêtelogo in",
|
||||
"overwrite_the_global_placement_of_the_survey": "Overschrijf de globale plaatsing van de enquête",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "Kies een achtergrond uit onze bibliotheek of upload je eigen achtergrond.",
|
||||
"picture_idx": "Afbeelding {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "atualizado",
|
||||
"updated_at": "Atualizado em",
|
||||
"upload": "Enviar",
|
||||
"upload_failed": "Falha no upload. Tente novamente.",
|
||||
"upload_input_description": "Clique ou arraste para fazer o upload de arquivos.",
|
||||
"url": "URL",
|
||||
"user": "Usuário",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "Feche automaticamente a pesquisa se o usuário não responder depois de alguns segundos.",
|
||||
"automatically_mark_the_survey_as_complete_after": "Marcar automaticamente a pesquisa como concluída após",
|
||||
"back_button_label": "Voltar",
|
||||
"background_styling": "Estilo do plano de fundo",
|
||||
"background_styling": "Estilo de Fundo",
|
||||
"block_duplicated": "Bloco duplicado.",
|
||||
"bold": "Negrito",
|
||||
"brand_color": "Cor da marca",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "Arranjo de Cartões para Pesquisas {surveyTypeDerived}",
|
||||
"card_background_color": "Cor de fundo do cartão",
|
||||
"card_border_color": "Cor da borda do cartão",
|
||||
"card_styling": "Estilo do cartão",
|
||||
"card_styling": "Estilização de Cartão",
|
||||
"casual": "Casual",
|
||||
"caution_edit_duplicate": "Duplicar e editar",
|
||||
"caution_edit_published_survey": "Editar uma pesquisa publicada?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "Seletor CSS",
|
||||
"cta_button_label": "Rótulo do botão \"CTA\"",
|
||||
"custom_hostname": "Hostname personalizado",
|
||||
"customize_survey_logo": "Personalizar o logo da pesquisa",
|
||||
"darken_or_lighten_background_of_your_choice": "Escureça ou clareie o fundo da sua escolha.",
|
||||
"date_format": "Formato de data",
|
||||
"days_before_showing_this_survey_again": "dias após qualquer pesquisa ser mostrada antes que esta pesquisa possa aparecer.",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "Não exibir o botão de voltar na pesquisa",
|
||||
"hide_block_settings": "Ocultar configurações do bloco",
|
||||
"hide_logo": "Esconder logo",
|
||||
"hide_logo_from_survey": "Esconder logo desta pesquisa",
|
||||
"hide_progress_bar": "Esconder barra de progresso",
|
||||
"hide_question_settings": "Ocultar configurações da pergunta",
|
||||
"hide_the_logo_in_this_specific_survey": "Esconder o logo nessa pesquisa específica",
|
||||
"hostname": "nome do host",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "Quão descoladas você quer suas cartas em Pesquisas {surveyTypeDerived}",
|
||||
"if_you_need_more_please": "Se você precisar de mais, por favor",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "segmento de carga",
|
||||
"logic_error_warning": "Mudar vai causar erros de lógica",
|
||||
"logic_error_warning_text": "Mudar o tipo de pergunta vai remover as condições lógicas dessa pergunta",
|
||||
"logo_settings": "Configurações do logo",
|
||||
"long_answer": "resposta longa",
|
||||
"long_answer_toggle_description": "Permitir que os respondentes escrevam respostas mais longas e com várias linhas.",
|
||||
"lower_label": "Etiqueta Inferior",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "Definir tempo de espera personalizado",
|
||||
"overwrite_global_waiting_time_description": "Substituir a configuração do projeto apenas para esta pesquisa.",
|
||||
"overwrite_placement": "Substituir posicionamento",
|
||||
"overwrite_survey_logo": "Definir logo personalizado para a pesquisa",
|
||||
"overwrite_the_global_placement_of_the_survey": "Substituir a posição global da pesquisa",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "Escolha um fundo da nossa biblioteca ou faça upload do seu próprio.",
|
||||
"picture_idx": "Imagem {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "Atualizado",
|
||||
"updated_at": "Atualizado em",
|
||||
"upload": "Carregar",
|
||||
"upload_failed": "Falha no carregamento. Por favor, tente novamente.",
|
||||
"upload_input_description": "Clique ou arraste para carregar ficheiros.",
|
||||
"url": "URL",
|
||||
"user": "Utilizador",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "Fechar automaticamente o inquérito se o utilizador não responder após um certo número de segundos.",
|
||||
"automatically_mark_the_survey_as_complete_after": "Marcar automaticamente o inquérito como concluído após",
|
||||
"back_button_label": "Rótulo do botão \"Voltar\"",
|
||||
"background_styling": "Estilo de fundo",
|
||||
"background_styling": "Estilo de Fundo",
|
||||
"block_duplicated": "Bloco duplicado.",
|
||||
"bold": "Negrito",
|
||||
"brand_color": "Cor da marca",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "Arranjo de Cartões para Inquéritos {surveyTypeDerived}",
|
||||
"card_background_color": "Cor de fundo do cartão",
|
||||
"card_border_color": "Cor da borda do cartão",
|
||||
"card_styling": "Estilo de cartão",
|
||||
"card_styling": "Estilo do cartão",
|
||||
"casual": "Casual",
|
||||
"caution_edit_duplicate": "Duplicar e editar",
|
||||
"caution_edit_published_survey": "Editar um inquérito publicado?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "Seletor CSS",
|
||||
"cta_button_label": "Etiqueta do botão \"CTA\"",
|
||||
"custom_hostname": "Nome do host personalizado",
|
||||
"customize_survey_logo": "Personalizar o logótipo do inquérito",
|
||||
"darken_or_lighten_background_of_your_choice": "Escurecer ou clarear o fundo da sua escolha.",
|
||||
"date_format": "Formato da data",
|
||||
"days_before_showing_this_survey_again": "dias após qualquer inquérito ser mostrado antes que este inquérito possa aparecer.",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "Não mostrar o botão de retroceder no inquérito",
|
||||
"hide_block_settings": "Ocultar definições do bloco",
|
||||
"hide_logo": "Esconder logótipo",
|
||||
"hide_logo_from_survey": "Ocultar logótipo deste inquérito",
|
||||
"hide_progress_bar": "Ocultar barra de progresso",
|
||||
"hide_question_settings": "Ocultar definições da pergunta",
|
||||
"hide_the_logo_in_this_specific_survey": "Ocultar o logótipo neste inquérito específico",
|
||||
"hostname": "Nome do host",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "Quão extravagantes quer os seus cartões em Inquéritos {surveyTypeDerived}",
|
||||
"if_you_need_more_please": "Se precisar de mais, por favor",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "Carregar segmento",
|
||||
"logic_error_warning": "A alteração causará erros de lógica",
|
||||
"logic_error_warning_text": "Alterar o tipo de pergunta irá remover as condições lógicas desta pergunta",
|
||||
"logo_settings": "Definições do logótipo",
|
||||
"long_answer": "Resposta longa",
|
||||
"long_answer_toggle_description": "Permitir que os inquiridos escrevam respostas mais longas e com várias linhas.",
|
||||
"lower_label": "Etiqueta Inferior",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "Definir tempo de espera personalizado",
|
||||
"overwrite_global_waiting_time_description": "Substituir a configuração do projeto apenas para este inquérito.",
|
||||
"overwrite_placement": "Substituir colocação",
|
||||
"overwrite_survey_logo": "Definir logótipo de inquérito personalizado",
|
||||
"overwrite_the_global_placement_of_the_survey": "Substituir a colocação global do inquérito",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "Escolha um fundo da nossa biblioteca ou carregue o seu próprio.",
|
||||
"picture_idx": "Imagem {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "Actualizat",
|
||||
"updated_at": "Actualizat la",
|
||||
"upload": "Încărcați",
|
||||
"upload_failed": "Încărcarea a eșuat. Vă rugăm să încercați din nou.",
|
||||
"upload_input_description": "Faceți clic sau trageți pentru a încărca fișiere.",
|
||||
"url": "URL",
|
||||
"user": "Utilizator",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "Selector CSS",
|
||||
"cta_button_label": "Eticheta butonului \"CTA\"",
|
||||
"custom_hostname": "Gazdă personalizată",
|
||||
"customize_survey_logo": "Personalizează logo-ul chestionarului",
|
||||
"darken_or_lighten_background_of_your_choice": "Întunecați sau luminați fundalul după preferințe.",
|
||||
"date_format": "Format dată",
|
||||
"days_before_showing_this_survey_again": "zile după afișarea oricărui sondaj înainte ca acest sondaj să poată apărea din nou.",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "Nu afișa butonul Înapoi în sondaj",
|
||||
"hide_block_settings": "Ascunde setările blocului",
|
||||
"hide_logo": "Ascunde logo",
|
||||
"hide_logo_from_survey": "Ascunde logo-ul din acest chestionar",
|
||||
"hide_progress_bar": "Ascunde bara de progres",
|
||||
"hide_question_settings": "Ascunde setările întrebării",
|
||||
"hide_the_logo_in_this_specific_survey": "Ascunde logo-ul în acest chestionar specific",
|
||||
"hostname": "Nume gazdă",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "Cât de funky doriți să fie cardurile dumneavoastră în sondajele de tip {surveyTypeDerived}",
|
||||
"if_you_need_more_please": "Dacă aveți nevoie de mai multe, vă rugăm să",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "Încarcă segment",
|
||||
"logic_error_warning": "Schimbarea va provoca erori de logică",
|
||||
"logic_error_warning_text": "Schimbarea tipului de întrebare va elimina condițiile de logică din această întrebare",
|
||||
"logo_settings": "Setări logo",
|
||||
"long_answer": "Răspuns lung",
|
||||
"long_answer_toggle_description": "Permite respondenților să scrie răspunsuri mai lungi, pe mai multe rânduri.",
|
||||
"lower_label": "Etichetă inferioară",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "Setează un timp de așteptare personalizat",
|
||||
"overwrite_global_waiting_time_description": "Suprascrie configurația proiectului doar pentru acest sondaj.",
|
||||
"overwrite_placement": "Suprascriere amplasare",
|
||||
"overwrite_survey_logo": "Setează un logo personalizat pentru chestionar",
|
||||
"overwrite_the_global_placement_of_the_survey": "Suprascrie amplasarea globală a sondajului",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "Alege un fundal din biblioteca noastră sau încarcă unul propriu.",
|
||||
"picture_idx": "Poză {idx}",
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -422,7 +422,6 @@
|
||||
"updated": "已更新",
|
||||
"updated_at": "更新 于",
|
||||
"upload": "上传",
|
||||
"upload_failed": "上传失败,请重试。",
|
||||
"upload_input_description": "点击 或 拖动 上传 文件",
|
||||
"url": "URL",
|
||||
"user": "用户",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "用户未在一定秒数内应答时 自动关闭 问卷",
|
||||
"automatically_mark_the_survey_as_complete_after": "自动 标记 调查 为 完成 在",
|
||||
"back_button_label": "\"返回\" 按钮标签",
|
||||
"background_styling": "背景样式",
|
||||
"background_styling": "背景 样式",
|
||||
"block_duplicated": "区块已复制。",
|
||||
"bold": "粗体",
|
||||
"brand_color": "品牌 颜色",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "{surveyTypeDerived} 调查 的 卡片 布局",
|
||||
"card_background_color": "卡片 的 背景 颜色",
|
||||
"card_border_color": "卡片 的 边框 颜色",
|
||||
"card_styling": "卡片样式",
|
||||
"card_styling": "卡 样式",
|
||||
"casual": "休闲",
|
||||
"caution_edit_duplicate": "复制 并 编辑",
|
||||
"caution_edit_published_survey": "编辑 已 发布 的 survey?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "CSS 选择器",
|
||||
"cta_button_label": "“CTA”按钮标签",
|
||||
"custom_hostname": "自 定 义 主 机 名",
|
||||
"customize_survey_logo": "自定义调查 logo",
|
||||
"darken_or_lighten_background_of_your_choice": "根据 您 的 选择 暗化 或 亮化 背景。",
|
||||
"date_format": "日期格式",
|
||||
"days_before_showing_this_survey_again": "在显示此调查之前,需等待的天数。",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "不 显示 调查 中 的 返回 按钮",
|
||||
"hide_block_settings": "隐藏区块设置",
|
||||
"hide_logo": "隐藏 徽标",
|
||||
"hide_logo_from_survey": "隐藏此调查中的 logo",
|
||||
"hide_progress_bar": "隐藏 进度 条",
|
||||
"hide_question_settings": "隐藏问题设置",
|
||||
"hide_the_logo_in_this_specific_survey": "隐藏此特定调查中的 logo",
|
||||
"hostname": "主 机 名",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "在 {surveyTypeDerived} 调查 中,您 想要 卡片 多么 有趣",
|
||||
"if_you_need_more_please": "如果你需要更多,请",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "载入 段落",
|
||||
"logic_error_warning": "更改 将 导致 逻辑 错误",
|
||||
"logic_error_warning_text": "更改问题类型 会 移除 此问题 的 逻辑条件",
|
||||
"logo_settings": "Logo 设置",
|
||||
"long_answer": "长答案",
|
||||
"long_answer_toggle_description": "允许受访者填写较长的多行答案。",
|
||||
"lower_label": "下限标签",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "设置自定义等待时间",
|
||||
"overwrite_global_waiting_time_description": "仅为此调查覆盖项目配置。",
|
||||
"overwrite_placement": "覆盖 放置",
|
||||
"overwrite_survey_logo": "设置自定义调查 logo",
|
||||
"overwrite_the_global_placement_of_the_survey": "覆盖 全局 调查 放置",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "从我们的库中选择一种 背景 或 上传您自己的。",
|
||||
"picture_idx": "图片 {idx}",
|
||||
|
||||
@@ -422,7 +422,6 @@
|
||||
"updated": "已更新",
|
||||
"updated_at": "更新時間",
|
||||
"upload": "上傳",
|
||||
"upload_failed": "上傳失敗。請再試一次。",
|
||||
"upload_input_description": "點擊或拖曳以上傳檔案。",
|
||||
"url": "網址",
|
||||
"user": "使用者",
|
||||
@@ -1256,7 +1255,7 @@
|
||||
"automatically_close_the_survey_if_the_user_does_not_respond_after_certain_number_of_seconds": "如果用戶在特定秒數後未回應,則自動關閉問卷。",
|
||||
"automatically_mark_the_survey_as_complete_after": "在指定時間後自動將問卷標記為完成",
|
||||
"back_button_label": "「返回」按鈕標籤",
|
||||
"background_styling": "背景樣式",
|
||||
"background_styling": "背景樣式設定",
|
||||
"block_duplicated": "區塊已複製。",
|
||||
"bold": "粗體",
|
||||
"brand_color": "品牌顏色",
|
||||
@@ -1272,7 +1271,7 @@
|
||||
"card_arrangement_for_survey_type_derived": "'{'surveyTypeDerived'}' 問卷的卡片排列",
|
||||
"card_background_color": "卡片背景顏色",
|
||||
"card_border_color": "卡片邊框顏色",
|
||||
"card_styling": "卡片樣式",
|
||||
"card_styling": "卡片樣式設定",
|
||||
"casual": "隨意",
|
||||
"caution_edit_duplicate": "複製 & 編輯",
|
||||
"caution_edit_published_survey": "編輯已發佈的調查?",
|
||||
@@ -1328,7 +1327,6 @@
|
||||
"css_selector": "CSS 選取器",
|
||||
"cta_button_label": "「CTA」按鈕標籤",
|
||||
"custom_hostname": "自訂主機名稱",
|
||||
"customize_survey_logo": "自訂問卷標誌",
|
||||
"darken_or_lighten_background_of_your_choice": "變暗或變亮您選擇的背景。",
|
||||
"date_format": "日期格式",
|
||||
"days_before_showing_this_survey_again": "在顯示此問卷之前,需等待其他問卷顯示後的天數。",
|
||||
@@ -1429,9 +1427,9 @@
|
||||
"hide_back_button_description": "不要在問卷中顯示返回按鈕",
|
||||
"hide_block_settings": "隱藏區塊設定",
|
||||
"hide_logo": "隱藏標誌",
|
||||
"hide_logo_from_survey": "隱藏此問卷的標誌",
|
||||
"hide_progress_bar": "隱藏進度列",
|
||||
"hide_question_settings": "隱藏問題設定",
|
||||
"hide_the_logo_in_this_specific_survey": "在此特定問卷中隱藏標誌",
|
||||
"hostname": "主機名稱",
|
||||
"how_funky_do_you_want_your_cards_in_survey_type_derived_surveys": "您希望 '{'surveyTypeDerived'}' 問卷中的卡片有多酷炫",
|
||||
"if_you_need_more_please": "如果您需要更多,請",
|
||||
@@ -1478,7 +1476,6 @@
|
||||
"load_segment": "載入區隔",
|
||||
"logic_error_warning": "變更將導致邏輯錯誤",
|
||||
"logic_error_warning_text": "變更問題類型將會從此問題中移除邏輯條件",
|
||||
"logo_settings": "標誌設定",
|
||||
"long_answer": "長回答",
|
||||
"long_answer_toggle_description": "允許受訪者撰寫較長的多行回答。",
|
||||
"lower_label": "下標籤",
|
||||
@@ -1511,7 +1508,6 @@
|
||||
"overwrite_global_waiting_time": "設定自訂等待時間",
|
||||
"overwrite_global_waiting_time_description": "僅覆蓋此問卷的專案設定。",
|
||||
"overwrite_placement": "覆寫位置",
|
||||
"overwrite_survey_logo": "設定自訂問卷標誌",
|
||||
"overwrite_the_global_placement_of_the_survey": "覆寫問卷的整體位置",
|
||||
"pick_a_background_from_our_library_or_upload_your_own": "從我們的媒體庫中選取背景或上傳您自己的背景。",
|
||||
"picture_idx": "圖片 '{'idx'}'",
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ export const LanguageDropdown = ({ survey, setLanguage, locale }: LanguageDropdo
|
||||
{enabledLanguages.map((surveyLanguage) => (
|
||||
<button
|
||||
key={surveyLanguage.language.code}
|
||||
className="w-full truncate rounded-md p-2 text-start hover:cursor-pointer hover:bg-slate-700"
|
||||
className="w-full rounded-md p-2 text-start hover:cursor-pointer hover:bg-slate-700"
|
||||
onClick={() => {
|
||||
setLanguage(surveyLanguage.language.code);
|
||||
setShowLanguageSelect(false);
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
"use server";
|
||||
|
||||
import { getServerSession } from "next-auth";
|
||||
import { getToken } from "next-auth/jwt";
|
||||
import { cookies } from "next/headers";
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { logger } from "@formbricks/logger";
|
||||
import { NEXTAUTH_SECRET } from "@/lib/constants";
|
||||
import { authOptions } from "@/modules/auth/lib/authOptions";
|
||||
|
||||
/**
|
||||
* Invalidates the current user's session by deleting it from the database.
|
||||
* This is called during logout to ensure JWT tokens cannot be reused.
|
||||
*/
|
||||
export async function invalidateCurrentSession() {
|
||||
try {
|
||||
const cookieStore = await cookies();
|
||||
const cookieHeader = cookieStore
|
||||
.getAll()
|
||||
.map((c) => `${c.name}=${c.value}`)
|
||||
.join("; ");
|
||||
|
||||
const token = await getToken({
|
||||
req: { headers: { cookie: cookieHeader } } as any,
|
||||
secret: NEXTAUTH_SECRET,
|
||||
});
|
||||
|
||||
const sessionToken = (token as any)?.sessionToken as string | undefined;
|
||||
if (sessionToken) {
|
||||
await prisma.session.deleteMany({ where: { sessionToken } });
|
||||
logger.info({ sessionToken }, "Invalidated current session by sessionToken");
|
||||
return;
|
||||
}
|
||||
|
||||
// Fallback: if we can't decode the token, invalidate all sessions for the current user.
|
||||
const session = await getServerSession(authOptions);
|
||||
if (!session?.user?.id) {
|
||||
logger.warn("No active session to invalidate");
|
||||
return;
|
||||
}
|
||||
|
||||
const result = await prisma.session.deleteMany({ where: { userId: session.user.id } });
|
||||
logger.info({ userId: session.user.id, sessionsDeleted: result.count }, "Invalidated all user sessions");
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
},
|
||||
"Failed to invalidate current session"
|
||||
);
|
||||
// Don't throw - we don't want to block logout if session deletion fails
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates all sessions for a given user.
|
||||
* Useful for "logout from all devices" functionality.
|
||||
*
|
||||
* @param userId - The ID of the user whose sessions should be invalidated
|
||||
* @throws Error if the operation fails
|
||||
*/
|
||||
export async function invalidateAllUserSessions(userId: string) {
|
||||
try {
|
||||
const result = await prisma.session.deleteMany({
|
||||
where: { userId },
|
||||
});
|
||||
|
||||
logger.info(
|
||||
{
|
||||
userId,
|
||||
sessionsDeleted: result.count,
|
||||
},
|
||||
"Invalidated all user sessions"
|
||||
);
|
||||
|
||||
return result.count;
|
||||
} catch (error) {
|
||||
logger.error(
|
||||
{
|
||||
userId,
|
||||
error: error instanceof Error ? error.message : String(error),
|
||||
},
|
||||
"Failed to invalidate user sessions"
|
||||
);
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
import { signOut } from "next-auth/react";
|
||||
import { logger } from "@formbricks/logger";
|
||||
import { FORMBRICKS_ENVIRONMENT_ID_LS } from "@/lib/localStorage";
|
||||
import { invalidateCurrentSession } from "@/modules/auth/actions/invalidate-sessions";
|
||||
import { logSignOutAction } from "@/modules/auth/actions/sign-out";
|
||||
|
||||
interface UseSignOutOptions {
|
||||
@@ -45,19 +44,11 @@ export const useSignOut = (sessionUser?: SessionUser | null) => {
|
||||
}
|
||||
}
|
||||
|
||||
// Invalidate session in database before clearing JWT
|
||||
try {
|
||||
await invalidateCurrentSession();
|
||||
} catch (error) {
|
||||
// Don't block signOut if session invalidation fails
|
||||
logger.error("Failed to invalidate session:", error);
|
||||
}
|
||||
|
||||
if (options?.clearEnvironmentId) {
|
||||
localStorage.removeItem(FORMBRICKS_ENVIRONMENT_ID_LS);
|
||||
}
|
||||
|
||||
// Call NextAuth signOut (clears JWT cookie)
|
||||
// Call NextAuth signOut
|
||||
return await signOut({
|
||||
redirect: options?.redirect,
|
||||
callbackUrl: options?.callbackUrl,
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
import { PrismaAdapter } from "@auth/prisma-adapter";
|
||||
import type { Account, NextAuthOptions } from "next-auth";
|
||||
import type { Adapter } from "next-auth/adapters";
|
||||
import CredentialsProvider from "next-auth/providers/credentials";
|
||||
import { cookies } from "next/headers";
|
||||
import crypto from "node:crypto";
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { logger } from "@formbricks/logger";
|
||||
import { TUser } from "@formbricks/types/user";
|
||||
@@ -16,7 +13,7 @@ import {
|
||||
} from "@/lib/constants";
|
||||
import { symmetricDecrypt, symmetricEncrypt } from "@/lib/crypto";
|
||||
import { verifyToken } from "@/lib/jwt";
|
||||
import { updateUser, updateUserLastLoginAt } from "@/modules/auth/lib/user";
|
||||
import { getUserByEmail, updateUser, updateUserLastLoginAt } from "@/modules/auth/lib/user";
|
||||
import {
|
||||
logAuthAttempt,
|
||||
logAuthEvent,
|
||||
@@ -34,8 +31,6 @@ import { handleSsoCallback } from "@/modules/ee/sso/lib/sso-handlers";
|
||||
import { createBrevoCustomer } from "./brevo";
|
||||
|
||||
export const authOptions: NextAuthOptions = {
|
||||
// Note: Adapter is only used for OAuth providers, not for CredentialsProvider
|
||||
adapter: PrismaAdapter(prisma) as Adapter,
|
||||
providers: [
|
||||
CredentialsProvider({
|
||||
id: "credentials",
|
||||
@@ -315,120 +310,30 @@ export const authOptions: NextAuthOptions = {
|
||||
...(ENTERPRISE_LICENSE_KEY ? getSSOProviders() : []),
|
||||
],
|
||||
session: {
|
||||
// Use JWT strategy for CredentialsProvider compatibility
|
||||
// Database sessions via adapter work for OAuth providers only
|
||||
strategy: "jwt",
|
||||
maxAge: SESSION_MAX_AGE,
|
||||
},
|
||||
callbacks: {
|
||||
async jwt({ token, user }) {
|
||||
// IMPORTANT:
|
||||
// This code runs inside `/api/auth/[...nextauth]/route.ts` which wraps and rethrows
|
||||
// callback errors. So we must NEVER throw here; instead, return an empty token to
|
||||
// force `getServerSession()` to return null (unauthenticated).
|
||||
async jwt({ token }) {
|
||||
const existingUser = await getUserByEmail(token?.email!);
|
||||
|
||||
// On sign in (when user object is available), create a server-side session record
|
||||
// and bind it to the JWT as `sessionToken`. This enables revocation on logout.
|
||||
if (user) {
|
||||
token.email = user.email;
|
||||
token.profile = { id: user.id };
|
||||
if (!existingUser) {
|
||||
return token;
|
||||
}
|
||||
|
||||
if (user && !token.sessionToken) {
|
||||
try {
|
||||
const sessionToken = crypto.randomUUID();
|
||||
const expires = new Date(Date.now() + SESSION_MAX_AGE * 1000);
|
||||
|
||||
await prisma.session.create({
|
||||
data: {
|
||||
sessionToken,
|
||||
userId: user.id,
|
||||
expires,
|
||||
},
|
||||
});
|
||||
|
||||
token.sessionToken = sessionToken;
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Failed to create server-side session record");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// Validate that the server-side session record still exists (revocation).
|
||||
if (token.sessionToken) {
|
||||
try {
|
||||
const session = await prisma.session.findUnique({
|
||||
where: { sessionToken: token.sessionToken as string },
|
||||
select: { expires: true },
|
||||
});
|
||||
|
||||
if (!session || session.expires < new Date()) {
|
||||
return {};
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Failed to validate server-side session record");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// Attach latest user state (e.g., isActive) to token.
|
||||
const userId = (token.profile as { id?: string } | undefined)?.id;
|
||||
if (!userId) return {};
|
||||
|
||||
// Backfill sessionToken for existing JWTs (e.g. after deploying this change),
|
||||
// so that logout revocation works without requiring an explicit re-login.
|
||||
if (!token.sessionToken) {
|
||||
try {
|
||||
const sessionToken = crypto.randomUUID();
|
||||
const expires = new Date(Date.now() + SESSION_MAX_AGE * 1000);
|
||||
|
||||
await prisma.session.create({
|
||||
data: {
|
||||
sessionToken,
|
||||
userId,
|
||||
expires,
|
||||
},
|
||||
});
|
||||
|
||||
token.sessionToken = sessionToken;
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Failed to backfill server-side session record");
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const existingUser = await prisma.user.findUnique({
|
||||
where: { id: userId },
|
||||
select: { id: true, isActive: true },
|
||||
});
|
||||
|
||||
if (!existingUser) return {};
|
||||
|
||||
return {
|
||||
...token,
|
||||
profile: { id: existingUser.id },
|
||||
isActive: existingUser.isActive,
|
||||
};
|
||||
} catch (err) {
|
||||
logger.error({ err }, "Failed to load user for session token");
|
||||
return {};
|
||||
}
|
||||
return {
|
||||
...token,
|
||||
profile: { id: existingUser.id },
|
||||
isActive: existingUser.isActive,
|
||||
};
|
||||
},
|
||||
async session({ session, token }) {
|
||||
// If token was invalidated (empty token), treat as unauthenticated.
|
||||
const profile = token.profile as { id?: string } | undefined;
|
||||
if (!profile?.id) {
|
||||
// Make downstream checks like `if (!session?.user)` work reliably.
|
||||
// (Default NextAuth session type allows `user` to be undefined.)
|
||||
session.user = undefined;
|
||||
return session;
|
||||
}
|
||||
// @ts-expect-error
|
||||
session.user.id = token?.id;
|
||||
// @ts-expect-error
|
||||
session.user = token.profile;
|
||||
// @ts-expect-error
|
||||
session.user.isActive = token.isActive;
|
||||
|
||||
const sessionUser = session.user ?? ({} as NonNullable<typeof session.user>);
|
||||
sessionUser.id = profile.id;
|
||||
(sessionUser as { id: string; isActive: boolean }).isActive = token.isActive !== false;
|
||||
session.user = sessionUser;
|
||||
return session;
|
||||
},
|
||||
async signIn({ user, account }: { user: TUser; account: Account }) {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
|
||||
import type { Mock } from "vitest";
|
||||
import { prisma } from "@formbricks/database";
|
||||
import { getInstanceId, getInstanceInfo } from "@/lib/instance";
|
||||
import {
|
||||
TEnterpriseLicenseDetails,
|
||||
TEnterpriseLicenseFeatures,
|
||||
@@ -56,7 +55,6 @@ vi.mock("@formbricks/database", () => ({
|
||||
},
|
||||
organization: {
|
||||
findUnique: vi.fn(),
|
||||
findFirst: vi.fn(),
|
||||
},
|
||||
},
|
||||
}));
|
||||
@@ -72,11 +70,6 @@ vi.mock("@formbricks/logger", () => ({
|
||||
logger: mockLogger,
|
||||
}));
|
||||
|
||||
vi.mock("@/lib/instance", () => ({
|
||||
getInstanceId: vi.fn(),
|
||||
getInstanceInfo: vi.fn(),
|
||||
}));
|
||||
|
||||
// Mock constants as they are used in the original license.ts indirectly
|
||||
vi.mock("@/lib/constants", async (importOriginal) => {
|
||||
const actual = await importOriginal();
|
||||
@@ -109,15 +102,6 @@ describe("License Core Logic", () => {
|
||||
mockCache.withCache.mockImplementation(async (fn) => await fn());
|
||||
|
||||
vi.mocked(prisma.response.count).mockResolvedValue(100);
|
||||
vi.mocked(prisma.organization.findFirst).mockResolvedValue({
|
||||
id: "test-org-id",
|
||||
createdAt: new Date("2024-01-01"),
|
||||
} as any);
|
||||
vi.mocked(getInstanceId).mockResolvedValue("test-hashed-instance-id");
|
||||
vi.mocked(getInstanceInfo).mockResolvedValue({
|
||||
instanceId: "test-hashed-instance-id",
|
||||
createdAt: new Date("2024-01-01"),
|
||||
});
|
||||
vi.clearAllMocks();
|
||||
// Mock window to be undefined for server-side tests
|
||||
vi.stubGlobal("window", undefined);
|
||||
|
||||
@@ -9,7 +9,6 @@ import { logger } from "@formbricks/logger";
|
||||
import { cache } from "@/lib/cache";
|
||||
import { env } from "@/lib/env";
|
||||
import { hashString } from "@/lib/hash-string";
|
||||
import { getInstanceId } from "@/lib/instance";
|
||||
import {
|
||||
TEnterpriseLicenseDetails,
|
||||
TEnterpriseLicenseFeatures,
|
||||
@@ -261,20 +260,14 @@ const fetchLicenseFromServerInternal = async (retryCount = 0): Promise<TEnterpri
|
||||
// first millisecond of next year => current year is fully included
|
||||
const startOfNextYear = new Date(now.getFullYear() + 1, 0, 1);
|
||||
|
||||
const [instanceId, responseCount] = await Promise.all([
|
||||
getInstanceId(),
|
||||
prisma.response.count({
|
||||
where: {
|
||||
createdAt: {
|
||||
gte: startOfYear,
|
||||
lt: startOfNextYear,
|
||||
},
|
||||
const responseCount = await prisma.response.count({
|
||||
where: {
|
||||
createdAt: {
|
||||
gte: startOfYear,
|
||||
lt: startOfNextYear,
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
// No organization exists, cannot perform license check
|
||||
if (!instanceId) return null;
|
||||
},
|
||||
});
|
||||
|
||||
const proxyUrl = env.HTTPS_PROXY ?? env.HTTP_PROXY;
|
||||
const agent = proxyUrl ? new HttpsProxyAgent(proxyUrl) : undefined;
|
||||
@@ -286,7 +279,6 @@ const fetchLicenseFromServerInternal = async (retryCount = 0): Promise<TEnterpri
|
||||
body: JSON.stringify({
|
||||
licenseKey: env.ENTERPRISE_LICENSE_KEY,
|
||||
usage: { responseCount },
|
||||
instanceId,
|
||||
}),
|
||||
headers: { "Content-Type": "application/json" },
|
||||
method: "POST",
|
||||
|
||||
@@ -48,33 +48,29 @@ export function LanguageIndicator({
|
||||
<button
|
||||
aria-expanded={showLanguageDropdown}
|
||||
aria-haspopup="true"
|
||||
className="relative z-20 flex max-w-[120px] items-center justify-center rounded-md bg-slate-900 p-1 px-2 text-xs text-white hover:bg-slate-700"
|
||||
className="relative z-20 flex items-center justify-center rounded-md bg-slate-900 p-1 px-2 text-xs text-white hover:bg-slate-700"
|
||||
onClick={toggleDropdown}
|
||||
tabIndex={-1}
|
||||
type="button">
|
||||
<span className="max-w-full truncate">
|
||||
{languageToBeDisplayed ? getLanguageLabel(languageToBeDisplayed.language.code, locale) : ""}
|
||||
</span>
|
||||
<ChevronDown className="ml-1 h-4 w-4 flex-shrink-0" />
|
||||
{languageToBeDisplayed ? getLanguageLabel(languageToBeDisplayed.language.code, locale) : ""}
|
||||
<ChevronDown className="ml-1 h-4 w-4" />
|
||||
</button>
|
||||
{showLanguageDropdown ? (
|
||||
<div
|
||||
className="absolute right-0 z-30 mt-1 max-h-64 w-48 space-y-2 overflow-auto rounded-md bg-slate-900 p-1 text-xs text-white"
|
||||
className="absolute right-0 z-30 mt-1 max-h-64 space-y-2 overflow-auto rounded-md bg-slate-900 p-1 text-xs text-white"
|
||||
ref={languageDropdownRef}>
|
||||
{surveyLanguages.map(
|
||||
(language) =>
|
||||
language.language.code !== languageToBeDisplayed?.language.code &&
|
||||
language.enabled && (
|
||||
<button
|
||||
className="flex w-full rounded-sm p-1 text-left hover:bg-slate-700"
|
||||
className="block w-full rounded-sm p-1 text-left hover:bg-slate-700"
|
||||
key={language.language.id}
|
||||
onClick={() => {
|
||||
changeLanguage(language);
|
||||
}}
|
||||
type="button">
|
||||
<span className="min-w-0 flex-1 truncate">
|
||||
{getLanguageLabel(language.language.code, locale)}
|
||||
</span>
|
||||
{getLanguageLabel(language.language.code, locale)}
|
||||
</button>
|
||||
)
|
||||
)}
|
||||
|
||||
@@ -154,6 +154,7 @@ export const ThemeStyling = ({
|
||||
open={cardStylingOpen}
|
||||
setOpen={setCardStylingOpen}
|
||||
isSettingsPage
|
||||
project={project}
|
||||
surveyType={previewSurveyType}
|
||||
form={form as UseFormReturn<TProjectStyling | TSurveyStyling>}
|
||||
/>
|
||||
|
||||
@@ -133,16 +133,13 @@ export const BlockCard = ({
|
||||
// A button label is invalid if it exists but doesn't have valid text for all enabled languages
|
||||
const surveyLanguages = localSurvey.languages ?? [];
|
||||
const hasInvalidButtonLabel =
|
||||
block.buttonLabel !== undefined &&
|
||||
block.buttonLabel["default"]?.trim() !== "" &&
|
||||
!isLabelValidForAllLanguages(block.buttonLabel, surveyLanguages);
|
||||
block.buttonLabel !== undefined && !isLabelValidForAllLanguages(block.buttonLabel, surveyLanguages);
|
||||
|
||||
// Check if back button label is invalid
|
||||
// Back button label should exist for all blocks except the first one
|
||||
const hasInvalidBackButtonLabel =
|
||||
blockIdx > 0 &&
|
||||
block.backButtonLabel !== undefined &&
|
||||
block.backButtonLabel["default"]?.trim() !== "" &&
|
||||
!isLabelValidForAllLanguages(block.backButtonLabel, surveyLanguages);
|
||||
|
||||
// Block should be highlighted if it has invalid elements OR invalid button labels
|
||||
@@ -294,29 +291,29 @@ export const BlockCard = ({
|
||||
open={!isBlockCollapsed}
|
||||
onOpenChange={() => setIsBlockCollapsed(!isBlockCollapsed)}
|
||||
className={cn(isBlockCollapsed ? "h-full" : "")}>
|
||||
<Collapsible.CollapsibleTrigger asChild>
|
||||
<div className="block h-full w-full cursor-pointer hover:bg-slate-100">
|
||||
<div className="flex h-full items-center justify-between px-4 py-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<div>
|
||||
<h4 className="text-sm font-medium text-slate-700">{block.name}</h4>
|
||||
<p className="text-xs text-slate-500">
|
||||
{blockElementsCount} {blockElementsCountText}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<Collapsible.CollapsibleTrigger
|
||||
asChild
|
||||
className="block h-full w-full cursor-pointer hover:bg-slate-100">
|
||||
<div className="flex h-full items-center justify-between px-4 py-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<div>
|
||||
<BlockMenu
|
||||
isFirstBlock={blockIdx === 0}
|
||||
isLastBlock={blockIdx === totalBlocks - 1}
|
||||
isOnlyBlock={totalBlocks === 1}
|
||||
onDuplicate={() => duplicateBlock(block.id)}
|
||||
onDelete={() => deleteBlock(block.id)}
|
||||
onMoveUp={() => moveBlock(block.id, "up")}
|
||||
onMoveDown={() => moveBlock(block.id, "down")}
|
||||
/>
|
||||
<h4 className="text-sm font-medium text-slate-700">{block.name}</h4>
|
||||
<p className="text-xs text-slate-500">
|
||||
{blockElementsCount} {blockElementsCountText}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<BlockMenu
|
||||
isFirstBlock={blockIdx === 0}
|
||||
isLastBlock={blockIdx === totalBlocks - 1}
|
||||
isOnlyBlock={totalBlocks === 1}
|
||||
onDuplicate={() => duplicateBlock(block.id)}
|
||||
onDelete={() => deleteBlock(block.id)}
|
||||
onMoveUp={() => moveBlock(block.id, "up")}
|
||||
onMoveDown={() => moveBlock(block.id, "down")}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</Collapsible.CollapsibleTrigger>
|
||||
|
||||
|
||||
@@ -513,8 +513,8 @@ export const ElementsView = ({
|
||||
id: newBlockId,
|
||||
name: getBlockName(index ?? prevSurvey.blocks.length),
|
||||
elements: [{ ...updatedElement, isDraft: true }],
|
||||
buttonLabel: createI18nString("", []),
|
||||
backButtonLabel: createI18nString("", []),
|
||||
buttonLabel: createI18nString(t("templates.next"), []),
|
||||
backButtonLabel: createI18nString(t("templates.back"), []),
|
||||
};
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,262 +0,0 @@
|
||||
"use client";
|
||||
|
||||
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
||||
import * as Collapsible from "@radix-ui/react-collapsible";
|
||||
import { CheckIcon } from "lucide-react";
|
||||
import Image from "next/image";
|
||||
import React, { ChangeEvent, useRef, useState } from "react";
|
||||
import { UseFormReturn } from "react-hook-form";
|
||||
import toast from "react-hot-toast";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TProjectStyling } from "@formbricks/types/project";
|
||||
import { TSurveyStyling } from "@formbricks/types/surveys/types";
|
||||
import { cn } from "@/lib/cn";
|
||||
import { handleFileUpload } from "@/modules/storage/file-upload";
|
||||
import { AdvancedOptionToggle } from "@/modules/ui/components/advanced-option-toggle";
|
||||
import { Button } from "@/modules/ui/components/button";
|
||||
import { ColorPicker } from "@/modules/ui/components/color-picker";
|
||||
import { FileInput } from "@/modules/ui/components/file-input";
|
||||
import { FormControl, FormDescription, FormField, FormItem, FormLabel } from "@/modules/ui/components/form";
|
||||
import { Input } from "@/modules/ui/components/input";
|
||||
import { showStorageNotConfiguredToast } from "@/modules/ui/components/storage-not-configured-toast/lib/utils";
|
||||
import { Switch } from "@/modules/ui/components/switch";
|
||||
|
||||
type LogoSettingsCardProps = {
|
||||
open: boolean;
|
||||
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
||||
environmentId: string;
|
||||
form: UseFormReturn<TProjectStyling | TSurveyStyling>;
|
||||
disabled?: boolean;
|
||||
isStorageConfigured: boolean;
|
||||
};
|
||||
|
||||
export const LogoSettingsCard = ({
|
||||
open,
|
||||
setOpen,
|
||||
environmentId,
|
||||
form,
|
||||
disabled = false,
|
||||
isStorageConfigured,
|
||||
}: LogoSettingsCardProps) => {
|
||||
const { t } = useTranslation();
|
||||
const [parent] = useAutoAnimate();
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
|
||||
const logoUrl = form.watch("logo")?.url;
|
||||
const logoBgColor = form.watch("logo")?.bgColor;
|
||||
const isBgColorEnabled = !!logoBgColor;
|
||||
const isLogoHidden = form.watch("isLogoHidden");
|
||||
|
||||
const setLogoUrl = (url: string | undefined) => {
|
||||
const currentLogo = form.getValues("logo");
|
||||
form.setValue("logo", url ? { ...currentLogo, url } : undefined);
|
||||
};
|
||||
|
||||
const setLogoBgColor = (bgColor: string | undefined) => {
|
||||
const currentLogo = form.getValues("logo");
|
||||
form.setValue("logo", {
|
||||
...currentLogo,
|
||||
url: logoUrl,
|
||||
bgColor,
|
||||
});
|
||||
};
|
||||
|
||||
const handleFileInputChange = async (files: string[]) => {
|
||||
if (files.length > 0) {
|
||||
setLogoUrl(files[0]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleHiddenFileChange = async (event: ChangeEvent<HTMLInputElement>) => {
|
||||
if (!isStorageConfigured) {
|
||||
showStorageNotConfiguredToast();
|
||||
return;
|
||||
}
|
||||
|
||||
const file = event.target.files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
setIsLoading(true);
|
||||
try {
|
||||
const uploadResult = await handleFileUpload(file, environmentId);
|
||||
if (uploadResult.error) {
|
||||
toast.error(t("common.upload_failed"));
|
||||
return;
|
||||
}
|
||||
setLogoUrl(uploadResult.url);
|
||||
} catch {
|
||||
toast.error(t("common.upload_failed"));
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
// Reset the input so the same file can be selected again
|
||||
if (fileInputRef.current) {
|
||||
fileInputRef.current.value = "";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleRemoveLogo = () => {
|
||||
form.setValue("logo", undefined);
|
||||
};
|
||||
|
||||
const toggleBackgroundColor = (enabled: boolean) => {
|
||||
setLogoBgColor(enabled ? logoBgColor || "#f8f8f8" : undefined);
|
||||
};
|
||||
|
||||
const handleBgColorChange = (color: string) => {
|
||||
setLogoBgColor(color);
|
||||
};
|
||||
|
||||
return (
|
||||
<Collapsible.Root
|
||||
open={open}
|
||||
onOpenChange={(openState) => {
|
||||
if (disabled) return;
|
||||
setOpen(openState);
|
||||
}}
|
||||
className="w-full rounded-lg border border-slate-300 bg-white">
|
||||
<Collapsible.CollapsibleTrigger
|
||||
asChild
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
"w-full cursor-pointer rounded-lg hover:bg-slate-50",
|
||||
disabled && "cursor-not-allowed opacity-60 hover:bg-white"
|
||||
)}>
|
||||
<div className="inline-flex w-full px-4 py-4">
|
||||
<div className="flex items-center pl-2 pr-5">
|
||||
<CheckIcon
|
||||
strokeWidth={3}
|
||||
className="h-7 w-7 rounded-full border border-green-300 bg-green-100 p-1.5 text-green-600"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p className="text-base font-semibold text-slate-800">
|
||||
{t("environments.surveys.edit.logo_settings")}
|
||||
</p>
|
||||
<p className="mt-1 text-sm text-slate-500">
|
||||
{t("environments.surveys.edit.customize_survey_logo")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Collapsible.CollapsibleTrigger>
|
||||
|
||||
<Collapsible.CollapsibleContent className="flex flex-col" ref={parent}>
|
||||
<hr className="py-1 text-slate-600" />
|
||||
|
||||
<div className="flex flex-col gap-6 p-6 pt-2">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="isLogoHidden"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex items-center gap-2 space-y-0">
|
||||
<FormControl>
|
||||
<Switch checked={!!field.value} onCheckedChange={field.onChange} disabled={disabled} />
|
||||
</FormControl>
|
||||
<div>
|
||||
<FormLabel className="text-base font-semibold text-slate-900">
|
||||
{t("environments.surveys.edit.hide_logo")}
|
||||
</FormLabel>
|
||||
<FormDescription className="text-sm text-slate-800">
|
||||
{t("environments.surveys.edit.hide_logo_from_survey")}
|
||||
</FormDescription>
|
||||
</div>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
|
||||
{!isLogoHidden && (
|
||||
<div className="space-y-4">
|
||||
<div className="font-medium text-slate-800">
|
||||
{t("environments.surveys.edit.overwrite_survey_logo")}
|
||||
</div>
|
||||
|
||||
{/* Hidden file input for replacing logo */}
|
||||
<Input
|
||||
ref={fileInputRef}
|
||||
type="file"
|
||||
accept="image/jpeg, image/png, image/webp, image/heic"
|
||||
className="hidden"
|
||||
disabled={disabled}
|
||||
onChange={handleHiddenFileChange}
|
||||
/>
|
||||
|
||||
{logoUrl ? (
|
||||
<>
|
||||
<div className="flex items-center gap-4">
|
||||
<Image
|
||||
src={logoUrl}
|
||||
alt="Survey Logo"
|
||||
width={256}
|
||||
height={56}
|
||||
style={{ backgroundColor: logoBgColor || undefined }}
|
||||
className="h-20 w-auto max-w-64 rounded-lg border object-contain p-1"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
type="button"
|
||||
onClick={() => {
|
||||
if (!isStorageConfigured) {
|
||||
showStorageNotConfiguredToast();
|
||||
return;
|
||||
}
|
||||
|
||||
fileInputRef.current?.click();
|
||||
}}
|
||||
variant="secondary"
|
||||
size="sm"
|
||||
disabled={disabled || isLoading}>
|
||||
{t("environments.project.look.replace_logo")}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={handleRemoveLogo}
|
||||
disabled={disabled}>
|
||||
{t("environments.project.look.remove_logo")}
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<AdvancedOptionToggle
|
||||
isChecked={isBgColorEnabled}
|
||||
onToggle={toggleBackgroundColor}
|
||||
htmlId="surveyLogoBgColor"
|
||||
title={t("environments.project.look.add_background_color")}
|
||||
description={t("environments.project.look.add_background_color_description")}
|
||||
childBorder
|
||||
customContainerClass="p-0"
|
||||
childrenContainerClass="overflow-visible"
|
||||
disabled={disabled}>
|
||||
{isBgColorEnabled && (
|
||||
<div className="px-2">
|
||||
<ColorPicker
|
||||
color={logoBgColor || "#f8f8f8"}
|
||||
onChange={handleBgColorChange}
|
||||
disabled={disabled}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</AdvancedOptionToggle>
|
||||
</>
|
||||
) : (
|
||||
<FileInput
|
||||
id="survey-logo-input"
|
||||
allowedFileExtensions={["png", "jpeg", "jpg", "webp", "heic"]}
|
||||
environmentId={environmentId}
|
||||
onFileUpload={handleFileInputChange}
|
||||
disabled={disabled}
|
||||
maxSizeInMB={5}
|
||||
isStorageConfigured={isStorageConfigured}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</Collapsible.CollapsibleContent>
|
||||
</Collapsible.Root>
|
||||
);
|
||||
};
|
||||
@@ -11,7 +11,6 @@ import { TProjectStyling } from "@formbricks/types/project";
|
||||
import { TSurvey, TSurveyStyling } from "@formbricks/types/surveys/types";
|
||||
import { defaultStyling } from "@/lib/styling/constants";
|
||||
import { FormStylingSettings } from "@/modules/survey/editor/components/form-styling-settings";
|
||||
import { LogoSettingsCard } from "@/modules/survey/editor/components/logo-settings-card";
|
||||
import { AlertDialog } from "@/modules/ui/components/alert-dialog";
|
||||
import { BackgroundStylingCard } from "@/modules/ui/components/background-styling-card";
|
||||
import { Button } from "@/modules/ui/components/button";
|
||||
@@ -65,7 +64,6 @@ export const StylingView = ({
|
||||
const setOverwriteThemeStyling = (value: boolean) => form.setValue("overwriteThemeStyling", value);
|
||||
|
||||
const [formStylingOpen, setFormStylingOpen] = useState(false);
|
||||
const [logoSettingsOpen, setLogoSettingsOpen] = useState(false);
|
||||
const [cardStylingOpen, setCardStylingOpen] = useState(false);
|
||||
const [stylingOpen, setStylingOpen] = useState(false);
|
||||
const [confirmResetStylingModalOpen, setConfirmResetStylingModalOpen] = useState(false);
|
||||
@@ -90,7 +88,6 @@ export const StylingView = ({
|
||||
useEffect(() => {
|
||||
if (!overwriteThemeStyling) {
|
||||
setFormStylingOpen(false);
|
||||
setLogoSettingsOpen(false);
|
||||
setCardStylingOpen(false);
|
||||
setStylingOpen(false);
|
||||
}
|
||||
@@ -201,31 +198,21 @@ export const StylingView = ({
|
||||
setOpen={setCardStylingOpen}
|
||||
surveyType={localSurvey.type}
|
||||
disabled={!overwriteThemeStyling}
|
||||
project={project}
|
||||
form={form as UseFormReturn<TProjectStyling | TSurveyStyling>}
|
||||
/>
|
||||
|
||||
{localSurvey.type === "link" && (
|
||||
<>
|
||||
<BackgroundStylingCard
|
||||
open={stylingOpen}
|
||||
setOpen={setStylingOpen}
|
||||
environmentId={environmentId}
|
||||
colors={colors}
|
||||
disabled={!overwriteThemeStyling}
|
||||
isUnsplashConfigured={isUnsplashConfigured}
|
||||
form={form as UseFormReturn<TProjectStyling | TSurveyStyling>}
|
||||
isStorageConfigured={isStorageConfigured}
|
||||
/>
|
||||
|
||||
<LogoSettingsCard
|
||||
open={logoSettingsOpen}
|
||||
setOpen={setLogoSettingsOpen}
|
||||
disabled={!overwriteThemeStyling}
|
||||
environmentId={environmentId}
|
||||
form={form as UseFormReturn<TProjectStyling | TSurveyStyling>}
|
||||
isStorageConfigured={isStorageConfigured}
|
||||
/>
|
||||
</>
|
||||
<BackgroundStylingCard
|
||||
open={stylingOpen}
|
||||
setOpen={setStylingOpen}
|
||||
environmentId={environmentId}
|
||||
colors={colors}
|
||||
disabled={!overwriteThemeStyling}
|
||||
isUnsplashConfigured={isUnsplashConfigured}
|
||||
form={form as UseFormReturn<TProjectStyling | TSurveyStyling>}
|
||||
isStorageConfigured={isStorageConfigured}
|
||||
/>
|
||||
)}
|
||||
|
||||
{!isCxMode && (
|
||||
|
||||
@@ -79,7 +79,7 @@ export const LinkSurveyWrapper = ({
|
||||
styling={styling}
|
||||
onBackgroundLoaded={handleBackgroundLoaded}>
|
||||
<div className="flex max-h-dvh min-h-dvh items-center justify-center overflow-clip">
|
||||
{!styling.isLogoHidden && (project.logo?.url || styling.logo?.url) && <ClientLogo projectLogo={project.logo} surveyLogo={styling.logo} />}
|
||||
{!styling.isLogoHidden && project.logo?.url && <ClientLogo projectLogo={project.logo} />}
|
||||
<div className="h-full w-full max-w-4xl space-y-6 px-1.5">
|
||||
{isPreview && (
|
||||
<div className="fixed left-0 top-0 flex w-full items-center justify-between bg-slate-600 p-2 px-4 text-center text-sm text-white shadow-sm">
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
||||
import { Project } from "@prisma/client";
|
||||
import * as Collapsible from "@radix-ui/react-collapsible";
|
||||
import { CheckIcon } from "lucide-react";
|
||||
import React from "react";
|
||||
@@ -10,6 +11,7 @@ import { TProjectStyling } from "@formbricks/types/project";
|
||||
import { TSurveyStyling, TSurveyType } from "@formbricks/types/surveys/types";
|
||||
import { cn } from "@/lib/cn";
|
||||
import { COLOR_DEFAULTS } from "@/lib/styling/constants";
|
||||
import { Badge } from "@/modules/ui/components/badge";
|
||||
import { CardArrangementTabs } from "@/modules/ui/components/card-arrangement-tabs";
|
||||
import { ColorPicker } from "@/modules/ui/components/color-picker";
|
||||
import { FormControl, FormDescription, FormField, FormItem, FormLabel } from "@/modules/ui/components/form";
|
||||
@@ -22,6 +24,7 @@ type CardStylingSettingsProps = {
|
||||
isSettingsPage?: boolean;
|
||||
surveyType?: TSurveyType;
|
||||
disabled?: boolean;
|
||||
project: Project;
|
||||
form: UseFormReturn<TProjectStyling | TSurveyStyling>;
|
||||
};
|
||||
|
||||
@@ -30,12 +33,14 @@ export const CardStylingSettings = ({
|
||||
surveyType,
|
||||
disabled,
|
||||
open,
|
||||
project,
|
||||
setOpen,
|
||||
form,
|
||||
}: CardStylingSettingsProps) => {
|
||||
const { t } = useTranslation();
|
||||
const isAppSurvey = surveyType === "app";
|
||||
const surveyTypeDerived = isAppSurvey ? "App" : "Link";
|
||||
const isLogoVisible = !!project.logo?.url;
|
||||
|
||||
const linkCardArrangement = form.watch("cardArrangement.linkSurveys") ?? "straight";
|
||||
const appCardArrangement = form.watch("cardArrangement.appSurveys") ?? "straight";
|
||||
@@ -217,6 +222,35 @@ export const CardStylingSettings = ({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{isLogoVisible && (!surveyType || surveyType === "link") && !isSettingsPage && (
|
||||
<div className="flex items-center space-x-1">
|
||||
<FormField
|
||||
control={form.control}
|
||||
name="isLogoHidden"
|
||||
render={({ field }) => (
|
||||
<FormItem className="flex w-full items-center gap-2 space-y-0">
|
||||
<FormControl>
|
||||
<Switch
|
||||
id="isLogoHidden"
|
||||
checked={!!field.value}
|
||||
onCheckedChange={(checked) => field.onChange(checked)}
|
||||
/>
|
||||
</FormControl>
|
||||
<div>
|
||||
<FormLabel>
|
||||
{t("environments.surveys.edit.hide_logo")}
|
||||
<Badge type="gray" size="normal" text={t("common.link_surveys")} />
|
||||
</FormLabel>
|
||||
<FormDescription>
|
||||
{t("environments.surveys.edit.hide_the_logo_in_this_specific_survey")}
|
||||
</FormDescription>
|
||||
</div>
|
||||
</FormItem>
|
||||
)}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(!surveyType || isAppSurvey) && (
|
||||
<div className="flex max-w-xs flex-col gap-4">
|
||||
<div className="flex items-center space-x-1">
|
||||
|
||||
@@ -5,24 +5,20 @@ import { ArrowUpRight } from "lucide-react";
|
||||
import Image from "next/image";
|
||||
import Link from "next/link";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { TLogo } from "@formbricks/types/styling";
|
||||
import { cn } from "@/lib/cn";
|
||||
|
||||
interface ClientLogoProps {
|
||||
environmentId?: string;
|
||||
projectLogo: Project["logo"] | null;
|
||||
surveyLogo?: TLogo | null;
|
||||
previewSurvey?: boolean;
|
||||
}
|
||||
|
||||
export const ClientLogo = ({ environmentId, projectLogo, surveyLogo, previewSurvey = false }: ClientLogoProps) => {
|
||||
export const ClientLogo = ({ environmentId, projectLogo, previewSurvey = false }: ClientLogoProps) => {
|
||||
const { t } = useTranslation();
|
||||
const logoToUse = surveyLogo?.url ? surveyLogo : projectLogo;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(previewSurvey ? "" : "left-3 top-3 md:left-7 md:top-7", "group absolute z-0 rounded-lg")}
|
||||
style={{ backgroundColor: logoToUse?.bgColor }}>
|
||||
style={{ backgroundColor: projectLogo?.bgColor }}>
|
||||
{previewSurvey && environmentId && (
|
||||
<Link
|
||||
href={`/environments/${environmentId}/project/look`}
|
||||
@@ -34,9 +30,9 @@ export const ClientLogo = ({ environmentId, projectLogo, surveyLogo, previewSurv
|
||||
/>
|
||||
</Link>
|
||||
)}
|
||||
{logoToUse?.url ? (
|
||||
{projectLogo?.url ? (
|
||||
<Image
|
||||
src={logoToUse?.url}
|
||||
src={projectLogo?.url}
|
||||
className={cn(
|
||||
previewSurvey ? "max-h-12" : "max-h-16 md:max-h-20",
|
||||
"w-auto max-w-40 object-contain p-1 md:max-w-56"
|
||||
|
||||
@@ -117,7 +117,7 @@ export const ConfirmationModal = ({
|
||||
<CircleAlert className="h-4 w-4 text-slate-500" />
|
||||
)}
|
||||
<div className="flex flex-col">
|
||||
<DialogTitle className="w-full truncate text-left">{title}</DialogTitle>
|
||||
<DialogTitle className="w-full text-left">{title}</DialogTitle>
|
||||
<DialogDescription className="w-full text-left">
|
||||
<span className="mt-2 whitespace-pre-wrap">
|
||||
{description ?? t("environments.project.general.this_action_cannot_be_undone")}
|
||||
|
||||
@@ -263,12 +263,7 @@ export const PreviewSurvey = ({
|
||||
<div className="flex h-full w-full flex-col justify-center px-1">
|
||||
<div className="absolute left-5 top-5">
|
||||
{!styling.isLogoHidden && (
|
||||
<ClientLogo
|
||||
environmentId={environment.id}
|
||||
projectLogo={project.logo}
|
||||
surveyLogo={styling.logo}
|
||||
previewSurvey
|
||||
/>
|
||||
<ClientLogo environmentId={environment.id} projectLogo={project.logo} previewSurvey />
|
||||
)}
|
||||
</div>
|
||||
<div className="z-10 w-full rounded-lg border border-transparent">
|
||||
@@ -368,12 +363,7 @@ export const PreviewSurvey = ({
|
||||
isEditorView>
|
||||
<div className="absolute left-5 top-5">
|
||||
{!styling.isLogoHidden && (
|
||||
<ClientLogo
|
||||
environmentId={environment.id}
|
||||
projectLogo={project.logo}
|
||||
surveyLogo={styling.logo}
|
||||
previewSurvey
|
||||
/>
|
||||
<ClientLogo environmentId={environment.id} projectLogo={project.logo} previewSurvey />
|
||||
)}
|
||||
</div>
|
||||
<div className="z-0 w-full max-w-4xl rounded-lg border-transparent">
|
||||
|
||||
@@ -15,11 +15,9 @@
|
||||
"test:coverage": "dotenv -e ../../.env -- vitest run --coverage",
|
||||
"generate-api-specs": "./scripts/openapi/generate.sh",
|
||||
"merge-client-endpoints": "tsx ./scripts/openapi/merge-client-endpoints.ts",
|
||||
"generate-and-merge-api-specs": "pnpm run generate-api-specs && pnpm run merge-client-endpoints",
|
||||
"i18n:generate": "npx lingo.dev@latest i18n"
|
||||
"generate-and-merge-api-specs": "pnpm run generate-api-specs && pnpm run merge-client-endpoints"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/prisma-adapter": "2.11.1",
|
||||
"@aws-sdk/client-s3": "3.879.0",
|
||||
"@aws-sdk/s3-presigned-post": "3.879.0",
|
||||
"@aws-sdk/s3-request-presigner": "3.879.0",
|
||||
@@ -103,11 +101,11 @@
|
||||
"lucide-react": "0.507.0",
|
||||
"markdown-it": "14.1.0",
|
||||
"mime-types": "3.0.1",
|
||||
"next": "15.5.7",
|
||||
"next": "15.5.6",
|
||||
"next-auth": "4.24.12",
|
||||
"next-safe-action": "7.10.8",
|
||||
"node-fetch": "3.3.2",
|
||||
"nodemailer": "7.0.11",
|
||||
"nodemailer": "7.0.9",
|
||||
"otplib": "12.0.1",
|
||||
"papaparse": "5.5.2",
|
||||
"prismjs": "1.30.0",
|
||||
|
||||
@@ -62,7 +62,7 @@ test.describe("Survey Create & Submit Response without logic", async () => {
|
||||
await expect(page.getByPlaceholder(surveys.createAndSubmit.openTextQuestion.placeholder)).toBeVisible();
|
||||
await page
|
||||
.getByPlaceholder(surveys.createAndSubmit.openTextQuestion.placeholder)
|
||||
.fill("Open Text answer");
|
||||
.fill("This is my Open Text answer");
|
||||
await page.locator("#questionCard-0").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Single Select Question
|
||||
@@ -116,7 +116,7 @@ test.describe("Survey Create & Submit Response without logic", async () => {
|
||||
expect(await page.getByRole("group", { name: "Choices" }).locator("label").count()).toBe(5);
|
||||
await expect(page.locator("#questionCard-3").getByRole("button", { name: "Next" })).toBeVisible();
|
||||
await expect(page.locator("#questionCard-3").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
await page.getByRole("radio", { name: "Rate 3 out of" }).check();
|
||||
await page.locator("path").nth(3).click();
|
||||
await page.locator("#questionCard-3").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// NPS Question
|
||||
@@ -212,9 +212,11 @@ test.describe("Survey Create & Submit Response without logic", async () => {
|
||||
// Address Question
|
||||
await expect(page.getByText(surveys.createAndSubmit.address.question)).toBeVisible();
|
||||
await expect(page.getByLabel(surveys.createAndSubmit.address.placeholder.addressLine1)).toBeVisible();
|
||||
await page.getByLabel(surveys.createAndSubmit.address.placeholder.addressLine1).fill("Address");
|
||||
await page
|
||||
.getByLabel(surveys.createAndSubmit.address.placeholder.addressLine1)
|
||||
.fill("This is my Address");
|
||||
await expect(page.getByLabel(surveys.createAndSubmit.address.placeholder.city)).toBeVisible();
|
||||
await page.getByLabel(surveys.createAndSubmit.address.placeholder.city).fill("city");
|
||||
await page.getByLabel(surveys.createAndSubmit.address.placeholder.city).fill("This is my city");
|
||||
await expect(page.getByLabel(surveys.createAndSubmit.address.placeholder.zip)).toBeVisible();
|
||||
await page.getByLabel(surveys.createAndSubmit.address.placeholder.zip).fill("12345");
|
||||
await page.locator("#questionCard-10").getByRole("button", { name: "Next" }).click();
|
||||
@@ -230,7 +232,7 @@ test.describe("Survey Create & Submit Response without logic", async () => {
|
||||
for (let i = 0; i < surveys.createAndSubmit.ranking.choices.length; i++) {
|
||||
await page.getByText(surveys.createAndSubmit.ranking.choices[i]).click();
|
||||
}
|
||||
await page.locator("#questionCard-12").getByRole("button", { name: "Finish" }).click();
|
||||
await page.locator("#questionCard-12").getByRole("button", { name: "Next" }).click();
|
||||
// loading spinner -> wait for it to disappear
|
||||
await page.getByTestId("loading-spinner").waitFor({ state: "hidden" });
|
||||
});
|
||||
@@ -783,7 +785,7 @@ test.describe("Testing Survey with advanced logic", async () => {
|
||||
).toBeVisible();
|
||||
await page
|
||||
.getByPlaceholder(surveys.createWithLogicAndSubmit.openTextQuestion.placeholder)
|
||||
.fill("Open Text answer");
|
||||
.fill("This is my Open Text answer");
|
||||
await page.locator("#questionCard-0").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// Single Select Question
|
||||
@@ -856,9 +858,10 @@ test.describe("Testing Survey with advanced logic", async () => {
|
||||
await expect(
|
||||
page.locator("#questionCard-4").getByText(surveys.createWithLogicAndSubmit.ratingQuestion.highLabel)
|
||||
).toBeVisible();
|
||||
expect(await page.getByRole("group", { name: "Choices" }).locator("label").count()).toBe(5);
|
||||
await expect(page.locator("#questionCard-4").getByRole("button", { name: "Next" })).toBeVisible();
|
||||
await expect(page.locator("#questionCard-4").getByRole("button", { name: "Back" })).toBeVisible();
|
||||
await page.getByRole("radio", { name: "Rate 4 out of" }).check();
|
||||
await page.getByRole("group", { name: "Choices" }).locator("path").nth(3).click();
|
||||
await page.locator("#questionCard-4").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// NPS Question
|
||||
@@ -969,12 +972,14 @@ test.describe("Testing Survey with advanced logic", async () => {
|
||||
).toBeVisible();
|
||||
await page
|
||||
.getByLabel(surveys.createWithLogicAndSubmit.address.placeholder.addressLine1)
|
||||
.fill("Address");
|
||||
.fill("This is my Address");
|
||||
await expect(page.getByLabel(surveys.createWithLogicAndSubmit.address.placeholder.city)).toBeVisible();
|
||||
await page.getByLabel(surveys.createWithLogicAndSubmit.address.placeholder.city).fill("city");
|
||||
await page
|
||||
.getByLabel(surveys.createWithLogicAndSubmit.address.placeholder.city)
|
||||
.fill("This is my city");
|
||||
await expect(page.getByLabel(surveys.createWithLogicAndSubmit.address.placeholder.zip)).toBeVisible();
|
||||
await page.getByLabel(surveys.createWithLogicAndSubmit.address.placeholder.zip).fill("12345");
|
||||
await page.locator("#questionCard-13").getByRole("button", { name: "Finish" }).click();
|
||||
await page.locator("#questionCard-13").getByRole("button", { name: "Next" }).click();
|
||||
|
||||
// loading spinner -> wait for it to disappear
|
||||
await page.getByTestId("loading-spinner").waitFor({ state: "hidden" });
|
||||
@@ -992,26 +997,13 @@ test.describe("Testing Survey with advanced logic", async () => {
|
||||
const updatedUrl = currentUrl.replace("summary?share=true", "responses");
|
||||
|
||||
await page.goto(updatedUrl);
|
||||
await page.waitForSelector("table#response-table");
|
||||
await page.waitForSelector("#response-table");
|
||||
|
||||
await expect(page.getByRole("cell", { name: "score" })).toBeVisible();
|
||||
|
||||
await page.waitForLoadState("networkidle");
|
||||
await page.waitForTimeout(5000);
|
||||
|
||||
await page.pause();
|
||||
|
||||
// Look for any cell containing "32" or a score-related value
|
||||
const scoreCell = page.getByRole("cell").filter({ hasText: /^32/ });
|
||||
await expect(scoreCell).toBeVisible({
|
||||
timeout: 15000,
|
||||
});
|
||||
|
||||
// Look for the secret message in the table
|
||||
const secretCell = page.getByRole("cell").filter({ hasText: /This is a secret message for e2e tests/ });
|
||||
await expect(secretCell).toBeVisible({
|
||||
timeout: 15000,
|
||||
});
|
||||
await expect(page.getByRole("cell", { name: "32", exact: true })).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -656,7 +656,7 @@ export const createSurveyWithLogic = async (page: Page, params: CreateSurveyWith
|
||||
await page.locator("#action-2-operator").click();
|
||||
await page.getByRole("option", { name: "Assign =" }).click();
|
||||
await page.locator("#action-2-value-input").click();
|
||||
await page.locator("#action-2-value-input").fill("This ");
|
||||
await page.locator("#action-2-value-input").fill("1");
|
||||
// Close Block 1 settings before moving to Block 2
|
||||
await page
|
||||
.locator("div")
|
||||
|
||||
@@ -106,51 +106,51 @@ export const surveys = {
|
||||
createAndSubmit: {
|
||||
welcomeCard: {
|
||||
headline: "Welcome to My Testing Survey Welcome Card!",
|
||||
description: "the description of my Welcome Card!",
|
||||
description: "This is the description of my Welcome Card!",
|
||||
},
|
||||
openTextQuestion: {
|
||||
question: "Open Text Question",
|
||||
description: "Open Text Description",
|
||||
placeholder: "Placeholder",
|
||||
question: "This is my Open Text Question",
|
||||
description: "This is my Open Text Description",
|
||||
placeholder: "This is my Placeholder",
|
||||
},
|
||||
singleSelectQuestion: {
|
||||
question: "Single Select Question",
|
||||
description: "Single Select Description",
|
||||
question: "This is my Single Select Question",
|
||||
description: "This is my Single Select Description",
|
||||
options: ["Option 1", "Option 2"],
|
||||
},
|
||||
multiSelectQuestion: {
|
||||
question: "Multi Select Question",
|
||||
description: "Multi Select Description",
|
||||
question: "This is my Multi Select Question",
|
||||
description: "This is Multi Select Description",
|
||||
options: ["Option 1", "Option 2", "Option 3"],
|
||||
},
|
||||
ratingQuestion: {
|
||||
question: "Rating Question",
|
||||
description: "Rating Description",
|
||||
question: "This is my Rating Question",
|
||||
description: "This is Rating Description",
|
||||
lowLabel: "My Lower Label",
|
||||
highLabel: "My Upper Label",
|
||||
},
|
||||
npsQuestion: {
|
||||
question: "NPS Question",
|
||||
question: "This is my NPS Question",
|
||||
lowLabel: "My Lower Label",
|
||||
highLabel: "My Upper Label",
|
||||
},
|
||||
ctaQuestion: {
|
||||
question: "CTA Question",
|
||||
question: "This is my CTA Question",
|
||||
buttonLabel: "My Button Label",
|
||||
},
|
||||
consentQuestion: {
|
||||
question: "Consent Question",
|
||||
question: "This is my Consent Question",
|
||||
checkboxLabel: "My Checkbox Label",
|
||||
},
|
||||
pictureSelectQuestion: {
|
||||
question: "Picture Select Question",
|
||||
description: "Picture Select Description",
|
||||
question: "This is my Picture Select Question",
|
||||
description: "This is Picture Select Description",
|
||||
},
|
||||
dateQuestion: {
|
||||
question: "Date Question",
|
||||
question: "This is my Date Question",
|
||||
},
|
||||
fileUploadQuestion: {
|
||||
question: "File Upload Question",
|
||||
question: "This is my File Upload Question",
|
||||
},
|
||||
matrix: {
|
||||
question: "How much do you love these flowers?",
|
||||
@@ -178,57 +178,57 @@ export const surveys = {
|
||||
createWithLogicAndSubmit: {
|
||||
welcomeCard: {
|
||||
headline: "Welcome to My Testing Survey Welcome Card!",
|
||||
description: "the description of my Welcome Card!",
|
||||
description: "This is the description of my Welcome Card!",
|
||||
},
|
||||
openTextQuestion: {
|
||||
question: "Open Text Question",
|
||||
description: "Open Text Description",
|
||||
placeholder: "Placeholder",
|
||||
question: "This is my Open Text Question",
|
||||
description: "This is my Open Text Description",
|
||||
placeholder: "This is my Placeholder",
|
||||
},
|
||||
singleSelectQuestion: {
|
||||
question: "Single Select Question",
|
||||
description: "Single Select Description",
|
||||
question: "This is my Single Select Question",
|
||||
description: "This is my Single Select Description",
|
||||
options: ["Option 1", "Option 2"],
|
||||
},
|
||||
multiSelectQuestion: {
|
||||
question: "Multi Select Question",
|
||||
description: "Multi Select Description",
|
||||
question: "This is my Multi Select Question",
|
||||
description: "This is Multi Select Description",
|
||||
options: ["Option 1", "Option 2", "Option 3"],
|
||||
},
|
||||
ratingQuestion: {
|
||||
question: "Rating Question",
|
||||
description: "Rating Description",
|
||||
question: "This is my Rating Question",
|
||||
description: "This is Rating Description",
|
||||
lowLabel: "My Lower Label",
|
||||
highLabel: "My Upper Label",
|
||||
},
|
||||
npsQuestion: {
|
||||
question: "NPS Question",
|
||||
question: "This is my NPS Question",
|
||||
lowLabel: "My Lower Label",
|
||||
highLabel: "My Upper Label",
|
||||
},
|
||||
ctaQuestion: {
|
||||
question: "CTA Question",
|
||||
question: "This is my CTA Question",
|
||||
buttonLabel: "My Button Label",
|
||||
},
|
||||
consentQuestion: {
|
||||
question: "Consent Question",
|
||||
question: "This is my Consent Question",
|
||||
checkboxLabel: "My Checkbox Label",
|
||||
},
|
||||
pictureSelectQuestion: {
|
||||
question: "Picture Select Question",
|
||||
description: "Picture Select Description",
|
||||
question: "This is my Picture Select Question",
|
||||
description: "This is Picture Select Description",
|
||||
},
|
||||
fileUploadQuestion: {
|
||||
question: "File Upload Question",
|
||||
question: "This is my File Upload Question",
|
||||
},
|
||||
date: {
|
||||
question: "Date Question",
|
||||
question: "This is my Date Question",
|
||||
},
|
||||
cal: {
|
||||
question: "cal Question",
|
||||
question: "This is my cal Question",
|
||||
},
|
||||
matrix: {
|
||||
question: "Matrix Question",
|
||||
question: "This is my Matrix Question",
|
||||
description: "0: Not at all, 3: Love it",
|
||||
rows: ["Roses", "Trees", "Ocean"],
|
||||
columns: ["0", "1", "2", "3"],
|
||||
@@ -242,7 +242,7 @@ export const surveys = {
|
||||
},
|
||||
},
|
||||
ranking: {
|
||||
question: "Ranking Question",
|
||||
question: "This is my Ranking Question",
|
||||
choices: ["Work", "Money", "Travel", "Family", "Friends"],
|
||||
},
|
||||
endingCard: {
|
||||
@@ -342,12 +342,12 @@ export const actions = {
|
||||
noCode: {
|
||||
click: {
|
||||
name: "Create Click Action (CSS Selector)",
|
||||
description: "Create Action (click, CSS Selector)",
|
||||
description: "This is my Create Action (click, CSS Selector)",
|
||||
selector: ".my-custom-class",
|
||||
},
|
||||
pageView: {
|
||||
name: "Create Page view Action (specific Page URL)",
|
||||
description: "Create Action (Page view)",
|
||||
description: "This is my Create Action (Page view)",
|
||||
matcher: {
|
||||
label: "Contains",
|
||||
value: "custom-url",
|
||||
@@ -355,16 +355,16 @@ export const actions = {
|
||||
},
|
||||
exitIntent: {
|
||||
name: "Create Exit Intent Action",
|
||||
description: "Create Action (Exit Intent)",
|
||||
description: "This is my Create Action (Exit Intent)",
|
||||
},
|
||||
fiftyPercentScroll: {
|
||||
name: "Create 50% Scroll Action",
|
||||
description: "Create Action (50% Scroll)",
|
||||
description: "This is my Create Action (50% Scroll)",
|
||||
},
|
||||
},
|
||||
code: {
|
||||
name: "Create Action (Code)",
|
||||
description: "Create Action (Code)",
|
||||
description: "This is my Create Action (Code)",
|
||||
key: "Create Action (Code)",
|
||||
},
|
||||
},
|
||||
@@ -372,12 +372,12 @@ export const actions = {
|
||||
noCode: {
|
||||
click: {
|
||||
name: "Edit Click Action (CSS Selector)",
|
||||
description: "Edit Action (click, CSS Selector)",
|
||||
description: "This is my Edit Action (click, CSS Selector)",
|
||||
selector: ".my-custom-class-edited",
|
||||
},
|
||||
pageView: {
|
||||
name: "Edit Page view Action (specific Page URL)",
|
||||
description: "Edit Action (Page view)",
|
||||
description: "This is my Edit Action (Page view)",
|
||||
matcher: {
|
||||
label: "Starts with",
|
||||
value: "custom-url0-edited",
|
||||
@@ -386,26 +386,26 @@ export const actions = {
|
||||
},
|
||||
exitIntent: {
|
||||
name: "Edit Exit Intent Action",
|
||||
description: "Edit Action (Exit Intent)",
|
||||
description: "This is my Edit Action (Exit Intent)",
|
||||
},
|
||||
fiftyPercentScroll: {
|
||||
name: "Edit 50% Scroll Action",
|
||||
description: "Edit Action (50% Scroll)",
|
||||
description: "This is my Edit Action (50% Scroll)",
|
||||
},
|
||||
},
|
||||
code: {
|
||||
description: "Edit Action (Code)",
|
||||
description: "This is my Edit Action (Code)",
|
||||
},
|
||||
},
|
||||
delete: {
|
||||
noCode: {
|
||||
name: "Delete click Action (CSS Selector)",
|
||||
description: "Delete Action (CSS Selector)",
|
||||
description: "This is my Delete Action (CSS Selector)",
|
||||
selector: ".my-custom-class-deleted",
|
||||
},
|
||||
code: {
|
||||
name: "Delete Action (Code)",
|
||||
description: "Delete Action (Code)",
|
||||
description: "This is my Delete Action (Code)",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
import { DefaultSession } from "next-auth";
|
||||
|
||||
declare module "next-auth" {
|
||||
interface Session {
|
||||
user?: {
|
||||
id: string;
|
||||
isActive: boolean;
|
||||
} & DefaultSession["user"];
|
||||
}
|
||||
}
|
||||
@@ -220,7 +220,6 @@ vi.mock("@/lib/constants", () => ({
|
||||
"ja-JP",
|
||||
"zh-Hans-CN",
|
||||
"es-ES",
|
||||
"sv-SE",
|
||||
],
|
||||
DEFAULT_LOCALE: "en-US",
|
||||
BREVO_API_KEY: "mock-brevo-api-key",
|
||||
|
||||
@@ -234,7 +234,6 @@
|
||||
"self-hosting/configuration/smtp",
|
||||
"self-hosting/configuration/file-uploads",
|
||||
"self-hosting/configuration/domain-configuration",
|
||||
"self-hosting/configuration/custom-subpath",
|
||||
{
|
||||
"group": "Auth & SSO",
|
||||
"icon": "lock",
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
---
|
||||
title: "Custom Subpath"
|
||||
description: "Serve Formbricks from a custom URL prefix when you cannot expose it on the root domain."
|
||||
icon: "link"
|
||||
---
|
||||
|
||||
<Note>
|
||||
Custom subpath deployments are currently under internal review. If you need early access, please reach out via
|
||||
[GitHub Discussions](https://github.com/formbricks/formbricks/discussions).
|
||||
</Note>
|
||||
|
||||
### When to use a custom subpath
|
||||
|
||||
Use a custom subpath (also called a Next.js base path) when your reverse proxy reserves the root domain for another
|
||||
service, but you still want Formbricks to live under the same hostname—for example `https://example.com/feedback`.
|
||||
Support for a build-time `BASE_PATH` variable is available in the Formbricks web app so that all internal routes,
|
||||
assets, and sign-in redirects honor the prefix.
|
||||
|
||||
### Requirements and limitations
|
||||
|
||||
- `BASE_PATH` must be present during `pnpm build`; changing it afterward requires a rebuild.
|
||||
- Official Formbricks Docker images do **not** accept this flag for technical reasons, so you must build your own image.
|
||||
- All public URLs (`WEBAPP_URL`, `NEXTAUTH_URL`, webhook targets, OAuth callbacks, etc.) need the same prefix.
|
||||
- Your proxy must rewrite `/custom-path/*` to the Formbricks container while keeping the prefix visible to clients.
|
||||
|
||||
### Configure environment variables
|
||||
|
||||
Add the following variables to the environment you use for builds (local, CI, or Docker build args):
|
||||
|
||||
```bash
|
||||
BASE_PATH="/custom-path"
|
||||
WEBAPP_URL="https://yourdomain.com/custom-path"
|
||||
NEXTAUTH_URL="https://yourdomain.com/custom-path/api/auth"
|
||||
```
|
||||
|
||||
If you use email links, webhooks, or third-party OAuth providers, ensure every URL you register includes the prefix.
|
||||
|
||||
### Build a Docker image with a custom subpath
|
||||
|
||||
<Steps>
|
||||
<Step title="Clone Formbricks and prepare secrets">
|
||||
Make sure you have the repository checked out and create temporary files (or use <code>--secret</code>) for the
|
||||
required build-time secrets such as <code>DATABASE_URL</code>, <code>ENCRYPTION_KEY</code>, <code>REDIS_URL</code>,
|
||||
and optional telemetry tokens.
|
||||
</Step>
|
||||
<Step title="Pass BASE_PATH as a build argument">
|
||||
Use the Formbricks web Dockerfile and supply the custom subpath via <code>--build-arg</code>. Example:
|
||||
|
||||
```bash
|
||||
docker build \
|
||||
--progress=plain \
|
||||
--no-cache \
|
||||
--build-arg BASE_PATH=/custom-path \
|
||||
--secret id=database_url,src=<(printf "postgresql://user:password@localhost:5432/formbricks?schema=public") \
|
||||
--secret id=encryption_key,src=<(printf "your-32-character-encryption-key-here") \
|
||||
--secret id=redis_url,src=<(printf "redis://localhost:6379") \
|
||||
--secret id=sentry_auth_token,src=<(printf "") \
|
||||
-f apps/web/Dockerfile \
|
||||
-t formbricks-web \
|
||||
.
|
||||
```
|
||||
|
||||
During the build logs you should see <code>BASE PATH /custom-path</code>, confirming that Next.js picked up the
|
||||
prefix.
|
||||
</Step>
|
||||
<Step title="Run the container behind your proxy">
|
||||
Start the resulting image with the same runtime environment variables you normally use (database credentials,
|
||||
mailing provider, etc.). Point your reverse proxy so that <code>/custom-path</code> requests forward to
|
||||
<code>http://formbricks-web:3000/custom-path</code> without stripping the prefix.
|
||||
</Step>
|
||||
</Steps>
|
||||
|
||||
### Verify the deployment
|
||||
|
||||
1. Open `https://yourdomain.com/custom-path` and complete the onboarding flow.
|
||||
2. Create a survey and preview it—embedded scripts now load assets relative to the subpath.
|
||||
3. Sign out and confirm the login page still includes `/custom-path`.
|
||||
|
||||
### Troubleshooting checklist
|
||||
|
||||
- Confirm your build pipeline actually passes `BASE_PATH` (and, if needed, `WEBAPP_URL`/`NEXTAUTH_URL`) into the build
|
||||
stage—check CI logs for the `BASE PATH /your-prefix` line and make sure custom Dockerfiles or wrappers forward
|
||||
`--build-arg BASE_PATH=...` correctly.
|
||||
- If you cannot log in, double-check that `NEXTAUTH_URL` includes the prefix and uses the full route to the API as stated above. NextAuth rejects callbacks that do not
|
||||
match exactly.
|
||||
- Re-run the Docker build when changing `BASE_PATH`; simply editing the container environment is not sufficient.
|
||||
- Inspect your proxy configuration to ensure it does not rewrite paths internally (e.g., `strip_prefix` needs to stay
|
||||
disabled).
|
||||
- When in doubt, rebuild locally with `--progress=plain` and verify that the `BASE PATH` line reflects your prefix.
|
||||
|
||||
@@ -81,13 +81,6 @@ Example of Response Created webhook payload:
|
||||
}
|
||||
},
|
||||
"singleUseId": null,
|
||||
"survey": {
|
||||
"title": "Customer Satisfaction Survey",
|
||||
"type": "link",
|
||||
"status": "inProgress",
|
||||
"createdAt": "2025-07-20T10:30:00.000Z",
|
||||
"updatedAt": "2025-07-24T07:45:00.000Z"
|
||||
},
|
||||
"surveyId": "surveyId",
|
||||
"tags": [],
|
||||
"ttc": {
|
||||
@@ -132,13 +125,6 @@ Example of Response Updated webhook payload:
|
||||
}
|
||||
},
|
||||
"singleUseId": null,
|
||||
"survey": {
|
||||
"title": "Customer Satisfaction Survey",
|
||||
"type": "link",
|
||||
"status": "inProgress",
|
||||
"createdAt": "2025-07-20T10:30:00.000Z",
|
||||
"updatedAt": "2025-07-24T07:45:00.000Z"
|
||||
},
|
||||
"surveyId": "surveyId",
|
||||
"tags": [],
|
||||
"ttc": {
|
||||
@@ -184,13 +170,6 @@ Example of Response Finished webhook payload:
|
||||
}
|
||||
},
|
||||
"singleUseId": null,
|
||||
"survey": {
|
||||
"title": "Customer Satisfaction Survey",
|
||||
"type": "link",
|
||||
"status": "inProgress",
|
||||
"createdAt": "2025-07-20T10:30:00.000Z",
|
||||
"updatedAt": "2025-07-24T07:45:00.000Z"
|
||||
},
|
||||
"surveyId": "surveyId",
|
||||
"tags": [],
|
||||
"ttc": {
|
||||
|
||||
@@ -17,36 +17,36 @@ Integrate the **Formbricks App Survey SDK** into your app using multiple options
|
||||
|
||||
<CardGroup cols={2}>
|
||||
<Card title="HTML" icon="html5" color="orange" href="#html">
|
||||
All you need to do is add three lines of code to your HTML script, and that's it!
|
||||
[All you need to do is add three lines of code to your HTML script, and that's it!](https://formbricks.com/docs/app-surveys/framework-guides#html)
|
||||
</Card>
|
||||
|
||||
<Card title="React.js" icon="react" color="lightblue" href="#react-js">
|
||||
Load our JavaScript library with your environment ID, and you're ready to
|
||||
go!
|
||||
[Load our JavaScript library with your environment ID, and you're ready to
|
||||
go!](https://formbricks.com/docs/app-surveys/framework-guides#react-js)
|
||||
</Card>
|
||||
|
||||
<Card title="Next.js" icon="react" href="#next-js">
|
||||
Natively add us to your Next.js project, with support for both App and Pages project
|
||||
structure.
|
||||
[Natively add us to your Next.js project, with support for both App and Pages project
|
||||
structure.](https://formbricks.com/docs/app-surveys/framework-guides#next-js)
|
||||
</Card>
|
||||
|
||||
<Card title="Vue.js" icon="vuejs" href="#vue-js">
|
||||
Learn how to use Formbricks' Vue.js SDK to integrate your surveys into Vue.js applications.
|
||||
Learn how to use Formbricks' React Native SDK to integrate your surveys into React Native applications.
|
||||
</Card>
|
||||
|
||||
<Card title="React Native" icon="react" color="lightblue" href="#react-native">
|
||||
Easily integrate our SDK with your React Native app for seamless survey
|
||||
support.
|
||||
[Easily integrate our SDK with your React Native app for seamless survey
|
||||
support.](https://formbricks.com/docs/app-surveys/framework-guides#react-native)
|
||||
</Card>
|
||||
|
||||
<Card title="Swift" icon="swift" color="orange" href="#swift">
|
||||
Use our iOS SDK to quickly integrate surveys into your iOS
|
||||
applications.
|
||||
[Use our iOS SDK to quickly integrate surveys into your iOS
|
||||
applications.](https://formbricks.com/docs/app-surveys/framework-guides#swift)
|
||||
</Card>
|
||||
|
||||
<Card title="Android" icon="android" color="green" href="#android">
|
||||
Integrate surveys into your Android applications using our native Kotlin
|
||||
SDK.
|
||||
[Integrate surveys into your Android applications using our native Kotlin
|
||||
SDK.](https://formbricks.com/docs/app-surveys/framework-guides#android)
|
||||
</Card>
|
||||
|
||||
</CardGroup>
|
||||
@@ -345,8 +345,6 @@ Now, visit the [Validate Your Setup](#validate-your-setup) section to verify you
|
||||
|
||||
## Swift
|
||||
|
||||
<Info>**Minimum iOS Version:** The Formbricks iOS SDK requires **iOS 16.4** or higher.</Info>
|
||||
|
||||
Install the Formbricks iOS SDK using the following steps:
|
||||
|
||||
**Swift Package Manager**
|
||||
@@ -365,7 +363,7 @@ Install the Formbricks iOS SDK using the following steps:
|
||||
1. Add the following to your `Podfile`:
|
||||
|
||||
```ruby
|
||||
platform :ios, '16.4'
|
||||
platform :ios, '16.6'
|
||||
use_frameworks! :linkage => :static
|
||||
|
||||
target 'YourTargetName' do
|
||||
@@ -431,10 +429,6 @@ Now, visit the [Validate Your Setup](#validate-your-setup) section to verify you
|
||||
|
||||
## Android
|
||||
|
||||
<Info>
|
||||
**Minimum Android Version:** The Formbricks Android SDK requires **Android 10 (API level 29)** or higher.
|
||||
</Info>
|
||||
|
||||
Install the Formbricks Android SDK using the following steps:
|
||||
|
||||
### Installation
|
||||
|
||||
+5
-7
@@ -34,16 +34,15 @@
|
||||
"prepare": "husky install",
|
||||
"storybook": "turbo run storybook",
|
||||
"fb-migrate-dev": "pnpm --filter @formbricks/database create-migration && pnpm prisma generate",
|
||||
"i18n:surveys:generate": "pnpm --filter @formbricks/surveys i18n:generate",
|
||||
"i18n:web:generate": "pnpm --filter @formbricks/web i18n:generate",
|
||||
"generate-translations": "pnpm i18n:web:generate && pnpm i18n:surveys:generate",
|
||||
"i18n:generate": " pnpm --filter @formbricks/surveys i18n:generate",
|
||||
"generate-translations": "cd apps/web && npx lingo.dev@latest i18n",
|
||||
"scan-translations": "pnpm --filter @formbricks/i18n-utils scan-translations",
|
||||
"i18n": "pnpm generate-translations && pnpm scan-translations",
|
||||
"i18n:validate": "pnpm scan-translations"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "19.1.2",
|
||||
"react-dom": "19.1.2"
|
||||
"react": "19.1.0",
|
||||
"react-dom": "19.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@azure/microsoft-playwright-testing": "1.0.0-beta.7",
|
||||
@@ -84,12 +83,11 @@
|
||||
},
|
||||
"overrides": {
|
||||
"axios": ">=1.12.2",
|
||||
"node-forge": ">=1.3.2",
|
||||
"tar-fs": "2.1.4",
|
||||
"typeorm": ">=0.3.26"
|
||||
},
|
||||
"comments": {
|
||||
"overrides": "Security fixes for transitive dependencies. Remove when upstream packages update: axios (CVE-2025-58754) - awaiting @boxyhq/saml-jackson update | node-forge (Dependabot #230) - awaiting @boxyhq/saml-jackson update | tar-fs (Dependabot #205) - awaiting upstream dependency updates | typeorm (Dependabot #223) - awaiting @boxyhq/saml-jackson update"
|
||||
"overrides": "Security fixes for transitive dependencies. Remove when upstream packages update: axios (CVE-2025-58754) - awaiting @boxyhq/saml-jackson update | tar-fs (Dependabot #205) - awaiting upstream dependency updates | typeorm (Dependabot #223) - awaiting @boxyhq/saml-jackson update"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+8
-52
@@ -3,7 +3,7 @@ import type { RedisClient } from "@/types/client";
|
||||
import { type CacheError, CacheErrorClass, ErrorCode, type Result, err, ok } from "@/types/error";
|
||||
import type { CacheKey } from "@/types/keys";
|
||||
import { ZCacheKey } from "@/types/keys";
|
||||
import { ZTtlMs, ZTtlMsOptional } from "@/types/service";
|
||||
import { ZTtlMs } from "@/types/service";
|
||||
import { validateInputs } from "./utils/validation";
|
||||
|
||||
/**
|
||||
@@ -116,13 +116,13 @@ export class CacheService {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a value in cache with automatic JSON serialization and optional TTL
|
||||
* Set a value in cache with automatic JSON serialization and TTL
|
||||
* @param key - Cache key to store under
|
||||
* @param value - Value to store
|
||||
* @param ttlMs - Time to live in milliseconds (optional - if omitted, key persists indefinitely)
|
||||
* @param ttlMs - Time to live in milliseconds
|
||||
* @returns Result containing void or an error
|
||||
*/
|
||||
async set(key: CacheKey, value: unknown, ttlMs?: number): Promise<Result<void, CacheError>> {
|
||||
async set(key: CacheKey, value: unknown, ttlMs: number): Promise<Result<void, CacheError>> {
|
||||
// Check Redis availability first
|
||||
if (!this.isRedisClientReady()) {
|
||||
return err({
|
||||
@@ -130,8 +130,8 @@ export class CacheService {
|
||||
});
|
||||
}
|
||||
|
||||
// Validate key and optional TTL
|
||||
const validation = validateInputs([key, ZCacheKey], [ttlMs, ZTtlMsOptional]);
|
||||
// Validate both key and TTL in one call
|
||||
const validation = validateInputs([key, ZCacheKey], [ttlMs, ZTtlMs]);
|
||||
if (!validation.ok) {
|
||||
return validation;
|
||||
}
|
||||
@@ -141,13 +141,7 @@ export class CacheService {
|
||||
const normalizedValue = value === undefined ? null : value;
|
||||
const serialized = JSON.stringify(normalizedValue);
|
||||
|
||||
if (ttlMs === undefined) {
|
||||
// Set without expiration (persists indefinitely)
|
||||
await this.withTimeout(this.redis.set(key, serialized));
|
||||
} else {
|
||||
// Set with expiration
|
||||
await this.withTimeout(this.redis.setEx(key, Math.floor(ttlMs / 1000), serialized));
|
||||
}
|
||||
await this.withTimeout(this.redis.setEx(key, Math.floor(ttlMs / 1000), serialized));
|
||||
return ok(undefined);
|
||||
} catch (error) {
|
||||
logger.error({ error, key, ttlMs }, "Cache set operation failed");
|
||||
@@ -191,44 +185,6 @@ export class CacheService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to acquire a distributed lock (atomic SET NX operation)
|
||||
* @param key - Lock key
|
||||
* @param value - Lock value (typically "locked" or instance identifier)
|
||||
* @param ttlMs - Time to live in milliseconds (lock expiration)
|
||||
* @returns Result containing boolean indicating if lock was acquired, or an error
|
||||
*/
|
||||
async tryLock(key: CacheKey, value: string, ttlMs: number): Promise<Result<boolean, CacheError>> {
|
||||
// Check Redis availability first
|
||||
if (!this.isRedisClientReady()) {
|
||||
return err({
|
||||
code: ErrorCode.RedisConnectionError,
|
||||
});
|
||||
}
|
||||
|
||||
const validation = validateInputs([key, ZCacheKey], [ttlMs, ZTtlMs]);
|
||||
if (!validation.ok) {
|
||||
return validation;
|
||||
}
|
||||
|
||||
try {
|
||||
// Use SET with NX (only set if not exists) and PX (expiration in milliseconds) for atomic lock acquisition
|
||||
const result = await this.withTimeout(
|
||||
this.redis.set(key, value, {
|
||||
NX: true,
|
||||
PX: ttlMs,
|
||||
})
|
||||
);
|
||||
// SET returns "OK" if lock was acquired, null if key already exists
|
||||
return ok(result === "OK");
|
||||
} catch (error) {
|
||||
logger.error({ error, key, ttlMs }, "Cache lock operation failed");
|
||||
return err({
|
||||
code: ErrorCode.RedisOperationError,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Cache wrapper for functions (cache-aside).
|
||||
* Never throws due to cache errors; function errors propagate without retry.
|
||||
@@ -287,7 +243,7 @@ export class CacheService {
|
||||
}
|
||||
|
||||
private async trySetCache(key: CacheKey, value: unknown, ttlMs: number): Promise<void> {
|
||||
if (value === undefined) {
|
||||
if (typeof value === "undefined") {
|
||||
return; // Skip caching undefined values
|
||||
}
|
||||
|
||||
|
||||
Vendored
-7
@@ -5,10 +5,3 @@ export const ZTtlMs = z
|
||||
.int()
|
||||
.min(1000, "TTL must be at least 1000ms (1 second)")
|
||||
.finite("TTL must be finite");
|
||||
|
||||
export const ZTtlMsOptional = z
|
||||
.number()
|
||||
.int()
|
||||
.min(1000, "TTL must be at least 1000ms (1 second)")
|
||||
.finite("TTL must be finite")
|
||||
.optional();
|
||||
|
||||
+55
-189
@@ -1,15 +1,8 @@
|
||||
import { createId } from "@paralleldrive/cuid2";
|
||||
import { logger } from "@formbricks/logger";
|
||||
import type { MigrationScript } from "../../src/scripts/migration-runner";
|
||||
import type {
|
||||
Block,
|
||||
CTAMigrationStats,
|
||||
IntegrationConfig,
|
||||
IntegrationMigrationStats,
|
||||
MigratedIntegration,
|
||||
SurveyRecord,
|
||||
} from "./types";
|
||||
import { migrateIntegrationConfig, migrateQuestionsSurveyToBlocks } from "./utils";
|
||||
import type { Block, CTAMigrationStats, SurveyRecord } from "./types";
|
||||
import { migrateQuestionsSurveyToBlocks } from "./utils";
|
||||
|
||||
export const migrateQuestionsToBlocks: MigrationScript = {
|
||||
type: "data",
|
||||
@@ -32,198 +25,71 @@ export const migrateQuestionsToBlocks: MigrationScript = {
|
||||
|
||||
if (surveys.length === 0) {
|
||||
logger.info("No surveys found that need migration");
|
||||
} else {
|
||||
logger.info(`Found ${surveys.length.toString()} surveys to migrate`);
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Process each survey
|
||||
const updates: { id: string; blocks: Block[] }[] = [];
|
||||
logger.info(`Found ${surveys.length.toString()} surveys to migrate`);
|
||||
|
||||
for (const survey of surveys) {
|
||||
try {
|
||||
const migrated = migrateQuestionsSurveyToBlocks(survey, createId, ctaStats);
|
||||
updates.push({
|
||||
id: migrated.id,
|
||||
blocks: migrated.blocks,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(error, `Failed to migrate survey ${survey.id}`);
|
||||
throw new Error(
|
||||
`Migration failed for survey ${survey.id}: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
// 2. Process each survey
|
||||
const updates: { id: string; blocks: Block[] }[] = [];
|
||||
|
||||
logger.info(`Successfully processed ${updates.length.toString()} surveys`);
|
||||
|
||||
// 3. Update surveys in batches using UNNEST for performance
|
||||
// Batch size of 150 balances performance with query size safety (~7.5MB per batch)
|
||||
const SURVEY_BATCH_SIZE = 150;
|
||||
let updatedCount = 0;
|
||||
|
||||
for (let i = 0; i < updates.length; i += SURVEY_BATCH_SIZE) {
|
||||
const batch = updates.slice(i, i + SURVEY_BATCH_SIZE);
|
||||
|
||||
try {
|
||||
// Build arrays for batch update
|
||||
const ids = batch.map((u) => u.id);
|
||||
const blocksJsonStrings = batch.map((u) => JSON.stringify(u.blocks));
|
||||
|
||||
// Use UNNEST to update multiple surveys in a single query
|
||||
await tx.$executeRawUnsafe(
|
||||
`UPDATE "Survey" AS s
|
||||
SET
|
||||
blocks = (
|
||||
SELECT array_agg(elem)
|
||||
FROM jsonb_array_elements(data.blocks_json::jsonb) AS elem
|
||||
),
|
||||
questions = '[]'::jsonb
|
||||
FROM (
|
||||
SELECT
|
||||
unnest($1::text[]) AS id,
|
||||
unnest($2::text[]) AS blocks_json
|
||||
) AS data
|
||||
WHERE s.id = data.id`,
|
||||
ids,
|
||||
blocksJsonStrings
|
||||
);
|
||||
|
||||
updatedCount += batch.length;
|
||||
|
||||
// Log progress
|
||||
logger.info(`Progress: ${updatedCount.toString()}/${updates.length.toString()} surveys updated`);
|
||||
} catch (error) {
|
||||
logger.error(error, `Failed to update survey batch starting at index ${i.toString()}`);
|
||||
throw new Error(
|
||||
`Database batch update failed at index ${i.toString()}: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`Migration complete: ${updatedCount.toString()} surveys migrated to blocks`);
|
||||
|
||||
// 4. Log CTA migration statistics
|
||||
if (ctaStats.totalCTAElements > 0) {
|
||||
logger.info(
|
||||
`CTA elements processed: ${ctaStats.totalCTAElements.toString()} total (${ctaStats.ctaWithExternalLink.toString()} with external link, ${ctaStats.ctaWithoutExternalLink.toString()} without)`
|
||||
for (const survey of surveys) {
|
||||
try {
|
||||
const migrated = migrateQuestionsSurveyToBlocks(survey, createId, ctaStats);
|
||||
updates.push({
|
||||
id: migrated.id,
|
||||
blocks: migrated.blocks,
|
||||
});
|
||||
} catch (error) {
|
||||
logger.error(error, `Failed to migrate survey ${survey.id}`);
|
||||
throw new Error(
|
||||
`Migration failed for survey ${survey.id}: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. Migrate Integration configs
|
||||
logger.info("Starting integration config migration");
|
||||
logger.info(`Successfully processed ${updates.length.toString()} surveys`);
|
||||
|
||||
// Initialize integration statistics
|
||||
const integrationStats: IntegrationMigrationStats = {
|
||||
totalIntegrations: 0,
|
||||
googleSheets: { processed: 0, skipped: 0 },
|
||||
airtable: { processed: 0, skipped: 0 },
|
||||
slack: { processed: 0, skipped: 0 },
|
||||
notion: { processed: 0, skipped: 0 },
|
||||
n8n: { skipped: 0 },
|
||||
errors: 0,
|
||||
};
|
||||
// 3. Update surveys individually for safety (avoids SQL injection risks with complex JSONB arrays)
|
||||
let updatedCount = 0;
|
||||
|
||||
// Query all integrations
|
||||
const integrations = await tx.$queryRaw<{ id: string; type: string; config: IntegrationConfig }[]>`
|
||||
SELECT id, type, config
|
||||
FROM "Integration"
|
||||
`;
|
||||
|
||||
integrationStats.totalIntegrations = integrations.length;
|
||||
|
||||
if (integrations.length === 0) {
|
||||
logger.info("No integrations found to migrate");
|
||||
} else {
|
||||
logger.info(`Found ${integrations.length.toString()} integrations to process`);
|
||||
|
||||
// Process integrations in memory
|
||||
const integrationUpdates: MigratedIntegration[] = [];
|
||||
|
||||
for (const integration of integrations) {
|
||||
try {
|
||||
// Config is JSON from database - cast to IntegrationConfig for runtime processing
|
||||
const result = migrateIntegrationConfig(integration.type, integration.config);
|
||||
|
||||
// Track statistics
|
||||
const typeStats = integrationStats[integration.type as keyof typeof integrationStats];
|
||||
if (typeStats && typeof typeStats === "object" && "processed" in typeStats) {
|
||||
if (result.migrated) {
|
||||
typeStats.processed++;
|
||||
integrationUpdates.push({
|
||||
id: integration.id,
|
||||
config: result.config,
|
||||
});
|
||||
} else {
|
||||
typeStats.skipped++;
|
||||
}
|
||||
} else if (integration.type === "n8n") {
|
||||
integrationStats.n8n.skipped++;
|
||||
}
|
||||
} catch (error) {
|
||||
integrationStats.errors++;
|
||||
logger.error(error, `Failed to migrate integration ${integration.id} (type: ${integration.type})`);
|
||||
throw new Error(
|
||||
`Migration failed for integration ${integration.id}: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`Processed ${integrations.length.toString()} integrations: ${integrationUpdates.length.toString()} to update, ${(integrations.length - integrationUpdates.length).toString()} skipped`
|
||||
);
|
||||
|
||||
// Update integrations using Promise.all for better throughput
|
||||
if (integrationUpdates.length > 0) {
|
||||
// Batch size of 150 provides good parallelization (~750KB per batch)
|
||||
const INTEGRATION_BATCH_SIZE = 150;
|
||||
let integrationUpdatedCount = 0;
|
||||
|
||||
for (let i = 0; i < integrationUpdates.length; i += INTEGRATION_BATCH_SIZE) {
|
||||
const batch = integrationUpdates.slice(i, i + INTEGRATION_BATCH_SIZE);
|
||||
|
||||
try {
|
||||
// Execute all updates in parallel for this batch
|
||||
await Promise.all(
|
||||
batch.map((update) =>
|
||||
tx.$executeRawUnsafe(
|
||||
`UPDATE "Integration"
|
||||
SET config = $1::jsonb
|
||||
WHERE id = $2`,
|
||||
JSON.stringify(update.config),
|
||||
update.id
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
integrationUpdatedCount += batch.length;
|
||||
|
||||
// Log progress
|
||||
logger.info(
|
||||
`Integration progress: ${integrationUpdatedCount.toString()}/${integrationUpdates.length.toString()} updated`
|
||||
);
|
||||
} catch (error) {
|
||||
logger.error(error, `Failed to update integration batch starting at index ${i.toString()}`);
|
||||
throw new Error(
|
||||
`Database update failed for integration batch at index ${i.toString()}: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(
|
||||
`Integration migration complete: ${integrationUpdatedCount.toString()} integrations updated`
|
||||
for (const update of updates) {
|
||||
try {
|
||||
// PostgreSQL requires proper array format for jsonb[]
|
||||
// We need to convert the JSON array to a PostgreSQL jsonb array using array_to_json
|
||||
// The trick is to use jsonb_array_elements to convert the JSON array into rows, then array_agg to collect them back
|
||||
await tx.$executeRawUnsafe(
|
||||
`UPDATE "Survey"
|
||||
SET blocks = (
|
||||
SELECT array_agg(elem)
|
||||
FROM jsonb_array_elements($1::jsonb) AS elem
|
||||
),
|
||||
questions = '[]'::jsonb
|
||||
WHERE id = $2`,
|
||||
JSON.stringify(update.blocks),
|
||||
update.id
|
||||
);
|
||||
} else {
|
||||
logger.info("No integrations needed updating (all already migrated or skipped)");
|
||||
}
|
||||
|
||||
// Log detailed statistics
|
||||
updatedCount++;
|
||||
|
||||
// Log progress every 10000 surveys
|
||||
if (updatedCount % 10000 === 0) {
|
||||
logger.info(`Progress: ${updatedCount.toString()}/${updates.length.toString()} surveys updated`);
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error(error, `Failed to update survey ${update.id} in database`);
|
||||
throw new Error(
|
||||
`Database update failed for survey ${update.id}: ${error instanceof Error ? error.message : String(error)}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
logger.info(`Migration complete: ${updatedCount.toString()} surveys migrated to blocks`);
|
||||
|
||||
// 4. Log CTA migration statistics
|
||||
if (ctaStats.totalCTAElements > 0) {
|
||||
logger.info(
|
||||
`Integration statistics: ` +
|
||||
`GoogleSheets: ${integrationStats.googleSheets.processed.toString()} migrated, ${integrationStats.googleSheets.skipped.toString()} skipped | ` +
|
||||
`Airtable: ${integrationStats.airtable.processed.toString()} migrated, ${integrationStats.airtable.skipped.toString()} skipped | ` +
|
||||
`Slack: ${integrationStats.slack.processed.toString()} migrated, ${integrationStats.slack.skipped.toString()} skipped | ` +
|
||||
`Notion: ${integrationStats.notion.processed.toString()} migrated, ${integrationStats.notion.skipped.toString()} skipped | ` +
|
||||
`n8n: ${integrationStats.n8n.skipped.toString()} skipped`
|
||||
`CTA elements processed: ${ctaStats.totalCTAElements.toString()} total (${ctaStats.ctaWithExternalLink.toString()} with external link, ${ctaStats.ctaWithoutExternalLink.toString()} without)`
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,151 +76,6 @@ export interface CTAMigrationStats {
|
||||
ctaWithoutExternalLink: number;
|
||||
}
|
||||
|
||||
// Base integration config data (shared between all integrations except Notion)
|
||||
// This represents both old (questionIds/questions) and new (elementIds/elements) formats
|
||||
export interface IntegrationBaseSurveyData {
|
||||
createdAt: Date;
|
||||
surveyId: string;
|
||||
surveyName: string;
|
||||
// Old format fields
|
||||
questionIds?: string[];
|
||||
questions?: string;
|
||||
// New format fields
|
||||
elementIds?: string[];
|
||||
elements?: string;
|
||||
// Optional fields
|
||||
includeVariables?: boolean;
|
||||
includeHiddenFields?: boolean;
|
||||
includeMetadata?: boolean;
|
||||
includeCreatedAt?: boolean;
|
||||
}
|
||||
|
||||
// Google Sheets specific config
|
||||
export interface GoogleSheetsConfigData extends IntegrationBaseSurveyData {
|
||||
spreadsheetId: string;
|
||||
spreadsheetName: string;
|
||||
}
|
||||
|
||||
export interface GoogleSheetsConfig {
|
||||
key: {
|
||||
token_type: "Bearer";
|
||||
access_token: string;
|
||||
scope: string;
|
||||
expiry_date: number;
|
||||
refresh_token: string;
|
||||
};
|
||||
data: GoogleSheetsConfigData[];
|
||||
email: string;
|
||||
}
|
||||
|
||||
// Airtable specific config
|
||||
export interface AirtableConfigData extends IntegrationBaseSurveyData {
|
||||
tableId: string;
|
||||
baseId: string;
|
||||
tableName: string;
|
||||
}
|
||||
|
||||
export interface AirtableConfig {
|
||||
key: {
|
||||
expiry_date: string;
|
||||
access_token: string;
|
||||
refresh_token: string;
|
||||
};
|
||||
data: AirtableConfigData[];
|
||||
email: string;
|
||||
}
|
||||
|
||||
// Slack specific config
|
||||
export interface SlackConfigData extends IntegrationBaseSurveyData {
|
||||
channelId: string;
|
||||
channelName: string;
|
||||
}
|
||||
|
||||
export interface SlackConfig {
|
||||
key: {
|
||||
app_id: string;
|
||||
authed_user: { id: string };
|
||||
token_type: "bot";
|
||||
access_token: string;
|
||||
bot_user_id: string;
|
||||
team: { id: string; name: string };
|
||||
};
|
||||
data: SlackConfigData[];
|
||||
}
|
||||
|
||||
// Notion specific config (different structure - uses mapping instead of elementIds/elements)
|
||||
export interface NotionMappingItem {
|
||||
// Old format
|
||||
question?: { id: string; name: string; type: string };
|
||||
// New format
|
||||
element?: { id: string; name: string; type: string };
|
||||
column: { id: string; name: string; type: string };
|
||||
}
|
||||
|
||||
export interface NotionConfigData {
|
||||
createdAt: Date;
|
||||
surveyId: string;
|
||||
surveyName: string;
|
||||
mapping: NotionMappingItem[];
|
||||
databaseId: string;
|
||||
databaseName: string;
|
||||
}
|
||||
|
||||
export interface NotionConfig {
|
||||
key: {
|
||||
access_token: string;
|
||||
bot_id: string;
|
||||
token_type: string;
|
||||
duplicated_template_id: string | null;
|
||||
owner: {
|
||||
type: string;
|
||||
workspace?: boolean | null;
|
||||
user: {
|
||||
id: string;
|
||||
name?: string | null;
|
||||
type?: string | null;
|
||||
object: string;
|
||||
person?: { email: string } | null;
|
||||
avatar_url?: string | null;
|
||||
} | null;
|
||||
};
|
||||
workspace_icon: string | null;
|
||||
workspace_id: string;
|
||||
workspace_name: string | null;
|
||||
};
|
||||
data: NotionConfigData[];
|
||||
}
|
||||
|
||||
// Union type for all integration configs
|
||||
export type IntegrationConfig =
|
||||
| GoogleSheetsConfig
|
||||
| AirtableConfig
|
||||
| SlackConfig
|
||||
| NotionConfig
|
||||
| Record<string, unknown>;
|
||||
|
||||
// Integration migration types
|
||||
export interface IntegrationRecord {
|
||||
id: string;
|
||||
type: string;
|
||||
config: IntegrationConfig;
|
||||
}
|
||||
|
||||
export interface MigratedIntegration {
|
||||
id: string;
|
||||
config: IntegrationConfig;
|
||||
}
|
||||
|
||||
export interface IntegrationMigrationStats {
|
||||
totalIntegrations: number;
|
||||
googleSheets: { processed: number; skipped: number };
|
||||
airtable: { processed: number; skipped: number };
|
||||
slack: { processed: number; skipped: number };
|
||||
notion: { processed: number; skipped: number };
|
||||
n8n: { skipped: number };
|
||||
errors: number;
|
||||
}
|
||||
|
||||
// Type guards
|
||||
export const isSingleCondition = (condition: Condition): condition is SingleCondition => {
|
||||
return "leftOperand" in condition && "operator" in condition;
|
||||
|
||||
@@ -3,10 +3,8 @@ import {
|
||||
type CTAMigrationStats,
|
||||
type Condition,
|
||||
type ConditionGroup,
|
||||
type IntegrationConfig,
|
||||
type LogicAction,
|
||||
type MigratedSurvey,
|
||||
type NotionConfig,
|
||||
type SingleCondition,
|
||||
type SurveyLogic,
|
||||
type SurveyQuestion,
|
||||
@@ -416,198 +414,3 @@ export const migrateQuestionsSurveyToBlocks = (
|
||||
blocks,
|
||||
};
|
||||
};
|
||||
|
||||
// Type guard for config items with data array
|
||||
interface ConfigWithData {
|
||||
data: Record<string, unknown>[];
|
||||
[key: string]: unknown;
|
||||
}
|
||||
|
||||
const hasDataArray = (config: unknown): config is ConfigWithData => {
|
||||
return (
|
||||
typeof config === "object" &&
|
||||
config !== null &&
|
||||
"data" in config &&
|
||||
Array.isArray((config as ConfigWithData).data)
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if config item is already migrated (has elementIds/elements)
|
||||
*/
|
||||
const isAlreadyMigrated = (item: Record<string, unknown>): boolean => {
|
||||
return "elementIds" in item || "elements" in item;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if config item needs migration (has questionIds/questions)
|
||||
*/
|
||||
const needsMigration = (item: Record<string, unknown>): boolean => {
|
||||
return "questionIds" in item || "questions" in item;
|
||||
};
|
||||
|
||||
/**
|
||||
* Migrate Airtable/Google Sheets/Slack config (shared base type)
|
||||
* Returns an object with migrated flag and updated config
|
||||
*/
|
||||
export const migrateSharedIntegrationConfig = (
|
||||
config: IntegrationConfig
|
||||
): { migrated: boolean; config: IntegrationConfig } => {
|
||||
// Validate config structure
|
||||
if (!hasDataArray(config)) {
|
||||
return { migrated: false, config };
|
||||
}
|
||||
|
||||
let anyMigrated = false;
|
||||
|
||||
const newData = config.data.map((item) => {
|
||||
// Skip if already migrated
|
||||
if (isAlreadyMigrated(item)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
// Skip if nothing to migrate
|
||||
if (!needsMigration(item)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
anyMigrated = true;
|
||||
const migrated: Record<string, unknown> = { ...item };
|
||||
|
||||
// Rename questionIds to elementIds
|
||||
if ("questionIds" in migrated) {
|
||||
migrated.elementIds = migrated.questionIds;
|
||||
delete migrated.questionIds;
|
||||
}
|
||||
|
||||
// Rename questions to elements
|
||||
if ("questions" in migrated) {
|
||||
migrated.elements = migrated.questions;
|
||||
delete migrated.questions;
|
||||
}
|
||||
|
||||
// All other fields (includeVariables, etc.) are preserved automatically via spread
|
||||
|
||||
return migrated;
|
||||
});
|
||||
|
||||
return {
|
||||
migrated: anyMigrated,
|
||||
config: { ...config, data: newData },
|
||||
};
|
||||
};
|
||||
|
||||
// Type guard for Notion config
|
||||
const isNotionConfig = (config: unknown): config is NotionConfig => {
|
||||
return (
|
||||
typeof config === "object" &&
|
||||
config !== null &&
|
||||
"data" in config &&
|
||||
Array.isArray((config as NotionConfig).data)
|
||||
);
|
||||
};
|
||||
|
||||
// Type for Notion mapping entry
|
||||
interface NotionMappingEntry {
|
||||
question?: { id: string; name: string; type: string };
|
||||
element?: { id: string; name: string; type: string };
|
||||
column: { id: string; name: string; type: string };
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if Notion config item has any mapping entries that need migration
|
||||
* @param mapping - Notion mapping entries
|
||||
* @returns boolean
|
||||
*/
|
||||
const needsNotionMigration = (mapping: NotionMappingEntry[] | undefined): boolean => {
|
||||
if (!mapping || !Array.isArray(mapping) || mapping.length === 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if ANY mapping item has "question" field (needs migration)
|
||||
return mapping.some((mapItem) => "question" in mapItem && !("element" in mapItem));
|
||||
};
|
||||
|
||||
/**
|
||||
* Migrate Notion config (custom mapping structure)
|
||||
* @param config - Notion config
|
||||
* @returns \{ migrated: boolean; config: IntegrationConfig \}
|
||||
*/
|
||||
export const migrateNotionIntegrationConfig = (
|
||||
config: IntegrationConfig
|
||||
): { migrated: boolean; config: IntegrationConfig } => {
|
||||
// Validate config structure
|
||||
if (!isNotionConfig(config)) {
|
||||
return { migrated: false, config };
|
||||
}
|
||||
|
||||
let anyMigrated = false;
|
||||
|
||||
const newData = config.data.map((item) => {
|
||||
// Cast mapping to the migration type that includes both old and new formats
|
||||
const mapping = item.mapping as NotionMappingEntry[] | undefined;
|
||||
|
||||
// Skip if nothing to migrate
|
||||
if (!needsNotionMigration(mapping)) {
|
||||
return item;
|
||||
}
|
||||
|
||||
anyMigrated = true;
|
||||
|
||||
// Migrate mapping array - check EACH item individually
|
||||
const newMapping = mapping?.map((mapItem) => {
|
||||
// Already has element field - skip this item
|
||||
if ("element" in mapItem) {
|
||||
return mapItem;
|
||||
}
|
||||
|
||||
// Has question field - migrate it
|
||||
if ("question" in mapItem) {
|
||||
const { question, ...rest } = mapItem;
|
||||
return {
|
||||
...rest,
|
||||
element: question,
|
||||
};
|
||||
}
|
||||
|
||||
// Neither element nor question - return as is
|
||||
return mapItem;
|
||||
});
|
||||
|
||||
return {
|
||||
...item,
|
||||
mapping: newMapping,
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
migrated: anyMigrated,
|
||||
config: { ...config, data: newData },
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Migrate integration config based on type
|
||||
* @param type - Integration type
|
||||
* @param config - Integration config
|
||||
* @returns \{ migrated: boolean; config: IntegrationConfig \}
|
||||
*/
|
||||
export const migrateIntegrationConfig = (
|
||||
type: string,
|
||||
config: IntegrationConfig
|
||||
): { migrated: boolean; config: IntegrationConfig } => {
|
||||
switch (type) {
|
||||
case "googleSheets":
|
||||
case "airtable":
|
||||
case "slack":
|
||||
return migrateSharedIntegrationConfig(config);
|
||||
case "notion":
|
||||
return migrateNotionIntegrationConfig(config);
|
||||
case "n8n":
|
||||
// n8n has no config schema to migrate
|
||||
return { migrated: false, config };
|
||||
default:
|
||||
// Unknown type - return unchanged
|
||||
return { migrated: false, config };
|
||||
}
|
||||
};
|
||||
|
||||
-99
@@ -1,99 +0,0 @@
|
||||
import { Prisma } from "@prisma/client";
|
||||
import { logger } from "@formbricks/logger";
|
||||
import type { MigrationScript } from "../../src/scripts/migration-runner";
|
||||
import { type SurveyRecord } from "./types";
|
||||
|
||||
export const removeEmptyImageAndVideoUrlsFromElements: MigrationScript = {
|
||||
type: "data",
|
||||
id: "ohw7fb1f64yfh2vax294agp0",
|
||||
name: "20251208033316_remove_empty_image_and_video_urls_from_elements",
|
||||
run: async ({ tx }) => {
|
||||
// Find all surveys with empty imageUrl or videoUrl
|
||||
const surveysFindQuery = `
|
||||
SELECT s.id, s.blocks, s."welcomeCard", s.endings
|
||||
FROM "Survey" AS s
|
||||
WHERE EXISTS (
|
||||
SELECT 1
|
||||
FROM unnest(s.blocks) AS block
|
||||
CROSS JOIN jsonb_array_elements(block->'elements') AS element
|
||||
WHERE element->>'imageUrl' = ''
|
||||
OR element->>'videoUrl' = ''
|
||||
) OR s."welcomeCard"->>'fileUrl' = ''
|
||||
OR s."welcomeCard"->>'videoUrl' = ''
|
||||
OR EXISTS (
|
||||
SELECT 1
|
||||
FROM unnest(s.endings) AS ending
|
||||
WHERE ending->>'imageUrl' = ''
|
||||
OR ending->>'videoUrl' = ''
|
||||
)
|
||||
`;
|
||||
const surveysWithEmptyUrls: SurveyRecord[] = await tx.$queryRaw`${Prisma.raw(surveysFindQuery)}`;
|
||||
|
||||
logger.info(`Found ${surveysWithEmptyUrls.length.toString()} surveys with empty imageUrl or videoUrl`);
|
||||
|
||||
// Process in batches to avoid overwhelming the connection pool
|
||||
const BATCH_SIZE = 1000;
|
||||
|
||||
for (let i = 0; i < surveysWithEmptyUrls.length; i += BATCH_SIZE) {
|
||||
const batch = surveysWithEmptyUrls.slice(i, i + BATCH_SIZE);
|
||||
|
||||
const batchPromises = batch.map((survey) => {
|
||||
// Clean the blocks
|
||||
const cleanedBlocks = survey.blocks.map((block) => {
|
||||
const cleanedElements = block.elements.map((element) => {
|
||||
const cleanedElement = { ...element };
|
||||
if (cleanedElement.imageUrl === "") {
|
||||
delete cleanedElement.imageUrl;
|
||||
}
|
||||
if (cleanedElement.videoUrl === "") {
|
||||
delete cleanedElement.videoUrl;
|
||||
}
|
||||
return cleanedElement;
|
||||
});
|
||||
|
||||
return { ...block, elements: cleanedElements };
|
||||
});
|
||||
|
||||
const cleanedWelcomeCard = { ...survey.welcomeCard };
|
||||
if (cleanedWelcomeCard.fileUrl === "") {
|
||||
delete cleanedWelcomeCard.fileUrl;
|
||||
}
|
||||
if (cleanedWelcomeCard.videoUrl === "") {
|
||||
delete cleanedWelcomeCard.videoUrl;
|
||||
}
|
||||
|
||||
const cleanedEndings = survey.endings.map((ending) => {
|
||||
const cleanedEnding = { ...ending };
|
||||
if (cleanedEnding.imageUrl === "") {
|
||||
delete cleanedEnding.imageUrl;
|
||||
}
|
||||
if (cleanedEnding.videoUrl === "") {
|
||||
delete cleanedEnding.videoUrl;
|
||||
}
|
||||
return cleanedEnding;
|
||||
});
|
||||
|
||||
// Convert JSON arrays to PostgreSQL jsonb[] using array_agg + jsonb_array_elements
|
||||
const blocksJson = JSON.stringify(cleanedBlocks);
|
||||
const endingsJson = JSON.stringify(cleanedEndings);
|
||||
const welcomeCardJson = JSON.stringify(cleanedWelcomeCard);
|
||||
|
||||
return tx.$executeRaw`
|
||||
UPDATE "Survey"
|
||||
SET
|
||||
blocks = (SELECT array_agg(elem) FROM jsonb_array_elements(${blocksJson}::jsonb) AS elem),
|
||||
endings = (SELECT array_agg(elem) FROM jsonb_array_elements(${endingsJson}::jsonb) AS elem),
|
||||
"welcomeCard" = ${welcomeCardJson}::jsonb
|
||||
WHERE id = ${survey.id}
|
||||
`;
|
||||
});
|
||||
|
||||
await Promise.all(batchPromises);
|
||||
logger.info(
|
||||
`Processed batch ${(Math.floor(i / BATCH_SIZE) + 1).toString()}/${Math.ceil(surveysWithEmptyUrls.length / BATCH_SIZE).toString()}`
|
||||
);
|
||||
}
|
||||
|
||||
logger.info(`Successfully cleaned ${surveysWithEmptyUrls.length.toString()} surveys`);
|
||||
},
|
||||
};
|
||||
-22
@@ -1,22 +0,0 @@
|
||||
export interface SurveyElement {
|
||||
id: string;
|
||||
imageUrl?: string;
|
||||
videoUrl?: string;
|
||||
}
|
||||
export interface Block {
|
||||
id: string;
|
||||
elements: SurveyElement[];
|
||||
}
|
||||
|
||||
export interface SurveyRecord {
|
||||
id: string;
|
||||
blocks: Block[];
|
||||
welcomeCard: {
|
||||
fileUrl?: string;
|
||||
videoUrl?: string;
|
||||
};
|
||||
endings: {
|
||||
imageUrl?: string;
|
||||
videoUrl?: string;
|
||||
}[];
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
-- CreateTable
|
||||
CREATE TABLE "public"."sessions" (
|
||||
"id" TEXT NOT NULL,
|
||||
"session_token" TEXT NOT NULL,
|
||||
"user_id" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL,
|
||||
|
||||
CONSTRAINT "sessions_pkey" PRIMARY KEY ("id")
|
||||
);
|
||||
|
||||
-- CreateTable
|
||||
CREATE TABLE "public"."verification_tokens" (
|
||||
"identifier" TEXT NOT NULL,
|
||||
"token" TEXT NOT NULL,
|
||||
"expires" TIMESTAMP(3) NOT NULL
|
||||
);
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "sessions_session_token_key" ON "public"."sessions"("session_token");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE INDEX "sessions_user_id_idx" ON "public"."sessions"("user_id");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "verification_tokens_token_key" ON "public"."verification_tokens"("token");
|
||||
|
||||
-- CreateIndex
|
||||
CREATE UNIQUE INDEX "verification_tokens_identifier_token_key" ON "public"."verification_tokens"("identifier", "token");
|
||||
|
||||
-- AddForeignKey
|
||||
ALTER TABLE "public"."sessions" ADD CONSTRAINT "sessions_user_id_fkey" FOREIGN KEY ("user_id") REFERENCES "public"."User"("id") ON DELETE CASCADE ON UPDATE CASCADE;
|
||||
@@ -832,7 +832,6 @@ model User {
|
||||
identityProviderAccountId String?
|
||||
memberships Membership[]
|
||||
accounts Account[]
|
||||
sessions Session[]
|
||||
groupId String?
|
||||
invitesCreated Invite[] @relation("inviteCreatedBy")
|
||||
invitesAccepted Invite[] @relation("inviteAcceptedBy")
|
||||
@@ -848,34 +847,6 @@ model User {
|
||||
@@index([email])
|
||||
}
|
||||
|
||||
/// Represents an active user session for authentication.
|
||||
/// Used by NextAuth for database session strategy.
|
||||
///
|
||||
/// @property sessionToken - Unique token identifying the session
|
||||
/// @property userId - The user this session belongs to
|
||||
/// @property expires - When the session expires
|
||||
model Session {
|
||||
id String @id @default(cuid())
|
||||
sessionToken String @unique @map("session_token")
|
||||
userId String @map("user_id")
|
||||
expires DateTime
|
||||
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
||||
|
||||
@@index([userId])
|
||||
@@map("sessions")
|
||||
}
|
||||
|
||||
/// Stores verification tokens for email verification flows.
|
||||
/// Used by NextAuth for magic link authentication.
|
||||
model VerificationToken {
|
||||
identifier String
|
||||
token String @unique
|
||||
expires DateTime
|
||||
|
||||
@@unique([identifier, token])
|
||||
@@map("verification_tokens")
|
||||
}
|
||||
|
||||
/// Defines a segment of contacts based on attributes.
|
||||
/// Used for targeting surveys to specific user groups.
|
||||
///
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
import { SurveyStatus, SurveyType } from "@prisma/client";
|
||||
import { z } from "zod";
|
||||
import { extendZodWithOpenApi } from "zod-openapi";
|
||||
// eslint-disable-next-line import/no-relative-packages -- Need to import from parent package
|
||||
import { ZLogo } from "../../types/styling";
|
||||
import { ZSurveyBlocks } from "../../types/surveys/blocks";
|
||||
import {
|
||||
ZSurveyEnding,
|
||||
@@ -174,7 +172,6 @@ const ZSurveyBase = z.object({
|
||||
background: ZSurveyStylingBackground.nullish(),
|
||||
hideProgressBar: z.boolean().nullish(),
|
||||
isLogoHidden: z.boolean().nullish(),
|
||||
logo: ZLogo.nullish(),
|
||||
})
|
||||
.nullable()
|
||||
.openapi({
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
},
|
||||
"locale": {
|
||||
"source": "en",
|
||||
"targets": ["de", "it", "fr", "es", "ar", "pt", "ru", "uz", "ro", "ja", "zh-Hans", "hi", "nl", "sv"]
|
||||
"targets": ["de", "it", "fr", "es", "ar", "pt", "ru", "uz", "ro", "ja", "zh-Hans", "hi", "nl"]
|
||||
},
|
||||
"version": 1.8
|
||||
}
|
||||
|
||||
@@ -1,73 +0,0 @@
|
||||
{
|
||||
"common": {
|
||||
"and": "och",
|
||||
"apply": "Tillämpa",
|
||||
"auto_close_wrapper": "Automatisk stängning",
|
||||
"back": "Tillbaka",
|
||||
"click_or_drag_to_upload_files": "Klicka eller dra för att ladda upp filer.",
|
||||
"close_survey": "Stäng enkät",
|
||||
"company_logo": "Företagslogotyp",
|
||||
"delete_file": "Ta bort fil",
|
||||
"file_upload": "Ladda upp fil",
|
||||
"finish": "Slutför",
|
||||
"language_switch": "Språkväxlare",
|
||||
"less_than_x_minutes": "{count, plural, one {mindre än 1 minut} other {mindre än {count} minuter}}",
|
||||
"move_down": "Flytta {item} nedåt",
|
||||
"move_up": "Flytta {item} uppåt",
|
||||
"next": "Nästa",
|
||||
"open_in_new_tab": "Öppna i ny flik",
|
||||
"optional": "Valfritt",
|
||||
"options": "Alternativ",
|
||||
"people_responded": "{count, plural, one {1 person har svarat} other {{count} personer har svarat}}",
|
||||
"please_retry_now_or_try_again_later": "Försök igen nu eller försök igen senare.",
|
||||
"powered_by": "Drivs av",
|
||||
"privacy_policy": "Integritetspolicy",
|
||||
"protected_by_reCAPTCHA_and_the_Google": "Skyddas av reCAPTCHA och Googles",
|
||||
"question": "Fråga",
|
||||
"question_video": "Frågevideo",
|
||||
"ranking_items": "Rangordna objekt",
|
||||
"respondents_will_not_see_this_card": "Respondenter kommer inte att se detta kort",
|
||||
"retry": "Försök igen",
|
||||
"select_a_date": "Välj ett datum",
|
||||
"select_for_ranking": "Välj {item} för rangordning",
|
||||
"sending_responses": "Skickar svar...",
|
||||
"takes": "Tar",
|
||||
"terms_of_service": "Användarvillkor",
|
||||
"the_servers_cannot_be_reached_at_the_moment": "Servrarna kan inte nås för tillfället.",
|
||||
"they_will_be_redirected_immediately": "De kommer att omdirigeras omedelbart",
|
||||
"upload_files_by_clicking_or_dragging_them_here": "Ladda upp filer genom att klicka eller dra dem hit",
|
||||
"uploading": "Laddar upp",
|
||||
"x_minutes": "{count, plural, one {1 minut} other {{count} minuter}}",
|
||||
"x_plus_minutes": "{count}+ minuter",
|
||||
"you_have_selected_x_date": "Du har valt {date}",
|
||||
"you_have_successfully_uploaded_the_file": "Du har framgångsrikt laddat upp filen {fileName}",
|
||||
"your_feedback_is_stuck": "Din feedback fastnade :("
|
||||
},
|
||||
"errors": {
|
||||
"file_input": {
|
||||
"duplicate_files": "Följande filer är redan uppladdade: {duplicateNames}. Dubbletter av filer är inte tillåtna.",
|
||||
"file_size_exceeded": "Följande filer överstiger maxstorleken på {maxSizeInMB} MB och togs bort: {fileNames}",
|
||||
"file_size_exceeded_alert": "Filen måste vara mindre än {maxSizeInMB} MB",
|
||||
"no_valid_file_types_selected": "Inga giltiga filtyper valda. Vänligen välj en giltig filtyp.",
|
||||
"only_one_file_can_be_uploaded_at_a_time": "Endast en fil kan laddas upp åt gången.",
|
||||
"upload_failed": "Uppladdning misslyckades! Försök igen.",
|
||||
"you_can_only_upload_a_maximum_of_files": "Du kan ladda upp maximalt {FILE_LIMIT} filer."
|
||||
},
|
||||
"invalid_device_error": {
|
||||
"message": "Vänligen inaktivera skräppostskyddet i enkätinställningarna för att fortsätta använda denna enhet.",
|
||||
"title": "Denna enhet stöder inte skräppostskydd."
|
||||
},
|
||||
"please_book_an_appointment": "Vänligen boka ett möte",
|
||||
"please_enter_a_valid_email_address": "Vänligen ange en giltig e-postadress",
|
||||
"please_enter_a_valid_phone_number": "Vänligen ange ett giltigt telefonnummer",
|
||||
"please_enter_a_valid_url": "Vänligen ange en giltig URL",
|
||||
"please_fill_out_this_field": "Vänligen fyll i detta fält",
|
||||
"please_rank_all_items_before_submitting": "Vänligen rangordna alla objekt innan du skickar",
|
||||
"please_select_a_date": "Vänligen välj ett datum",
|
||||
"please_upload_a_file": "Vänligen ladda upp en fil",
|
||||
"recaptcha_error": {
|
||||
"message": "Ditt svar kunde inte skickas eftersom det flaggades som automatiserad aktivitet. Om du andas, försök igen.",
|
||||
"title": "Vi kunde inte verifiera att du är människa."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,8 @@ export function AddressElement({
|
||||
return Array.isArray(value) ? value : ["", "", "", "", "", ""];
|
||||
}, [value]);
|
||||
|
||||
const isCurrent = element.id === currentElementId;
|
||||
|
||||
const fields = useMemo(
|
||||
() => [
|
||||
{
|
||||
@@ -164,7 +166,7 @@ export function AddressElement({
|
||||
handleChange(field.id, e.currentTarget.value);
|
||||
}}
|
||||
ref={index === 0 ? addressRef : null}
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
aria-label={field.label}
|
||||
dir={!safeValue[index] ? dir : "auto"}
|
||||
/>
|
||||
|
||||
@@ -32,6 +32,7 @@ export function ConsentElement({
|
||||
}: Readonly<ConsentElementProps>) {
|
||||
const [startTime, setStartTime] = useState(performance.now());
|
||||
const isMediaAvailable = element.imageUrl || element.videoUrl;
|
||||
const isCurrent = element.id === currentElementId;
|
||||
|
||||
useTtc(element.id, ttc, setTtc, startTime, setStartTime, element.id === currentElementId);
|
||||
|
||||
@@ -65,7 +66,7 @@ export function ConsentElement({
|
||||
/>
|
||||
<label
|
||||
ref={consentRef}
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
id={`${element.id}-label`}
|
||||
onKeyDown={(e) => {
|
||||
// Accessibility: if spacebar was pressed pass this down to the input
|
||||
|
||||
@@ -37,6 +37,7 @@ export function ContactInfoElement({
|
||||
const isMediaAvailable = element.imageUrl || element.videoUrl;
|
||||
const formRef = useRef<HTMLFormElement>(null);
|
||||
useTtc(element.id, ttc, setTtc, startTime, setStartTime, element.id === currentElementId);
|
||||
const isCurrent = element.id === currentElementId;
|
||||
const safeValue = useMemo(() => {
|
||||
return Array.isArray(value) ? value : ["", "", "", "", ""];
|
||||
}, [value]);
|
||||
@@ -148,7 +149,7 @@ export function ContactInfoElement({
|
||||
onChange={(e) => {
|
||||
handleChange(field.id, e.currentTarget.value);
|
||||
}}
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
aria-label={field.label}
|
||||
dir={!safeValue[index] ? dir : "auto"}
|
||||
/>
|
||||
|
||||
@@ -67,7 +67,7 @@ export function CTAElement({
|
||||
<button
|
||||
dir="auto"
|
||||
type="button"
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
onClick={handleExternalButtonClick}
|
||||
className="fb-text-heading focus:fb-ring-focus fb-flex fb-items-center fb-rounded-md fb-px-3 fb-py-3 fb-text-base fb-font-medium fb-leading-4 hover:fb-opacity-90 focus:fb-outline-none focus:fb-ring-2 focus:fb-ring-offset-2">
|
||||
{getLocalizedValue(element.ctaButtonLabel, languageCode)}
|
||||
|
||||
@@ -86,6 +86,7 @@ export function DateElement({
|
||||
const [errorMessage, setErrorMessage] = useState("");
|
||||
const isMediaAvailable = element.imageUrl || element.videoUrl;
|
||||
useTtc(element.id, ttc, setTtc, startTime, setStartTime, element.id === currentElementId);
|
||||
const isCurrent = element.id === currentElementId;
|
||||
const [datePickerOpen, setDatePickerOpen] = useState(false);
|
||||
const [selectedDate, setSelectedDate] = useState<Date | undefined>(value ? new Date(value) : undefined);
|
||||
const [hideInvalid, setHideInvalid] = useState(!selectedDate);
|
||||
@@ -160,7 +161,7 @@ export function DateElement({
|
||||
onClick={() => {
|
||||
setDatePickerOpen(true);
|
||||
}}
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
type="button"
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === " ") setDatePickerOpen(true);
|
||||
|
||||
@@ -31,6 +31,7 @@ export function MatrixElement({
|
||||
const [startTime, setStartTime] = useState(performance.now());
|
||||
const isMediaAvailable = element.imageUrl || element.videoUrl;
|
||||
useTtc(element.id, ttc, setTtc, startTime, setStartTime, element.id === currentElementId);
|
||||
const isCurrent = element.id === currentElementId;
|
||||
const rowShuffleIdx = useMemo(() => {
|
||||
if (element.shuffleOption !== "none") {
|
||||
return getShuffledRowIndices(element.rows.length, element.shuffleOption);
|
||||
@@ -126,7 +127,7 @@ export function MatrixElement({
|
||||
{element.columns.map((column, columnIndex) => (
|
||||
<td
|
||||
key={`column-${columnIndex.toString()}`}
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
className={`fb-outline-brand fb-px-4 fb-py-2 fb-text-slate-800 ${columnIndex === element.columns.length - 1 ? "fb-rounded-r-custom" : ""}`}
|
||||
onClick={() => {
|
||||
handleSelect(
|
||||
|
||||
@@ -57,6 +57,7 @@ export function MultipleChoiceMultiElement({
|
||||
const [startTime, setStartTime] = useState(performance.now());
|
||||
const isMediaAvailable = element.imageUrl || element.videoUrl;
|
||||
useTtc(element.id, ttc, setTtc, startTime, setStartTime, element.id === currentElementId);
|
||||
const isCurrent = element.id === currentElementId;
|
||||
const shuffledChoicesIds = useMemo(() => {
|
||||
if (element.shuffleOption) {
|
||||
return getShuffledChoicesIds(element.choices, element.shuffleOption);
|
||||
@@ -211,9 +212,9 @@ export function MultipleChoiceMultiElement({
|
||||
return (
|
||||
<label
|
||||
key={choice.id}
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
className={labelClassName}
|
||||
onKeyDown={handleKeyDown(choice.id)} // NOSONAR - needed for keyboard navigation through options
|
||||
onKeyDown={handleKeyDown(choice.id)}
|
||||
autoFocus={idx === 0 && autoFocusEnabled}>
|
||||
<span className="fb-flex fb-items-center fb-text-sm">
|
||||
<input
|
||||
@@ -260,16 +261,14 @@ export function MultipleChoiceMultiElement({
|
||||
|
||||
return (
|
||||
<label
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
className={labelClassName}
|
||||
// Disable keyboard navigation when 'other' option is selected to allow space key in input field
|
||||
onKeyDown={otherSelected ? undefined : handleKeyDown(otherOption.id)} // NOSONAR - needed for keyboard navigation through options
|
||||
>
|
||||
onKeyDown={handleKeyDown(otherOption.id)}>
|
||||
<span className="fb-flex fb-items-center fb-text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
dir={dir}
|
||||
tabIndex={-1}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
id={otherOption.id}
|
||||
name={element.id}
|
||||
value={otherLabel}
|
||||
@@ -290,7 +289,7 @@ export function MultipleChoiceMultiElement({
|
||||
id={`${otherOption.id}-specify`}
|
||||
maxLength={250}
|
||||
name={element.id}
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
value={otherValue}
|
||||
pattern=".*\S+.*"
|
||||
onChange={(e) => setOtherValue(e.currentTarget.value)}
|
||||
@@ -315,10 +314,9 @@ export function MultipleChoiceMultiElement({
|
||||
|
||||
return (
|
||||
<label
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
className={labelClassName}
|
||||
onKeyDown={handleKeyDown(noneOption.id)} // NOSONAR - needed for keyboard navigation through options
|
||||
>
|
||||
onKeyDown={handleKeyDown(noneOption.id)}>
|
||||
<span className="fb-flex fb-items-center fb-text-sm">
|
||||
<input
|
||||
type="checkbox"
|
||||
|
||||
@@ -36,6 +36,7 @@ export function MultipleChoiceSingleElement({
|
||||
const otherSpecify = useRef<HTMLInputElement | null>(null);
|
||||
const choicesContainerRef = useRef<HTMLDivElement | null>(null);
|
||||
const isMediaAvailable = element.imageUrl || element.videoUrl;
|
||||
const isCurrent = element.id === currentElementId;
|
||||
const shuffledChoicesIds = useMemo(() => {
|
||||
if (element.shuffleOption) {
|
||||
return getShuffledChoicesIds(element.choices, element.shuffleOption);
|
||||
@@ -157,9 +158,9 @@ export function MultipleChoiceSingleElement({
|
||||
return (
|
||||
<label
|
||||
key={choice.id}
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
className={labelClassName}
|
||||
onKeyDown={handleKeyDown(choice.id)} // NOSONAR - needed for keyboard navigation through options
|
||||
onKeyDown={handleKeyDown(choice.id)}
|
||||
autoFocus={idx === 0 && autoFocusEnabled}>
|
||||
<span className="fb-flex fb-items-center fb-text-sm">
|
||||
<input
|
||||
@@ -196,11 +197,7 @@ export function MultipleChoiceSingleElement({
|
||||
: "Please specify";
|
||||
|
||||
return (
|
||||
<label
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
className={labelClassName}
|
||||
onKeyDown={handleOtherKeyDown} // NOSONAR - needed for keyboard navigation through options
|
||||
>
|
||||
<label tabIndex={isCurrent ? 0 : -1} className={labelClassName} onKeyDown={handleOtherKeyDown}>
|
||||
<span className="fb-flex fb-items-center fb-text-sm">
|
||||
<input
|
||||
tabIndex={-1}
|
||||
@@ -249,7 +246,7 @@ export function MultipleChoiceSingleElement({
|
||||
|
||||
return (
|
||||
<label
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
className={labelClassName}
|
||||
onKeyDown={handleKeyDown(noneOption.id)}>
|
||||
<span className="fb-flex fb-items-center fb-text-sm">
|
||||
|
||||
@@ -33,6 +33,7 @@ export function NPSElement({
|
||||
const [startTime, setStartTime] = useState(performance.now());
|
||||
const [hoveredNumber, setHoveredNumber] = useState(-1);
|
||||
const isMediaAvailable = element.imageUrl || element.videoUrl;
|
||||
const isCurrent = element.id === currentElementId;
|
||||
useTtc(element.id, ttc, setTtc, startTime, setStartTime, element.id === currentElementId);
|
||||
|
||||
const handleClick = (number: number) => {
|
||||
@@ -73,7 +74,7 @@ export function NPSElement({
|
||||
return (
|
||||
<label
|
||||
key={number}
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
onMouseOver={() => {
|
||||
setHoveredNumber(number);
|
||||
}}
|
||||
|
||||
@@ -169,7 +169,7 @@ export function OpenTextElement({
|
||||
<input
|
||||
ref={inputRef as RefObject<HTMLInputElement>}
|
||||
autoFocus={isCurrent ? autoFocusEnabled : undefined}
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
name={element.id}
|
||||
id={element.id}
|
||||
placeholder={getLocalizedValue(element.placeholder, languageCode)}
|
||||
@@ -195,7 +195,7 @@ export function OpenTextElement({
|
||||
rows={3}
|
||||
autoFocus={isCurrent ? autoFocusEnabled : undefined}
|
||||
name={element.id}
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
aria-label="textarea"
|
||||
id={element.id}
|
||||
placeholder={getLocalizedValue(element.placeholder, languageCode, true)}
|
||||
|
||||
@@ -148,7 +148,7 @@ export function PictureSelectionElement({
|
||||
<div className="fb-relative" key={choice.id}>
|
||||
<button
|
||||
type="button"
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
onKeyDown={handleKeyDown}
|
||||
onClick={() => handleChange(choice.id)}
|
||||
className={getButtonClassName(choice.id)}>
|
||||
|
||||
@@ -159,7 +159,7 @@ export function RankingElement({
|
||||
)}>
|
||||
<button
|
||||
autoFocus={idx === 0 && autoFocusEnabled}
|
||||
tabIndex={0}
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === " ") {
|
||||
e.preventDefault();
|
||||
|
||||
@@ -46,6 +46,7 @@ export function RatingElement({
|
||||
const [hoveredNumber, setHoveredNumber] = useState(0);
|
||||
const [startTime, setStartTime] = useState(performance.now());
|
||||
const isMediaAvailable = element.imageUrl || element.videoUrl;
|
||||
const isCurrent = element.id === currentElementId;
|
||||
useTtc(element.id, ttc, setTtc, startTime, setStartTime, element.id === currentElementId);
|
||||
|
||||
const handleSelect = (number: number) => {
|
||||
@@ -54,6 +55,23 @@ export function RatingElement({
|
||||
setTtc(updatedTtcObj);
|
||||
};
|
||||
|
||||
function HiddenRadioInput({ number, id }: { number: number; id?: string }) {
|
||||
return (
|
||||
<input
|
||||
type="radio"
|
||||
id={id}
|
||||
name="rating"
|
||||
value={number}
|
||||
className="fb-invisible fb-absolute fb-left-0 fb-h-full fb-w-full fb-cursor-pointer fb-opacity-0"
|
||||
onClick={() => {
|
||||
handleSelect(number);
|
||||
}}
|
||||
required={element.required}
|
||||
checked={value === number}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setHoveredNumber(0);
|
||||
}, [element.id, setHoveredNumber]);
|
||||
@@ -79,6 +97,14 @@ export function RatingElement({
|
||||
setTtc(updatedTtcObj);
|
||||
};
|
||||
|
||||
const handleKeyDown = (number: number) => (e: KeyboardEvent) => {
|
||||
const isActivationKey = e.key === " " || e.key === "Enter";
|
||||
if (isActivationKey) {
|
||||
e.preventDefault();
|
||||
handleSelect(number);
|
||||
}
|
||||
};
|
||||
|
||||
const handleMouseOver = (number: number) => () => {
|
||||
setHoveredNumber(number);
|
||||
};
|
||||
@@ -134,21 +160,10 @@ export function RatingElement({
|
||||
);
|
||||
};
|
||||
|
||||
const getRatingInputId = (number: number) => `${element.id}-${number}`;
|
||||
|
||||
const handleKeyDown = (number: number) => (e: KeyboardEvent) => {
|
||||
if (e.key === " ") {
|
||||
e.preventDefault();
|
||||
const inputId = getRatingInputId(number);
|
||||
document.getElementById(inputId)?.click();
|
||||
document.getElementById(inputId)?.focus();
|
||||
}
|
||||
};
|
||||
|
||||
const renderNumberScale = (number: number, totalLength: number) => {
|
||||
return (
|
||||
<label
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
onKeyDown={handleKeyDown(number)}
|
||||
className={getNumberLabelClassName(number, totalLength)}>
|
||||
{element.isColorCodingEnabled && (
|
||||
@@ -156,19 +171,7 @@ export function RatingElement({
|
||||
className={`fb-absolute fb-left-0 fb-top-0 fb-h-[6px] fb-w-full ${getRatingNumberOptionColor(element.range, number)}`}
|
||||
/>
|
||||
)}
|
||||
<input
|
||||
type="radio"
|
||||
id={getRatingInputId(number)}
|
||||
name="rating"
|
||||
value={number}
|
||||
className="fb-absolute fb-left-0 fb-h-full fb-w-full fb-cursor-pointer fb-opacity-0"
|
||||
onClick={() => {
|
||||
handleSelect(number);
|
||||
}}
|
||||
required={element.required}
|
||||
checked={value === number}
|
||||
tabIndex={-1}
|
||||
/>
|
||||
<HiddenRadioInput number={number} id={number.toString()} />
|
||||
{number}
|
||||
</label>
|
||||
);
|
||||
@@ -177,25 +180,12 @@ export function RatingElement({
|
||||
const renderStarScale = (number: number) => {
|
||||
return (
|
||||
<label
|
||||
aria-label={`Rate ${number} out of ${element.range}`}
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
onKeyDown={handleKeyDown(number)}
|
||||
className={getStarLabelClassName(number)}
|
||||
onFocus={handleFocus(number)}
|
||||
onBlur={handleBlur}>
|
||||
<input
|
||||
type="radio"
|
||||
id={getRatingInputId(number)}
|
||||
name="rating"
|
||||
value={number}
|
||||
className="fb-absolute fb-left-0 fb-h-full fb-w-full fb-cursor-pointer fb-opacity-0"
|
||||
onClick={() => {
|
||||
handleSelect(number);
|
||||
}}
|
||||
required={element.required}
|
||||
checked={value === number}
|
||||
tabIndex={-1}
|
||||
/>
|
||||
<HiddenRadioInput number={number} id={number.toString()} />
|
||||
<div className="fb-h-full fb-w-full fb-max-w-[74px] fb-object-contain">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
|
||||
<path
|
||||
@@ -211,25 +201,12 @@ export function RatingElement({
|
||||
const renderSmileyScale = (number: number, idx: number) => {
|
||||
return (
|
||||
<label
|
||||
aria-label={`Rate ${number} out of ${element.range}`}
|
||||
tabIndex={0} // NOSONAR - needed for keyboard navigation through options
|
||||
tabIndex={isCurrent ? 0 : -1}
|
||||
className={getSmileyLabelClassName(number)}
|
||||
onKeyDown={handleKeyDown(number)}
|
||||
onFocus={handleFocus(number)}
|
||||
onBlur={handleBlur}>
|
||||
<input
|
||||
type="radio"
|
||||
id={getRatingInputId(number)}
|
||||
name="rating"
|
||||
value={number}
|
||||
className="fb-absolute fb-left-0 fb-h-full fb-w-full fb-cursor-pointer fb-opacity-0"
|
||||
onClick={() => {
|
||||
handleSelect(number);
|
||||
}}
|
||||
required={element.required}
|
||||
checked={value === number}
|
||||
tabIndex={-1}
|
||||
/>
|
||||
<HiddenRadioInput number={number} id={number.toString()} />
|
||||
<div className="fb-h-full fb-w-full fb-max-w-[74px] fb-object-contain">
|
||||
<RatingSmiley
|
||||
active={value === number || hoveredNumber === number}
|
||||
@@ -277,7 +254,7 @@ export function RatingElement({
|
||||
renderRatingOption(number, i, a.length)
|
||||
)}
|
||||
</div>
|
||||
<div className="fb-text-subheading fb-mt-8 fb-flex fb-justify-between fb-px-1.5 fb-text-xs fb-leading-6 fb-gap-8">
|
||||
<div className="fb-text-subheading fb-mt-4 fb-flex fb-justify-between fb-px-1.5 fb-text-xs fb-leading-6 fb-gap-8">
|
||||
<p className="fb-max-w-[50%]" dir="auto">
|
||||
{getLocalizedValue(element.lowerLabel, languageCode)}
|
||||
</p>
|
||||
|
||||
@@ -99,7 +99,7 @@ export function LanguageSwitch({
|
||||
{showLanguageDropdown ? (
|
||||
<div
|
||||
className={cn(
|
||||
"fb-bg-input-bg fb-text-heading fb-absolute fb-top-10 fb-max-h-64 fb-space-y-2 fb-overflow-auto fb-rounded-md fb-p-2 fb-text-xs fb-border-border fb-border",
|
||||
"fb-bg-input-bg fb-text-heading fb-absolute fb-top-10 fb-max-h-64 fb-space-y-2 fb-overflow-auto fb-rounded-md fb-p-2 fb-text-xs",
|
||||
dir === "rtl" ? "fb-left-8" : "fb-right-8"
|
||||
)}
|
||||
ref={languageDropdownRef}>
|
||||
|
||||
@@ -13,7 +13,6 @@ import nlTranslations from "../../locales/nl.json";
|
||||
import ptTranslations from "../../locales/pt.json";
|
||||
import roTranslations from "../../locales/ro.json";
|
||||
import ruTranslations from "../../locales/ru.json";
|
||||
import svTranslations from "../../locales/sv.json";
|
||||
import uzTranslations from "../../locales/uz.json";
|
||||
import zhHansTranslations from "../../locales/zh-Hans.json";
|
||||
|
||||
@@ -22,23 +21,7 @@ i18n
|
||||
.use(initReactI18next)
|
||||
.init({
|
||||
fallbackLng: "en",
|
||||
supportedLngs: [
|
||||
"en",
|
||||
"de",
|
||||
"it",
|
||||
"fr",
|
||||
"es",
|
||||
"ar",
|
||||
"pt",
|
||||
"ro",
|
||||
"ja",
|
||||
"ru",
|
||||
"uz",
|
||||
"zh-Hans",
|
||||
"hi",
|
||||
"nl",
|
||||
"sv",
|
||||
],
|
||||
supportedLngs: ["en", "de", "it", "fr", "es", "ar", "pt", "ro", "ja", "ru", "uz", "zh-Hans", "hi", "nl"],
|
||||
|
||||
resources: {
|
||||
en: { translation: enTranslations },
|
||||
@@ -53,7 +36,6 @@ i18n
|
||||
nl: { translation: nlTranslations },
|
||||
ru: { translation: ruTranslations },
|
||||
uz: { translation: uzTranslations },
|
||||
sv: { translation: svTranslations },
|
||||
"zh-Hans": { translation: zhHansTranslations },
|
||||
hi: { translation: hiTranslations },
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { z } from "zod";
|
||||
import { ZColor, ZPlacement } from "./common";
|
||||
import { ZEnvironment } from "./environment";
|
||||
import { ZBaseStyling, ZLogo } from "./styling";
|
||||
import { ZBaseStyling } from "./styling";
|
||||
|
||||
export const ZProjectStyling = ZBaseStyling.extend({
|
||||
allowStyleOverwrite: z.boolean(),
|
||||
@@ -46,6 +46,11 @@ export const ZLanguageUpdate = z.object({
|
||||
});
|
||||
export type TLanguageUpdate = z.infer<typeof ZLanguageUpdate>;
|
||||
|
||||
export const ZLogo = z.object({
|
||||
url: z.string().optional(),
|
||||
bgColor: z.string().optional(),
|
||||
});
|
||||
|
||||
export type TLogo = z.infer<typeof ZLogo>;
|
||||
|
||||
export const ZProject = z.object({
|
||||
|
||||
@@ -15,12 +15,6 @@ export const ZCardArrangement = z.object({
|
||||
appSurveys: ZCardArrangementOptions,
|
||||
});
|
||||
|
||||
export const ZLogo = z.object({
|
||||
url: z.string().optional(),
|
||||
bgColor: z.string().optional(),
|
||||
});
|
||||
export type TLogo = z.infer<typeof ZLogo>;
|
||||
|
||||
export const ZSurveyStylingBackground = z
|
||||
.object({
|
||||
bg: z.string().nullish(),
|
||||
@@ -54,7 +48,6 @@ export const ZBaseStyling = z.object({
|
||||
background: ZSurveyStylingBackground.nullish(),
|
||||
hideProgressBar: z.boolean().nullish(),
|
||||
isLogoHidden: z.boolean().nullish(),
|
||||
logo: ZLogo.nullish(),
|
||||
});
|
||||
|
||||
export type TBaseStyling = z.infer<typeof ZBaseStyling>;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { type ZodIssue, z } from "zod";
|
||||
import { ZSurveyFollowUp } from "@formbricks/database/types/survey-follow-up";
|
||||
import { ZActionClass, ZActionClassNoCodeConfig } from "../action-classes";
|
||||
import { ZColor, ZId, ZPlacement, ZUrl, getZSafeUrl } from "../common";
|
||||
import { ZColor, ZId, ZPlacement, getZSafeUrl } from "../common";
|
||||
import { ZContactAttributes } from "../contact-attribute";
|
||||
import { type TI18nString, ZI18nString } from "../i18n";
|
||||
import { ZLanguage } from "../project";
|
||||
@@ -60,16 +60,16 @@ export const ZSurveyEndScreenCard = ZSurveyEndingBase.extend({
|
||||
headline: ZI18nString.optional(),
|
||||
subheader: ZI18nString.optional(),
|
||||
buttonLabel: ZI18nString.optional(),
|
||||
buttonLink: ZUrl.optional(),
|
||||
imageUrl: ZUrl.optional(),
|
||||
videoUrl: ZUrl.optional(),
|
||||
buttonLink: z.string().optional(),
|
||||
imageUrl: z.string().optional(),
|
||||
videoUrl: z.string().optional(),
|
||||
});
|
||||
|
||||
export type TSurveyEndScreenCard = z.infer<typeof ZSurveyEndScreenCard>;
|
||||
|
||||
export const ZSurveyRedirectUrlCard = ZSurveyEndingBase.extend({
|
||||
type: z.literal("redirectToUrl"),
|
||||
url: ZUrl.optional(),
|
||||
url: z.string().optional(),
|
||||
label: z.string().optional(),
|
||||
});
|
||||
|
||||
@@ -143,11 +143,11 @@ export const ZSurveyWelcomeCard = z
|
||||
enabled: z.boolean(),
|
||||
headline: ZI18nString.optional(),
|
||||
subheader: ZI18nString.optional(),
|
||||
fileUrl: ZUrl.optional(),
|
||||
fileUrl: z.string().optional(),
|
||||
buttonLabel: ZI18nString.optional(),
|
||||
timeToFinish: z.boolean().default(true),
|
||||
showResponseCount: z.boolean().default(false),
|
||||
videoUrl: ZUrl.optional(),
|
||||
videoUrl: z.string().optional(),
|
||||
})
|
||||
.refine((schema) => !(schema.enabled && !schema.headline), {
|
||||
message: "Welcome card must have a headline",
|
||||
@@ -1355,10 +1355,7 @@ export const ZSurvey = z
|
||||
}
|
||||
}
|
||||
|
||||
//only validate back button label for blocks other than the first one and if back button is not hidden
|
||||
if (
|
||||
!isBackButtonHidden &&
|
||||
blockIndex > 0 &&
|
||||
block.backButtonLabel?.[defaultLanguageCode] &&
|
||||
block.backButtonLabel[defaultLanguageCode].trim() !== ""
|
||||
) {
|
||||
|
||||
@@ -12,7 +12,6 @@ export const ZUserLocale = z.enum([
|
||||
"ja-JP",
|
||||
"zh-Hans-CN",
|
||||
"es-ES",
|
||||
"sv-SE",
|
||||
]);
|
||||
|
||||
export type TUserLocale = z.infer<typeof ZUserLocale>;
|
||||
|
||||
Generated
+595
-667
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user