From dbe4e6a784640ee8abebae512908988e63bd753d Mon Sep 17 00:00:00 2001 From: Zaid0412 <108808139+Zaid0412@users.noreply.github.com> Date: Thu, 7 Aug 2025 17:34:07 +0300 Subject: [PATCH] feat: disable Giphy analytics to prevent beforeunload handlers (#16314) --- giphy-analytics-stub.js | 16 ++++++++++++++++ patches/@giphy+js-analytics+4.3.2.patch | 14 -------------- webpack.config.js | 3 ++- 3 files changed, 18 insertions(+), 15 deletions(-) create mode 100644 giphy-analytics-stub.js delete mode 100644 patches/@giphy+js-analytics+4.3.2.patch diff --git a/giphy-analytics-stub.js b/giphy-analytics-stub.js new file mode 100644 index 0000000000..f9f293685d --- /dev/null +++ b/giphy-analytics-stub.js @@ -0,0 +1,16 @@ +// Stub replacement for @giphy/js-analytics to prevent beforeunload handlers +// This completely disables all Giphy analytics functionality + +export const pingback = () => { + // Completely disabled - do nothing + +}; + +export const mergeAttributes = (attributes, newAttributes) => { + // Return merged attributes without any analytics calls + return { ...attributes, + ...newAttributes }; +}; + +// Ensure no beforeunload handlers are ever registered +export default pingback; diff --git a/patches/@giphy+js-analytics+4.3.2.patch b/patches/@giphy+js-analytics+4.3.2.patch deleted file mode 100644 index 66b2494523..0000000000 --- a/patches/@giphy+js-analytics+4.3.2.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/node_modules/@giphy/js-analytics/dist/send-pingback.js b/node_modules/@giphy/js-analytics/dist/send-pingback.js -index 989f0ff..52471cb 100644 ---- a/node_modules/@giphy/js-analytics/dist/send-pingback.js -+++ b/node_modules/@giphy/js-analytics/dist/send-pingback.js -@@ -10,6 +10,9 @@ var global_1 = __importDefault(require("./global")); - var environment = (global_1.default === null || global_1.default === void 0 ? void 0 : global_1.default.GIPHY_PINGBACK_URL) || 'https://pingback.giphy.com'; - var pingBackUrl = "".concat(environment, "/v2/pingback?apikey=l0HlIwPWyBBUDAUgM"); - var sendPingback = function (events) { -+ // Disabled. -+ return Promise.resolve(); -+ - var headers = (0, js_util_1.getGiphySDKRequestHeaders)(); - /* istanbul ignore next */ - headers === null || headers === void 0 ? void 0 : headers.set('Content-Type', 'application/json'); diff --git a/webpack.config.js b/webpack.config.js index 740877a293..8235c5b163 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -204,7 +204,8 @@ function getConfig(options = {}) { ].filter(Boolean), resolve: { alias: { - 'focus-visible': 'focus-visible/dist/focus-visible.min.js' + 'focus-visible': 'focus-visible/dist/focus-visible.min.js', + '@giphy/js-analytics': resolve(__dirname, 'giphy-analytics-stub.js') }, aliasFields: [ 'browser'