rrwebIntegration.tsx 1.8 KB

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