Skip to content

Fix sessionRecording bug - #234

Merged
neilkakkar merged 2 commits into
masterfrom
sessionrecording-bug
May 25, 2021
Merged

neilkakkar merged 2 commits into
masterfrom
sessionrecording-bug

Conversation

@neilkakkar

@neilkakkar neilkakkar commented May 24, 2021 •

Copy link
Copy Markdown
Contributor

Changes

Fixes #183

What a rollercoaster! The url is just one of many possible values for the key in the request object, the other possible options being: batchKey, which, ofcourse, we set to sessionRecording for session recording! ( https://github.com/PostHog/posthog-js/blob/master/src/extensions/sessionrecording.js#L122 )

The annoying bit was figuring out that it was this specific part of the request queue that was mangling things up.

...

Checklist

  • Tests for new code (if applicable)
  • TypeScript definitions (module.d.ts) updated and in sync with library exports (if applicable)

Comment thread src/request-queue.js
for (let url in requests) {
const { data, options } = requests[url]
for (let key in requests) {
const { url, data, options } = requests[key]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. There are tests under src/tests/request-queue.js - mind adding one or editing existing ones in a way which demonstrates the problem? E.g. how was enqueue called in this case?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, that was the first item for today!

It's kinda unfortunate: we had a similar test for poll that works, but didn't have one for unload.

[{ event: '$identify', timestamp: 1_620_000_000 }],
{ transport: 'sendbeacon' }
)
expect(given.handlePollRequest).toHaveBeenCalledWith('/e', [{ event: 'zeta', timestamp: 1_640_000_000 }], {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with the old code, this would be called with ('sessionRecording', data, options)

@macobo

macobo commented May 25, 2021

Copy link
Copy Markdown
Contributor

Great detective work! Reminder: don't forget to set bump X label before merging

@neilkakkar
neilkakkar merged commit 6dc7620 into master May 25, 2021
@neilkakkar
neilkakkar deleted the sessionrecording-bug branch May 25, 2021 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Posthog-js sending requests to /sessionRecording on user's own servers

3 participants