Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix sessionRecording bug #234

Merged
merged 2 commits into from
May 25, 2021
Merged

Fix sessionRecording bug #234

merged 2 commits into from
May 25, 2021

Conversation

neilkakkar
Copy link
Collaborator

@neilkakkar neilkakkar commented May 24, 2021

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)

for (let url in requests) {
const { data, options } = requests[url]
for (let key in requests) {
const { url, data, options } = requests[key]
Copy link
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
Collaborator 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
Collaborator 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
Copy link
Contributor

macobo commented May 25, 2021

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

@neilkakkar neilkakkar added the bump patch Bump patch version when this PR gets merged label May 25, 2021
@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
bump patch Bump patch version when this PR gets merged
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