From d71ce35c6f8d82f5890fb3c253233527f9397c03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Pota=CC=81c=CC=8Cek?= Date: Fri, 31 Jan 2025 14:43:24 +0100 Subject: [PATCH] use signalfx cdn --- packages/session-recorder/src/index.ts | 3 ++- .../src/session-replay/constants.ts | 23 +++++++++++++++++++ .../src/session-replay/load.ts | 5 ++-- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 packages/session-recorder/src/session-replay/constants.ts diff --git a/packages/session-recorder/src/index.ts b/packages/session-recorder/src/index.ts index 6ffee918..70b3c3dd 100644 --- a/packages/session-recorder/src/index.ts +++ b/packages/session-recorder/src/index.ts @@ -28,6 +28,7 @@ import type { SplunkOtelWebType } from '@splunk/otel-web' import { loadRecorderBrowserScript } from './session-replay/load' import { getSessionReplayPlainGlobal } from './session-replay/utils' import { SessionReplayPlain as SessionReplayPlainType } from './session-replay/types' +import { SESSION_REPLAY_BACKGROUND_SERVICE_URL } from './session-replay/constants' interface BasicTracerProvider extends TracerProvider { readonly resource: Resource @@ -159,7 +160,7 @@ const SplunkRumRecorder = { sessionReplay = new SessionReplayPlain({ features: { - backgroundServiceSrc: 'https://domain.com/web/latest/background-service.html', + backgroundServiceSrc: SESSION_REPLAY_BACKGROUND_SERVICE_URL, cacheAssets: false, iframes: false, imageBitmap: false, diff --git a/packages/session-recorder/src/session-replay/constants.ts b/packages/session-recorder/src/session-replay/constants.ts new file mode 100644 index 00000000..909e3f25 --- /dev/null +++ b/packages/session-recorder/src/session-replay/constants.ts @@ -0,0 +1,23 @@ +/** + * + * Copyright 2020-2025 Splunk Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +const SESSION_REPLAY_VERSION_TAG = 'v1.30.0' +const SESSION_REPLAY_CDN_BASE_URL = `https://cdn.signalfx.com/o11y-gdi-rum/session-replay/${SESSION_REPLAY_VERSION_TAG}` + +export const SESSION_REPLAY_BROWSER_SCRIPT_URL = `${SESSION_REPLAY_CDN_BASE_URL}/session-replay.browser.min.js` +export const SESSION_REPLAY_BROWSER_LEGACY_SCRIPT_URL = `${SESSION_REPLAY_CDN_BASE_URL}/session-replay.browser.legacy.min.js` +export const SESSION_REPLAY_BACKGROUND_SERVICE_URL = `${SESSION_REPLAY_CDN_BASE_URL}/background-service.html` diff --git a/packages/session-recorder/src/session-replay/load.ts b/packages/session-recorder/src/session-replay/load.ts index 23f4a027..7f1e8dd3 100644 --- a/packages/session-recorder/src/session-replay/load.ts +++ b/packages/session-recorder/src/session-replay/load.ts @@ -16,11 +16,12 @@ * */ import { isRequiredAPISupported } from './required-api-check.js' +import { SESSION_REPLAY_BROWSER_SCRIPT_URL, SESSION_REPLAY_BROWSER_LEGACY_SCRIPT_URL } from './constants' export const loadRecorderBrowserScript = async () => { const recorderScriptUrl: string = isRequiredAPISupported() - ? 'https://domain.com/web/latest/session-replay.browser.min.js' - : 'https://domain.com/web/latest/session-replay.browser.legacy.min.js' + ? SESSION_REPLAY_BROWSER_SCRIPT_URL + : SESSION_REPLAY_BROWSER_LEGACY_SCRIPT_URL // const currentScript = document.currentScript as HTMLScriptElement | null // if (currentScript) {