Skip to content

Commit

Permalink
Merge pull request #26 from campfire-previews/session-replay-route
Browse files Browse the repository at this point in the history
Added 'Session Replay' React Route
  • Loading branch information
6207ALS authored Mar 28, 2024
2 parents 16d939f + 8ee8dc5 commit 832f840
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from "react";
import "./App.css";
import Dashboard from "./components/Dashboard.jsx";
import PreviewEnvironment from "./components/PreviewEnvironment.jsx";
import SessionReplay from "./components/SessionReplay.jsx";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";

function App() {
Expand All @@ -11,6 +12,7 @@ function App() {
<Routes>
<Route path="/" element={<Dashboard />} />
<Route path="/:repo/:issue_number" element={<PreviewEnvironment />} />
<Route path="/:repo/:issue_number/session-replay/:id" element={<SessionReplay />} />
</Routes>
</Router>
</div>
Expand Down
36 changes: 36 additions & 0 deletions src/components/SessionReplay.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useState, useEffect, useRef } from "react";

import { useParams } from "react-router";

import * as rrweb from "rrweb";
import rrwebPlayer from 'rrweb-player';
import 'rrweb-player/dist/style.css';


// 8bfd3309-4af1-4abf-8067-8468394a2d42
function SessionReplay({ }) {
const { repo, issue_number, id } = useParams();
const playerRef = useRef(null);

useEffect(() => {
(async () => {
const response = await fetch(`https://r5mggbu5q0.execute-api.us-east-2.amazonaws.com/demo/repos/${repo}/issue_number/${issue_number}/session-replay/${id}`)
const { data: events } = await response.json();
const replayer = new rrwebPlayer({
target: playerRef.current,
props: { events }
});
replayer.play();
})()
}, []);


return (
<>
<main ref={playerRef}>
</main>
</>
)
}

export default SessionReplay;

0 comments on commit 832f840

Please sign in to comment.