15 |
16 |
17 |
18 |
19 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/packages/web/src/filters/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './node'
19 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/long-task/buffered.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Longtask tracking test
6 |
15 | <%- renderAgent() %>
16 |
17 |
18 |
11 |
12 |
15 |
16 |
17 |
23 |
24 |
25 |
26 |
--------------------------------------------------------------------------------
/tests/servers/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './socket-io'
19 | export * from './websocket'
20 |
--------------------------------------------------------------------------------
/examples/installing-npm/src/app.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | console.log('installing-npm example works')
20 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/native/native.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Native
6 |
13 |
14 | <%- renderAgent({debug: true}) %>
15 |
16 |
22 |
23 |
24 |
Native
25 |
26 |
27 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/type-guards/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './primitive-types'
19 |
--------------------------------------------------------------------------------
/examples/installing-npm/src/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import './instrumentation.js'
20 | import './app.js'
21 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/synthetics/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Splunk Synthetics integration
6 |
7 |
11 | <%- renderAgent() %>
12 |
13 |
14 |
11 |
12 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/packages/web/src/otel-api-globals.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export { context, trace } from '@opentelemetry/api'
20 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/api/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './api-error'
19 | export * from './api-fetch'
20 |
--------------------------------------------------------------------------------
/turbo.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://turbo.build/schema.json",
3 | "globalDependencies": ["package.json", "pnpm-lock.yaml", "tsconfig.json", "eslint.config.js"],
4 | "tasks": {
5 | "build": {
6 | "cache": true,
7 | "dependsOn": ["clean", "^build"],
8 | "outputs": ["dist/**", ".next/**", "tests/project/dist/**"]
9 | },
10 | "dev": {
11 | "cache": false,
12 | "persistent": true,
13 | "dependsOn": ["^wait"]
14 | },
15 | "clean": {
16 | "cache": false
17 | },
18 | "//#test:unit": {
19 | "cache": false,
20 | "dependsOn": ["@splunk/rum-build-plugins#build"]
21 | },
22 | "test:e2e": {
23 | "cache": false,
24 | "dependsOn": ["^build"]
25 | },
26 | "wait": {
27 | "cache": false
28 | }
29 | },
30 | "ui": "tui"
31 | }
32 |
--------------------------------------------------------------------------------
/packages/web/src/managers/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export * from './session-manager'
20 | export * from './storage'
21 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/errors/views/module.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | const variable = 1
19 |
20 | export default variable
21 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/resource-observer/assets/test-alt.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | /* eslint-disable unicorn/no-empty-file */
19 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/resource-observer/assets/test.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | /* eslint-disable unicorn/no-empty-file */
20 |
--------------------------------------------------------------------------------
/packages/web/src/managers/storage/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export * from './constants'
20 | export * from './storage-manager'
21 |
--------------------------------------------------------------------------------
/packages/web/src/types/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './config'
19 | export * from './type-guards'
20 | export * from './window'
21 |
--------------------------------------------------------------------------------
/packages/web/src/types/type-guards/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './error'
19 | export * from './node'
20 | export * from './string'
21 |
--------------------------------------------------------------------------------
/examples/nextjs/app/globals.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --background: #ffffff;
3 | --foreground: #171717;
4 | }
5 |
6 | @media (prefers-color-scheme: dark) {
7 | :root {
8 | --background: #0a0a0a;
9 | --foreground: #ededed;
10 | }
11 | }
12 |
13 | html,
14 | body {
15 | max-width: 100vw;
16 | overflow-x: hidden;
17 | }
18 |
19 | body {
20 | color: var(--foreground);
21 | background: var(--background);
22 | font-family: Arial, Helvetica, sans-serif;
23 | -webkit-font-smoothing: antialiased;
24 | -moz-osx-font-smoothing: grayscale;
25 | }
26 |
27 | * {
28 | box-sizing: border-box;
29 | padding: 0;
30 | margin: 0;
31 | }
32 |
33 | a {
34 | color: inherit;
35 | text-decoration: none;
36 | }
37 |
38 | @media (prefers-color-scheme: dark) {
39 | html {
40 | color-scheme: dark;
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/examples/todolist/README.md:
--------------------------------------------------------------------------------
1 | # Example todo application with a node.js backend
2 |
3 | This example todo application consists of React frontend app and express backend app.
4 |
5 | ## Try it yourself!
6 |
7 | After downloading this folder:
8 |
9 | 1. If you don't have one already [make a trial account to try out Splunk Observability Cloud](https://www.splunk.com/en_us/observability/o11y-cloud-free-trial.html)
10 | 2. Run `pnpm install`
11 | 3. Copy `.env.example` to `.env`
12 | 4. Fill out `PUBLIC_REACT_APP_RUM_*` with your ingest URL and RUM token
13 | 5. Start backend with `pnpm run backend`
14 | 6. Start frontend with `pnpm run start`
15 |
16 | Frontend instrumentation is done in `public/index.html` which is loaded at document load. It also demonstrates a few configuration options you can use.
17 |
--------------------------------------------------------------------------------
/packages/web/src/utils/is-safari.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export const isSafari = () => /^((?!chrome|android).)*safari/i.test(navigator.userAgent)
20 |
--------------------------------------------------------------------------------
/packages/web/src/version.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | // this is an autogenerated file, see scripts/version-update.js
20 | export const VERSION = '1.2.0'
21 |
--------------------------------------------------------------------------------
/packages/build-plugins/src/version.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | // this is an autogenerated file, see scripts/version-update.js
20 | export const VERSION = '1.2.0'
21 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/errors/views/console-error.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Errors test
6 | <%- renderAgent({}) %>
7 |
22 |
23 |
24 |
Manual console.error
25 |
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/version.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | // this is an autogenerated file, see scripts/version-update.js
20 | export const VERSION = '1.2.0'
21 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/session-replay/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './cdn-module'
19 | export * from './config'
20 | export * from './recorder'
21 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/version.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | // this is an autogenerated file, see scripts/version-update.js
20 | export const VERSION = '1.2.0'
21 |
--------------------------------------------------------------------------------
/packages/web/src/utils/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './detect-latest'
19 | export * from './text'
20 | export * from './traverse'
21 | export * from './url'
22 |
--------------------------------------------------------------------------------
/packages/web/src/upstream/user-interaction/version.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | // this is autogenerated file, see scripts/version-update.js
20 | export const VERSION = '0.34.0'
21 |
--------------------------------------------------------------------------------
/examples/todolist/server/instrumentation.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { start } from '@splunk/otel'
20 |
21 | start({
22 | serviceName: 'RUM Todo Example Backend',
23 | })
24 |
--------------------------------------------------------------------------------
/packages/web/src/managers/session-manager/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export * from './constants'
20 | export * from './session-manager'
21 | export * from './session-state'
22 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://json.schemastore.org/tsconfig",
3 | "compilerOptions": {
4 | "baseUrl": ".",
5 | "moduleResolution": "NodeNext",
6 | "noImplicitAny": true,
7 | "module": "NodeNext",
8 | "target": "esnext",
9 | "inlineSourceMap": true,
10 | "inlineSources": true,
11 | "strict": true,
12 | "lib": ["ESNext", "DOM"],
13 | "declaration": true,
14 | "downlevelIteration": false,
15 | "skipLibCheck": true,
16 | "experimentalDecorators": true,
17 | "incremental": true,
18 | "noEmit": true,
19 | "allowJs": true,
20 | "esModuleInterop": true
21 | },
22 | "include": [
23 | "*.ts",
24 | "*.js",
25 | "*.cjs",
26 | ".*.cjs",
27 | "*.mjs",
28 | "*.mts",
29 | "tests/**/*.ts",
30 | "scripts/**/*.ts",
31 | "scripts/**/*.mts"
32 | ],
33 | "exclude": ["node_modules", "dist"]
34 | }
35 |
--------------------------------------------------------------------------------
/examples/todolist/index.d.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { SplunkRum } from '@splunk/otel-web'
19 |
20 | declare global {
21 | interface Window {
22 | SplunkRum: typeof SplunkRum
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/docload/docload-all.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Test docload
6 |
7 | <%- renderAgent({
8 | bufferTimeout: 200
9 | }) %>
10 |
11 |
12 |
13 |
Docload
14 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/server/middlewares/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './delay-middleware'
19 | export * from './no-cache-middleware'
20 | export * from './server-timing-middleware'
21 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/errors/views/minified-file-errors.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Errors test
6 | <%- renderAgent({}) %>
7 |
8 |
9 |
Minified files with source map ids
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/.prettierrc.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | module.exports = {
19 | printWidth: 120,
20 | quoteProps: 'consistent',
21 | semi: false,
22 | singleQuote: true,
23 | trailingComma: 'all',
24 | useTabs: true,
25 | }
26 |
--------------------------------------------------------------------------------
/examples/installing-npm/rsbuild.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { defineConfig } from '@rsbuild/core'
19 |
20 | export default defineConfig({
21 | html: {
22 | template: './index.html',
23 | },
24 | })
25 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/log/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export { log } from './logger'
19 | export type { LogLevel, LogSource } from './types'
20 |
21 | export { createNamedLog, isLogLevel } from './utils'
22 |
--------------------------------------------------------------------------------
/packages/web/src/managers/storage/providers/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export * from './base-storage-provider'
20 | export * from './cookie-storage-provider'
21 | export * from './local-storage-provider'
22 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/location-hash.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | location.hash
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
location.hash
15 |
16 |
17 |
18 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/packages/web/src/types/type-guards/string.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export const hasToString = (val: unknown): val is { toString: () => string } =>
19 | !!val && typeof (val as { toString?: unknown }).toString === 'function'
20 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/xhr-onload.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | XHR - events
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
11 |
12 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/webpack.config.without-plugin.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | const { getBaseConfig } = require('./webpack-utils')
19 |
20 | module.exports = {
21 | ...getBaseConfig(__filename),
22 | devtool: 'source-map',
23 | }
24 |
--------------------------------------------------------------------------------
/scripts/utils/arguments.mts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export const getPositionalArguments = () =>
19 | process.argv.filter(
20 | (arg, i) =>
21 | // Skip the first two args (node and script), and any flags
22 | i >= 2 && !arg.startsWith('-'),
23 | )
24 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/framework/vue2.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Vue 2
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
15 |
16 |
11 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/packages/web/tests/utils/index.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './init'
19 | export * from './memory-exporter'
20 | export * from './navigator'
21 | export * from './span'
22 | export * from './span-capturer'
23 | export * from './web-tracer-provider'
24 |
--------------------------------------------------------------------------------
/packages/web/src/index-browser.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { SplunkOtelWebType } from './index'
20 |
21 | declare global {
22 | interface Window {
23 | SplunkRum: SplunkOtelWebType | undefined
24 | }
25 | }
26 |
27 | export { default } from './index'
28 |
--------------------------------------------------------------------------------
/packages/web/src/upstream/user-interaction/enums/attribute-names.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export enum AttributeNames {
20 | EVENT_TYPE = 'event_type',
21 | TARGET_ELEMENT = 'target_element',
22 | TARGET_XPATH = 'target_xpath',
23 | HTTP_URL = 'http.url',
24 | }
25 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/errors/views/splunkrum-reporterror.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Errors test
6 | <%- renderAgent({}) %>
7 |
27 |
28 |
29 |
Manual console.error
30 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/packages/web/src/managers/storage/constants.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { SESSION_INACTIVITY_TIMEOUT_MS } from '../session-manager'
20 |
21 | export const SESSION_STORAGE_KEY = '_splunk_rum_sid'
22 | export const SESSION_EXPIRATION_COOKIE_SEC = SESSION_INACTIVITY_TIMEOUT_MS / 1000
23 |
--------------------------------------------------------------------------------
/packages/web/src/utils/url.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export const isExtensionUrl = (url: string): boolean =>
19 | ['chrome-extension://', 'moz-extension://'].some((extensionPrefix) => url.startsWith(extensionPrefix))
20 |
21 | export const isBlobUrl = (url: string) => url.startsWith('blob:')
22 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/resource-observer/resources-twice.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Resource observer test
6 | <%- renderAgent() %>
7 |
8 |
9 |
Resource observer test
10 |
11 |
12 |
13 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: Continuous Integration
2 | on:
3 | pull_request:
4 | types: [opened, synchronize]
5 | push:
6 | branches: [main]
7 | tags: [v*]
8 |
9 | permissions: read-all
10 |
11 | jobs:
12 | build:
13 | name: Build
14 | runs-on: ubuntu-latest
15 | permissions: read-all
16 | steps:
17 | - name: Checkout
18 | uses: actions/checkout@v6.0.0
19 |
20 | - name: Setup
21 | uses: ./.github/actions/setup
22 |
23 | - run: pnpm run version:check
24 |
25 | - name: Size check
26 | run: npm run size-limit
27 |
28 | - name: Lint code
29 | run: pnpm run lint
30 |
31 | - name: Lint docs
32 | run: pnpm run lint:markdown
33 |
34 | tests:
35 | name: Tests
36 | uses: ./.github/workflows/tests.yml
37 | secrets: inherit
38 |
--------------------------------------------------------------------------------
/packages/web/src/upstream/user-interaction/internal-types.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { HrTime } from '@opentelemetry/api'
20 |
21 | /**
22 | * interface to store information in weak map per span
23 | */
24 | export interface SpanData {
25 | hrTimeLastTimeout?: HrTime
26 | taskCount: number
27 | }
28 |
--------------------------------------------------------------------------------
/packages/web/tests/utils/web-tracer-provider.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { SplunkWebTracerProvider } from '../../src/splunk-web-tracer-provider'
19 |
20 | export const createWebTracerProvider = (params?: ConstructorParameters[0]) =>
21 | new SplunkWebTracerProvider(params)
22 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/resource-observer/resources-twice-no-cache.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Resource observer test
6 | <%- renderAgent() %>
7 |
8 |
9 |
Resource observer test
10 |
11 |
12 |
13 |
31 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | # Description
2 |
3 | _Replace this with a description of the PR. Explain the problem it solves and the proposed solution._
4 |
5 | _List Github issue(s) which this PR fixes._
6 |
7 | ## Type of change
8 |
9 | Delete options that are not relevant.
10 |
11 | - Bug fix (non-breaking change which fixes an issue)
12 | - New feature (non-breaking change which adds functionality)
13 | - Breaking change (fix or feature that would cause existing functionality to not work as expected)
14 | - Chore or internal change (changes not visible to the consumers of the package)
15 | - Documentation update
16 |
17 | # How has this been tested?
18 |
19 | Delete options that are not relevant.
20 |
21 | - Manual testing
22 | - Added unit tests
23 | - Added integration tests
24 |
25 |
32 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/long-task/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Longtask tracking test
6 | <%- renderAgent() %>
7 |
8 |
9 |
23 |
24 |
40 |
41 |
--------------------------------------------------------------------------------
/packages/web/src/managers/session-manager/constants.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export const SESSION_ID_LENGTH = 32
19 | export const SESSION_DURATION_SECONDS = 4 * 60 * 60 // 4 hours
20 | export const SESSION_DURATION_MS = SESSION_DURATION_SECONDS * 1000
21 | export const SESSION_INACTIVITY_TIMEOUT_MS = 15 * 60 * 1000 // 15 minutes
22 |
--------------------------------------------------------------------------------
/packages/web/src/synthetics.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | declare global {
20 | interface Window {
21 | syntheticsRunId: string | undefined
22 | }
23 | }
24 |
25 | export const SYNTHETICS_RUN_ID_ATTRIBUTE = 'Synthetics-RunId'
26 |
27 | export function getSyntheticsRunId(): string | undefined {
28 | return window.syntheticsRunId
29 | }
30 |
--------------------------------------------------------------------------------
/vitest.config.debug.mts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { defineConfig } from 'vitest/config'
19 |
20 | import config from './vitest.config.mjs'
21 |
22 | export default defineConfig({
23 | test: {
24 | ...config.test,
25 | browser: {
26 | ...config.test?.browser,
27 | instances: [{ browser: 'chromium' }],
28 | },
29 | },
30 | })
31 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/xhr-events.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | XHR - events
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
XHR - events
15 |
16 |
17 |
18 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/examples/electron/src/renderer.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | // IMPORTANT: Import instrumentation first, before any other imports
20 | // This ensures RUM agent is initialized before any user code runs
21 | import './instrumentation'
22 | import './index.css'
23 |
24 | console.log('👋 This message is being logged by "renderer.js", included via webpack')
25 |
--------------------------------------------------------------------------------
/packages/web/src/types/type-guards/error.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export const isError = (maybeError: unknown): maybeError is Error =>
19 | maybeError !== null &&
20 | typeof maybeError === 'object' &&
21 | (maybeError instanceof Error ||
22 | maybeError.constructor.name?.endsWith('Error') ||
23 | maybeError.constructor.name?.endsWith('Exception'))
24 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/fetch/fetch-post.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | FETCH post
6 |
7 | <%- renderAgent({debug: true}) %>
8 |
9 |
10 |
23 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/packages/web/src/managers/session-manager/session-state.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export type SessionState = {
20 | expiresAt: number
21 | id: string
22 | startTime: number
23 | state: 'active' | 'native' | 'expired-inactivity' | 'expired-duration'
24 | }
25 |
26 | export type PersistedSessionState = Pick
27 |
--------------------------------------------------------------------------------
/packages/web/src/utils/is-trusted-event.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export const isTrustedEvent = (eventToCheck: Event): boolean => {
20 | // Some old browsers do not have this property
21 | // See more at:
22 | // https://caniuse.com/?search=isTrusted
23 | if (eventToCheck.isTrusted === undefined) {
24 | return true
25 | }
26 |
27 | return eventToCheck.isTrusted
28 | }
29 |
--------------------------------------------------------------------------------
/.github/actions/setup/action.yml:
--------------------------------------------------------------------------------
1 | name: 'Setup'
2 | description: 'Checkout repository, setup node, install deps, build'
3 | runs:
4 | using: 'composite'
5 | steps:
6 | - name: Cache turbo build output
7 | uses: actions/cache@v4.2.3
8 | with:
9 | path: .turbo
10 | key: '${{ runner.os }}-turbo-${{ github.sha }}'
11 | restore-keys: |
12 | ${{ runner.os }}-turbo-
13 |
14 | - name: Install pnpm
15 | uses: pnpm/action-setup@v4.1.0
16 | with:
17 | version: 10.20.0
18 |
19 | - name: Setup
20 | uses: actions/setup-node@v4.3.0
21 | with:
22 | node-version: 24.11.0
23 | registry-url: 'https://registry.npmjs.org'
24 | cache: 'pnpm'
25 |
26 | - name: Install deps
27 | shell: bash
28 | run: pnpm install --frozen-lockfile
29 |
30 | - name: Build
31 | shell: bash
32 | run: pnpm run build
33 |
--------------------------------------------------------------------------------
/examples/nextjs/public/globe.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/src/other-entry.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { otherHelperFunction, sharedHelperFunction } from './common/helpers'
19 |
20 | const result = sharedHelperFunction(1, 2)
21 | otherHelperFunction(result)
22 |
23 | window.globalFunctionFromOtherEntry = function () {
24 | console.log('executing function in other-entry.js', otherHelperFunction(5))
25 | }
26 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/messageport-onmessage.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MessagePort - onmessage
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/scripts/utils/index.mts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export * from './arguments.mjs'
19 | export * from './cf-invalidation.mjs'
20 | export * from './generate-release-links.mjs'
21 | export * from './generate-script-snippet.mjs'
22 | export * from './get-package-roots.mjs'
23 | export * from './github.mjs'
24 | export * from './mimetypes.mjs'
25 | export * from './upload-to-s3.mjs'
26 | export * from './versions.mjs'
27 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/user-interaction/mouse.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Mouse events test
6 | <%- renderAgent() %>
7 |
8 |
9 |
10 |
Mouse events test
11 |
12 |
13 |
18 |
19 |
20 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/packages/web/src/utils/iframe.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export const safelyAccessFrameElementFromDocument = (documentNode: Document) => {
20 | let frameElement = null
21 | try {
22 | frameElement = documentNode.defaultView?.frameElement ?? null
23 | } catch {
24 | // Accessing frameElement from cross-origin iframe might throw Access Denied error in some browsers
25 | }
26 |
27 | return frameElement
28 | }
29 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/messageport-addeventlistener.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MessagePort - addEventListener
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
23 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/webpack.config.without-source-maps-options.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | const { SplunkRumWebpackPlugin } = require('@splunk/rum-build-plugins')
19 |
20 | const { getBaseConfig } = require('./webpack-utils')
21 |
22 | module.exports = {
23 | ...getBaseConfig(__filename),
24 | plugins: [
25 | new SplunkRumWebpackPlugin({
26 | applicationName: 'sample-app',
27 | version: '0.1.0',
28 | }),
29 | ],
30 | }
31 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/log/types.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export type LogSource = 'console' | 'internal'
19 |
20 | export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'critical'
21 |
22 | export type MiddlewareFunction = (source: LogSource, level: LogLevel, message: string, ...data: unknown[]) => void
23 |
24 | export enum LogLevelNumber {
25 | DEBUG = 0,
26 | INFO = 1,
27 | WARN = 2,
28 | ERROR = 3,
29 | CRITICAL = 4,
30 | }
31 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/xhr/xhr-ignored.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Ignore urls
6 |
7 | <%- renderAgent({}, true) %>
8 |
13 |
14 |
15 |
Ignore urls test
16 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/packages/web/tests/utils/span.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { Span } from '@opentelemetry/api'
19 |
20 | import { createWebTracerProvider } from './web-tracer-provider'
21 |
22 | export const createSpan = (name: string) => {
23 | const webTracerProvider = createWebTracerProvider()
24 | const tracer = webTracerProvider.getTracer('test')
25 | const span = tracer.startSpan(name)
26 |
27 | return span as Span & { attributes: Record }
28 | }
29 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/socketio/socketio.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Socket.io
6 |
7 | <%- renderAgent({instrumentations: {socketio: true}}) %>
8 |
9 |
10 |
12 |
13 |
14 |
15 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/webpack-utils.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | const path = require('node:path')
19 | module.exports = {
20 | getBaseConfig: (configFilename) => ({
21 | entry: {
22 | main: './src/index.js',
23 | other: './src/other-entry.js',
24 | },
25 | mode: 'production',
26 | output: {
27 | filename: '[name].js',
28 | path: path.resolve(__dirname, 'dist/' + path.basename(configFilename).replaceAll('.', '-')),
29 | },
30 | }),
31 | }
32 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/user-interaction/keyboard.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Keyboard events test
6 | <%- renderAgent({
7 | instrumentations: {
8 | interactions: {
9 | events: {
10 | keydown: true,
11 | keyup: true
12 | }
13 | }
14 | }
15 | }) %>
16 |
17 |
18 |
Keyboard events test
19 |
20 |
21 |
22 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/examples/todolist/rsbuild.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { defineConfig } from '@rsbuild/core'
19 | import { pluginReact } from '@rsbuild/plugin-react'
20 |
21 | export default defineConfig({
22 | html: {
23 | template: './public/index.html',
24 | templateParameters: {
25 | PUBLIC_REACT_APP_RUM_BEACON_URL: process.env.PUBLIC_REACT_APP_RUM_BEACON_URL,
26 | PUBLIC_REACT_APP_RUM_TOKEN: process.env.PUBLIC_REACT_APP_RUM_TOKEN,
27 | },
28 | },
29 | plugins: [pluginReact()],
30 | })
31 |
--------------------------------------------------------------------------------
/examples/todolist/src/index.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { StrictMode } from 'react'
20 | import { createRoot } from 'react-dom/client'
21 |
22 | import App from './app'
23 |
24 | const container = document.querySelector('#root')
25 |
26 | if (!container) {
27 | throw new Error('No container element found')
28 | }
29 |
30 | const root = createRoot(container) // createRoot(container!) if you use TypeScript
31 | root.render(
32 |
33 |
34 | ,
35 | )
36 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/src/common/helpers.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export function sharedHelperFunction(value1, value2) {
19 | const result = value1 + value2
20 | return result
21 | }
22 |
23 | export function sharedHelperFunctionThatThrowsError() {
24 | /* eslint-disable no-undef */
25 | return thisFunctionDoesNotExist()
26 | }
27 |
28 | // eslint-disable-next-line unicorn/prefer-native-coercion-functions
29 | export function otherHelperFunction(value) {
30 | return String(value)
31 | }
32 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 |
3 | updates:
4 | - package-ecosystem: 'npm'
5 | directory: '/'
6 | schedule:
7 | interval: 'monthly'
8 | open-pull-requests-limit: 10
9 | groups:
10 | size-limit:
11 | patterns:
12 | - '@size-limit/*'
13 | - 'size-limit*'
14 | playwright:
15 | patterns:
16 | - '@playwright/*'
17 | - 'playwright*'
18 | eslint:
19 | patterns:
20 | - '@eslint/*'
21 | - '*eslint*'
22 | vitest:
23 | patterns:
24 | - '@vitest/*'
25 | - 'vitest*'
26 | react:
27 | patterns:
28 | - 'react'
29 | - 'react-dom'
30 | opentelemetry:
31 | patterns:
32 | - '@opentelemetry/*'
33 | rsbuild:
34 | patterns:
35 | - '@rsbuild/*'
36 |
37 | - package-ecosystem: 'github-actions'
38 | directory: '/'
39 | schedule:
40 | interval: 'monthly'
41 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/mutation-observer-textnode.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Mutation Observer - textNode
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
Mutation Observer - textNode
15 |
16 |
17 |
18 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/session-replay/config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { mergeRecorderConfig } from './migrations/config-merge'
19 | import { migrateRRWebConfigToSplunkConfig } from './migrations/config-migration'
20 | import { RecorderPublicConfig } from './recorder'
21 |
22 | export const getSplunkRecorderConfig = (config: RecorderPublicConfig): RecorderPublicConfig => {
23 | const migratedRRWebConfig = migrateRRWebConfigToSplunkConfig(config)
24 | return mergeRecorderConfig(config, migratedRRWebConfig)
25 | }
26 |
--------------------------------------------------------------------------------
/packages/web/tests/utils.test.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { describe, expect, it } from 'vitest'
20 |
21 | import { generateId } from '../src/utils'
22 |
23 | describe('generateId', () => {
24 | it('should generate IDs of 64 and 128 bits', () => {
25 | const id64 = generateId(64)
26 | const id128 = generateId(128)
27 | expect(id64.length).toBe(16)
28 | expect(id128.length).toBe(32)
29 | expect(id64.match('^[0-9a-z]+$')).toBeTruthy()
30 | expect(id128.match('^[0-9a-z]+$')).toBeTruthy()
31 | })
32 | })
33 |
--------------------------------------------------------------------------------
/examples/electron/webpack.renderer.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import type { Configuration } from 'webpack'
19 |
20 | import { plugins } from './webpack.plugins'
21 | import { rules } from './webpack.rules'
22 |
23 | rules.push({
24 | test: /\.css$/,
25 | use: [{ loader: 'style-loader' }, { loader: 'css-loader' }],
26 | })
27 |
28 | export const rendererConfig: Configuration = {
29 | module: {
30 | rules,
31 | },
32 | plugins,
33 | resolve: {
34 | extensions: ['.js', '.ts', '.jsx', '.tsx', '.css'],
35 | },
36 | }
37 |
--------------------------------------------------------------------------------
/examples/electron/webpack.plugins.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import Dotenv from 'dotenv-webpack'
19 | import type IForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
20 | const ForkTsCheckerWebpackPlugin: typeof IForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin')
21 |
22 | export const plugins = [
23 | new ForkTsCheckerWebpackPlugin({
24 | logger: 'webpack-infrastructure',
25 | }),
26 | new Dotenv({
27 | defaults: false,
28 | path: '.env',
29 | safe: false,
30 | silent: false,
31 | }),
32 | ]
33 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/xhr-events-removed.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | XHR - events
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
XHR - events
15 |
16 |
17 |
18 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/packages/web/src/utils/detect-latest.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { isScriptElement } from '../types'
19 |
20 | export const isAgentLoadedViaLatestTag = () => {
21 | let isLatestTagUsed = false
22 | try {
23 | if (document.currentScript && isScriptElement(document.currentScript)) {
24 | const src = document.currentScript.src
25 | // Check for "latest" version in CDN URL
26 | isLatestTagUsed = /\/o11y-gdi-rum\/latest\//i.test(src)
27 | }
28 | } catch {
29 | // ignore
30 | }
31 |
32 | return isLatestTagUsed
33 | }
34 |
--------------------------------------------------------------------------------
/tests/servers/socket-io.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { Server } from 'socket.io'
19 |
20 | export const initSocketIo = () => {
21 | const io = new Server({
22 | cors: {
23 | origin: true,
24 | },
25 | })
26 |
27 | io.on('connection', (socket) => {
28 | socket.on('hello', () => {
29 | // Does nothing
30 | })
31 |
32 | socket.on('ping', (...args) => {
33 | socket.emit('pong', ...args)
34 | })
35 | })
36 |
37 | io.listen(8980)
38 |
39 | return () => new Promise((resolve) => io.close(() => resolve()))
40 | }
41 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/webpack.config.no-source-maps.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | const { SplunkRumWebpackPlugin } = require('@splunk/rum-build-plugins')
19 |
20 | const { getBaseConfig } = require('./webpack-utils')
21 |
22 | module.exports = {
23 | ...getBaseConfig(__filename),
24 | plugins: [
25 | new SplunkRumWebpackPlugin({
26 | applicationName: 'sample-app',
27 | sourceMaps: {
28 | disableUpload: true,
29 | realm: 'us0',
30 | token: '',
31 | },
32 | version: '0.1.0',
33 | }),
34 | ],
35 | }
36 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/messageport-cors.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MessagePort Iframe
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
22 |
23 |
32 |
33 |
34 |
--------------------------------------------------------------------------------
/packages/web/src/utils/parse-version.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export function parseVersion(version: string): {
20 | exactVersion: string
21 | majorVersion: string
22 | minorVersion: string
23 | } {
24 | // Remove prerelease tags like -beta.0, -alpha.5, -rc.1, etc.
25 | const cleanVersion = version.split('-')[0]
26 | const versionParts = cleanVersion.split('.')
27 |
28 | return {
29 | exactVersion: `v${cleanVersion}`,
30 | majorVersion: `v${versionParts[0]}`,
31 | minorVersion: `v${versionParts[0]}.${versionParts[1]}`,
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/errors/views/script1.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | document.querySelector('#button1').addEventListener('click', function () {
20 | throw new Error('Error from script1.js')
21 | })
22 | window.sourceMapIds = window.sourceMapIds || {}
23 | let s = ''
24 | try {
25 | throw new Error('error')
26 | } catch (error) {
27 | s = (error.stack.match(/https?:\/\/[^\s]+?(?::\d+)?(?=:[\d]+:[\d]+)/) || [])[0]
28 | }
29 | if (s) {
30 | window.sourceMapIds[s] = '9663c60664c425cef3b141c167e9b324240ce10ae488726293892b7130266a6b'
31 | }
32 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/errors/views/script2.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | document.querySelector('#button2').addEventListener('click', function () {
20 | throw new Error('Error from script2.js')
21 | })
22 | window.sourceMapIds = window.sourceMapIds || {}
23 | let s = ''
24 | try {
25 | throw new Error('error')
26 | } catch (error) {
27 | s = (error.stack.match(/https?:\/\/[^\s]+?(?::\d+)?(?=:[\d]+:[\d]+)/) || [])[0]
28 | }
29 | if (s) {
30 | window.sourceMapIds[s] = '9793573cdc2ab308a0b1996bea14253ec8832bc036210475ded0813cafa27066'
31 | }
32 |
--------------------------------------------------------------------------------
/.size-limit.cjs:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | module.exports = [
19 | {
20 | limit: '3 kB',
21 | name: 'artifacts/otel-api-globals.js',
22 | path: './packages/web/dist/artifacts/otel-api-globals.js',
23 | },
24 |
25 | {
26 | limit: '81 kB',
27 | name: 'artifacts/splunk-otel-web.js',
28 | path: './packages/web/dist/artifacts/splunk-otel-web.js',
29 | },
30 |
31 | {
32 | limit: '109 kB',
33 | name: 'artifacts/splunk-otel-web-session-recorder.js',
34 | path: './packages/session-recorder/dist/artifacts/splunk-otel-web-session-recorder.js',
35 | },
36 | ]
37 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/webpack.config.devtool.eval.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | const { SplunkRumWebpackPlugin } = require('@splunk/rum-build-plugins')
19 |
20 | const { getBaseConfig } = require('./webpack-utils')
21 |
22 | module.exports = {
23 | ...getBaseConfig(__filename),
24 | devtool: 'eval',
25 | plugins: [
26 | new SplunkRumWebpackPlugin({
27 | applicationName: 'sample-app',
28 | sourceMaps: {
29 | disableUpload: true,
30 | realm: 'us0',
31 | token: '',
32 | },
33 | version: '0.1.0',
34 | }),
35 | ],
36 | }
37 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/detect-latest.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { isScriptElement } from './type-guards'
19 |
20 | export const isRecorderLoadedViaLatestTag = () => {
21 | let isLatestTagUsed = false
22 | try {
23 | if (document.currentScript && isScriptElement(document.currentScript)) {
24 | const src = document.currentScript.src
25 | // Check for "latest" version in CDN URL for session recorder
26 | isLatestTagUsed = /\/o11y-gdi-rum\/latest\//i.test(src)
27 | }
28 | } catch {
29 | // ignore
30 | }
31 |
32 | return isLatestTagUsed
33 | }
34 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/webpack.config.devtool.source-map.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | const { SplunkRumWebpackPlugin } = require('@splunk/rum-build-plugins')
19 |
20 | const { getBaseConfig } = require('./webpack-utils')
21 |
22 | module.exports = {
23 | ...getBaseConfig(__filename),
24 | devtool: 'source-map',
25 | plugins: [
26 | new SplunkRumWebpackPlugin({
27 | applicationName: 'sample-app',
28 | sourceMaps: {
29 | disableUpload: true,
30 | realm: 'us0',
31 | token: '',
32 | },
33 | version: '0.1.0',
34 | }),
35 | ],
36 | }
37 |
--------------------------------------------------------------------------------
/examples/todolist/src/app.tsx:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { useEffect } from 'react'
20 |
21 | import { TodoList } from './todo-list'
22 |
23 | function App() {
24 | useEffect(() => {
25 | const interval = setInterval(() => {
26 | void fetch(process.env.PUBLIC_REACT_APP_BACKEND + '/ping')
27 | }, 60_000)
28 |
29 | return () => {
30 | clearInterval(interval)
31 | }
32 | })
33 |
34 | return (
35 |
36 |
Great Todo App!
37 |
38 |
39 | )
40 | }
41 |
42 | export default App
43 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/server/middlewares/no-cache-middleware.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { FastifyReply, FastifyRequest } from 'fastify'
20 |
21 | export const noCacheMiddleware = (
22 | req: FastifyRequest<{ Querystring: { noCache?: string } }>,
23 | reply: FastifyReply,
24 | payload: unknown,
25 | done: (err?: Error) => void,
26 | ) => {
27 | if (typeof req.query.noCache === 'string') {
28 | reply.header('Cache-Control', 'no-store, max-age=0')
29 | reply.removeHeader('Etag')
30 | reply.removeHeader('Last-Modified')
31 | }
32 |
33 | done()
34 | }
35 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/src/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { sharedHelperFunction, sharedHelperFunctionThatThrowsError } from './common/helpers'
19 |
20 | function globalFunction() {
21 | const value1 = 1
22 | const value2 = 2
23 | console.log('running index.js of the build-plugins sample project', sharedHelperFunction(value1, value2))
24 | }
25 |
26 | function globalFunctionThatThrowsError() {
27 | sharedHelperFunctionThatThrowsError()
28 | }
29 |
30 | window.globalFunction = globalFunction
31 | window.globalFunctionThatThrowsError = globalFunctionThatThrowsError
32 |
--------------------------------------------------------------------------------
/packages/build-plugins/tests/project/webpack.config.devtool.hidden-source-map.js:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | const { SplunkRumWebpackPlugin } = require('@splunk/rum-build-plugins')
19 |
20 | const { getBaseConfig } = require('./webpack-utils')
21 |
22 | module.exports = {
23 | ...getBaseConfig(__filename),
24 | devtool: 'hidden-source-map',
25 | plugins: [
26 | new SplunkRumWebpackPlugin({
27 | applicationName: 'sample-app',
28 | sourceMaps: {
29 | disableUpload: true,
30 | realm: 'us0',
31 | token: '',
32 | },
33 | version: '0.1.0',
34 | }),
35 | ],
36 | }
37 |
--------------------------------------------------------------------------------
/packages/web/src/utils/hash.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | export async function hashSHA256(key: string): Promise {
20 | if (typeof crypto === 'undefined' || !crypto.subtle || !crypto.subtle.digest) {
21 | return null
22 | }
23 |
24 | try {
25 | const encoder = new TextEncoder()
26 | const data = encoder.encode(key)
27 | const hashBuffer = await crypto.subtle.digest('SHA-256', data)
28 | const hashArray = Array.from(new Uint8Array(hashBuffer))
29 | return hashArray.map((b) => b.toString(16).padStart(2, '0')).join('')
30 | } catch {
31 | return null
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/server/utils.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | // dummy function that just takes template literals and return them back without any modification
19 | // the reason behind this is to imitate behaviour of css/html in js so the IDE properly highlights syntax
20 | const dummyTemplate = (strings: TemplateStringsArray, ...keys: string[]): string => {
21 | const result = [strings[0]]
22 | keys.forEach(function (key, i) {
23 | result.push(key, strings[i + 1])
24 | })
25 | return result.join('')
26 | }
27 |
28 | export const css = dummyTemplate
29 | export const html = dummyTemplate
30 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/user-interaction/causality.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Mouse events test
6 |
7 | <%- renderAgent({
8 | instrumentations: {
9 | webvitals: false
10 | }
11 | }) %>
12 |
13 |
14 |
Mouse events test
15 |
16 |
17 |
18 |
19 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/packages/web/tests/utils/span-capturer.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { ReadableSpan, SpanProcessor } from '@opentelemetry/sdk-trace-base'
20 |
21 | export class SpanCapturer implements SpanProcessor {
22 | public readonly spans: ReadableSpan[] = []
23 |
24 | clear(): void {
25 | this.spans.length = 0
26 | }
27 |
28 | forceFlush(): Promise {
29 | return Promise.resolve()
30 | }
31 |
32 | onEnd(span: ReadableSpan): void {
33 | this.spans.push(span)
34 | }
35 |
36 | onStart(): void {}
37 |
38 | shutdown(): Promise {
39 | return Promise.resolve()
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/scripts/utils/mimetypes.mts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | const mimetypes: Record = {
20 | '.html': 'text/html',
21 | '.js': 'application/javascript',
22 | '.js.map': 'application/octet-stream',
23 | '.tgz': 'application/x-gtar',
24 | '.txt': 'text/plain',
25 | }
26 |
27 | export const getMimeType = (filename: string) => {
28 | const sortedExtensions = Object.keys(mimetypes).toSorted((a, b) => b.length - a.length)
29 | for (const ext of sortedExtensions) {
30 | if (filename.endsWith(ext)) {
31 | return mimetypes[ext]
32 | }
33 | }
34 | return 'application/octet-stream'
35 | }
36 |
--------------------------------------------------------------------------------
/.github/workflows/cla.yml:
--------------------------------------------------------------------------------
1 | name: 'CLA Assistant'
2 | on:
3 | issue_comment:
4 | types: [created]
5 | pull_request_target:
6 | types: [opened, closed, synchronize]
7 |
8 | permissions:
9 | actions: write
10 | contents: read
11 | pull-requests: write
12 | statuses: write
13 |
14 | jobs:
15 | ContributorLicenseAgreement:
16 | runs-on: ubuntu-latest
17 | steps:
18 | - name: 'CLA Assistant'
19 | if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the CLA Document and I hereby sign the CLA') || github.event_name == 'pull_request_target'
20 | uses: cla-assistant/github-action@v2.6.1
21 | env:
22 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 | PERSONAL_ACCESS_TOKEN: ${{ secrets.PAT_CLATOOL }}
24 | with:
25 | remote-organization-name: splunk
26 | remote-repository-name: cla-agreement
27 | branch: main
28 | path-to-signatures: signatures/version1/cla.json
29 | path-to-document: https://github.com/splunk/cla-agreement/blob/main/CLA.md
30 | allowlist: dependabot[bot]
31 |
--------------------------------------------------------------------------------
/examples/installing-npm/src/instrumentation.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import SplunkOtelWeb from '@splunk/otel-web'
19 |
20 | SplunkOtelWeb.init({
21 | allowInsecureBeacon: true,
22 | applicationName: 'splunk-otel-web-example-npm',
23 | beaconEndpoint: 'http://localhost:9101/api/v2/spans',
24 | debug: true,
25 |
26 | // uncomment to start sending to Splunk RUM backend
27 | // beaconEndpoint: 'https://rum-ingest.signalfx.com/api/v2/spans',
28 |
29 | // get the token by going to https://app.signalfx.com/#/organization/current?selectedKeyValue=sf_section:accesstokens
30 | rumAccessToken: 'ABC123...789',
31 | })
32 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/redacting-attributes/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Redacting attributes with exporter.onAttributesSerializing
6 | <%- renderAgent({}, true) %>
7 |
18 |
19 |
20 |
Redacting attributes with exporter.onAttributesSerializing
21 |
22 | Please note that redaction is applied right before sending the data.
23 | Debug span preview in DevTools is not affected.
24 |
25 |
26 |
27 |
28 |
29 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/examples/electron/webpack.main.config.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import type { Configuration } from 'webpack'
19 |
20 | import { plugins } from './webpack.plugins'
21 | import { rules } from './webpack.rules'
22 |
23 | export const mainConfig: Configuration = {
24 | /**
25 | * This is the main entry point for your application, it's the first file
26 | * that runs in the main process.
27 | */
28 | entry: './src/index.ts',
29 | // Put your normal webpack config below here
30 | module: {
31 | rules,
32 | },
33 | plugins,
34 | resolve: {
35 | extensions: ['.js', '.ts', '.jsx', '.tsx', '.css', '.json'],
36 | },
37 | }
38 |
--------------------------------------------------------------------------------
/tests/global-setup.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { initSocketIo, initWebSocketServer } from './servers'
19 |
20 | let teardown = false
21 | let isRunning = false
22 |
23 | export default function globalSetup() {
24 | if (isRunning) {
25 | return
26 | }
27 |
28 | const closeSocketIoServer = initSocketIo()
29 | const closeWebSocketServer = initWebSocketServer()
30 |
31 | isRunning = true
32 |
33 | return async () => {
34 | if (teardown) {
35 | throw new Error('teardown called twice')
36 | }
37 |
38 | teardown = true
39 |
40 | await Promise.all([closeSocketIoServer(), closeWebSocketServer()])
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/packages/web/tests/utils/memory-exporter.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { SplunkZipkinExporter, ZipkinSpan } from '../../src/exporters/zipkin'
19 |
20 | export const buildInMemorySplunkExporter = () => {
21 | const spans: ZipkinSpan[] = []
22 | const exporter = new SplunkZipkinExporter({
23 | beaconSender: () => {},
24 | url: '',
25 | xhrSender: (_, data) => {
26 | if (typeof data === 'string') {
27 | const newSpans = JSON.parse(data) as ZipkinSpan[]
28 | spans.splice(spans.length, 0, ...newSpans)
29 | }
30 | },
31 | })
32 |
33 | return {
34 | exporter,
35 | getFinishedSpans: () => spans,
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/scripts/utils/generate-script-snippet.mts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export const generateScriptSnippet = ({
19 | filename,
20 | integrityValue,
21 | isVersionImmutable,
22 | publicUrl,
23 | }: {
24 | filename: string
25 | integrityValue: string
26 | isVersionImmutable: boolean
27 | publicUrl: string
28 | }) => {
29 | const lines = [`${filename}:`]
30 |
31 | if (isVersionImmutable) {
32 | lines.push(``)
33 | } else {
34 | lines.push(``)
35 | }
36 |
37 | return lines.join('\n')
38 | }
39 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/server/middlewares/delay-middleware.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { FastifyRequest } from 'fastify'
19 |
20 | const sleep = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))
21 |
22 | export const delayMiddleware = async (
23 | request: FastifyRequest<{
24 | Querystring: {
25 | delay?: string
26 | }
27 | }>,
28 | ) => {
29 | const delayParam = request.query?.delay
30 |
31 | if (delayParam) {
32 | const delay = Number.parseInt(delayParam, 10)
33 | if (!Number.isNaN(delay) && delay > 0) {
34 | request.log.info(`Delaying request for ${delay}ms`)
35 | await sleep(delay)
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/websocket/websocket.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Websocket
6 |
7 | <%- renderAgent({instrumentations: {websocket: true}}) %>
8 |
9 |
10 |
Websocket
11 |
12 |
13 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/utils/test.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { test as base } from '@playwright/test'
20 |
21 | import { RecordPage } from '../pages/record-page'
22 |
23 | type TestFixtures = {
24 | recordPage: RecordPage
25 | }
26 |
27 | export const test = base.extend({
28 | recordPage: async ({ browser }, use) => {
29 | const recordingContext = await browser.newContext({ viewport: { height: 1080, width: 1920 } })
30 | const recordPage = new RecordPage(await recordingContext.newPage(), recordingContext)
31 | await recordPage.mockNetwork()
32 |
33 | await use(recordPage)
34 |
35 | await recordingContext.close()
36 | },
37 | })
38 |
--------------------------------------------------------------------------------
/packages/web/src/utils/observable.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { diag } from '@opentelemetry/api'
19 |
20 | export class Observable {
21 | private observers: Array<(data: T) => void> = []
22 |
23 | notify(data: T) {
24 | this.observers.forEach((observer) => {
25 | try {
26 | observer(data)
27 | } catch (error) {
28 | diag.error('Observable: Error happened in subscriber', error)
29 | }
30 | })
31 | }
32 |
33 | subscribe(f: (data: T) => void) {
34 | this.observers.push(f)
35 |
36 | return () => {
37 | const index = this.observers.indexOf(f)
38 | if (index !== -1) {
39 | this.observers.splice(index, 1)
40 | }
41 | }
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/tests/servers/websocket.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import WebSocket, { WebSocketServer } from 'ws'
19 |
20 | export const initWebSocketServer = () => {
21 | const wsServer = new WebSocketServer({
22 | port: 8979,
23 | })
24 |
25 | wsServer.on('connection', (cx: WebSocket) => {
26 | cx.on('message', (msg: WebSocket.Data) => {
27 | // allow client to terminate the connection from the server to expand unit testing possibilities
28 | if (msg === 'close') {
29 | console.log('closing ws connection')
30 | cx.close()
31 | }
32 |
33 | cx.send('Response')
34 | })
35 | })
36 |
37 | return () => new Promise((resolve) => wsServer.close(() => resolve()))
38 | }
39 |
--------------------------------------------------------------------------------
/examples/electron/src/preload.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | /**
20 | * Preload Script
21 | *
22 | * This script runs in an ISOLATED context (when contextIsolation is enabled).
23 | * It has access to Node.js APIs but runs in a separate JavaScript context
24 | * from the renderer process.
25 | *
26 | * IMPORTANT: DO NOT initialize Splunk RUM here!
27 | * - RUM must run in the actual renderer context (renderer.ts)
28 | * - Initializing RUM here would instrument the wrong context
29 | * - Your app would remain uninstrumented
30 | */
31 |
32 | // Preload script content goes here
33 | // Currently empty as no Node.js APIs need to be exposed
34 | console.log('Preload script loaded')
35 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/websocket/websocket-sub-protocol.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Websocket
6 |
7 | <%- renderAgent({instrumentations: {websocket: true}}) %>
8 |
9 |
10 |
Websocket sub protocol
11 |
12 |
13 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/scripts/utils/get-package-roots.mts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { accessSync, readdirSync } from 'node:fs'
19 | import path from 'node:path'
20 |
21 | export const getPackageRoots = () => {
22 | const appRoot = process.cwd()
23 | const packagesDir = path.resolve(appRoot, 'packages')
24 |
25 | return readdirSync(packagesDir, { withFileTypes: true })
26 | .filter((dirent) => {
27 | if (!dirent.isDirectory()) {
28 | return false
29 | }
30 |
31 | try {
32 | accessSync(path.resolve(packagesDir, dirent.name, 'package.json'))
33 | return true
34 | } catch {
35 | return false
36 | }
37 | })
38 | .map((dirent) => path.resolve(packagesDir, dirent.name))
39 | }
40 |
--------------------------------------------------------------------------------
/scripts/utils/cf-invalidation.mts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { CloudFrontClient, CreateInvalidationCommand } from '@aws-sdk/client-cloudfront'
19 |
20 | const cfClient = new CloudFrontClient({ region: process.env.AWS_REGION ?? 'us-east-1' })
21 |
22 | export const invalidateCloudFrontFiles = async (distributionId: string, invalidationRef: string) => {
23 | const { Invalidation } = await cfClient.send(
24 | new CreateInvalidationCommand({
25 | DistributionId: distributionId,
26 | InvalidationBatch: {
27 | CallerReference: invalidationRef,
28 | Paths: {
29 | Items: ['/o11y-gdi-rum/*'],
30 | Quantity: 1,
31 | },
32 | },
33 | }),
34 | )
35 | return Invalidation
36 | }
37 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/native/native.spec.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { expect } from '@playwright/test'
19 |
20 | import { test } from '../../utils/test'
21 |
22 | test.describe('native', () => {
23 | test('native session id integration', async ({ recordPage }) => {
24 | await recordPage.goTo('/native/native.ejs')
25 |
26 | await recordPage.waitForSpans((spans) => spans.some((s) => s.name === 'documentFetch'))
27 | const receivedSpans = recordPage.receivedSpans
28 |
29 | expect(
30 | receivedSpans.every((span) => span.tags['splunk.rumSessionId'] === '12341234123412341234123412341234'),
31 | ).toBe(true)
32 | expect(recordPage.receivedErrorSpans).toHaveLength(0)
33 | })
34 | })
35 |
--------------------------------------------------------------------------------
/examples/nextjs/public/next.svg:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/packages/session-recorder/src/type-guards/primitive-types.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | export const isString = (maybeString: unknown): maybeString is string => typeof maybeString === 'string'
19 |
20 | export function isObject(obj: unknown): obj is object {
21 | return typeof obj == 'object' && !Array.isArray(obj) && obj !== null
22 | }
23 |
24 | export function isNumber(value: unknown): value is number {
25 | return typeof value == 'number'
26 | }
27 |
28 | export function isBoolean(value: unknown): value is boolean {
29 | return typeof value == 'boolean'
30 | }
31 |
32 | export const isScriptElement = (maybeScriptElement: Node): maybeScriptElement is HTMLScriptElement =>
33 | maybeScriptElement.nodeName === 'SCRIPT'
34 |
--------------------------------------------------------------------------------
/examples/nextjs/instrumentation-client.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import SplunkOtelWeb from '@splunk/otel-web'
19 | import SplunkSessionRecorder from '@splunk/otel-web-session-recorder'
20 |
21 | SplunkOtelWeb.init({
22 | applicationName: process.env.NEXT_PUBLIC_SPLUNK_RUM_APPLICATION_NAME,
23 | beaconEndpoint: process.env.NEXT_PUBLIC_SPLUNK_RUM_BEACON_ENDPOINT,
24 | deploymentEnvironment: process.env.NEXT_PUBLIC_SPLUNK_RUM_DEPLOYMENT_ENVIROMENT,
25 | rumAccessToken: process.env.NEXT_PUBLIC_SPLUNK_RUM_ACCESS_TOKEN,
26 | })
27 |
28 | SplunkSessionRecorder.init({
29 | beaconEndpoint: process.env.NEXT_PUBLIC_SPLUNK_RUM_SESSION_REPLAY_BEACON_ENDPOINT,
30 | rumAccessToken: process.env.NEXT_PUBLIC_SPLUNK_RUM_ACCESS_TOKEN,
31 | })
32 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/server/middlewares/server-timing-middleware.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { FastifyReply, FastifyRequest } from 'fastify'
19 |
20 | import { setServerTimingHeader } from '../server-timing'
21 |
22 | export const serverTimingMiddleware = (
23 | req: FastifyRequest<{ Querystring: { serverTiming?: string } }>,
24 | reply: FastifyReply,
25 | payload: unknown,
26 | done: (err?: Error) => void,
27 | ) => {
28 | if (req.url.includes('no-server-timings')) {
29 | done()
30 | return
31 | }
32 |
33 | if (typeof req.query.serverTiming === 'string') {
34 | reply.header('Server-Timing', req.query.serverTiming)
35 | } else {
36 | setServerTimingHeader(reply)
37 | }
38 |
39 | done()
40 | }
41 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/server/server-timing.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { FastifyReply } from 'fastify'
19 |
20 | const generateHex = (length: number) =>
21 | [...Array.from({ length }).keys()].map(() => Math.floor(Math.random() * 16).toString(16)).join('')
22 |
23 | export const generateServerTiming = () => {
24 | const traceId = generateHex(32)
25 | const spanId = generateHex(16)
26 | const formatted = `traceparent;desc="00-${traceId}-${spanId}-01"`
27 | return {
28 | header: formatted,
29 | spanId,
30 | traceId,
31 | }
32 | }
33 |
34 | export const setServerTimingHeader = (reply: FastifyReply, serverTiming = generateServerTiming()) => {
35 | reply.header('Server-Timing', serverTiming.header)
36 | }
37 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/redacting-attributes/index.spec.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { expect } from '@playwright/test'
19 |
20 | import { test } from '../../utils/test'
21 |
22 | test.describe('redacting-attributes', () => {
23 | test('with custom exporter', async ({ recordPage }) => {
24 | await recordPage.goTo('/redacting-attributes/index.ejs')
25 |
26 | await recordPage.locator('#btnClick').click()
27 |
28 | await recordPage.waitForSpans((spans) => spans.some((s) => s.name === 'click'))
29 | const receivedSpans = recordPage.receivedSpans
30 | const clickSpans = receivedSpans.filter((span) => span.name === 'click')
31 |
32 | expect(clickSpans.every((s) => s.tags['http.url'] === '[redacted]'))
33 | })
34 | })
35 |
--------------------------------------------------------------------------------
/packages/web/src/splunk-web-tracer-provider.ts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 |
19 | import { context, propagation, trace } from '@opentelemetry/api'
20 | import { WebTracerProvider as BaseWebTracerProvider } from '@opentelemetry/sdk-trace-web'
21 |
22 | export class SplunkWebTracerProvider extends BaseWebTracerProvider {
23 | shutdown(): Promise {
24 | return new Promise((resolve) => {
25 | // TODO: upstream
26 | // note: BasicTracerProvider registers the propagator given to it in config
27 | // if the global propagator is the same as the one we registered, then we should deregister it
28 | propagation.disable()
29 | context.disable()
30 | trace.disable()
31 | resolve()
32 | }).then(() => super.shutdown())
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/scripts/utils/upload-to-s3.mts:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2020-2025 Splunk Inc.
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * https://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'
19 |
20 | const s3Client = new S3Client({ region: process.env.AWS_REGION ?? 'us-east-1' })
21 |
22 | export const uploadToS3 = ({
23 | bucketName,
24 | buffer,
25 | contentType,
26 | isImmutable,
27 | key,
28 | }: {
29 | bucketName: string
30 | buffer: Uint8Array
31 | contentType: string
32 | isImmutable: boolean
33 | key: string
34 | }) =>
35 | s3Client.send(
36 | new PutObjectCommand({
37 | ACL: 'public-read',
38 | Body: buffer,
39 | Bucket: bucketName,
40 | CacheControl: isImmutable ? 'public, max-age=31536000, immutable' : 'max-age=3600',
41 | ContentType: contentType,
42 | Key: `cdn/${key}`,
43 | }),
44 | )
45 |
--------------------------------------------------------------------------------
/packages/integration-tests/src/tests/context/framework/react-16.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | React
6 |
7 | <%- renderAgent({
8 | context: {
9 | async: true
10 | }
11 | }) %>
12 |
13 |
14 |
15 |
16 |
17 |
18 |