@explorer02/cfm-survey-sdk 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +18 -18
- package/dist/cli/index.mjs +14 -14
- package/dist/index.d.mts +465 -580
- package/dist/index.d.ts +465 -580
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +6 -4
- package/postinstall.js +96 -64
- package/templates/AGENT.md +15 -7
- package/templates/docs/00-integration/answer-logic-and-navigation.md +50 -0
- package/templates/docs/00-integration/aws-deploy.md +281 -0
- package/templates/docs/00-integration/client-integration-guide.md +351 -0
- package/templates/docs/00-integration/component-checklist.md +84 -0
- package/templates/docs/00-integration/constraints.md +65 -3
- package/templates/docs/00-integration/custom-field-logic-and-navigation.md +174 -0
- package/templates/docs/00-integration/display-logic-and-navigation.md +49 -0
- package/templates/docs/00-integration/end-page-logic.md +64 -0
- package/templates/docs/00-integration/partial-save-and-recovery.md +74 -0
- package/templates/docs/00-integration/placeholders-and-tokens.md +116 -0
- package/templates/docs/00-integration/progress.md +61 -0
- package/templates/docs/00-integration/question-display-variants.md +65 -0
- package/templates/docs/00-integration/question-numbering.md +51 -0
- package/templates/docs/00-integration/question-type-sdk-matrix.md +242 -0
- package/templates/docs/00-integration/setup.md +84 -0
- package/templates/docs/00-integration/skip-logic-and-navigation.md +80 -0
- package/templates/docs/00-integration/survey-lifecycle-analytics.md +94 -0
- package/templates/docs/00-integration/useSurveySDK.md +151 -23
- package/templates/docs/01-components/01-survey-page.md +76 -54
- package/templates/docs/01-components/02-question.md +77 -89
- package/templates/docs/01-components/03-rating-scale.md +11 -1
- package/templates/docs/01-components/04-star-rating-scale.md +45 -0
- package/templates/docs/01-components/05-csat-matrix-scale.md +20 -11
- package/templates/docs/01-components/06-likert-matrix-scale.md +12 -3
- package/templates/docs/01-components/07-slider-matrix-scale.md +11 -2
- package/templates/docs/01-components/08-file-upload-scale.md +10 -1
- package/templates/docs/01-components/09-custom-slider-track.md +2 -2
- package/templates/docs/01-components/11-progress-bar.md +10 -4
- package/templates/docs/01-components/13-matrix-dropdown.md +3 -1
- package/templates/docs/01-components/14-intro-page.md +34 -0
- package/templates/docs/01-components/15-end-page.md +31 -0
- package/templates/docs/01-components/16-paused-page.md +27 -0
- package/templates/docs/01-components/17-heatmap-scale.md +75 -0
- package/templates/docs/01-components/18-rank-order-scale.md +100 -0
- package/templates/docs/01-components/README.md +44 -36
- package/templates/docs/02-reference/config-field-index.md +141 -139
- package/templates/docs/02-reference/exports.md +149 -0
- package/templates/docs/02-reference/question-types/01-rating.md +31 -32
- package/templates/docs/02-reference/question-types/04-csat.md +51 -42
- package/templates/docs/02-reference/question-types/05-rating-scale.md +16 -11
- package/templates/docs/02-reference/question-types/06-slider.md +2 -2
- package/templates/docs/02-reference/question-types/07-matrix-cfm.md +44 -30
- package/templates/docs/02-reference/question-types/08-matrix-csat.md +4 -26
- package/templates/docs/02-reference/question-types/09-matrix-rating.md +29 -13
- package/templates/docs/02-reference/question-types/10-slider-matrix.md +15 -4
- package/templates/docs/02-reference/question-types/11-file-upload.md +13 -2
- package/templates/docs/02-reference/question-types/12-heatmap.md +59 -0
- package/templates/docs/02-reference/question-types/13-rank-order.md +101 -0
- package/templates/docs/02-reference/question-types/README.md +86 -47
- package/templates/docs/02-reference/routing-table.md +33 -18
- package/templates/docs/02-reference/value-derivation.md +63 -0
- package/templates/docs/03-ui-specs/00-question-shell.md +24 -80
- package/templates/docs/03-ui-specs/01-rating.md +12 -54
- package/templates/docs/03-ui-specs/02-radio.md +21 -33
- package/templates/docs/03-ui-specs/03-text.md +2 -2
- package/templates/docs/03-ui-specs/04-csat.md +38 -33
- package/templates/docs/03-ui-specs/05-rating-scale.md +21 -18
- package/templates/docs/03-ui-specs/06-slider.md +3 -1
- package/templates/docs/03-ui-specs/07-matrix-cfm.md +25 -22
- package/templates/docs/03-ui-specs/08-matrix-csat-rating.md +18 -46
- package/templates/docs/03-ui-specs/09-slider-matrix.md +2 -2
- package/templates/docs/03-ui-specs/10-file-upload.md +2 -2
- package/templates/docs/03-ui-specs/11-text-and-media.md +29 -29
- package/templates/docs/03-ui-specs/12-survey-chrome.md +20 -14
- package/templates/docs/03-ui-specs/13-heatmap.md +73 -0
- package/templates/docs/03-ui-specs/14-rank-order.md +59 -0
- package/templates/docs/03-ui-specs/README.md +14 -13
- package/templates/docs/03-ui-specs/shared/custom-slider-track.md +3 -3
- package/templates/docs/03-ui-specs/shared/matrix-dropdown.md +6 -1
- package/templates/docs/MANIFEST.json +454 -67
- package/templates/docs/index.md +84 -29
- package/templates/docs/templates/Question.tsx +310 -0
- package/templates/docs/templates/deploy-to-aws.sh +114 -0
- package/templates/docs/templates/heatmapCoords.ts +58 -0
- package/templates/docs/templates/implementation_plan.md +115 -49
- package/templates/docs/templates/survey-inventory.schema.json +72 -0
- package/templates/docs/templates/verify-agent-build.sh +53 -0
- package/templates/docs/01-components/04-csat-scale.md +0 -40
- package/templates/docs/02-question-types/01-rating.md +0 -44
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# Progress Bar Calculation
|
|
2
|
+
|
|
3
|
+
> The progress percentage reflects **questions on the active path**, not all questions in the survey.
|
|
4
|
+
|
|
5
|
+
## Formula
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
active path = pages the respondent will visit (given current answers + skip logic)
|
|
9
|
+
total = answerable questions on that path (excludes TEXT_AND_MEDIA)
|
|
10
|
+
answered = earned question credits that still lie on the path
|
|
11
|
+
progress % = round(answered / total × 100)
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`state.progressPercentage` from `useSurveySDK` is already computed — bind it to your `ProgressBar`.
|
|
15
|
+
|
|
16
|
+
The same active path also drives **question numbering** on `state.currentQuestions[].questionNumber`. See [`question-numbering.md`](question-numbering.md).
|
|
17
|
+
|
|
18
|
+
Custom field values in `options.customFieldValues` affect the active path when skip or display logic references `CUSTOM_FIELD` entities — the denominator updates automatically. See [`custom-field-logic-and-navigation.md`](custom-field-logic-and-navigation.md).
|
|
19
|
+
|
|
20
|
+
## How credits are earned
|
|
21
|
+
|
|
22
|
+
| Question | When credited |
|
|
23
|
+
|----------|---------------|
|
|
24
|
+
| **Optional** | When the user **lands on** the page (`earnPageOnVisit`) |
|
|
25
|
+
| **Required** | When validly answered (on change, or on visit if already filled) |
|
|
26
|
+
|
|
27
|
+
Display-only `TEXT_AND_MEDIA` questions never count toward progress.
|
|
28
|
+
|
|
29
|
+
## Skip logic changes the denominator
|
|
30
|
+
|
|
31
|
+
If skip logic removes pages from the active path, the **total** shrinks automatically.
|
|
32
|
+
|
|
33
|
+
**Example:** Survey has 10 pages; skip removes pages 3–6 → total might drop from 10 questions to 6 on the active path.
|
|
34
|
+
|
|
35
|
+
## Path change vs prune (progress only)
|
|
36
|
+
|
|
37
|
+
| Event | Progress effect |
|
|
38
|
+
|-------|-----------------|
|
|
39
|
+
| **Path changed** (answer edit reshapes route) | Future answers cleared; off-path credits removed; bar recalculates |
|
|
40
|
+
| **Pruned only** (same route, stale credits) | Off-path credits removed; bar recalculates; answers kept |
|
|
41
|
+
|
|
42
|
+
## Example timeline
|
|
43
|
+
|
|
44
|
+
Survey: 4 questions on active path (Q1–Q4 sequential).
|
|
45
|
+
|
|
46
|
+
| Step | Action | Progress |
|
|
47
|
+
|------|--------|----------|
|
|
48
|
+
| 1 | Land page 1 | Optional Q2 on page 2 not yet counted |
|
|
49
|
+
| 2 | Answer required Q1 | 1/4 = 25% |
|
|
50
|
+
| 3 | Next → page 2 | Optional Q2 credited on visit → 2/4 = 50% |
|
|
51
|
+
| 4 | Change Q1 to trigger skip to Q4 | Path shrinks to 2 questions; stale credits pruned; sanitize clears middle answers |
|
|
52
|
+
|
|
53
|
+
## UI wiring
|
|
54
|
+
|
|
55
|
+
```tsx
|
|
56
|
+
<ProgressBar progressPercentage={state.progressPercentage} />
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
See [`01-components/11-progress-bar.md`](../01-components/11-progress-bar.md) and [`03-ui-specs/12-survey-chrome.md`](../03-ui-specs/12-survey-chrome.md).
|
|
60
|
+
|
|
61
|
+
See also: [`skip-logic-and-navigation.md`](skip-logic-and-navigation.md).
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Question Display Variants
|
|
2
|
+
|
|
3
|
+
> Integrator-facing behavior contract. Variant evaluation is handled inside the SDK — the client renders `question.questionText` from `state.currentQuestions` with no variant-aware code.
|
|
4
|
+
|
|
5
|
+
## What variants do
|
|
6
|
+
|
|
7
|
+
A question may define alternate rich-text prompts under `questionDisplayVariants[]` in the API. Each variant has:
|
|
8
|
+
|
|
9
|
+
- `questionText` / `questionRichText` (and optional `translations`)
|
|
10
|
+
- `controlConfig.displayLogic.condition` — the same nested AND/OR filter tree used for skip, display, answer, and custom-field logic
|
|
11
|
+
|
|
12
|
+
At runtime the SDK picks the **first variant whose condition evaluates true** and overrides `questionText` on `state.currentQuestions`. If no variant matches, the question's base shell text (root `questionRichText` / `questionText`) is used.
|
|
13
|
+
|
|
14
|
+
Variants change **wording only** — they do not show/hide the question. Question-level show/hide remains `question.displayLogic` (see [`display-logic-and-navigation.md`](display-logic-and-navigation.md)).
|
|
15
|
+
|
|
16
|
+
## Shared logic engine
|
|
17
|
+
|
|
18
|
+
Variant conditions use the same evaluator as all other logic kinds:
|
|
19
|
+
|
|
20
|
+
| Entity | Source |
|
|
21
|
+
|--------|--------|
|
|
22
|
+
| `QUESTION` | Prior answers in `state.answers` |
|
|
23
|
+
| `CUSTOM_FIELD` | `options.customFieldValues` (`_c_…` ids) |
|
|
24
|
+
|
|
25
|
+
See [`custom-field-logic-and-navigation.md`](custom-field-logic-and-navigation.md) when variant rules reference CRM/transaction fields.
|
|
26
|
+
|
|
27
|
+
## Client responsibilities
|
|
28
|
+
|
|
29
|
+
**None beyond normal rendering.**
|
|
30
|
+
|
|
31
|
+
- Use `state.currentQuestions` — `questionText` is already resolved for the current answers and custom field values.
|
|
32
|
+
- Render with `dangerouslySetInnerHTML` as today.
|
|
33
|
+
- Keep calling `resolveSurveyQuestionPlaceholders(question.questionText, allAnswers, allQuestions)` for `{{SURVEY_QUESTION-:-questionId}}` answer tokens (unchanged).
|
|
34
|
+
- Do **not** read `question.displayVariants` or re-implement condition evaluation in the client.
|
|
35
|
+
|
|
36
|
+
## Resolution order
|
|
37
|
+
|
|
38
|
+
1. **Map time:** language translation + static CRM placeholders (`{{FIRST_NAME}}`) applied to each variant's text
|
|
39
|
+
2. **Runtime (SDK):** first matching variant in API array order
|
|
40
|
+
3. **Render time (client):** dynamic answer placeholders via `resolveSurveyQuestionPlaceholders`
|
|
41
|
+
|
|
42
|
+
## Behavior summary
|
|
43
|
+
|
|
44
|
+
| Scenario | Result |
|
|
45
|
+
|----------|--------|
|
|
46
|
+
| No `displayVariants` | Base `questionText` |
|
|
47
|
+
| Variants present, none match | Base shell `questionText` |
|
|
48
|
+
| Multiple variants match | First in API order wins |
|
|
49
|
+
| Answers / custom fields change | `currentQuestions` updates on same page |
|
|
50
|
+
| Question hidden by display logic | Not in `currentQuestions`; variants not evaluated |
|
|
51
|
+
| Language switch | Re-fetch/remap applies translated variant text |
|
|
52
|
+
|
|
53
|
+
## SDK exports (optional advanced use)
|
|
54
|
+
|
|
55
|
+
```typescript
|
|
56
|
+
import {
|
|
57
|
+
resolveQuestionDisplayText,
|
|
58
|
+
applyQuestionDisplayVariants,
|
|
59
|
+
type QuestionDisplayVariant,
|
|
60
|
+
} from '@explorer02/cfm-survey-sdk';
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Most integrators only need `state.currentQuestions`.
|
|
64
|
+
|
|
65
|
+
See also: [`display-logic-and-navigation.md`](display-logic-and-navigation.md), [`custom-field-logic-and-navigation.md`](custom-field-logic-and-navigation.md), [`useSurveySDK.md`](useSurveySDK.md).
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Question Numbering (Active Path)
|
|
2
|
+
|
|
3
|
+
> Integrator-facing behavior contract. Question ordinals are computed inside the SDK — the client renders `question.questionNumber` from `state.currentQuestions` with no numbering logic.
|
|
4
|
+
|
|
5
|
+
## What the SDK does
|
|
6
|
+
|
|
7
|
+
The SDK assigns **1-indexed ordinals** to answerable questions on the respondent’s **active path** (same path used for the progress bar). The resolved value is written to `questionNumber` on each item in `state.currentQuestions`.
|
|
8
|
+
|
|
9
|
+
| Rule | Behavior |
|
|
10
|
+
|------|----------|
|
|
11
|
+
| Path source | `simulateActivePath()` — skip + display + custom-field logic |
|
|
12
|
+
| Which questions | Visible **answerable** questions (`getAnswerableQuestionsOnPage`) |
|
|
13
|
+
| Excluded | `TEXT_AND_MEDIA` (display-only, same as progress) |
|
|
14
|
+
| Order | Active-path page order, then question order within each page |
|
|
15
|
+
| Updates | When answers, custom fields, or path shape change |
|
|
16
|
+
|
|
17
|
+
Example: skip from Q3 to Q8 → path questions are numbered **1, 2, 3, 4…**, not builder indices.
|
|
18
|
+
|
|
19
|
+
## Client responsibilities
|
|
20
|
+
|
|
21
|
+
**Render only — no path simulation.**
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
{question.questionNumber != null && (
|
|
25
|
+
<span>{question.questionNumber}.</span>
|
|
26
|
+
)}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Use `state.currentQuestions` (not raw `survey.pages` questions). Optional chrome:
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
state.totalQuestionsCount // path denominator (same as progress)
|
|
33
|
+
state.answeredQuestionsCount // earned credits on path
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Relationship to progress
|
|
37
|
+
|
|
38
|
+
Question numbering and `state.progressPercentage` share the same active-path denominator. See [`progress.md`](progress.md).
|
|
39
|
+
|
|
40
|
+
## SDK exports (optional advanced use)
|
|
41
|
+
|
|
42
|
+
```typescript
|
|
43
|
+
import {
|
|
44
|
+
computeActivePathQuestionNumbers,
|
|
45
|
+
applyActivePathQuestionNumbers,
|
|
46
|
+
} from '@explorer02/cfm-survey-sdk';
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Most integrators only need `state.currentQuestions` and `state.totalQuestionsCount`.
|
|
50
|
+
|
|
51
|
+
See also: [`question-display-variants.md`](question-display-variants.md), [`useSurveySDK.md`](useSurveySDK.md).
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
# Question Type SDK Integration Matrix
|
|
2
|
+
|
|
3
|
+
> **Authoritative master table** for all **11** `QUESTION_TYPE` literals. Read this after [`client-integration-guide.md`](client-integration-guide.md) and before building any question component.
|
|
4
|
+
|
|
5
|
+
Each row uses the same columns so agents can inventory a fetched survey and wire every SDK feature without importing internal evaluators.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Cross-type logic applicability
|
|
10
|
+
|
|
11
|
+
| Feature | MCQ | TEXTFIELD | NPS | CFM | CSAT | RATING | SLIDER | FILE | T&M | HEATMAP | RANK |
|
|
12
|
+
|---------|:---:|:---------:|:---:|:---:|:----:|:------:|:------:|:----:|:---:|:-------:|:----:|
|
|
13
|
+
| Skip logic | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
14
|
+
| Display logic (question) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
15
|
+
| Answer logic (options/rows/cols) | opt | — | col | row+col | row+col | row | row | — | — | — | opt |
|
|
16
|
+
| Display variants | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
17
|
+
| Question numbering | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
18
|
+
| Placeholders | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
19
|
+
| Partial save | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | — | ✓ | ✓ |
|
|
20
|
+
| Custom field logic | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
|
|
21
|
+
|
|
22
|
+
Legend: **opt** = option-level; **row+col** = statement rows and scale columns; **col** = scale columns only; **—** = no answer stored or no answer-logic targets.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## MCQ
|
|
27
|
+
|
|
28
|
+
| Column | Value |
|
|
29
|
+
|--------|-------|
|
|
30
|
+
| **SDK type + answer shape** | `McqQuestion`; answer `string \| number` (option `id`) or `string[] \| number[]` when multi-select |
|
|
31
|
+
| **Component file(s)** | Inline in `Question.tsx` or dedicated `McqQuestion.tsx` |
|
|
32
|
+
| **Dispatcher branch** | `QUESTION_TYPE.MCQ` / `'MCQ'` |
|
|
33
|
+
| **Visibility helper** | `getVisibleMcqOptionsForAnswers(question, answers, allQuestions, customFieldValues?)` |
|
|
34
|
+
| **Answer logic scope** | Options |
|
|
35
|
+
| **Skip / display / variants / numbering** | SDK handles skip path, `currentQuestions`, resolved `questionText`, `questionNumber` — client renders visible options only |
|
|
36
|
+
| **Custom field logic** | Pass `customFieldValues` as 4th arg to visibility helper when rules reference CRM fields |
|
|
37
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: optionId \| optionId[] } }` |
|
|
38
|
+
| **Value derivation** | Store `option.id`; SDK maps to API value at submit |
|
|
39
|
+
| **Performance notes** | Filter options once per render via helper; avoid re-fetch on option click |
|
|
40
|
+
| **Docs to read** | [`02-question.md`](../01-components/02-question.md) · [`question-types/README.md#mcq`](../02-reference/question-types/README.md#mcq) · [`02-radio.md`](../03-ui-specs/02-radio.md) |
|
|
41
|
+
| **Known limitations** | Multi-select array shape is client responsibility; verify `selectionMode` from survey config |
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## TEXTFIELD
|
|
46
|
+
|
|
47
|
+
| Column | Value |
|
|
48
|
+
|--------|-------|
|
|
49
|
+
| **SDK type + answer shape** | `TextInputQuestion`; answer `string` |
|
|
50
|
+
| **Component file(s)** | Inline in `Question.tsx` |
|
|
51
|
+
| **Dispatcher branch** | `QUESTION_TYPE.TEXTFIELD` / `'TEXTFIELD'` |
|
|
52
|
+
| **Visibility helper** | None |
|
|
53
|
+
| **Answer logic scope** | None |
|
|
54
|
+
| **Skip / display / variants / numbering** | SDK auto; client renders `inputVariant` (`short` vs `long`) from question config |
|
|
55
|
+
| **Custom field logic** | Only in skip/display rules — no visibility helper |
|
|
56
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: string } }` — debounce long text in UI if needed |
|
|
57
|
+
| **Value derivation** | Raw string stored |
|
|
58
|
+
| **Performance notes** | Debounce `onAction` for long textarea (300–500 ms) to reduce partial-save churn |
|
|
59
|
+
| **Docs to read** | [`02-question.md`](../01-components/02-question.md) · [`03-text.md`](../03-ui-specs/03-text.md) |
|
|
60
|
+
| **Known limitations** | `short` variant uses single-line input; no answer logic on field content |
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## NPS_SCALE
|
|
65
|
+
|
|
66
|
+
| Column | Value |
|
|
67
|
+
|--------|-------|
|
|
68
|
+
| **SDK type + answer shape** | `NpsQuestion`; answer `number` (0–10 index or stored scale value) |
|
|
69
|
+
| **Component file(s)** | `RatingScale.tsx` (`variant="nps"`) |
|
|
70
|
+
| **Dispatcher branch** | `QUESTION_TYPE.NPS_SCALE` / `'NPS_SCALE'` |
|
|
71
|
+
| **Visibility helper** | `getVisibleScaleColumnsForAnswers` (when scale points have answer logic) |
|
|
72
|
+
| **Answer logic scope** | Scale columns/points only |
|
|
73
|
+
| **Skip / display / variants / numbering** | SDK auto; client renders NPS 0–10 row |
|
|
74
|
+
| **Custom field logic** | 4th arg on scale visibility helper when needed |
|
|
75
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: number } }` |
|
|
76
|
+
| **Value derivation** | Numeric from selected scale point; use `optionLabel` or index per ui-spec |
|
|
77
|
+
| **Performance notes** | Single row — no matrix overhead |
|
|
78
|
+
| **Docs to read** | [`03-rating-scale.md`](../01-components/03-rating-scale.md) · [`01-rating.md`](../02-reference/question-types/01-rating.md) · [`01-rating.md`](../03-ui-specs/01-rating.md) |
|
|
79
|
+
| **Known limitations** | Legacy `star_rating` maps here or to matrix display styles — not a separate literal |
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## CFM_MATRIX
|
|
84
|
+
|
|
85
|
+
| Column | Value |
|
|
86
|
+
|--------|-------|
|
|
87
|
+
| **SDK type + answer shape** | `CfmMatrixQuestion`; answer `MatrixRowAnswers` (`Record<rowId, columnStoredValue>`) |
|
|
88
|
+
| **Component file(s)** | `LikertMatrixScale.tsx`, `MatrixDropdown.tsx` (when `gridLayout: dropdown`) |
|
|
89
|
+
| **Dispatcher branch** | `QUESTION_TYPE.CFM_MATRIX` / `'CFM_MATRIX'` |
|
|
90
|
+
| **Visibility helper** | `getVisibleMatrixItemsForAnswers` — filters rows **and** columns |
|
|
91
|
+
| **Answer logic scope** | Statement rows + scale columns |
|
|
92
|
+
| **Skip / display / variants / numbering** | SDK auto; client picks Likert vs dropdown from `gridLayout` |
|
|
93
|
+
| **Custom field logic** | 4th arg on matrix visibility helper |
|
|
94
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: MatrixRowAnswers } }` — merge row updates |
|
|
95
|
+
| **Value derivation** | **`matrixColumnStoredValue(column)`** for each cell — never store raw label |
|
|
96
|
+
| **Performance notes** | Render only visible rows/cols; lazy-load large matrices |
|
|
97
|
+
| **Docs to read** | [`06-likert-matrix-scale.md`](../01-components/06-likert-matrix-scale.md) · [`07-matrix-cfm.md`](../02-reference/question-types/07-matrix-cfm.md) · [`07-matrix-cfm.md`](../03-ui-specs/07-matrix-cfm.md) |
|
|
98
|
+
| **Known limitations** | Bipolar layout is visual only — same answer shape |
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## CSAT_MATRIX
|
|
103
|
+
|
|
104
|
+
| Column | Value |
|
|
105
|
+
|--------|-------|
|
|
106
|
+
| **SDK type + answer shape** | `CsatQuestion`; answer `MatrixRowAnswers` |
|
|
107
|
+
| **Component file(s)** | `CsatMatrixScale.tsx`, `MatrixDropdown.tsx`, `CustomSliderTrack.tsx` (graphics) |
|
|
108
|
+
| **Dispatcher branch** | `QUESTION_TYPE.CSAT_MATRIX` / `'CSAT_MATRIX'` |
|
|
109
|
+
| **Visibility helper** | `getVisibleMatrixItemsForAnswers` |
|
|
110
|
+
| **Answer logic scope** | Statement rows + scale columns |
|
|
111
|
+
| **Skip / display / variants / numbering** | SDK auto; emoji/star UI is **client-implemented** (`react-icons`) |
|
|
112
|
+
| **Custom field logic** | 4th arg on matrix visibility helper |
|
|
113
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: MatrixRowAnswers } }` |
|
|
114
|
+
| **Value derivation** | `matrixColumnStoredValue(column)` |
|
|
115
|
+
| **Performance notes** | Graphics mode uses slider track per row; prefer memoized emoji maps |
|
|
116
|
+
| **Docs to read** | [`05-csat-matrix-scale.md`](../01-components/05-csat-matrix-scale.md) · [`04-csat.md`](../02-reference/question-types/04-csat.md) · [`04-csat.md`](../03-ui-specs/04-csat.md) |
|
|
117
|
+
| **Known limitations** | No SDK emoji exports — implement icons client-side |
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## RATING_MATRIX
|
|
122
|
+
|
|
123
|
+
| Column | Value |
|
|
124
|
+
|--------|-------|
|
|
125
|
+
| **SDK type + answer shape** | `RatingMatrixQuestion`; answer `MatrixRowAnswers` |
|
|
126
|
+
| **Component file(s)** | Same as CSAT: `CsatMatrixScale.tsx`, `MatrixDropdown.tsx`, `CustomSliderTrack.tsx` |
|
|
127
|
+
| **Dispatcher branch** | `QUESTION_TYPE.RATING_MATRIX` / `'RATING_MATRIX'` |
|
|
128
|
+
| **Visibility helper** | `getVisibleMatrixItemsForAnswers` |
|
|
129
|
+
| **Answer logic scope** | Statement rows; **column answer logic may be limited** — verify fetched survey |
|
|
130
|
+
| **Skip / display / variants / numbering** | SDK auto; reuse CSAT matrix component with rating display style |
|
|
131
|
+
| **Custom field logic** | 4th arg on matrix visibility helper |
|
|
132
|
+
| **`onAction` pattern** | Same as CSAT matrix |
|
|
133
|
+
| **Value derivation** | `matrixColumnStoredValue(column)` |
|
|
134
|
+
| **Performance notes** | Same as CSAT matrix |
|
|
135
|
+
| **Docs to read** | [`05-csat-matrix-scale.md`](../01-components/05-csat-matrix-scale.md) · [`09-matrix-rating.md`](../02-reference/question-types/09-matrix-rating.md) · [`08-matrix-csat-rating.md`](../03-ui-specs/08-matrix-csat-rating.md) |
|
|
136
|
+
| **Known limitations** | Shares CSAT component; column-level answer logic gap documented in reference |
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## SLIDER_MATRIX
|
|
141
|
+
|
|
142
|
+
| Column | Value |
|
|
143
|
+
|--------|-------|
|
|
144
|
+
| **SDK type + answer shape** | `SliderMatrixQuestion`; answer `MatrixRowAnswers` |
|
|
145
|
+
| **Component file(s)** | `SliderMatrixScale.tsx`, `CustomSliderTrack.tsx` |
|
|
146
|
+
| **Dispatcher branch** | `QUESTION_TYPE.SLIDER_MATRIX` / `'SLIDER_MATRIX'` |
|
|
147
|
+
| **Visibility helper** | `getVisibleStatementRowsForAnswers` (rows); columns from tick marks config |
|
|
148
|
+
| **Answer logic scope** | Statement rows |
|
|
149
|
+
| **Skip / display / variants / numbering** | SDK auto; tick marks from `tickMarks` array |
|
|
150
|
+
| **Custom field logic** | 4th arg on statement-row helper |
|
|
151
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: MatrixRowAnswers } }` |
|
|
152
|
+
| **Value derivation** | Stored value from tick mark / slider position per row |
|
|
153
|
+
| **Performance notes** | One slider per visible row; debounce drag if partial save enabled |
|
|
154
|
+
| **Docs to read** | [`07-slider-matrix-scale.md`](../01-components/07-slider-matrix-scale.md) · [`10-slider-matrix.md`](../02-reference/question-types/10-slider-matrix.md) · [`09-slider-matrix.md`](../03-ui-specs/09-slider-matrix.md) |
|
|
155
|
+
| **Known limitations** | Legacy standalone `slider` type maps here — not a separate literal |
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## FILE_UPLOAD
|
|
160
|
+
|
|
161
|
+
| Column | Value |
|
|
162
|
+
|--------|-------|
|
|
163
|
+
| **SDK type + answer shape** | `FileUploadQuestion`; answer `UploadedFile[]` |
|
|
164
|
+
| **Component file(s)** | `FileUploadScale.tsx` |
|
|
165
|
+
| **Dispatcher branch** | `QUESTION_TYPE.FILE_UPLOAD` / `'FILE_UPLOAD'` |
|
|
166
|
+
| **Visibility helper** | None |
|
|
167
|
+
| **Answer logic scope** | None |
|
|
168
|
+
| **Skip / display / variants / numbering** | SDK auto |
|
|
169
|
+
| **Custom field logic** | Skip/display only |
|
|
170
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: UploadedFile[] } }` after upload completes |
|
|
171
|
+
| **Value derivation** | SDK submit maps file metadata to API |
|
|
172
|
+
| **Performance notes** | Upload to presigned URL before CHANGE; show progress UI |
|
|
173
|
+
| **Docs to read** | [`08-file-upload-scale.md`](../01-components/08-file-upload-scale.md) · [`11-file-upload.md`](../02-reference/question-types/11-file-upload.md) · [`10-file-upload.md`](../03-ui-specs/10-file-upload.md) |
|
|
174
|
+
| **Known limitations** | Blocking question — validate file count/size client-side per config |
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## TEXT_AND_MEDIA
|
|
179
|
+
|
|
180
|
+
| Column | Value |
|
|
181
|
+
|--------|-------|
|
|
182
|
+
| **SDK type + answer shape** | `TextAndMediaQuestion`; **no answer** |
|
|
183
|
+
| **Component file(s)** | Inline in `Question.tsx` |
|
|
184
|
+
| **Dispatcher branch** | `QUESTION_TYPE.TEXT_AND_MEDIA` / `'TEXT_AND_MEDIA'` |
|
|
185
|
+
| **Visibility helper** | None |
|
|
186
|
+
| **Answer logic scope** | None |
|
|
187
|
+
| **Skip / display / variants / numbering** | SDK auto; container media from survey shell |
|
|
188
|
+
| **Custom field logic** | Skip/display only |
|
|
189
|
+
| **`onAction` pattern** | No CHANGE — user advances with NEXT |
|
|
190
|
+
| **Value derivation** | N/A |
|
|
191
|
+
| **Performance notes** | Lazy-load media; respect alignment from ui-spec |
|
|
192
|
+
| **Docs to read** | [`02-question.md`](../01-components/02-question.md) · [`11-text-and-media.md`](../03-ui-specs/11-text-and-media.md) |
|
|
193
|
+
| **Known limitations** | Display-only; excluded from partial-save answer payload |
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## HEATMAP
|
|
198
|
+
|
|
199
|
+
| Column | Value |
|
|
200
|
+
|--------|-------|
|
|
201
|
+
| **SDK type + answer shape** | `HeatmapQuestion`; answer `HeatmapAnswer` (`{ clicks: HeatmapClickPoint[] }`) |
|
|
202
|
+
| **Component file(s)** | `HeatmapScale.tsx` + portable coord helper (see [`templates/heatmapCoords.ts`](../templates/heatmapCoords.ts)) |
|
|
203
|
+
| **Dispatcher branch** | `QUESTION_TYPE.HEATMAP` / `'HEATMAP'` |
|
|
204
|
+
| **Visibility helper** | None |
|
|
205
|
+
| **Answer logic scope** | None |
|
|
206
|
+
| **Skip / display / variants / numbering** | SDK auto |
|
|
207
|
+
| **Custom field logic** | Skip/display only |
|
|
208
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: HeatmapAnswer } }` on each click add/remove |
|
|
209
|
+
| **Value derivation** | Normalized 0–1 coordinates; respect `maxClicksAllowed` |
|
|
210
|
+
| **Performance notes** | Normalize coords on image load; use `findSpotNearClick` for hit testing |
|
|
211
|
+
| **Docs to read** | [`17-heatmap-scale.md`](../01-components/17-heatmap-scale.md) · [`12-heatmap.md`](../02-reference/question-types/12-heatmap.md) · [`13-heatmap.md`](../03-ui-specs/13-heatmap.md) |
|
|
212
|
+
| **Known limitations** | Coord helper is client code — copy template, not monorepo-only path |
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## RANK_ORDER
|
|
217
|
+
|
|
218
|
+
| Column | Value |
|
|
219
|
+
|--------|-------|
|
|
220
|
+
| **SDK type + answer shape** | `RankOrderQuestion`; answer `RankOrderAnswers` (`Record<optionId, rank>`) |
|
|
221
|
+
| **Component file(s)** | `RankOrderScale.tsx` — requires `@dnd-kit/core`, `@dnd-kit/sortable`, `@dnd-kit/utilities` |
|
|
222
|
+
| **Dispatcher branch** | `QUESTION_TYPE.RANK_ORDER` / `'RANK_ORDER'` |
|
|
223
|
+
| **Visibility helper** | `getVisibleRankOrderOptionsForAnswers` |
|
|
224
|
+
| **Answer logic scope** | Options |
|
|
225
|
+
| **Skip / display / variants / numbering** | SDK auto |
|
|
226
|
+
| **Custom field logic** | 4th arg on rank visibility helper |
|
|
227
|
+
| **`onAction` pattern** | `{ type: 'CHANGE', payload: { questionId, answerValue: RankOrderAnswers } }` after reorder |
|
|
228
|
+
| **Value derivation** | Use `assignRankWithoutDuplicates`, `buildRankOrderFromOrderedOptionIds`, `getOrderedOptionIdsFromRanks`, `normalizeRankOrderAnswers` |
|
|
229
|
+
| **Performance notes** | Prefer `option.imageUrl` over `previewImageUrl`; dnd-kit sensors for touch |
|
|
230
|
+
| **Docs to read** | [`18-rank-order-scale.md`](../01-components/18-rank-order-scale.md) · [`13-rank-order.md`](../02-reference/question-types/13-rank-order.md) · [`14-rank-order.md`](../03-ui-specs/14-rank-order.md) |
|
|
231
|
+
| **Known limitations** | Image preview URLs may 403 on static deploy — use full `imageUrl` |
|
|
232
|
+
|
|
233
|
+
---
|
|
234
|
+
|
|
235
|
+
## Agent workflow
|
|
236
|
+
|
|
237
|
+
1. Inventory types from fetched survey → one row per type above.
|
|
238
|
+
2. Fill [`implementation_plan.md`](../templates/implementation_plan.md) §3d from this matrix.
|
|
239
|
+
3. For each type, read blueprint + reference + uiSpec from MANIFEST `questionTypes.{key}`.
|
|
240
|
+
4. Wire lifecycle features per [`survey-lifecycle-analytics.md`](survey-lifecycle-analytics.md).
|
|
241
|
+
5. Wire placeholders per [`placeholders-and-tokens.md`](placeholders-and-tokens.md).
|
|
242
|
+
6. Enable partial save per [`partial-save-and-recovery.md`](partial-save-and-recovery.md) when required.
|
|
@@ -41,6 +41,41 @@ import { useSurveySDK } from '@explorer02/cfm-survey-sdk';
|
|
|
41
41
|
|
|
42
42
|
---
|
|
43
43
|
|
|
44
|
+
## Next.js static export for AWS deploy {#nextjs-aws-static-export}
|
|
45
|
+
|
|
46
|
+
Required when deploying to **Sprinklr AWS** (S3 + CloudFront via EC2 middle API). See [`aws-deploy.md`](aws-deploy.md) for the full deploy procedure.
|
|
47
|
+
|
|
48
|
+
**`next.config.js`** — add static export settings alongside `transpilePackages`:
|
|
49
|
+
|
|
50
|
+
```javascript
|
|
51
|
+
/** @type {import('next').NextConfig} */
|
|
52
|
+
const nextConfig = {
|
|
53
|
+
reactStrictMode: true,
|
|
54
|
+
transpilePackages: ['@explorer02/cfm-survey-sdk'], // or '@repo/sdk'
|
|
55
|
+
output: 'export',
|
|
56
|
+
assetPrefix: './',
|
|
57
|
+
images: { unoptimized: true },
|
|
58
|
+
};
|
|
59
|
+
module.exports = nextConfig;
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**`package.json`** — copy RSC payload so `index.html` URLs work on CloudFront:
|
|
63
|
+
|
|
64
|
+
```json
|
|
65
|
+
"build": "next build && cp out/index.txt out/index.html.txt"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
| Setting | Why |
|
|
69
|
+
|---------|-----|
|
|
70
|
+
| `output: 'export'` | Produces uploadable `out/` folder |
|
|
71
|
+
| `assetPrefix: './'` | Assets work under nested `/sites/{surveyId}/{deployId}/` path |
|
|
72
|
+
| `images.unoptimized` | No server for Next Image Optimization |
|
|
73
|
+
| `index.html.txt` copy | Fixes 403 on `index.html.txt?_rsc` requests |
|
|
74
|
+
|
|
75
|
+
**Vite:** set `OUT_DIR` to `dist/` at deploy time. Use `base: './'` in `vite.config.ts` if built HTML uses absolute `/` asset paths.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
44
79
|
## Vite + React {#vite}
|
|
45
80
|
|
|
46
81
|
```bash
|
|
@@ -67,6 +102,24 @@ If you hit ESM resolution errors, migrate to Vite or use CRACO to transpile `nod
|
|
|
67
102
|
|
|
68
103
|
---
|
|
69
104
|
|
|
105
|
+
## Monorepo (`@repo/sdk`) {#monorepo}
|
|
106
|
+
|
|
107
|
+
When the client app lives in the same monorepo as the SDK:
|
|
108
|
+
|
|
109
|
+
1. Ensure `package.json` depends on `@repo/sdk` (workspace link).
|
|
110
|
+
2. **Build the SDK before running the client dev server:**
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
cd packages/sdk && npm run build
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
3. Use `@repo/sdk` in imports and set `transpilePackages: ['@repo/sdk']` in Next.js config.
|
|
117
|
+
4. Rebuild the SDK after any change to `packages/sdk/src/**` — the client reads from `packages/sdk/dist/`.
|
|
118
|
+
|
|
119
|
+
Missing `dist/index.mjs` causes runtime module-not-found errors. See [`constraints.md`](constraints.md) troubleshooting.
|
|
120
|
+
|
|
121
|
+
---
|
|
122
|
+
|
|
70
123
|
## Framework Detection (for agents)
|
|
71
124
|
|
|
72
125
|
```
|
|
@@ -78,3 +131,34 @@ else → ask client which React setup to use
|
|
|
78
131
|
```
|
|
79
132
|
|
|
80
133
|
For **existing apps**, read `package.json` and project structure — do not scaffold from scratch unless the client asks.
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## Survey-type conditional dependencies
|
|
138
|
+
|
|
139
|
+
After fetching the survey, install extra packages only when those types appear:
|
|
140
|
+
|
|
141
|
+
### RANK_ORDER — drag-and-drop mode
|
|
142
|
+
|
|
143
|
+
When the survey contains `RANK_ORDER` with `interactionMode: 'dragAndDrop'` (or you implement drag UI):
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm install @dnd-kit/core @dnd-kit/sortable @dnd-kit/utilities
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
See [`18-rank-order-scale.md`](../01-components/18-rank-order-scale.md) and [`question-type-sdk-matrix.md#rank_order`](question-type-sdk-matrix.md#rank_order).
|
|
150
|
+
|
|
151
|
+
### HEATMAP — coordinate normalization
|
|
152
|
+
|
|
153
|
+
When the survey contains `HEATMAP`, copy the portable coord helper into your project:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Example destination — adjust to your src layout
|
|
157
|
+
cp node_modules/@explorer02/cfm-survey-sdk/templates/docs/templates/heatmapCoords.ts src/lib/heatmapCoords.ts
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Monorepo agents: copy from `packages/sdk/templates/docs/templates/heatmapCoords.ts`.
|
|
161
|
+
|
|
162
|
+
Import `getNormalizedClickFromImage`, `findSpotNearClick`, and `createNewSpot` in `HeatmapScale.tsx`. Do **not** reference monorepo-only paths like `apps/client/src/lib/...` in shipped agent docs.
|
|
163
|
+
|
|
164
|
+
See [`17-heatmap-scale.md`](../01-components/17-heatmap-scale.md) and [`question-type-sdk-matrix.md#heatmap`](question-type-sdk-matrix.md#heatmap).
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Skip Logic and Navigation
|
|
2
|
+
|
|
3
|
+
> Integrator-facing behavior contract. Skip evaluation is handled inside the SDK — do not import internal `surveyLogic` paths.
|
|
4
|
+
|
|
5
|
+
## When skip rules run
|
|
6
|
+
|
|
7
|
+
- Skip rules live on individual questions (`question.skipLogics`).
|
|
8
|
+
- When a question has **multiple skip logic blocks**, the SDK evaluates them **top-to-bottom (API order)** and applies the **first** whose condition is true.
|
|
9
|
+
- On **Next**, the SDK evaluates skip logic on the **last question of the current page** only.
|
|
10
|
+
- Skip targets:
|
|
11
|
+
- `QUESTION` — jump forward to another question's page
|
|
12
|
+
- `END_OF_SURVEY` — trigger submit flow (validation bypass for skipped pages)
|
|
13
|
+
|
|
14
|
+
**Forward-only:** backward skip targets are rejected. The respondent cannot skip to an earlier page via skip logic.
|
|
15
|
+
|
|
16
|
+
## Multiselect MCQ — count of choice
|
|
17
|
+
|
|
18
|
+
Multiselect MCQ skip rules may use `field: 'NUM_OF_SELECTED_OPTIONS'` (**Count of Choice** in the builder). The SDK compares the number of selected option ids with numeric operators (`EQUALS`, `NOT_EQUALS`, `GT`, `GTE`, `LT`, `LTE`). Zero selections is treated as missing for `MISSING` / `EXISTS`.
|
|
19
|
+
|
|
20
|
+
## Custom field conditions
|
|
21
|
+
|
|
22
|
+
Skip rules may reference **custom fields** (`conditionEntity.entityType: 'CUSTOM_FIELD'`). See [`custom-field-logic-and-navigation.md`](custom-field-logic-and-navigation.md) for value shapes, operator contract, and the two wiring points (hook options + visibility helpers).
|
|
23
|
+
|
|
24
|
+
## Simple example
|
|
25
|
+
|
|
26
|
+
| Page | Question | Rule |
|
|
27
|
+
|------|----------|------|
|
|
28
|
+
| 1 | Q1 (NPS) | If score > 7 → skip to Q4 |
|
|
29
|
+
| 2 | Q2 | (middle) |
|
|
30
|
+
| 3 | Q3 | (middle) |
|
|
31
|
+
| 4 | Q4 | destination |
|
|
32
|
+
|
|
33
|
+
1. User sets Q1 = **5** → path is pages 1 → 2 → 3 → 4 (sequential).
|
|
34
|
+
2. User sets Q1 = **9** → simulated path becomes pages **1 → 4** (pages 2–3 skipped).
|
|
35
|
+
3. User clicks **Next** from page 1 → lands on page 4.
|
|
36
|
+
|
|
37
|
+
## Answer changes (`onChange`)
|
|
38
|
+
|
|
39
|
+
When the edited question has skip logic, the SDK compares the route **before** and **after** the edit.
|
|
40
|
+
|
|
41
|
+
| Check | Meaning | SDK action |
|
|
42
|
+
|-------|---------|------------|
|
|
43
|
+
| **Path changed** | Page route reshaped (e.g. sequential → skip) | Clear answers on all pages after current page; reset skip/visit tracking ahead; refresh progress |
|
|
44
|
+
| **Pruned only** | Route unchanged but progress credits were stale | Remove off-path earned credits; refresh progress; **keep answers** |
|
|
45
|
+
|
|
46
|
+
**Example — path changed:** User walked page 2, answered Q2, then on page 1 changes Q1 from 5 → 9. Q2 answer is cleared because page 2 is no longer on the active path.
|
|
47
|
+
|
|
48
|
+
**Example — pruned only:** User already on skip path; edits Q1 from 8 → 9 (still skips). Route unchanged; stale progress credits for pages visited earlier may be removed without clearing answers.
|
|
49
|
+
|
|
50
|
+
## Back navigation
|
|
51
|
+
|
|
52
|
+
- Back uses **`pageHistory`**, not `currentPageIndex - 1`.
|
|
53
|
+
- After a skip jump (e.g. page 1 → page 4), Back returns to the **skip origin** (page 1), not the sequential previous page.
|
|
54
|
+
- **Answers are preserved on Back** — the SDK does not sanitize answers when going back.
|
|
55
|
+
- Skip/visit tracking for pages ahead of the back target is reset.
|
|
56
|
+
|
|
57
|
+
## Forward navigation (`onNext`)
|
|
58
|
+
|
|
59
|
+
- Validates **current page only** before moving.
|
|
60
|
+
- On skip: marks intermediate pages in `skippedPageIndices`; may sanitize answers on skipped pages.
|
|
61
|
+
- Sequential Next skips empty pages automatically.
|
|
62
|
+
|
|
63
|
+
## Submit validation
|
|
64
|
+
|
|
65
|
+
- Submit validates **non-skipped pages** only (pages marked skipped via skip logic are excluded).
|
|
66
|
+
- End-of-survey skip triggers submit with `skipValidation: true` for remaining pages.
|
|
67
|
+
|
|
68
|
+
## Optional question telemetry
|
|
69
|
+
|
|
70
|
+
When the user leaves a page (Next or Submit), the SDK logs analytics for **optional questions left blank** on that page. This does not block navigation or affect answers.
|
|
71
|
+
|
|
72
|
+
Event: `optional_question_skipped` with `questionId` and `pageIndex`.
|
|
73
|
+
|
|
74
|
+
## Client responsibilities
|
|
75
|
+
|
|
76
|
+
- Wire `onAction({ type: 'NEXT' })`, `onAction({ type: 'PREVIOUS' })`, and `onAction({ type: 'CHANGE', payload: { questionId, answerValue } })`.
|
|
77
|
+
- Use `state.canGoBack` for the Back button (not `currentPageIndex === 0`).
|
|
78
|
+
- Use `state.primaryButtonType` for Next vs Submit label; SDK maps `NEXT` → `SUBMIT` on the last page when appropriate.
|
|
79
|
+
|
|
80
|
+
See also: [`progress.md`](progress.md), [`useSurveySDK.md`](useSurveySDK.md), [`display-logic-and-navigation.md`](display-logic-and-navigation.md), [`answer-logic-and-navigation.md`](answer-logic-and-navigation.md).
|