Files

70 lines
2.5 KiB
TypeScript

// The example code survey of the template (ADR-046): a short product-feedback questionnaire about
// notes, published at deploy with the module's other code guides. It starts only when the person asks
// for it -- the "Give feedback" button of the notes page (feedback-button.tsx) or the help offers of
// another module (the support chat lists it by its title) -- and runs once per person.
//
// Answers are stored per guide version on the platform and read in the console (Guides, the survey,
// Results); the free-text question shows a fixed hint not to enter personal data. The optional
// `screenshot` question takes up to three images or PDFs, each up to the project's survey file size
// (`max_file_size_mb: null`: data_policy.survey_file_max_mb, 10 MB unless configured), with the fixed
// hint that files must not contain personal data such as identity documents; the files go through
// this app's own server (guides.runtime.uploadFile) to the project's Blob store, and the console's
// Results list them. The project's guide settings must allow the `survey` kind (console, Guides,
// Settings) before it is served.
import { defineGuide } from "@conusai-kit/guides"
import { guideText } from "./messages.js"
const t = guideText.survey
export const feedbackSurvey = defineGuide({
key: "notes.feedback",
schema_version: 1,
kind: "survey",
default_locale: "en",
audience: { trait: { name: "role", in: ["owner", "admin", "member"] } },
trigger: { manual: true },
frequency: "once",
survey: {
title: t.title,
intro: t.intro,
questions: [
{
type: "rating",
id: "ease",
prompt: t.ease,
required: true,
scale: "1-5",
low_label: t.easeLow,
high_label: t.easeHigh,
},
{
type: "single_choice",
id: "use",
prompt: t.use,
required: false,
options: [
{ id: "meetings", label: t.useMeetings },
{ id: "ideas", label: t.useIdeas },
{ id: "tasks", label: t.useTasks },
],
allow_other: true,
},
{ type: "text", id: "improve", prompt: t.improve, required: false, multiline: true },
{
type: "file",
id: "screenshot",
prompt: t.screenshot,
required: false,
accept: ["image", "pdf"],
max_files: 3,
max_file_size_mb: null,
},
],
submit_label: null,
thank_you: t.thankYou,
allow_dismiss: true,
one_question_per_screen: true,
},
})