@posthog/core 1.50.4 → 1.50.5

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":"base.d.ts","sourceRoot":"","sources":["../../../src/error-tracking/parsers/base.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,eAAO,MAAM,gBAAgB,MAAM,CAAA;AAiBnC,wBAAgB,WAAW,CACzB,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,UAAU,CAmBZ"}
1
+ {"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../../src/error-tracking/parsers/base.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,eAAO,MAAM,gBAAgB,MAAM,CAAA;AAiBnC,wBAAgB,WAAW,CACzB,QAAQ,EAAE,UAAU,CAAC,UAAU,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,MAAM,CAAC,EAAE,MAAM,EACf,KAAK,CAAC,EAAE,MAAM,GACb,UAAU,CAuBZ"}
@@ -40,7 +40,7 @@ function createFrame(platform, filename, func, lineno, colno) {
40
40
  platform,
41
41
  filename,
42
42
  function: '<anonymous>' === func ? UNKNOWN_FUNCTION : func,
43
- in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
43
+ in_app: !!filename && !filename.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
44
44
  };
45
45
  if (!(0, index_js_namespaceObject.isUndefined)(lineno)) frame.lineno = lineno;
46
46
  if (!(0, index_js_namespaceObject.isUndefined)(colno)) frame.colno = colno;
@@ -7,7 +7,7 @@ function createFrame(platform, filename, func, lineno, colno) {
7
7
  platform,
8
8
  filename,
9
9
  function: '<anonymous>' === func ? UNKNOWN_FUNCTION : func,
10
- in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
10
+ in_app: !!filename && !filename.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME
11
11
  };
12
12
  if (!isUndefined(lineno)) frame.lineno = lineno;
13
13
  if (!isUndefined(colno)) frame.colno = colno;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@posthog/core",
3
- "version": "1.50.4",
3
+ "version": "1.50.5",
4
4
  "bugs": {
5
5
  "url": "https://github.com/PostHog/posthog-js/issues"
6
6
  },
@@ -70,7 +70,7 @@
70
70
  }
71
71
  },
72
72
  "dependencies": {
73
- "@posthog/types": "^1.408.1"
73
+ "@posthog/types": "^1.409.0"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@rslib/core": "0.23.2",
@@ -34,10 +34,16 @@ describe('createFrame', () => {
34
34
  expect(frame).toMatchObject({ filename: '<anonymous>', function: '?', lineno: 1, colno: 394 })
35
35
  })
36
36
 
37
- it('falls back to in_app when the parser could not determine a filename', () => {
37
+ it('does not mark frames without a filename as in_app', () => {
38
38
  // Regex capture groups that do not participate arrive here as undefined despite the type
39
39
  const frame = createFrame(platform, undefined as unknown as string, 'doThing')
40
- expect(frame.in_app).toBe(true)
40
+ expect(frame.in_app).toBe(false)
41
+ })
42
+
43
+ it('does not mark frames with an empty filename as in_app', () => {
44
+ const frame = createFrame(platform, '', 'sendDataToNative', 1, 10198)
45
+ expect(frame.in_app).toBe(false)
46
+ expect(frame).toMatchObject({ function: 'sendDataToNative', lineno: 1, colno: 10198 })
41
47
  })
42
48
  })
43
49
 
@@ -51,6 +57,19 @@ describe('createDefaultStackParser in_app classification', () => {
51
57
  ])
52
58
  })
53
59
 
60
+ it('demotes the native bridge frames an Android in-app browser injects', () => {
61
+ // The bridge script has no URL, so every frame arrives as `at <fn> (:1:<col>)`.
62
+ const frames = parse(
63
+ 'Error: Error invoking postMessage: Java object is gone\n' +
64
+ ' at sendDataToNative (:1:10198)\n' +
65
+ ' at sendJsBlockingTimeMessage (:1:14668)'
66
+ )
67
+ expect(frames.map((f) => [f.function, f.in_app])).toEqual([
68
+ ['sendJsBlockingTimeMessage', false],
69
+ ['sendDataToNative', false],
70
+ ])
71
+ })
72
+
54
73
  it("keeps the page's own eval'd code as in_app", () => {
55
74
  // V8 attributes eval'd code to the script that called eval; the chrome parser already
56
75
  // rewrites these frames to that URL, so they must not be caught by the <anonymous> rule.
@@ -34,8 +34,12 @@ export function createFrame(
34
34
  platform,
35
35
  filename,
36
36
  function: func === '<anonymous>' ? UNKNOWN_FUNCTION : func,
37
- // Browser frames are considered in_app unless the runtime has masked or dropped their origin
38
- in_app: !filename?.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME,
37
+ // Browser frames are considered in_app unless the runtime has masked or dropped their origin.
38
+ // A frame with no filename at all is the third case: the runtime reports a function name, a
39
+ // line and a column, but no script URL. Android in-app browsers report their injected native
40
+ // bridge scripts this way. Such a frame can never be symbolicated either, so it must not
41
+ // count as the page's own code.
42
+ in_app: !!filename && !filename.startsWith(MASKED_URL_PREFIX) && filename !== ANONYMOUS_FILENAME,
39
43
  }
40
44
 
41
45
  if (!isUndefined(lineno)) {