Skip to content

πŸ“ˆ Open source, privacy-first web analytics β€” a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

rrweb fixes & improvements

Blue Mousee57194be3d7b
diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.ts
index 0dc3a863a..40908ce8d 100644
--- a/backend/apps/cloud/src/analytics/analytics.service.ts
+++ b/backend/apps/cloud/src/analytics/analytics.service.ts
@@ -3187,7 +3187,13 @@ export class AnalyticsService {
},
)
- const events = chunkEvents.flat()
+ // Chunk index order is upload order, which can diverge from event time
+ // order (e.g. two tabs recording into the same replay). The replayer
+ // expects a monotonic timeline, so stable-sort by timestamp β€” the same
+ // normalisation the MP4 export applies.
+ const events = chunkEvents
+ .flat()
+ .sort((a, b) => (Number(a?.timestamp) || 0) - (Number(b?.timestamp) || 0))
return {
replay,
diff --git a/backend/apps/cloud/src/analytics/session-replay-s3.service.ts b/backend/apps/cloud/src/analytics/session-replay-s3.service.ts
index 7d26eaa41..a7c8e4727 100644
--- a/backend/apps/cloud/src/analytics/session-replay-s3.service.ts
+++ b/backend/apps/cloud/src/analytics/session-replay-s3.service.ts
@@ -14,6 +14,14 @@ type HeaderMap = Record<string, string>
type PutObjectBody = Buffer | Readable
const SESSION_REPLAY_STORAGE_TIMEOUT_MS = 30_000
+// Hetzner object storage intermittently returns 503s; dropped replay chunks
+// are unrecoverable, so transient failures get a couple of retries.
+const SESSION_REPLAY_STORAGE_MAX_ATTEMPTS = 3
+const SESSION_REPLAY_STORAGE_RETRY_BASE_DELAY_MS = 300
+const RETRYABLE_STATUS_CODES = new Set([429, 500, 502, 503, 504])
+
+const sleep = (ms: number) =>
+ new Promise<void>((resolve) => setTimeout(resolve, ms))
const sha256Hex = (value: Buffer | string) =>
crypto.createHash('sha256').update(value).digest('hex')
@@ -214,6 +222,55 @@ export class SessionReplayS3Service {
extraHeaders: HeaderMap = {},
payloadHashOverride?: string,
queryParams: Record<string, string | undefined> = {},
+ ): Promise<Response> {
+ // Stream bodies can only be read once, so they get a single attempt.
+ const attempts =
+ body instanceof Readable ? 1 : SESSION_REPLAY_STORAGE_MAX_ATTEMPTS
+ let lastError: unknown
+
+ for (let attempt = 0; attempt < attempts; attempt++) {
+ if (attempt > 0) {
+ await sleep(
+ SESSION_REPLAY_STORAGE_RETRY_BASE_DELAY_MS * 2 ** (attempt - 1),
+ )
+ }
+
+ try {
+ const response = await this.signedFetchOnce(
+ method,
+ key,
+ body,
+ extraHeaders,
+ payloadHashOverride,
+ queryParams,
+ )
+
+ if (
+ RETRYABLE_STATUS_CODES.has(response.status) &&
+ attempt < attempts - 1
+ ) {
+ lastError = new Error(
+ `Hetzner S3 ${method} failed with status ${response.status}`,
+ )
+ continue
+ }
+
+ return response
+ } catch (reason) {
+ lastError = reason
+ }
+ }
+
+ throw lastError
+ }
+
+ private async signedFetchOnce(
+ method: 'PUT' | 'GET' | 'DELETE',
+ key: string,
+ body?: PutObjectBody,
+ extraHeaders: HeaderMap = {},
+ payloadHashOverride?: string,
+ queryParams: Record<string, string | undefined> = {},
): Promise<Response> {
const config = this.getConfig()
if (!config) {
diff --git a/backend/knip.jsonc b/backend/knip.jsonc
index 3d900272e..8fd38aba8 100644
--- a/backend/knip.jsonc
+++ b/backend/knip.jsonc
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
- "ignoreDependencies": ["@types/ioredis", "rrweb"],
+ "ignoreDependencies": ["@types/ioredis", "@rrweb/replay"],
"ignore": [],
"exclude": ["enumMembers"],
"entry": ["./apps/cloud/src/main.ts", "./apps/community/src/main.ts"],
diff --git a/backend/package-lock.json b/backend/package-lock.json
index 5948e3bef..23ab43e3a 100644
--- a/backend/package-lock.json
+++ b/backend/package-lock.json
@@ -26,6 +26,7 @@
"@nestjs/terminus": "^11.1.1",
"@nestjs/typeorm": "^11.0.2",
"@nestjs/websockets": "^11.1.27",
+ "@rrweb/replay": "2.1.1",
"@sentry/nestjs": "^10.59.0",
"@sentry/profiling-node": "^10.59.0",
"@swetrix/node": "^3.2.0",
@@ -65,8 +66,7 @@
"php-serialize": "^5.1.3",
"reflect-metadata": "^0.2.2",
"request-filtering-agent": "^3.2.0",
- "rrvideo": "2.0.1",
- "rrweb": "2.0.1",
+ "rrvideo": "2.1.1",
"rxjs": "^7.8.2",
"sns-payload-validator": "^2.1.0",
"socket.io": "^4.8.3",
@@ -2171,7 +2171,7 @@
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"@jridgewell/sourcemap-codec": "^1.5.0",
@@ -2193,7 +2193,7 @@
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"engines": {
"node": ">=6.0.0"
@@ -2203,7 +2203,7 @@
"version": "0.3.11",
"resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.11.tgz",
"integrity": "sha512-ZMp1V8ZFcPG5dIWnQLr3NSI1MiCU7UETdS/A0G8V/XWHvJv3ZsFqutJn1Y5RPmAPX6F3BiE397OqveU/9NCuIA==",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"@jridgewell/gen-mapping": "^0.3.5",
@@ -2220,7 +2220,7 @@
"version": "0.3.31",
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"@jridgewell/resolve-uri": "^3.1.0",
@@ -4817,41 +4817,41 @@
"license": "BSD-3-Clause"
},
"node_modules/@rrweb/packer": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@rrweb/packer/-/packer-2.0.1.tgz",
- "integrity": "sha512-2U8RkVe+ZK3gTtmKjJKjoh6QL1Q6wIlt3sBTJeCPERLr9e0JIimNrZ1+bog1L30CTVP3ULuDf5Ba7RZO+QNcHg==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/packer/-/packer-2.1.1.tgz",
+ "integrity": "sha512-xPGT7/Cfn1yHD2MOwQhX/8yTvNculurUxPT6ZKXVW8Wh/LI7Jn19L+e8PYKFhj/M89uwNeoTr6hiUQxgb8SMzQ==",
"license": "MIT",
"dependencies": {
- "@rrweb/types": "^2.0.1",
+ "@rrweb/types": "^2.1.1",
"fflate": "^0.4.4"
}
},
"node_modules/@rrweb/packer/node_modules/fflate": {
- "version": "0.4.8",
- "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.4.8.tgz",
- "integrity": "sha512-FJqqoDBR00Mdj9ppamLa/Y7vxm+PRmNWA67N846RvsoYVMKB4q3y/de5PA7gUmRMYK/8CMz2GDZQmCRN1wBcWA==",
+ "version": "0.4.9",
+ "resolved": "https://registry.npmjs.org/fflate/-/fflate-0.4.9.tgz",
+ "integrity": "sha512-zdxgIEddhfsyCaWpJ2SdXEP8ZMrKJ6+5jl4OupODcywU0IhRk6gdXuVGcPICyfx2H97hVK7xmJtRLPjkxAX8Vw==",
"license": "MIT"
},
"node_modules/@rrweb/replay": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@rrweb/replay/-/replay-2.0.1.tgz",
- "integrity": "sha512-UrZONirb8o4t0urg1aJ8aMSWhNHvJ3a2usuVbPJIm/edyFbwTvvY9sg/rrXccyXOntFhhp73R5nCretODRZcCw==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/replay/-/replay-2.1.1.tgz",
+ "integrity": "sha512-jq64eyJvrh/ioBS1MpDrs/Lj+7QY2TW4xGxp4g4LJKdltSkqMjMbUmhTDcpzaEDZt66S0gasGcgqCulsksSXnw==",
"license": "MIT",
"dependencies": {
- "@rrweb/types": "^2.0.1",
- "rrweb": "^2.0.1"
+ "@rrweb/types": "^2.1.1",
+ "rrweb": "^2.1.1"
}
},
"node_modules/@rrweb/types": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@rrweb/types/-/types-2.0.1.tgz",
- "integrity": "sha512-x8cNaKFxdvS0/5IfKOj1xG8Htnw1fUwqoPqgP61bOaWqZL6t9UtRPpO9ZlMB2z+FiTxg9zlFFL+Da4ZpFuhoiA==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/types/-/types-2.1.1.tgz",
+ "integrity": "sha512-g0I3nCNL1S7slDXwhunxOuOoswkY8WVZJQrPFiwixOc6xoD514d1JLTuyAzCKIox8g/PaLKtV5g31Uk42inQSQ==",
"license": "MIT"
},
"node_modules/@rrweb/utils": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@rrweb/utils/-/utils-2.0.1.tgz",
- "integrity": "sha512-t+b+4rB23/e4EpoGMdPUr6cKtDsFuOb3LxA9IHE8e3A/Xo0nMUfH0bkwqdpUNa/VGDOdiGeG3bhHjuO9zWX54g==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/utils/-/utils-2.1.1.tgz",
+ "integrity": "sha512-x2SgJAD3YJ9eVcLZ5l6OqWMtczdA3VfS5XqPeqpZdQgV9oh6Id5GK2cDN4bimnkqryOcIJdz8cTvV0yNvqQ+nA==",
"license": "MIT"
},
"node_modules/@scarf/scarf": {
@@ -15438,18 +15438,18 @@
"license": "MIT"
},
"node_modules/rrdom": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/rrdom/-/rrdom-2.0.1.tgz",
- "integrity": "sha512-z8GdQWFmVfa8GpcGkAqfBXseb89z0ciTPSBkID0qr0i6KHCye1MdQ4VoXFf0Ejp3ELe/c7AObu4zsbSbMT+hiw==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrdom/-/rrdom-2.1.1.tgz",
+ "integrity": "sha512-VBkTF3bGNqcZjqnbo/gKi9GVQPIxiG0dofw7CQdAZQFQ2juJdt2YKIf3oS9QudL8HTpGh9bz5TUN+3amBn1Geg==",
"license": "MIT",
"dependencies": {
- "rrweb-snapshot": "^2.0.1"
+ "rrweb-snapshot": "^2.1.1"
}
},
"node_modules/rrvideo": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/rrvideo/-/rrvideo-2.0.1.tgz",
- "integrity": "sha512-gDf0oE1nLU4xMqdkm3nvAKWYLzkAIVSXOIL63CZZf75hqAzavEOJu3P0C7778z8yk18d2Yj79SdKmZyHSuc2IA==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrvideo/-/rrvideo-2.1.1.tgz",
+ "integrity": "sha512-ORJWh+Fh7LRDMFtOpBISXHouhUHiPLYHDfd6E3P+UHVyqLQOX1fB9vvY1e4dT9cz5/3vGOZ3+KkEL6lRVo5UkQ==",
"hasInstallScript": true,
"license": "MIT",
"dependencies": {
@@ -15457,7 +15457,7 @@
"fs-extra": "^11.1.1",
"minimist": "^1.2.5",
"playwright": "^1.60.0",
- "rrweb-player": "^2.0.1"
+ "rrweb-player": "^2.1.1"
},
"bin": {
"rrvideo": "build/cli.js"
@@ -15478,36 +15478,36 @@
}
},
"node_modules/rrweb": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/rrweb/-/rrweb-2.0.1.tgz",
- "integrity": "sha512-MQYzOtI7aZft9ffDMT6rmRSAj6hO4W6T7iA4eB9Mtcuiv3M7DbnnxDMrcPW0sQXepgYN46YhfSKe75d/mlUHrQ==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrweb/-/rrweb-2.1.1.tgz",
+ "integrity": "sha512-ToxhJg3SsrAhw+/DPhI/2iiwZQIrGK5BGkZ0kHn4qUExcvQYRaolkciD1FWX2+r6vf1IxFyhsoRY18h3D+XoCg==",
"license": "MIT",
"dependencies": {
- "@rrweb/types": "^2.0.1",
- "@rrweb/utils": "^2.0.1",
+ "@rrweb/types": "^2.1.1",
+ "@rrweb/utils": "^2.1.1",
"@types/css-font-loading-module": "0.0.7",
"@xstate/fsm": "^1.4.0",
"base64-arraybuffer": "^1.0.1",
"mitt": "^3.0.0",
- "rrdom": "^2.0.1",
- "rrweb-snapshot": "^2.0.1"
+ "rrdom": "^2.1.1",
+ "rrweb-snapshot": "^2.1.1"
}
},
"node_modules/rrweb-player": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/rrweb-player/-/rrweb-player-2.0.1.tgz",
- "integrity": "sha512-v8PVnOy7Q3kXqWriGuzZo4ndGEV06nCMRkH/jSHweJfTLwpLqb2evgMj0S5FwQLsN2X1VM+L2/i7QWGJfgj9zw==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrweb-player/-/rrweb-player-2.1.1.tgz",
+ "integrity": "sha512-oiAWx/m9Pz0DD5jlJdrF8QlotOZZBK0jINNSYAixxhGa2dI1TrzVVmF4eWFSd6AR8f2zjazKXI/PXCqj3PttXQ==",
"license": "MIT",
"dependencies": {
- "@rrweb/packer": "^2.0.1",
- "@rrweb/replay": "^2.0.1",
+ "@rrweb/packer": "^2.1.1",
+ "@rrweb/replay": "^2.1.1",
"@tsconfig/svelte": "^1.0.0"
}
},
"node_modules/rrweb-snapshot": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/rrweb-snapshot/-/rrweb-snapshot-2.0.1.tgz",
- "integrity": "sha512-H8TA29ct2tpYtr5oaB0N+ksRY9bhEErfAYcKbce4+w8lqEUQChpKZd41HpBJLkp04b5QUfWUg4v6r9Okf8r7vA==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrweb-snapshot/-/rrweb-snapshot-2.1.1.tgz",
+ "integrity": "sha512-al4Kx7Am7YlIn/5Yb2EMr7cdmjGiK+cLhdilJEXqkFXgpnys8t/yMJumXy2Ormgirpg3MBnFha0GTgny+iIL2w==",
"license": "MIT",
"dependencies": {
"postcss": "^8.4.38"
@@ -16057,7 +16057,7 @@
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
- "dev": true,
+ "devOptional": true,
"license": "MIT",
"dependencies": {
"buffer-from": "^1.0.0",
@@ -16068,7 +16068,7 @@
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
- "dev": true,
+ "devOptional": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
@@ -16572,7 +16572,7 @@
"version": "5.44.1",
"resolved": "https://registry.npmjs.org/terser/-/terser-5.44.1.tgz",
"integrity": "sha512-t/R3R/n0MSwnnazuPpPNVO60LX0SKL45pyl9YlvxIdkH0Of7D5qM2EVe+yASRIlY5pZ73nclYJfNANGWPwFDZw==",
- "dev": true,
+ "devOptional": true,
"license": "BSD-2-Clause",
"dependencies": {
"@jridgewell/source-map": "^0.3.3",
@@ -16663,7 +16663,7 @@
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
- "dev": true,
+ "devOptional": true,
"license": "MIT"
},
"node_modules/test-exclude": {
@@ -17244,7 +17244,6 @@
"version": "5.9.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz",
"integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==",
- "dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
diff --git a/backend/package.json b/backend/package.json
index 88e1a246e..ce5f4af46 100644
--- a/backend/package.json
+++ b/backend/package.json
@@ -48,6 +48,7 @@
"@nestjs/terminus": "^11.1.1",
"@nestjs/typeorm": "^11.0.2",
"@nestjs/websockets": "^11.1.27",
+ "@rrweb/replay": "2.1.1",
"@sentry/nestjs": "^10.59.0",
"@sentry/profiling-node": "^10.59.0",
"@swetrix/node": "^3.2.0",
@@ -87,8 +88,7 @@
"php-serialize": "^5.1.3",
"reflect-metadata": "^0.2.2",
"request-filtering-agent": "^3.2.0",
- "rrvideo": "2.0.1",
- "rrweb": "2.0.1",
+ "rrvideo": "2.1.1",
"rxjs": "^7.8.2",
"sns-payload-validator": "^2.1.0",
"socket.io": "^4.8.3",
diff --git a/backend/scripts/patch-rrvideo.js b/backend/scripts/patch-rrvideo.js
index 002cf79f5..1c90a512d 100644
--- a/backend/scripts/patch-rrvideo.js
+++ b/backend/scripts/patch-rrvideo.js
@@ -5,7 +5,7 @@ const packagePath = require.resolve('rrvideo/package.json')
const packageDir = path.dirname(packagePath)
const packageJson = JSON.parse(fs.readFileSync(packagePath, 'utf8'))
-if (packageJson.version !== '2.0.1') {
+if (packageJson.version !== '2.1.1') {
throw new Error(`Unsupported rrvideo version: ${packageJson.version}`)
}
@@ -14,11 +14,12 @@ let source = fs.readFileSync(filePath, 'utf8')
const playerBundle =
"require.resolve('rrweb-player'), '../../dist/rrweb-player.umd.cjs'"
-const rrwebBundle = "require.resolve('rrweb'), '../../dist/rrweb.umd.cjs'"
+const replayBundle =
+ "require.resolve('@rrweb/replay'), '../../dist/replay.umd.cjs'"
if (source.includes(playerBundle)) {
- source = source.replace(playerBundle, rrwebBundle)
-} else if (!source.includes(rrwebBundle)) {
+ source = source.replace(playerBundle, replayBundle)
+} else if (!source.includes(replayBundle)) {
throw new Error('Could not find rrvideo player bundle path')
}
@@ -119,7 +120,7 @@ const blockReplacement = [
' const userConfig = ${JSON.stringify((config === null || config === void 0 ? void 0 : config.rrwebPlayer) || {})};',
' try {',
' const insertStyleRules = Array.isArray(userConfig.insertStyleRules) ? userConfig.insertStyleRules : [];',
- ' window.replayer = new rrweb.Replayer(events, {',
+ ' window.replayer = new rrwebReplay.Replayer(events, {',
' ...userConfig,',
' root: document.body,',
' insertStyleRules: [...insertStyleRules, \'html, body { background-color: #fff; }\'],',
@@ -149,5 +150,5 @@ if (patched === fs.readFileSync(filePath, 'utf8')) {
console.log('rrvideo patch already applied')
} else {
fs.writeFileSync(filePath, patched)
- console.log('Patched rrvideo to render with rrweb Replayer')
+ console.log('Patched rrvideo to render with @rrweb/replay Replayer')
}
diff --git a/docs/content/docs/script-reference.mdx b/docs/content/docs/script-reference.mdx
index 310eb6480..34bb1fb69 100644
--- a/docs/content/docs/script-reference.mdx
+++ b/docs/content/docs/script-reference.mdx
@@ -278,7 +278,7 @@ const replay = await startSessionReplay({
});
```
-For npm installs, Swetrix dynamically imports the installed `rrweb` package only when the recorder is preloaded or started, so it can be split into an async chunk by your bundler. For script-tag installs, Swetrix loads the standalone replay recorder with an async script tag.
+For npm installs, Swetrix dynamically imports the installed `@rrweb/record` package only when the recorder is preloaded or started, so it can be split into an async chunk by your bundler. For script-tag installs, Swetrix loads the standalone replay recorder with an async script tag.
| Name | Description | Default value |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------- |
diff --git a/packages/tracker-js/README.md b/packages/tracker-js/README.md
index e34620fa0..d5732c2d3 100644
--- a/packages/tracker-js/README.md
+++ b/packages/tracker-js/README.md
@@ -200,7 +200,7 @@ clearExperimentsCache()
Start recording a session replay. Session replays use `total` privacy by default, which masks text and inputs and blocks media/canvas capture unless you explicitly choose another mode.
-If you use the npm package, rrweb is dynamically imported from your installed dependencies only when the recorder is preloaded or started. If you use the CDN/script-tag build, the standalone replay recorder is loaded with an async script tag.
+If you use the npm package, the recorder (`@rrweb/record`) is dynamically imported from your installed dependencies only when the recorder is preloaded or started. If you use the CDN/script-tag build, the standalone replay recorder is loaded with an async script tag.
```javascript
const replay = await startSessionReplay({
diff --git a/packages/tracker-js/package-lock.json b/packages/tracker-js/package-lock.json
index 02adfe2bf..fb2df4949 100644
--- a/packages/tracker-js/package-lock.json
+++ b/packages/tracker-js/package-lock.json
@@ -9,7 +9,7 @@
"version": "4.4.0",
"license": "MIT",
"dependencies": {
- "rrweb": "2.0.1"
+ "@rrweb/record": "2.1.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^29.0.3",
@@ -1732,16 +1732,27 @@
"win32"
]
},
+ "node_modules/@rrweb/record": {
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/record/-/record-2.1.1.tgz",
+ "integrity": "sha512-c2u175R+daC37PhbjaQV0migxtIXsLuD0mRgRstj/x/CRmLGctRlDi373/4miIUclleq4eZIQXAglH9opclFRQ==",
+ "license": "MIT",
+ "dependencies": {
+ "@rrweb/types": "^2.1.1",
+ "@rrweb/utils": "^2.1.1",
+ "rrweb": "^2.1.1"
+ }
+ },
"node_modules/@rrweb/types": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@rrweb/types/-/types-2.0.1.tgz",
- "integrity": "sha512-x8cNaKFxdvS0/5IfKOj1xG8Htnw1fUwqoPqgP61bOaWqZL6t9UtRPpO9ZlMB2z+FiTxg9zlFFL+Da4ZpFuhoiA==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/types/-/types-2.1.1.tgz",
+ "integrity": "sha512-g0I3nCNL1S7slDXwhunxOuOoswkY8WVZJQrPFiwixOc6xoD514d1JLTuyAzCKIox8g/PaLKtV5g31Uk42inQSQ==",
"license": "MIT"
},
"node_modules/@rrweb/utils": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/@rrweb/utils/-/utils-2.0.1.tgz",
- "integrity": "sha512-t+b+4rB23/e4EpoGMdPUr6cKtDsFuOb3LxA9IHE8e3A/Xo0nMUfH0bkwqdpUNa/VGDOdiGeG3bhHjuO9zWX54g==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/utils/-/utils-2.1.1.tgz",
+ "integrity": "sha512-x2SgJAD3YJ9eVcLZ5l6OqWMtczdA3VfS5XqPeqpZdQgV9oh6Id5GK2cDN4bimnkqryOcIJdz8cTvV0yNvqQ+nA==",
"license": "MIT"
},
"node_modules/@sinclair/typebox": {
@@ -4434,9 +4445,9 @@
"dev": true
},
"node_modules/nanoid": {
- "version": "3.3.12",
- "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.12.tgz",
- "integrity": "sha512-ZB9RH/39qpq5Vu6Y+NmUaFhQR6pp+M2Xt76XBnEwDaGcVAqhlvxrl3B2bKS5D3NH3QR76v3aSrKaF/Kiy7lEtQ==",
+ "version": "3.3.16",
+ "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.16.tgz",
+ "integrity": "sha512-bzlKTyNJ7+LdGIIwy8ijFpIqEQIvafahV7eYykJ8Cvh42EdJeODoJ6gUJXpQJvej1BddH8OqTXZNE/KfbWAu8Q==",
"funding": [
{
"type": "github",
@@ -4742,9 +4753,9 @@
}
},
"node_modules/postcss": {
- "version": "8.5.15",
- "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.15.tgz",
- "integrity": "sha512-FfR8sjd4em2T6fb3I2MwAJU7HWVMr9zba+enmQeeWFfCbm+UOC/0X4DS8XtpUTMwWMGbjKYP7xjfNekzyGmB3A==",
+ "version": "8.5.22",
+ "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.22.tgz",
+ "integrity": "sha512-KBDEIpLrvpv16pp3K0Fw+UCoZfopFjjgeB+0tA/aaThfEE74kKDLrgg603YvOWJyg3+WYtyq3xYsQWsIyZlPqQ==",
"funding": [
{
"type": "opencollective",
@@ -4761,7 +4772,7 @@
],
"license": "MIT",
"dependencies": {
- "nanoid": "^3.3.12",
+ "nanoid": "^3.3.16",
"picocolors": "^1.1.1",
"source-map-js": "^1.2.1"
},
@@ -5041,28 +5052,28 @@
}
},
"node_modules/rrdom": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/rrdom/-/rrdom-2.0.1.tgz",
- "integrity": "sha512-z8GdQWFmVfa8GpcGkAqfBXseb89z0ciTPSBkID0qr0i6KHCye1MdQ4VoXFf0Ejp3ELe/c7AObu4zsbSbMT+hiw==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrdom/-/rrdom-2.1.1.tgz",
+ "integrity": "sha512-VBkTF3bGNqcZjqnbo/gKi9GVQPIxiG0dofw7CQdAZQFQ2juJdt2YKIf3oS9QudL8HTpGh9bz5TUN+3amBn1Geg==",
"license": "MIT",
"dependencies": {
- "rrweb-snapshot": "^2.0.1"
+ "rrweb-snapshot": "^2.1.1"
}
},
"node_modules/rrweb": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/rrweb/-/rrweb-2.0.1.tgz",
- "integrity": "sha512-MQYzOtI7aZft9ffDMT6rmRSAj6hO4W6T7iA4eB9Mtcuiv3M7DbnnxDMrcPW0sQXepgYN46YhfSKe75d/mlUHrQ==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrweb/-/rrweb-2.1.1.tgz",
+ "integrity": "sha512-ToxhJg3SsrAhw+/DPhI/2iiwZQIrGK5BGkZ0kHn4qUExcvQYRaolkciD1FWX2+r6vf1IxFyhsoRY18h3D+XoCg==",
"license": "MIT",
"dependencies": {
- "@rrweb/types": "^2.0.1",
- "@rrweb/utils": "^2.0.1",
+ "@rrweb/types": "^2.1.1",
+ "@rrweb/utils": "^2.1.1",
"@types/css-font-loading-module": "0.0.7",
"@xstate/fsm": "^1.4.0",
"base64-arraybuffer": "^1.0.1",
"mitt": "^3.0.0",
- "rrdom": "^2.0.1",
- "rrweb-snapshot": "^2.0.1"
+ "rrdom": "^2.1.1",
+ "rrweb-snapshot": "^2.1.1"
}
},
"node_modules/rrweb-cssom": {
@@ -5073,9 +5084,9 @@
"license": "MIT"
},
"node_modules/rrweb-snapshot": {
- "version": "2.0.1",
- "resolved": "https://registry.npmjs.org/rrweb-snapshot/-/rrweb-snapshot-2.0.1.tgz",
- "integrity": "sha512-H8TA29ct2tpYtr5oaB0N+ksRY9bhEErfAYcKbce4+w8lqEUQChpKZd41HpBJLkp04b5QUfWUg4v6r9Okf8r7vA==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrweb-snapshot/-/rrweb-snapshot-2.1.1.tgz",
+ "integrity": "sha512-al4Kx7Am7YlIn/5Yb2EMr7cdmjGiK+cLhdilJEXqkFXgpnys8t/yMJumXy2Ormgirpg3MBnFha0GTgny+iIL2w==",
"license": "MIT",
"dependencies": {
"postcss": "^8.4.38"
diff --git a/packages/tracker-js/package.json b/packages/tracker-js/package.json
index 07d53862a..970b08e16 100644
--- a/packages/tracker-js/package.json
+++ b/packages/tracker-js/package.json
@@ -45,7 +45,7 @@
"test:coverage": "jest --coverage"
},
"dependencies": {
- "rrweb": "2.0.1"
+ "@rrweb/record": "2.1.1"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^29.0.3",
diff --git a/packages/tracker-js/rollup.config.mjs b/packages/tracker-js/rollup.config.mjs
index 232c36a74..6fb9c8fa4 100644
--- a/packages/tracker-js/rollup.config.mjs
+++ b/packages/tracker-js/rollup.config.mjs
@@ -9,9 +9,17 @@ import { dirname, join } from 'node:path'
const require = createRequire(import.meta.url)
const rrwebDistFile = 'replaylibrary.min.js'
-const rrwebPackageFile = 'rrweb.umd.min.cjs'
-const rrwebDistPath = join(dirname(require.resolve('rrweb')), rrwebPackageFile)
-const external = ['rrweb']
+const rrwebPackageFile = 'record.umd.min.cjs'
+const rrwebDistPath = join(
+ dirname(require.resolve('@rrweb/record')),
+ rrwebPackageFile,
+)
+// Older published trackers look for the recorder on `window.rrweb`, which the
+// full rrweb bundle used to define. The @rrweb/record UMD only defines
+// `window.rrwebRecord`, so alias it for scripts loaded via the shared CDN URL.
+const rrwebCompatFooter =
+ '\n;if (typeof window !== "undefined" && !window.rrweb) { window.rrweb = window.rrwebRecord; }\n'
+const external = ['@rrweb/record']
const copyRrweb = () => ({
name: 'copy-rrweb',
@@ -19,7 +27,7 @@ const copyRrweb = () => ({
this.emitFile({
type: 'asset',
fileName: rrwebDistFile,
- source: readFileSync(rrwebDistPath),
+ source: readFileSync(rrwebDistPath, 'utf8') + rrwebCompatFooter,
})
},
})
diff --git a/packages/tracker-js/src/Lib.ts b/packages/tracker-js/src/Lib.ts
index c06db66ac..1a1b01029 100644
--- a/packages/tracker-js/src/Lib.ts
+++ b/packages/tracker-js/src/Lib.ts
@@ -23,12 +23,17 @@ interface RrwebRecordOptions {
[key: string]: unknown
}
+interface RrwebRecordFn {
+ (options: RrwebRecordOptions): (() => void) | undefined
+ takeFullSnapshot?: (isCheckout?: boolean) => void
+}
+
interface RrwebGlobal {
- record?: (options: RrwebRecordOptions) => (() => void) | undefined
+ record?: RrwebRecordFn
Replayer?: unknown
}
-type RrwebModule = RrwebGlobal & {
+type RrwebRecordModule = RrwebGlobal & {
default?: RrwebGlobal
}
@@ -41,7 +46,10 @@ interface SessionReplayStartResponse {
declare global {
interface Window {
+ // Legacy global set by full rrweb bundles (self-hosted or custom rrwebUrl).
rrweb?: RrwebGlobal
+ // Global set by the @rrweb/record UMD bundle we ship.
+ rrwebRecord?: RrwebGlobal | RrwebRecordFn
__SWETRIX_RRWEB_LOADING__?: Promise<void>
}
}
@@ -321,6 +329,10 @@ const DEFAULT_SESSION_REPLAY_SLIM_DOM_OPTIONS = {
headMetaAuthorship: true,
headMetaVerification: true,
}
+const RRWEB_EVENT_FULL_SNAPSHOT = 2
+// Chunk indices are reserved server-side, so retrying with the same index is
+// idempotent β€” the backend dedupes on (replayId, chunkIndex).
+const SESSION_REPLAY_CHUNK_RETRY_DELAYS_MS = [2_000, 5_000, 15_000]
const SESSION_REPLAY_ACTIVITY_EVENTS = [
'click',
'keydown',
@@ -874,8 +886,8 @@ export class Lib {
return defaultSessionReplayActions
}
- const rrweb = window.rrweb
- if (!rrweb?.record) {
+ const record = this.getRrwebRecorder()
+ if (!record) {
return defaultSessionReplayActions
}
@@ -937,15 +949,27 @@ export class Lib {
flushing = flushing
.catch(() => undefined)
- .then(() =>
- this.sendSessionReplayChunk(
+ .then(async () => {
+ const delivered = await this.sendSessionReplayChunk(
replayId,
privacy,
currentChunkIndex,
chunk,
useBeacon,
- ),
- )
+ )
+
+ // Losing a full snapshot makes every later event unrenderable, so
+ // re-seed the stream instead of recording into the void.
+ if (
+ !delivered &&
+ !stopped &&
+ chunk.some((event) => event.type === RRWEB_EVENT_FULL_SNAPSHOT)
+ ) {
+ try {
+ record.takeFullSnapshot?.()
+ } catch {}
+ }
+ })
await flushing
}
@@ -991,7 +1015,7 @@ export class Lib {
options.maskAllText,
)
- const stopRecording = rrweb.record(recordOptions)
+ const stopRecording = record(recordOptions)
const timer = setInterval(() => void flush(), flushIntervalMs)
const flushOnPageExit = () => void flush(true)
const flushOnHidden = () => {
@@ -1242,12 +1266,33 @@ export class Lib {
return trackerScript
}
+ private getRrwebRecorder(): RrwebRecordFn | undefined {
+ if (!isInBrowser()) {
+ return undefined
+ }
+
+ if (typeof window.rrweb?.record === 'function') {
+ return window.rrweb.record
+ }
+
+ const globalRecord = window.rrwebRecord
+ if (typeof globalRecord === 'function') {
+ return globalRecord
+ }
+
+ if (globalRecord && typeof globalRecord.record === 'function') {
+ return globalRecord.record
+ }
+
+ return undefined
+ }
+
private preloadSessionReplay(): Promise<void> {
if (!isInBrowser()) {
return Promise.resolve()
}
- if (window.rrweb?.record) {
+ if (this.getRrwebRecorder()) {
return Promise.resolve()
}
@@ -1301,14 +1346,14 @@ export class Lib {
private async loadSessionReplayPackage(): Promise<boolean> {
try {
- const rrwebModule = (await import('rrweb')) as RrwebModule
- const rrweb = rrwebModule.record ? rrwebModule : rrwebModule.default
+ const rrwebModule = (await import('@rrweb/record')) as RrwebRecordModule
+ const record = rrwebModule.record || rrwebModule.default?.record
- if (!rrweb?.record) {
+ if (typeof record !== 'function') {
return false
}
- window.rrweb = rrweb
+ window.rrwebRecord = { record }
return true
} catch {
return false
@@ -1520,7 +1565,7 @@ export class Lib {
chunkIndex: number,
events: RrwebEvent[],
useBeacon: boolean,
- ): Promise<void> {
+ ): Promise<boolean> {
const apiBase = this.getApiBase()
const url = `${apiBase}/log/session-replay/chunk`
const payload = JSON.stringify({
@@ -1532,23 +1577,56 @@ export class Lib {
})
if (useBeacon && typeof navigator.sendBeacon === 'function') {
+ // sendBeacon refuses payloads over its ~64 KB quota; fall through to
+ // fetch when it does.
const sent = navigator.sendBeacon(
url,
new Blob([payload], { type: 'application/json' }),
)
- if (sent) return
+ if (sent) return true
}
- try {
- await fetch(url, {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- },
- keepalive: useBeacon,
- body: payload,
- })
- } catch {}
+ // On the beacon path the page is unloading, so there is no time to retry.
+ const attempts = useBeacon
+ ? 1
+ : SESSION_REPLAY_CHUNK_RETRY_DELAYS_MS.length + 1
+
+ for (let attempt = 0; attempt < attempts; attempt++) {
+ if (attempt > 0) {
+ await new Promise((resolve) =>
+ setTimeout(resolve, SESSION_REPLAY_CHUNK_RETRY_DELAYS_MS[attempt - 1]),
+ )
+ }
+
+ try {
+ const response = await fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ // Browsers reject keepalive bodies over ~64 KB, so oversized
+ // payloads go through a regular request instead.
+ keepalive: useBeacon && payload.length < 60_000,
+ body: payload,
+ })
+
+ if (response.ok) {
+ return true
+ }
+
+ // Client errors (except timeouts and rate limits) won't succeed on
+ // retry.
+ if (
+ response.status < 500 &&
+ response.status !== 408 &&
+ response.status !== 429
+ ) {
+ return false
+ }
+ } catch {}
+ }
+
+ return false
}
private async sendRequest(path: string, body: object): Promise<void> {
diff --git a/packages/tracker-js/src/types/rrweb-shim.d.ts b/packages/tracker-js/src/types/rrweb-shim.d.ts
index d20456a6c..9a1e5924e 100644
--- a/packages/tracker-js/src/types/rrweb-shim.d.ts
+++ b/packages/tracker-js/src/types/rrweb-shim.d.ts
@@ -1,11 +1,9 @@
-declare module 'rrweb' {
+declare module '@rrweb/record' {
export const record: unknown
- export const Replayer: unknown
- const rrweb: {
+ const rrwebRecord: {
record?: unknown
- Replayer?: unknown
}
- export default rrweb
+ export default rrwebRecord
}
diff --git a/packages/tracker-js/tests/sessionReplay.test.ts b/packages/tracker-js/tests/sessionReplay.test.ts
index e89b89913..66e5f24b1 100644
--- a/packages/tracker-js/tests/sessionReplay.test.ts
+++ b/packages/tracker-js/tests/sessionReplay.test.ts
@@ -7,7 +7,7 @@ const PROJECT_ID = 'test-project-id'
const RRWEB_URL = 'https://cdn.jsdelivr.net/npm/swetrix@latest/dist/replaylibrary.min.js'
const mockRrwebRecord = jest.fn()
-jest.mock('rrweb', () => ({
+jest.mock('@rrweb/record', () => ({
record: mockRrwebRecord,
}))
@@ -18,6 +18,7 @@ const loadTracker = async () => {
const resetReplayGlobals = () => {
delete (window as any).rrweb
+ delete (window as any).rrwebRecord
delete (window as any).__SWETRIX_RRWEB_LOADING__
document.head.innerHTML = ''
document.body.innerHTML = ''
@@ -67,7 +68,7 @@ describe('Session replay tracking', () => {
init(PROJECT_ID, { devMode: true, preloadSessionReplay: true })
await (window as any).__SWETRIX_RRWEB_LOADING__
- expect((window as any).rrweb.record).toBe(mockRrwebRecord)
+ expect((window as any).rrwebRecord.record).toBe(mockRrwebRecord)
expect(document.querySelector(`script[src="${RRWEB_URL}"]`)).toBeNull()
expect(mockRrwebRecord).not.toHaveBeenCalled()
expect(fetchMock).not.toHaveBeenCalled()
@@ -597,4 +598,66 @@ describe('Session replay tracking', () => {
expect(document.querySelector(`script[src="${RRWEB_URL}"]`)).toBeNull()
expect(mockRrwebRecord).not.toHaveBeenCalled()
})
+
+ test('failed chunk uploads are retried with the same chunk index', async () => {
+ const { recordOptions } = usePackageRrweb()
+ const { init, startSessionReplay } = await loadTracker()
+
+ init(PROJECT_ID, { devMode: true })
+ const actions = await startSessionReplay({ flushIntervalMs: 60_000 })
+
+ jest.useFakeTimers()
+ let chunkAttempts = 0
+ fetchMock.mockImplementation((url) => {
+ if (String(url).includes('/session-replay/chunk')) {
+ chunkAttempts += 1
+ return Promise.resolve({ ok: chunkAttempts > 1, status: 503 })
+ }
+
+ return Promise.resolve({ ok: true })
+ })
+
+ recordOptions().emit({ type: 2, timestamp: 100 })
+ const flushPromise = actions.flush()
+ await jest.advanceTimersByTimeAsync(2_000)
+ await flushPromise
+
+ expect(chunkAttempts).toBe(2)
+ const chunkCalls = fetchMock.mock.calls.filter(([url]) =>
+ String(url).includes('/session-replay/chunk'),
+ )
+ expect(JSON.parse(chunkCalls[0][1].body as string).chunkIndex).toBe(0)
+ expect(JSON.parse(chunkCalls[1][1].body as string).chunkIndex).toBe(0)
+
+ await actions.stop()
+ })
+
+ test('a permanently dropped snapshot chunk requests a fresh full snapshot', async () => {
+ const takeFullSnapshot = jest.fn()
+ ;(mockRrwebRecord as any).takeFullSnapshot = takeFullSnapshot
+ const { recordOptions } = usePackageRrweb()
+ const { init, startSessionReplay } = await loadTracker()
+
+ init(PROJECT_ID, { devMode: true })
+ const actions = await startSessionReplay({ flushIntervalMs: 60_000 })
+
+ fetchMock.mockImplementation((url) => {
+ if (String(url).includes('/session-replay/chunk')) {
+ return Promise.resolve({ ok: false, status: 400 })
+ }
+
+ return Promise.resolve({ ok: true })
+ })
+
+ recordOptions().emit({ type: 2, timestamp: 100 })
+ await actions.flush()
+ expect(takeFullSnapshot).toHaveBeenCalledTimes(1)
+
+ recordOptions().emit({ type: 3, timestamp: 200 })
+ await actions.flush()
+ expect(takeFullSnapshot).toHaveBeenCalledTimes(1)
+
+ await actions.stop()
+ delete (mockRrwebRecord as any).takeFullSnapshot
+ })
})
diff --git a/packages/tracker-js/tsconfig.esnext.json b/packages/tracker-js/tsconfig.esnext.json
index b9241802a..2c6d06fbf 100644
--- a/packages/tracker-js/tsconfig.esnext.json
+++ b/packages/tracker-js/tsconfig.esnext.json
@@ -10,7 +10,7 @@
"outDir": "dist/esnext",
"baseUrl": ".",
"paths": {
- "rrweb": ["src/types/rrweb-shim.d.ts"]
+ "@rrweb/record": ["src/types/rrweb-shim.d.ts"]
},
"types": []
},
diff --git a/packages/tracker-js/tsconfig.json b/packages/tracker-js/tsconfig.json
index 469d1fc3f..7606bc63e 100644
--- a/packages/tracker-js/tsconfig.json
+++ b/packages/tracker-js/tsconfig.json
@@ -10,7 +10,7 @@
"allowSyntheticDefaultImports": true,
"baseUrl": ".",
"paths": {
- "rrweb": ["src/types/rrweb-shim.d.ts"]
+ "@rrweb/record": ["src/types/rrweb-shim.d.ts"]
},
"types": []
},
diff --git a/web/app/pages/OpenStartup/index.tsx b/web/app/pages/OpenStartup/index.tsx
index c1e10fff2..3b52f81b2 100644
--- a/web/app/pages/OpenStartup/index.tsx
+++ b/web/app/pages/OpenStartup/index.tsx
@@ -406,8 +406,12 @@ const OpenStartup = ({ stats }: OpenStartupProps) => {
useEffect(() => {
const bbSettings = getSettings()
- // @ts-expect-error
- billboard.generate(bbSettings)
+ try {
+ // @ts-expect-error
+ billboard.generate(bbSettings)
+ } catch {
+ // billboard.js can throw when page translators rewrite the SVG internals
+ }
}, [])
return (
@@ -433,7 +437,11 @@ const OpenStartup = ({ stats }: OpenStartupProps) => {
{t('open.finance.desc')}
</Text>
- <div className='mt-4 h-80' id='open-startup' />
+ <div
+ className='notranslate mt-4 h-80'
+ id='open-startup'
+ translate='no'
+ />
<Text as='h2' size='2xl' weight='bold' className='mt-8 tracking-tight'>
{t('open.usage.title')}
diff --git a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
index 3356385de..8882923e0 100644
--- a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
+++ b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
@@ -1128,6 +1128,7 @@ const ErrorsViewInner = () => {
value={activeError.details.count || 0}
/>
),
+ valueClassName: 'text-xl sm:text-2xl',
},
{
key: 'users',
@@ -1137,6 +1138,7 @@ const ErrorsViewInner = () => {
value={activeError.details.users || 0}
/>
),
+ valueClassName: 'text-xl sm:text-2xl',
},
{
key: 'firstSeen',
@@ -1147,7 +1149,8 @@ const ErrorsViewInner = () => {
language,
) || '-',
// A relative date is a sentence, not a figure β€” at the
- // numeric card size it dwarfs the rest of the row.
+ // default card size it dwarfs the row, so all four stats
+ // share this smaller size.
valueClassName: 'text-xl sm:text-2xl',
},
{
diff --git a/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx b/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
index bad723473..b2f2a0a94 100644
--- a/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
+++ b/web/app/pages/Project/tabs/Sessions/SessionReplayModal.tsx
@@ -1087,10 +1087,30 @@ const SessionReplayModal = ({
const speedRef = useRef(1)
const skipInactiveRef = useRef(true)
- const events = useMemo(
+ const rawEvents = useMemo(
() => (payload?.events || []) as ReplayEvent[],
[payload?.events],
)
+ // A replay is only renderable from its first full snapshot. Leading
+ // incremental events belong to a snapshot chunk that was lost in transit,
+ // so trim to the snapshot (keeping the Meta event that precedes it).
+ const events = useMemo(() => {
+ const snapshotIndex = rawEvents.findIndex(
+ (event) => event.type === EVENT_FULL_SNAPSHOT,
+ )
+
+ if (snapshotIndex === -1) return []
+ if (snapshotIndex === 0) return rawEvents
+
+ const start =
+ rawEvents[snapshotIndex - 1]?.type === EVENT_META
+ ? snapshotIndex - 1
+ : snapshotIndex
+
+ return rawEvents.slice(start)
+ }, [rawEvents])
+ const isReplayIncomplete =
+ Boolean(payload) && rawEvents.length > 0 && events.length === 0
const replayStartTimestamp = getTimestamp(events[0])
const timelineSteps = useMemo(
() => buildTimelineSteps(events, t),
@@ -2007,9 +2027,29 @@ const SessionReplayModal = ({
) : null}
{!isPreparing && !error && payload && !hasEvents ? (
<div className='absolute inset-0 z-20 flex items-center justify-center px-6 text-center'>
- <Text colour='primary' weight='semibold' className='dark'>
- {t('project.sessionReplay.empty')}
- </Text>
+ {isReplayIncomplete ? (
+ <div className='max-w-md'>
+ <WarningOctagonIcon
+ className='mx-auto mb-3 size-8 text-amber-400'
+ weight='duotone'
+ />
+ <Text colour='primary' weight='semibold' className='dark'>
+ {t('project.sessionReplay.incompleteTitle')}
+ </Text>
+ <Text
+ as='p'
+ size='sm'
+ colour='secondary'
+ className='dark mt-1'
+ >
+ {t('project.sessionReplay.incompleteDescription')}
+ </Text>
+ </div>
+ ) : (
+ <Text colour='primary' weight='semibold' className='dark'>
+ {t('project.sessionReplay.empty')}
+ </Text>
+ )}
</div>
) : null}
diff --git a/web/app/ui/BillboardChart.tsx b/web/app/ui/BillboardChart.tsx
index 2e732ba5b..615efdd09 100644
--- a/web/app/ui/BillboardChart.tsx
+++ b/web/app/ui/BillboardChart.tsx
@@ -1,6 +1,9 @@
import billboard, { type Chart, type ChartOptions } from 'billboard.js'
+import cx from 'clsx'
import React, { useEffect, useMemo, useRef } from 'react'
+import { trackError } from '~/utils/analytics'
+
interface BillboardChartProps {
options: ChartOptions
dataNames?: Record<string, string>
@@ -112,10 +115,26 @@ const BillboardChart = ({
}
}
- const chart = billboard.generate(wrappedOptions)
+ // Translation tools (Google Translate, Immersive Translate etc.) can
+ // rewrite the SVG internals mid-session, which makes billboard.js throw
+ // during re-render. Keep the page alive instead of crashing to the
+ // route-level ErrorBoundary, but still report the error.
+ let chart: Chart | null = null
+ try {
+ chart = billboard.generate(wrappedOptions)
+ } catch (reason) {
+ containerRef.current.replaceChildren()
+ trackError({
+ name: `BillboardChart: ${reason instanceof Error ? reason.message : String(reason)}`,
+ message: reason instanceof Error ? reason.message : String(reason),
+ lineno: 0,
+ colno: 0,
+ stackTrace: reason instanceof Error ? reason.stack || '' : '',
+ })
+ }
chartRef.current = chart
- if (dataNames) {
+ if (chart && dataNames) {
try {
chart.data.names(dataNames)
} catch {
@@ -151,7 +170,15 @@ const BillboardChart = ({
// eslint-disable-next-line react-hooks/exhaustive-deps
}, mergedDeps)
- return <div ref={containerRef} className={className} />
+ // translate='no' + notranslate: page translators rewriting SVG <text> nodes
+ // break billboard.js's tick measurement (getBBox on a non-SVG element)
+ return (
+ <div
+ ref={containerRef}
+ translate='no'
+ className={cx('notranslate', className)}
+ />
+ )
}
export default BillboardChart
diff --git a/web/package-lock.json b/web/package-lock.json
index 4c806e310..3c4d35709 100644
--- a/web/package-lock.json
+++ b/web/package-lock.json
@@ -16,7 +16,7 @@
"@react-router/fs-routes": "^8.0.1",
"@react-router/node": "^8.0.1",
"@react-router/serve": "^8.0.1",
- "@rrweb/replay": "2.1.0",
+ "@rrweb/replay": "2.1.1",
"@swetrix/node": "^3.2.0",
"@takumi-rs/image-response": "^1.8.7",
"@tanstack/react-query": "^5.101.2",
@@ -61,7 +61,7 @@
"@crowdin/crowdin-api-client": "^1.56.0",
"@google/genai": "^2.9.0",
"@react-router/dev": "^8.0.1",
- "@rrweb/types": "^2.1.0",
+ "@rrweb/types": "^2.1.1",
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/typography": "^0.5.20",
"@tailwindcss/vite": "^4.3.1",
@@ -4217,41 +4217,41 @@
"dev": true
},
"node_modules/@rrweb/replay": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/@rrweb/replay/-/replay-2.1.0.tgz",
- "integrity": "sha512-a6s3Lzf4iIEL22o6+DHZrbjH/q6OIM9CFh/KzU6pDZ2mOYFP3u3Yd3IL57Oc9usnqFt/kNCvOjUf5JbBrQ9o7A==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/replay/-/replay-2.1.1.tgz",
+ "integrity": "sha512-jq64eyJvrh/ioBS1MpDrs/Lj+7QY2TW4xGxp4g4LJKdltSkqMjMbUmhTDcpzaEDZt66S0gasGcgqCulsksSXnw==",
"license": "MIT",
"dependencies": {
- "@rrweb/types": "^2.1.0",
- "rrweb": "^2.1.0"
+ "@rrweb/types": "^2.1.1",
+ "rrweb": "^2.1.1"
}
},
"node_modules/@rrweb/replay/node_modules/rrweb": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/rrweb/-/rrweb-2.1.0.tgz",
- "integrity": "sha512-gGGvd1eXWnOuJpQumH7+gPmBwTXzNrjmQyedWVePcEx0S5fe3VkQW4vw5f5ItY+vuigaaktte9cZKOg0OEvv+w==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrweb/-/rrweb-2.1.1.tgz",
+ "integrity": "sha512-ToxhJg3SsrAhw+/DPhI/2iiwZQIrGK5BGkZ0kHn4qUExcvQYRaolkciD1FWX2+r6vf1IxFyhsoRY18h3D+XoCg==",
"license": "MIT",
"dependencies": {
- "@rrweb/types": "^2.1.0",
- "@rrweb/utils": "^2.1.0",
+ "@rrweb/types": "^2.1.1",
+ "@rrweb/utils": "^2.1.1",
"@types/css-font-loading-module": "0.0.7",
"@xstate/fsm": "^1.4.0",
"base64-arraybuffer": "^1.0.1",
"mitt": "^3.0.0",
- "rrdom": "^2.1.0",
- "rrweb-snapshot": "^2.1.0"
+ "rrdom": "^2.1.1",
+ "rrweb-snapshot": "^2.1.1"
}
},
"node_modules/@rrweb/types": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/@rrweb/types/-/types-2.1.0.tgz",
- "integrity": "sha512-svOHkcuukP6rIjz2umwVsS7uYct+2h0N97+bg+8IJYKIUj5+YjwIvqx5y9NILFKPIu3yk+Mb+KDFfJ8RV+4JlA==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/types/-/types-2.1.1.tgz",
+ "integrity": "sha512-g0I3nCNL1S7slDXwhunxOuOoswkY8WVZJQrPFiwixOc6xoD514d1JLTuyAzCKIox8g/PaLKtV5g31Uk42inQSQ==",
"license": "MIT"
},
"node_modules/@rrweb/utils": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/@rrweb/utils/-/utils-2.1.0.tgz",
- "integrity": "sha512-hU7MT3TSdD+Do7FmMoHrBfPevFCheN5vo2mn97Y4vbXuwemopAmo8dqo5KJeMaA6oQQt7FinHJ0Xqb7k68Ci6Q==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/@rrweb/utils/-/utils-2.1.1.tgz",
+ "integrity": "sha512-x2SgJAD3YJ9eVcLZ5l6OqWMtczdA3VfS5XqPeqpZdQgV9oh6Id5GK2cDN4bimnkqryOcIJdz8cTvV0yNvqQ+nA==",
"license": "MIT"
},
"node_modules/@swc/helpers": {
@@ -9703,12 +9703,12 @@
}
},
"node_modules/rrdom": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/rrdom/-/rrdom-2.1.0.tgz",
- "integrity": "sha512-d7oaIHzwffxI74UJMZDGq/f97/Yfm3QX4CcTIlQelt2HsLavItLjp8x8nQ0g9Pet5+5wG1RGr9yvsxb1gJlo8A==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrdom/-/rrdom-2.1.1.tgz",
+ "integrity": "sha512-VBkTF3bGNqcZjqnbo/gKi9GVQPIxiG0dofw7CQdAZQFQ2juJdt2YKIf3oS9QudL8HTpGh9bz5TUN+3amBn1Geg==",
"license": "MIT",
"dependencies": {
- "rrweb-snapshot": "^2.1.0"
+ "rrweb-snapshot": "^2.1.1"
}
},
"node_modules/rrweb": {
@@ -9727,9 +9727,9 @@
}
},
"node_modules/rrweb-snapshot": {
- "version": "2.1.0",
- "resolved": "https://registry.npmjs.org/rrweb-snapshot/-/rrweb-snapshot-2.1.0.tgz",
- "integrity": "sha512-CFjUKWlO+Dl72gk8qwcDcNE/Pj9yr6IvGRAiRAx12pmJaSWaOKFoFgpQQ1j/mW0WKwEZXbHnMJL8M92gIsdwUQ==",
+ "version": "2.1.1",
+ "resolved": "https://registry.npmjs.org/rrweb-snapshot/-/rrweb-snapshot-2.1.1.tgz",
+ "integrity": "sha512-al4Kx7Am7YlIn/5Yb2EMr7cdmjGiK+cLhdilJEXqkFXgpnys8t/yMJumXy2Ormgirpg3MBnFha0GTgny+iIL2w==",
"license": "MIT",
"dependencies": {
"postcss": "^8.4.38"
diff --git a/web/package.json b/web/package.json
index d55590096..d2f5ab3c2 100644
--- a/web/package.json
+++ b/web/package.json
@@ -29,7 +29,7 @@
"@react-router/fs-routes": "^8.0.1",
"@react-router/node": "^8.0.1",
"@react-router/serve": "^8.0.1",
- "@rrweb/replay": "2.1.0",
+ "@rrweb/replay": "2.1.1",
"@swetrix/node": "^3.2.0",
"@takumi-rs/image-response": "^1.8.7",
"@tanstack/react-query": "^5.101.2",
@@ -74,7 +74,7 @@
"@crowdin/crowdin-api-client": "^1.56.0",
"@google/genai": "^2.9.0",
"@react-router/dev": "^8.0.1",
- "@rrweb/types": "^2.1.0",
+ "@rrweb/types": "^2.1.1",
"@tailwindcss/forms": "^0.5.11",
"@tailwindcss/typography": "^0.5.20",
"@tailwindcss/vite": "^4.3.1",
diff --git a/web/public/locales/en.json b/web/public/locales/en.json
index 8ef647a1a..2822feef5 100644
--- a/web/public/locales/en.json
+++ b/web/public/locales/en.json
@@ -1919,6 +1919,8 @@
"deleteConfirmMessage": "This permanently deletes the session replay recording. The analytics session data stays available.",
"playerError": "Could not initialise replay player",
"empty": "No replay events were found.",
+ "incompleteTitle": "This replay is incomplete",
+ "incompleteDescription": "The recording is missing its initial page snapshot, so it can't be played back. This usually means some recording data failed to upload from the visitor's browser.",
"back10": "Back 10 seconds",
"forward10": "Forward 10 seconds",
"play": "Play",