@posthog/browser-common 0.9.11 → 0.9.12
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/config.js
CHANGED
package/dist/config.mjs
CHANGED
|
@@ -9,4 +9,4 @@ export declare function getRatingBucketForResponseValue(responseValue: number, s
|
|
|
9
9
|
* Determine the next survey step based on branching configuration.
|
|
10
10
|
* Returns the next question index, or SurveyQuestionBranchingType.End if the survey should end.
|
|
11
11
|
*/
|
|
12
|
-
export declare function getNextSurveyStep(survey: Survey, currentQuestionIndex: number, response: string | string[] | number | null): number | typeof SurveyQuestionBranchingType.End;
|
|
12
|
+
export declare function getNextSurveyStep(survey: Survey, currentQuestionIndex: number, response: string | string[] | number | null | undefined): number | typeof SurveyQuestionBranchingType.End;
|
|
@@ -33,6 +33,7 @@ __webpack_require__.d(__webpack_exports__, {
|
|
|
33
33
|
});
|
|
34
34
|
const external_survey_constants_js_namespaceObject = require("../survey-constants.js");
|
|
35
35
|
const logger_js_namespaceObject = require("../utils/logger.js");
|
|
36
|
+
const core_namespaceObject = require("@posthog/core");
|
|
36
37
|
const logger = (0, logger_js_namespaceObject.createLogger)('[Surveys]');
|
|
37
38
|
function getRatingBucketForResponseValue(responseValue, scale) {
|
|
38
39
|
if (2 === scale) {
|
|
@@ -77,6 +78,7 @@ function getNextSurveyStep(survey, currentQuestionIndex, response) {
|
|
|
77
78
|
if (nextStep === external_survey_constants_js_namespaceObject.SurveyQuestionBranchingType.End) return external_survey_constants_js_namespaceObject.SurveyQuestionBranchingType.End;
|
|
78
79
|
}
|
|
79
80
|
} else if (question.type === external_survey_constants_js_namespaceObject.SurveyQuestionType.Rating) {
|
|
81
|
+
if (question.optional && (0, core_namespaceObject.isNullish)(response)) return nextQuestionIndex === survey.questions.length ? external_survey_constants_js_namespaceObject.SurveyQuestionBranchingType.End : nextQuestionIndex;
|
|
80
82
|
if ('number' != typeof response || !Number.isInteger(response)) throw new Error('The response type must be an integer');
|
|
81
83
|
const ratingBucket = getRatingBucketForResponseValue(response, question.scale);
|
|
82
84
|
if (question.branching?.responseValues?.hasOwnProperty(ratingBucket)) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SurveyQuestionBranchingType, SurveyQuestionType } from "../survey-constants.mjs";
|
|
2
2
|
import { createLogger } from "../utils/logger.mjs";
|
|
3
|
+
import { isNullish } from "@posthog/core";
|
|
3
4
|
const logger = createLogger('[Surveys]');
|
|
4
5
|
function getRatingBucketForResponseValue(responseValue, scale) {
|
|
5
6
|
if (2 === scale) {
|
|
@@ -44,6 +45,7 @@ function getNextSurveyStep(survey, currentQuestionIndex, response) {
|
|
|
44
45
|
if (nextStep === SurveyQuestionBranchingType.End) return SurveyQuestionBranchingType.End;
|
|
45
46
|
}
|
|
46
47
|
} else if (question.type === SurveyQuestionType.Rating) {
|
|
48
|
+
if (question.optional && isNullish(response)) return nextQuestionIndex === survey.questions.length ? SurveyQuestionBranchingType.End : nextQuestionIndex;
|
|
47
49
|
if ('number' != typeof response || !Number.isInteger(response)) throw new Error('The response type must be an integer');
|
|
48
50
|
const ratingBucket = getRatingBucketForResponseValue(response, question.scale);
|
|
49
51
|
if (question.branching?.responseValues?.hasOwnProperty(ratingBucket)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@posthog/browser-common",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.12",
|
|
4
4
|
"description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -241,7 +241,7 @@
|
|
|
241
241
|
"dependencies": {
|
|
242
242
|
"preact": "^10.29.3",
|
|
243
243
|
"@posthog/core": "^1.60.1",
|
|
244
|
-
"@posthog/types": "^1.416.
|
|
244
|
+
"@posthog/types": "^1.416.1"
|
|
245
245
|
},
|
|
246
246
|
"devDependencies": {
|
|
247
247
|
"@rsbuild/plugin-react": "^2.1.0",
|