@posthog/core 1.45.0 → 1.45.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.
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/error-tracking/parsers/node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAY,eAAe,EAAE,MAAM,UAAU,CAAA;AAOpD,eAAO,MAAM,mBAAmB,EAAE,eA4EjC,CAAA"}
1
+ {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../../src/error-tracking/parsers/node.ts"],"names":[],"mappings":"AAIA,OAAO,EAAY,eAAe,EAAE,MAAM,UAAU,CAAA;AAUpD,eAAO,MAAM,mBAAmB,EAAE,eAiFjC,CAAA"}
@@ -29,6 +29,9 @@ __webpack_require__.d(__webpack_exports__, {
29
29
  const external_base_js_namespaceObject = require("./base.js");
30
30
  const FILENAME_MATCH = /^\s*[-]{4,}$/;
31
31
  const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
32
+ const PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
33
+ const PROMISE_INDEX = /^index \d+$/;
34
+ const PROMISE_FRAME_FILENAME = 'node:internal/promise';
32
35
  const nodeStackLineParser = (line, platform)=>{
33
36
  const lineMatch = line.match(FULL_MATCH);
34
37
  if (lineMatch) {
@@ -68,6 +71,7 @@ const nodeStackLineParser = (line, platform)=>{
68
71
  const isNative = 'native' === lineMatch[5];
69
72
  if (filename?.match(/\/[A-Z]:/)) filename = filename.slice(1);
70
73
  if (!filename && lineMatch[5] && !isNative) filename = lineMatch[5];
74
+ if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || '')) filename = PROMISE_FRAME_FILENAME;
71
75
  return {
72
76
  filename: filename ? decodeURI(filename) : void 0,
73
77
  module: void 0,
@@ -1,6 +1,9 @@
1
1
  import { UNKNOWN_FUNCTION } from "./base.mjs";
2
2
  const FILENAME_MATCH = /^\s*[-]{4,}$/;
3
3
  const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/;
4
+ const PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/;
5
+ const PROMISE_INDEX = /^index \d+$/;
6
+ const PROMISE_FRAME_FILENAME = 'node:internal/promise';
4
7
  const nodeStackLineParser = (line, platform)=>{
5
8
  const lineMatch = line.match(FULL_MATCH);
6
9
  if (lineMatch) {
@@ -40,6 +43,7 @@ const nodeStackLineParser = (line, platform)=>{
40
43
  const isNative = 'native' === lineMatch[5];
41
44
  if (filename?.match(/\/[A-Z]:/)) filename = filename.slice(1);
42
45
  if (!filename && lineMatch[5] && !isNative) filename = lineMatch[5];
46
+ if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || '')) filename = PROMISE_FRAME_FILENAME;
43
47
  return {
44
48
  filename: filename ? decodeURI(filename) : void 0,
45
49
  module: void 0,
@@ -16,5 +16,13 @@ export declare function doesSurveyActivateByEvent(survey: SurveyForRepeatActivat
16
16
  * platform-specific state (e.g. the web SDK's in-progress partial responses).
17
17
  */
18
18
  export declare function canSurveyActivateRepeatedly(survey: SurveyForRepeatActivation): boolean;
19
+ type SurveyForIterationCheck = Pick<Survey, 'schedule' | 'current_iteration'>;
20
+ /**
21
+ * True when a survey is meant to come back around on its own: a recurring schedule, or an
22
+ * iteration already under way. Stored display state is keyed by iteration
23
+ * (see `getSurveyIterationKey`), so for these surveys it rolls over and stops being a
24
+ * dependable "already answered" record; other surveys keep one stable key for good.
25
+ */
26
+ export declare function isSurveyIterationBased(survey: SurveyForIterationCheck): boolean;
19
27
  export {};
20
28
  //# sourceMappingURL=activation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../src/surveys/activation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAA;AAIjD,KAAK,yBAAyB,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG;IAC1D,UAAU,CAAC,EAAE;QACX,MAAM,CAAC,EAAE;YACP,kBAAkB,CAAC,EAAE,OAAO,CAAA;YAC5B,MAAM,CAAC,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAC5B,GAAG,IAAI,CAAA;KACT,GAAG,IAAI,CAAA;CACT,CAAA;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAKtF"}
1
+ {"version":3,"file":"activation.d.ts","sourceRoot":"","sources":["../../src/surveys/activation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAkB,MAAM,UAAU,CAAA;AAIjD,KAAK,yBAAyB,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG;IAC1D,UAAU,CAAC,EAAE;QACX,MAAM,CAAC,EAAE;YACP,kBAAkB,CAAC,EAAE,OAAO,CAAA;YAC5B,MAAM,CAAC,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAA;aAAE,EAAE,CAAA;SAC5B,GAAG,IAAI,CAAA;KACT,GAAG,IAAI,CAAA;CACT,CAAA;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAEpF;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,yBAAyB,GAAG,OAAO,CAKtF;AAED,KAAK,uBAAuB,GAAG,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,mBAAmB,CAAC,CAAA;AAE7E;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,uBAAuB,GAAG,OAAO,CAE/E"}
@@ -25,6 +25,7 @@ var __webpack_exports__ = {};
25
25
  __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  doesSurveyActivateByEvent: ()=>doesSurveyActivateByEvent,
28
+ isSurveyIterationBased: ()=>isSurveyIterationBased,
28
29
  canSurveyActivateRepeatedly: ()=>canSurveyActivateRepeatedly
29
30
  });
30
31
  const external_types_js_namespaceObject = require("../types.js");
@@ -34,11 +35,16 @@ function doesSurveyActivateByEvent(survey) {
34
35
  function canSurveyActivateRepeatedly(survey) {
35
36
  return doesSurveyActivateByEvent(survey) && !!survey.conditions?.events?.repeatedActivation || survey.schedule === external_types_js_namespaceObject.SurveySchedule.Always;
36
37
  }
38
+ function isSurveyIterationBased(survey) {
39
+ return survey.schedule === external_types_js_namespaceObject.SurveySchedule.Recurring || (survey.current_iteration ?? 0) > 0;
40
+ }
37
41
  exports.canSurveyActivateRepeatedly = __webpack_exports__.canSurveyActivateRepeatedly;
38
42
  exports.doesSurveyActivateByEvent = __webpack_exports__.doesSurveyActivateByEvent;
43
+ exports.isSurveyIterationBased = __webpack_exports__.isSurveyIterationBased;
39
44
  for(var __webpack_i__ in __webpack_exports__)if (-1 === [
40
45
  "canSurveyActivateRepeatedly",
41
- "doesSurveyActivateByEvent"
46
+ "doesSurveyActivateByEvent",
47
+ "isSurveyIterationBased"
42
48
  ].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
43
49
  Object.defineProperty(exports, '__esModule', {
44
50
  value: true
@@ -5,4 +5,7 @@ function doesSurveyActivateByEvent(survey) {
5
5
  function canSurveyActivateRepeatedly(survey) {
6
6
  return doesSurveyActivateByEvent(survey) && !!survey.conditions?.events?.repeatedActivation || survey.schedule === SurveySchedule.Always;
7
7
  }
8
- export { canSurveyActivateRepeatedly, doesSurveyActivateByEvent };
8
+ function isSurveyIterationBased(survey) {
9
+ return survey.schedule === SurveySchedule.Recurring || (survey.current_iteration ?? 0) > 0;
10
+ }
11
+ export { canSurveyActivateRepeatedly, doesSurveyActivateByEvent, isSurveyIterationBased };
@@ -1,6 +1,6 @@
1
1
  export { getValidationError, getLengthFromRules, getRequirementsHint } from './validation';
2
2
  export { buildSurveyResponseProperties, getSurveyInteractionProperty, getSurveyOldResponseKey, getSurveyResponseKey, getSurveyResponseValue, SURVEY_LANGUAGE_PROPERTY, surveyHasResponses, } from './events';
3
3
  export { applySurveyTranslation, detectSurveyLanguage, findBestTranslationMatch, getBaseLanguage, getLanguageFromStoredPersonProperties, normalizeLanguageCode, } from './translations';
4
- export { canSurveyActivateRepeatedly, doesSurveyActivateByEvent } from './activation';
4
+ export { canSurveyActivateRepeatedly, doesSurveyActivateByEvent, isSurveyIterationBased } from './activation';
5
5
  export { getSurveyIterationKey, isSurveyKeyForSurvey, type SurveyWithIteration } from './keys';
6
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/surveys/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAC1F,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,qCAAqC,EACrC,qBAAqB,GACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACrF,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,QAAQ,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/surveys/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAC1F,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,EACxB,kBAAkB,GACnB,MAAM,UAAU,CAAA;AACjB,OAAO,EACL,sBAAsB,EACtB,oBAAoB,EACpB,wBAAwB,EACxB,eAAe,EACf,qCAAqC,EACrC,qBAAqB,GACtB,MAAM,gBAAgB,CAAA;AACvB,OAAO,EAAE,2BAA2B,EAAE,yBAAyB,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAA;AAC7G,OAAO,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,KAAK,mBAAmB,EAAE,MAAM,QAAQ,CAAA"}
@@ -28,6 +28,7 @@ __webpack_require__.d(__webpack_exports__, {
28
28
  getSurveyOldResponseKey: ()=>external_events_js_namespaceObject.getSurveyOldResponseKey,
29
29
  getBaseLanguage: ()=>external_translations_js_namespaceObject.getBaseLanguage,
30
30
  getSurveyResponseValue: ()=>external_events_js_namespaceObject.getSurveyResponseValue,
31
+ isSurveyIterationBased: ()=>external_activation_js_namespaceObject.isSurveyIterationBased,
31
32
  SURVEY_LANGUAGE_PROPERTY: ()=>external_events_js_namespaceObject.SURVEY_LANGUAGE_PROPERTY,
32
33
  detectSurveyLanguage: ()=>external_translations_js_namespaceObject.detectSurveyLanguage,
33
34
  applySurveyTranslation: ()=>external_translations_js_namespaceObject.applySurveyTranslation,
@@ -67,6 +68,7 @@ exports.getSurveyOldResponseKey = __webpack_exports__.getSurveyOldResponseKey;
67
68
  exports.getSurveyResponseKey = __webpack_exports__.getSurveyResponseKey;
68
69
  exports.getSurveyResponseValue = __webpack_exports__.getSurveyResponseValue;
69
70
  exports.getValidationError = __webpack_exports__.getValidationError;
71
+ exports.isSurveyIterationBased = __webpack_exports__.isSurveyIterationBased;
70
72
  exports.isSurveyKeyForSurvey = __webpack_exports__.isSurveyKeyForSurvey;
71
73
  exports.normalizeLanguageCode = __webpack_exports__.normalizeLanguageCode;
72
74
  exports.surveyHasResponses = __webpack_exports__.surveyHasResponses;
@@ -88,6 +90,7 @@ for(var __webpack_i__ in __webpack_exports__)if (-1 === [
88
90
  "getSurveyResponseKey",
89
91
  "getSurveyResponseValue",
90
92
  "getValidationError",
93
+ "isSurveyIterationBased",
91
94
  "isSurveyKeyForSurvey",
92
95
  "normalizeLanguageCode",
93
96
  "surveyHasResponses"
@@ -1,6 +1,6 @@
1
1
  import { getLengthFromRules, getRequirementsHint, getValidationError } from "./validation.mjs";
2
2
  import { SURVEY_LANGUAGE_PROPERTY, buildSurveyResponseProperties, getSurveyInteractionProperty, getSurveyOldResponseKey, getSurveyResponseKey, getSurveyResponseValue, surveyHasResponses } from "./events.mjs";
3
3
  import { applySurveyTranslation, detectSurveyLanguage, findBestTranslationMatch, getBaseLanguage, getLanguageFromStoredPersonProperties, normalizeLanguageCode } from "./translations.mjs";
4
- import { canSurveyActivateRepeatedly, doesSurveyActivateByEvent } from "./activation.mjs";
4
+ import { canSurveyActivateRepeatedly, doesSurveyActivateByEvent, isSurveyIterationBased } from "./activation.mjs";
5
5
  import { getSurveyIterationKey, isSurveyKeyForSurvey } from "./keys.mjs";
6
- export { SURVEY_LANGUAGE_PROPERTY, applySurveyTranslation, buildSurveyResponseProperties, canSurveyActivateRepeatedly, detectSurveyLanguage, doesSurveyActivateByEvent, findBestTranslationMatch, getBaseLanguage, getLanguageFromStoredPersonProperties, getLengthFromRules, getRequirementsHint, getSurveyInteractionProperty, getSurveyIterationKey, getSurveyOldResponseKey, getSurveyResponseKey, getSurveyResponseValue, getValidationError, isSurveyKeyForSurvey, normalizeLanguageCode, surveyHasResponses };
6
+ export { SURVEY_LANGUAGE_PROPERTY, applySurveyTranslation, buildSurveyResponseProperties, canSurveyActivateRepeatedly, detectSurveyLanguage, doesSurveyActivateByEvent, findBestTranslationMatch, getBaseLanguage, getLanguageFromStoredPersonProperties, getLengthFromRules, getRequirementsHint, getSurveyInteractionProperty, getSurveyIterationKey, getSurveyOldResponseKey, getSurveyResponseKey, getSurveyResponseValue, getValidationError, isSurveyIterationBased, isSurveyKeyForSurvey, normalizeLanguageCode, surveyHasResponses };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/core",
3
- "version": "1.45.0",
3
+ "version": "1.45.2",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -0,0 +1,19 @@
1
+ import { nodeStackLineParser } from './node'
2
+
3
+ describe('nodeStackLineParser', () => {
4
+ it.each([
5
+ ['at async Promise.all (index 3)', 'Promise.all'],
6
+ ['at async Promise.all (index 472)', 'Promise.all'],
7
+ ['at async Promise.any (index 11)', 'Promise.any'],
8
+ ])('canonicalizes the V8 Promise index in %s', (line, functionName) => {
9
+ expect(nodeStackLineParser(line, 'node:javascript')).toEqual({
10
+ filename: 'node:internal/promise',
11
+ module: undefined,
12
+ function: functionName,
13
+ lineno: undefined,
14
+ colno: undefined,
15
+ in_app: false,
16
+ platform: 'node:javascript',
17
+ })
18
+ })
19
+ })
@@ -8,6 +8,9 @@ import { UNKNOWN_FUNCTION } from './base'
8
8
  /** Node Stack line parser */
9
9
  const FILENAME_MATCH = /^\s*[-]{4,}$/
10
10
  const FULL_MATCH = /at (?:async )?(?:(.+?)\s+\()?(?:(.+):(\d+):(\d+)?|([^)]+))\)?/
11
+ const PROMISE_COMBINATOR = /^Promise\.(?:all|any)$/
12
+ const PROMISE_INDEX = /^index \d+$/
13
+ const PROMISE_FRAME_FILENAME = 'node:internal/promise'
11
14
 
12
15
  export const nodeStackLineParser: StackLineParser = (line: string, platform: Platform) => {
13
16
  const lineMatch = line.match(FULL_MATCH)
@@ -66,6 +69,11 @@ export const nodeStackLineParser: StackLineParser = (line: string, platform: Pla
66
69
  filename = lineMatch[5]
67
70
  }
68
71
 
72
+ // V8's Promise index identifies the input promise rather than a source file.
73
+ if (PROMISE_COMBINATOR.test(functionName) && PROMISE_INDEX.test(filename || '')) {
74
+ filename = PROMISE_FRAME_FILENAME
75
+ }
76
+
69
77
  return {
70
78
  filename: filename ? decodeURI(filename) : undefined,
71
79
  module: undefined,
@@ -26,3 +26,15 @@ export function canSurveyActivateRepeatedly(survey: SurveyForRepeatActivation):
26
26
  survey.schedule === SurveySchedule.Always
27
27
  )
28
28
  }
29
+
30
+ type SurveyForIterationCheck = Pick<Survey, 'schedule' | 'current_iteration'>
31
+
32
+ /**
33
+ * True when a survey is meant to come back around on its own: a recurring schedule, or an
34
+ * iteration already under way. Stored display state is keyed by iteration
35
+ * (see `getSurveyIterationKey`), so for these surveys it rolls over and stops being a
36
+ * dependable "already answered" record; other surveys keep one stable key for good.
37
+ */
38
+ export function isSurveyIterationBased(survey: SurveyForIterationCheck): boolean {
39
+ return survey.schedule === SurveySchedule.Recurring || (survey.current_iteration ?? 0) > 0
40
+ }
@@ -16,5 +16,5 @@ export {
16
16
  getLanguageFromStoredPersonProperties,
17
17
  normalizeLanguageCode,
18
18
  } from './translations'
19
- export { canSurveyActivateRepeatedly, doesSurveyActivateByEvent } from './activation'
19
+ export { canSurveyActivateRepeatedly, doesSurveyActivateByEvent, isSurveyIterationBased } from './activation'
20
20
  export { getSurveyIterationKey, isSurveyKeyForSurvey, type SurveyWithIteration } from './keys'