@posthog/browser-common 0.9.10 → 0.9.11

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
@@ -27,7 +27,7 @@ var __webpack_require__ = {};
27
27
  })();
28
28
  var __webpack_exports__ = {};
29
29
  __webpack_require__.r(__webpack_exports__);
30
- const packageVersion = "0.9.10";
30
+ const packageVersion = "0.9.11";
31
31
  const Config = {
32
32
  DEBUG: false,
33
33
  LIB_VERSION: packageVersion,
package/dist/config.mjs CHANGED
@@ -1,4 +1,4 @@
1
- const packageVersion = "0.9.10";
1
+ const packageVersion = "0.9.11";
2
2
  const Config = {
3
3
  DEBUG: false,
4
4
  LIB_VERSION: packageVersion,
@@ -105,7 +105,8 @@ function convertPrefillToResponses(survey, prefillParams) {
105
105
  {
106
106
  const rating = parseInt(values[0], 10);
107
107
  const scale = question.scale || 10;
108
- if (isNaN(rating) || rating < 0 || rating > scale) return void logger_js_namespaceObject.logger.warn(`[Survey Prefill] Invalid rating for q${index}: ${values[0]} (scale: 0-${scale})`);
108
+ const min = 10 === scale ? 0 : 1;
109
+ if (isNaN(rating) || rating < min || rating > scale) return void logger_js_namespaceObject.logger.warn(`[Survey Prefill] Invalid rating for q${index}: ${values[0]} (scale: ${min}-${scale})`);
109
110
  responses[responseKey] = rating;
110
111
  break;
111
112
  }
@@ -71,7 +71,8 @@ function convertPrefillToResponses(survey, prefillParams) {
71
71
  {
72
72
  const rating = parseInt(values[0], 10);
73
73
  const scale = question.scale || 10;
74
- if (isNaN(rating) || rating < 0 || rating > scale) return void logger.warn(`[Survey Prefill] Invalid rating for q${index}: ${values[0]} (scale: 0-${scale})`);
74
+ const min = 10 === scale ? 0 : 1;
75
+ if (isNaN(rating) || rating < min || rating > scale) return void logger.warn(`[Survey Prefill] Invalid rating for q${index}: ${values[0]} (scale: ${min}-${scale})`);
75
76
  responses[responseKey] = rating;
76
77
  break;
77
78
  }
@@ -498,7 +498,10 @@ class SurveyManager {
498
498
  return null;
499
499
  }
500
500
  const submissionId = (0, uuidv7_js_namespaceObject.uuidv7)();
501
- const prefilledIndices = Object.keys(prefillParams).map((k)=>parseInt(k, 10));
501
+ const prefilledIndices = Object.keys(prefillParams).map((k)=>parseInt(k, 10)).filter((index)=>{
502
+ const question = survey.questions[index];
503
+ return question?.id && !(0, core_namespaceObject.isUndefined)(responses[(0, surveys_extension_utils_js_namespaceObject.getSurveyResponseKey)(question.id)]);
504
+ });
502
505
  const { startQuestionIndex, skippedResponses, skippedIndices } = (0, survey_url_prefill_js_namespaceObject.calculatePrefillStartIndex)(survey, prefilledIndices, responses);
503
506
  const isSurveyCompleted = startQuestionIndex >= survey.questions.length;
504
507
  (0, surveys_extension_utils_js_namespaceObject.setInProgressSurveyState)(survey, {
@@ -456,7 +456,10 @@ class SurveyManager {
456
456
  return null;
457
457
  }
458
458
  const submissionId = uuidv7();
459
- const prefilledIndices = Object.keys(prefillParams).map((k)=>parseInt(k, 10));
459
+ const prefilledIndices = Object.keys(prefillParams).map((k)=>parseInt(k, 10)).filter((index)=>{
460
+ const question = survey.questions[index];
461
+ return question?.id && !isUndefined(responses[getSurveyResponseKey(question.id)]);
462
+ });
460
463
  const { startQuestionIndex, skippedResponses, skippedIndices } = calculatePrefillStartIndex(survey, prefilledIndices, responses);
461
464
  const isSurveyCompleted = startQuestionIndex >= survey.questions.length;
462
465
  setInProgressSurveyState(survey, {
@@ -42,13 +42,7 @@ const core_namespaceObject = require("@posthog/core");
42
42
  * @packageDocumentation
43
43
  *
44
44
  * from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts
45
- */ if (!Math.trunc) Math.trunc = function(v) {
46
- return v < 0 ? Math.ceil(v) : Math.floor(v);
47
- };
48
- if (!Number.isInteger) Number.isInteger = function(value) {
49
- return (0, core_namespaceObject.isNumber)(value) && isFinite(value) && Math.floor(value) === value;
50
- };
51
- class UUID {
45
+ */ class UUID {
52
46
  constructor(bytes){
53
47
  this.bytes = bytes;
54
48
  if (16 !== bytes.length) throw new TypeError('not 128-bit length');
@@ -8,13 +8,7 @@ import { isNumber, isUndefined } from "@posthog/core";
8
8
  * @packageDocumentation
9
9
  *
10
10
  * from https://github.com/LiosK/uuidv7/blob/e501462ea3d23241de13192ceae726956f9b3b7d/src/index.ts
11
- */ if (!Math.trunc) Math.trunc = function(v) {
12
- return v < 0 ? Math.ceil(v) : Math.floor(v);
13
- };
14
- if (!Number.isInteger) Number.isInteger = function(value) {
15
- return isNumber(value) && isFinite(value) && Math.floor(value) === value;
16
- };
17
- class UUID {
11
+ */ class UUID {
18
12
  constructor(bytes){
19
13
  this.bytes = bytes;
20
14
  if (16 !== bytes.length) throw new TypeError('not 128-bit length');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/browser-common",
3
- "version": "0.9.10",
3
+ "version": "0.9.11",
4
4
  "description": "Internal shared browser utilities and extension primitives for PostHog Browser SDKs",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -10,9 +10,7 @@
10
10
  },
11
11
  "sideEffects": [
12
12
  "./dist/utils/*-polyfill.js",
13
- "./dist/utils/*-polyfill.mjs",
14
- "./dist/utils/uuidv7.js",
15
- "./dist/utils/uuidv7.mjs"
13
+ "./dist/utils/*-polyfill.mjs"
16
14
  ],
17
15
  "files": [
18
16
  "dist",
@@ -242,7 +240,7 @@
242
240
  },
243
241
  "dependencies": {
244
242
  "preact": "^10.29.3",
245
- "@posthog/core": "^1.60.0",
243
+ "@posthog/core": "^1.60.1",
246
244
  "@posthog/types": "^1.416.0"
247
245
  },
248
246
  "devDependencies": {