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

refactor(session replay) use custom IDB store for event management #732

Merged
merged 8 commits into from
May 16, 2024

Conversation

kwalker3690
Copy link
Collaborator

@kwalker3690 kwalker3690 commented Apr 26, 2024

Summary

This PR migrates the SR SDK off of idb-keyval to a more robust IDB schema that will allow us more flexibility in the implementation of Targeted Replay Capture.

export interface SessionReplayDB extends DBSchema {
  sessionCurrentSequence: {
    key: number;
    value: {
      sessionId: number;
      events: Events;
    };
  };
  sequencesToSend: {
    key: number;
    value: SendingSequencesIDBInput;
    indexes: { sessionId: number };
  };
}

The current replay being captured will add events to sessionCurrentSequence. Once that list is large enough, as well as on blur, we will move that list to sequencesToSend, which will automatically provide it a sequence id. Then the list will be sent to the backend, upon a successful API response we will delete the list from sequencesToSend. In this model, IDB will be the source of truth for events (previously, they were also stored in memory).

https://www.loom.com/share/d3a5b4bc26b84f2d92d49458e9f7794f

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: no

@kwalker3690 kwalker3690 force-pushed the kwallach/revise-store branch 4 times, most recently from 35fe789 to 9241f52 Compare May 13, 2024 15:25
@kwalker3690 kwalker3690 changed the base branch from v1.x to kwallach/generic-remote-config May 13, 2024 15:27
@kwalker3690 kwalker3690 changed the base branch from kwallach/generic-remote-config to v1.x May 14, 2024 19:40
@kwalker3690 kwalker3690 changed the base branch from v1.x to kwallach/generic-remote-config May 14, 2024 19:45
@kwalker3690 kwalker3690 changed the title Kwallach/revise store refactor(session replay) use custom IDB store for event management May 14, 2024
@kwalker3690 kwalker3690 marked this pull request as ready for review May 14, 2024 19:59
Copy link

@lewgordon-amplitude lewgordon-amplitude left a comment

Choose a reason for hiding this comment

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

Looks good overall. Nothing hard blocking, but I think some suggestions might make the code trimmer.

Base automatically changed from kwallach/generic-remote-config to v1.x May 15, 2024 18:21
@kwalker3690 kwalker3690 merged commit a408875 into v1.x May 16, 2024
3 checks passed
@kwalker3690 kwalker3690 deleted the kwallach/revise-store branch May 16, 2024 00:11
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.

None yet

2 participants