Skip to content

Commit

Permalink
Merge branch 'main' into fix/chekc-url-for-delayed-surveys
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasheriques committed Feb 13, 2025
2 parents e54ea44 + bb36201 commit 0fdbf74
Show file tree
Hide file tree
Showing 11 changed files with 155 additions and 113 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## 1.217.3 - 2025-02-13

- Revert "fix: check url match twice because of potential race condition (#1722)" (#1733)

## 1.217.2 - 2025-02-12

- fix(no-code experiments): refactor (6) (#1728)

## 1.217.1 - 2025-02-11

- fix: canvas quality value (#1727)

## 1.217.0 - 2025-02-11

- feat: override exception capture clientside (#1726)

## 1.216.1 - 2025-02-10

- fix: capture when argument is not a string (#1724)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "posthog-js",
"version": "1.216.1",
"version": "1.217.3",
"description": "Posthog-js allows you to automatically capture usage and send events to PostHog.",
"repository": "https://github.com/PostHog/posthog-js",
"author": "hey@posthog.com",
Expand Down
5 changes: 5 additions & 0 deletions src/__tests__/__snapshots__/config-snapshot.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,11 @@ exports[`config snapshot for PostHogConfig 1`] = `
\\"Pick<AutocaptureConfig, \\\\\\"element_attribute_ignorelist\\\\\\">\\"
]
],
\\"capture_exceptions\\": [
\\"undefined\\",
\\"false\\",
\\"true\\"
],
\\"disable_scroll_properties\\": [
\\"undefined\\",
\\"false\\",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ describe('Exception Observer', () => {
})

it('should instrument handlers when started', () => {
expect(exceptionObserver.isCapturing).toBe(true)
expect(exceptionObserver.hasHandlers).toBe(true)
expect(exceptionObserver.isEnabled).toBe(true)

expect((window?.onerror as any).__POSTHOG_INSTRUMENTED__).toBe(true)
Expand All @@ -84,7 +84,7 @@ describe('Exception Observer', () => {
expect((window?.onerror as any)?.__POSTHOG_INSTRUMENTED__).not.toBeDefined()
expect((window?.onunhandledrejection as any)?.__POSTHOG_INSTRUMENTED__).not.toBeDefined()

expect(exceptionObserver.isCapturing).toBe(false)
expect(exceptionObserver.hasHandlers).toBe(false)
})

it('captures an event when an error is thrown', () => {
Expand Down Expand Up @@ -162,9 +162,17 @@ describe('Exception Observer', () => {
})
expect(request.batchKey).toBe('exceptionEvent')
})

it('should instrument handlers when started', () => {
posthog.config.capture_exceptions = false
exceptionObserver = new ExceptionObserver(posthog)

expect(exceptionObserver.hasHandlers).toBe(false)
expect(exceptionObserver.isEnabled).toBe(false)
})
})

describe('when there are handlers already', () => {
describe('when there are handlers already present', () => {
const originalOnError = jest.fn()
const originalOnUnhandledRejection = jest.fn()

Expand Down Expand Up @@ -224,9 +232,9 @@ describe('Exception Observer', () => {
describe('when no decide response', () => {
it('cannot be started', () => {
expect(exceptionObserver.isEnabled).toBe(false)
expect(exceptionObserver.isCapturing).toBe(false)
expect(exceptionObserver.hasHandlers).toBe(false)
exceptionObserver['startCapturing']()
expect(exceptionObserver.isCapturing).toBe(false)
expect(exceptionObserver.hasHandlers).toBe(false)
})
})

Expand All @@ -237,9 +245,9 @@ describe('Exception Observer', () => {

it('cannot be started', () => {
expect(exceptionObserver.isEnabled).toBe(false)
expect(exceptionObserver.isCapturing).toBe(false)
expect(exceptionObserver.hasHandlers).toBe(false)
exceptionObserver['startCapturing']()
expect(exceptionObserver.isCapturing).toBe(false)
expect(exceptionObserver.hasHandlers).toBe(false)
})
})
})
33 changes: 31 additions & 2 deletions src/__tests__/extensions/replay/sessionrecording.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,10 +344,39 @@ describe('SessionRecording', () => {
'%s',
(_name: string, serverSide: boolean | undefined, clientSide: boolean | undefined, expected: boolean) => {
posthog.persistence?.register({
[SESSION_RECORDING_CANVAS_RECORDING]: { enabled: serverSide, fps: 4, quality: 0.1 },
[SESSION_RECORDING_CANVAS_RECORDING]: { enabled: serverSide, fps: 4, quality: '0.1' },
})
posthog.config.session_recording.captureCanvas = { recordCanvas: clientSide }
expect(sessionRecording['canvasRecording']).toMatchObject({ enabled: expected })
expect(sessionRecording['canvasRecording']).toMatchObject({ enabled: expected, fps: 4, quality: 0.1 })
}
)

it.each([
['max fps and quality', 12, '1.0', 12, 1],
['min fps and quality', 0, '0.0', 0, 0],
['mid fps and quality', 6, '0.5', 6, 0.5],
['null fps and quality', null, null, 4, 0.4],
['undefined fps and quality', undefined, undefined, 4, 0.4],
['string fps and quality', '12', '1.0', 4, 1],
['over max fps and quality', 15, '1.5', 12, 1],
])(
'%s',
(
_name: string,
fps: number | string | null | undefined,
quality: string | null | undefined,
expectedFps: number,
expectedQuality: number
) => {
posthog.persistence?.register({
[SESSION_RECORDING_CANVAS_RECORDING]: { enabled: true, fps, quality },
})

expect(sessionRecording['canvasRecording']).toMatchObject({
enabled: true,
fps: expectedFps,
quality: expectedQuality,
})
}
)
})
Expand Down
Loading

0 comments on commit 0fdbf74

Please sign in to comment.