From 76396d18c07900867893ec19b5b78387df06f752 Mon Sep 17 00:00:00 2001 From: Alex Gyujin Kim Date: Wed, 15 Feb 2023 07:50:52 -0500 Subject: [PATCH] chore(recordings): bundle recorder.js in posthog-js (#14121) --- bin/copy-posthog-js | 9 +++++++++ bin/copy-scripts-recorder | 12 ------------ package.json | 4 +--- 3 files changed, 10 insertions(+), 15 deletions(-) create mode 100755 bin/copy-posthog-js delete mode 100755 bin/copy-scripts-recorder diff --git a/bin/copy-posthog-js b/bin/copy-posthog-js new file mode 100755 index 00000000000..b05330facfc --- /dev/null +++ b/bin/copy-posthog-js @@ -0,0 +1,9 @@ +#!/bin/sh + +set -e + +# This script copies the following built files from posthog-js so that they can served on Posthog's CDN + +cp node_modules/posthog-js/dist/array.js* frontend/dist/ +cp node_modules/posthog-js/dist/array.full.js* frontend/dist/ +cp node_modules/posthog-js/dist/recorder.js* frontend/dist/ diff --git a/bin/copy-scripts-recorder b/bin/copy-scripts-recorder deleted file mode 100755 index bfeca749052..00000000000 --- a/bin/copy-scripts-recorder +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -set -e - -cp node_modules/rrweb/dist/record/rrweb-record.min.js frontend/dist/recorder.js -cp node_modules/rrweb/dist/record/rrweb-record.min.js.map frontend/dist/recorder.js.map -sed -i -e s/rrweb-record.min.js.map/recorder.js.map/ frontend/dist/recorder.js - -cat node_modules/rrweb/dist/plugins/console-record.min.js >> frontend/dist/recorder.js -cp node_modules/rrweb/dist/plugins/console-record.min.js.map frontend/dist/console-record.min.js.map - -sed -i -e 's/\/\/\# sourceMappingURL=recorder/window.rrweb = {record: rrwebRecord}\n\/\/# sourceMappingURL=recorder/g' frontend/dist/recorder.js diff --git a/package.json b/package.json index 13ea76b83e5..9fde08be247 100644 --- a/package.json +++ b/package.json @@ -17,9 +17,7 @@ }, "packageManager": "pnpm@7.14.2", "scripts": { - "copy-scripts": "mkdir -p frontend/dist/ && pnpm copy-scripts:array && pnpm copy-scripts:recorder", - "copy-scripts:array": "cp node_modules/posthog-js/dist/array.js* frontend/dist/", - "copy-scripts:recorder": "./bin/copy-scripts-recorder", + "copy-scripts": "mkdir -p frontend/dist/ && ./bin/copy-posthog-js", "test": "pnpm test:unit && pnpm test:visual-regression", "test:unit": "jest --testPathPattern=frontend/", "test:visual-regression": "docker compose -f docker-compose.playwright.yml run --rm -it --build playwright pnpm test:visual-regression:legacy:docker && pnpm test:visual-regression:stories:docker",