rrwebIntegration.tsx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import styled from '@emotion/styled';
  2. import AsyncComponent from 'app/components/asyncComponent';
  3. import EventDataSection from 'app/components/events/eventDataSection';
  4. import LazyLoad from 'app/components/lazyLoad';
  5. import {t} from 'app/locale';
  6. import space from 'app/styles/space';
  7. import {EventAttachment, Organization, Project} from 'app/types';
  8. import {Event} from 'app/types/event';
  9. type Props = {
  10. event: Event;
  11. orgId: Organization['id'];
  12. projectId: Project['id'];
  13. } & AsyncComponent['props'];
  14. type State = {
  15. attachmentList: Array<EventAttachment> | null;
  16. } & AsyncComponent['state'];
  17. class RRWebIntegration extends AsyncComponent<Props, State> {
  18. getEndpoints(): ReturnType<AsyncComponent['getEndpoints']> {
  19. const {orgId, projectId, event} = this.props;
  20. return [
  21. [
  22. 'attachmentList',
  23. `/projects/${orgId}/${projectId}/events/${event.id}/attachments/`,
  24. {query: {query: 'rrweb.json'}},
  25. ],
  26. ];
  27. }
  28. renderLoading() {
  29. // hide loading indicator
  30. return null;
  31. }
  32. renderBody() {
  33. const {attachmentList} = this.state;
  34. if (!attachmentList?.length) {
  35. return null;
  36. }
  37. const attachment = attachmentList[0];
  38. const {orgId, projectId, event} = this.props;
  39. return (
  40. <StyledEventDataSection type="context-replay" title={t('Replay')}>
  41. <LazyLoad
  42. component={() => import('./rrwebReplayer')}
  43. url={`/api/0/projects/${orgId}/${projectId}/events/${event.id}/attachments/${attachment.id}/?download`}
  44. />
  45. </StyledEventDataSection>
  46. );
  47. }
  48. }
  49. const StyledEventDataSection = styled(EventDataSection)`
  50. overflow: hidden;
  51. margin-bottom: ${space(3)};
  52. `;
  53. export default RRWebIntegration;