Skip to content

Commit e991120

Browse files
committed
✨ add extra slim package with navigation tracking and session management
1 parent 66ce71d commit e991120

File tree

23 files changed

+323
-4
lines changed

23 files changed

+323
-4
lines changed

developer-extension/src/background/domain/syncRules.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ function buildRules(
7171
createRedirectRule(/^https:\/\/.*\/datadog-rum-slim(-[\w-]+)?\.js$/, {
7272
url: DEV_RUM_SLIM_URL,
7373
}),
74+
createRedirectRule(/^https:\/\/.*\/datadog-rum-extra-slim(-[\w-]+)?\.js$/, {
75+
url: DEV_RUM_SLIM_URL,
76+
}),
7477
createRedirectRule(/^https:\/\/.*\/datadog-logs(-[\w-]+)?\.js$/, { url: DEV_LOGS_URL }),
7578
createRedirectRule(/^https:\/\/.*\/chunks\/recorder(-[\w-]+)?-datadog-rum.js$/, {
7679
url: DEV_RUM_RECORDER_CHUNK_URL,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export const DEV_LOGS_URL = 'http://localhost:8080/datadog-logs.js'
22
export const DEV_RUM_RECORDER_CHUNK_URL = 'http://localhost:8080/chunks/recorder-datadog-rum.js'
33
export const DEV_RUM_SLIM_URL = 'http://localhost:8080/datadog-rum-slim.js'
4+
export const DEV_RUM_EXTRA_SLIM_URL = 'http://localhost:8080/datadog-rum-extra-slim.js'
45
export const DEV_RUM_URL = 'http://localhost:8080/datadog-rum.js'

eslint.config.mjs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,19 @@ export default tseslint.config(
341341
},
342342

343343
{
344-
files: ['packages/{rum,logs,rum-slim}/src/entries/*.ts'],
344+
files: ['packages/{rum,logs,rum-slim,rum-extra-slim}/src/entries/*.ts'],
345345
rules: {
346346
'local-rules/disallow-enum-exports': 'error',
347347
},
348348
},
349349

350+
{
351+
files: ['packages/rum-extra-slim/**/*.ts'],
352+
rules: {
353+
'local-rules/disallow-side-effects': 'off',
354+
},
355+
},
356+
350357
{
351358
// Files executed by nodejs
352359
files: [

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"postinstall": "scripts/cli init_submodule",
1212
"build": "lerna run build --stream",
1313
"build:bundle": "lerna run build:bundle --stream",
14+
"build:xs": "lerna run build --scope @datadog/browser-rum-extra-slim",
1415
"build:app": "lerna run pack --stream && cd test/apps/vanilla && rm -rf node_modules && yarn install --no-immutable && yarn build",
1516
"build:react-app": "lerna run pack --stream && cd test/apps/react && rm -rf node_modules && yarn install --no-immutable && yarn build",
1617
"build:apps": "yarn build:app && yarn build:react-app",

packages/rum-extra-slim/.npmignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
*
2+
!/bundle/datadog-rum-extra-slim.js
3+
!/cjs/**/*
4+
!/esm/**/*
5+
!/src/**/*
6+
/src/**/*.spec.ts
7+
/src/**/*.specHelper.ts

packages/rum-extra-slim/.yarnrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
save-exact true
2+

packages/rum-extra-slim/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# RUM Browser Monitoring - extra slim package
2+
3+
## Overview
4+
5+
> [!CAUTION]
6+
> Experimental package. Not recommended for production use.
7+
8+
## Setup
9+
10+
See the [RUM package](../rum/README.md) documentation.

packages/rum-extra-slim/package.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@datadog/browser-rum-extra-slim",
3+
"version": "6.6.3",
4+
"license": "Apache-2.0",
5+
"main": "cjs/entries/main.js",
6+
"module": "esm/entries/main.js",
7+
"types": "cjs/entries/main.d.ts",
8+
"private": true,
9+
"scripts": {
10+
"pack": "yarn pack",
11+
"build": "build:bundle",
12+
"build:bundle": "rm -rf bundle && SDK_SETUP=cdn webpack --mode=production",
13+
"build:cjs": "rm -rf cjs && tsc -p tsconfig.cjs.json",
14+
"build:esm": "rm -rf esm && tsc -p tsconfig.esm.json"
15+
},
16+
"dependencies": {
17+
"@datadog/browser-core": "6.6.3",
18+
"@datadog/browser-rum-core": "6.6.3"
19+
},
20+
"peerDependencies": {
21+
"@datadog/browser-logs": "6.6.3"
22+
},
23+
"peerDependenciesMeta": {
24+
"@datadog/browser-logs": {
25+
"optional": true
26+
}
27+
},
28+
"repository": {
29+
"type": "git",
30+
"url": "https://github.com/DataDog/browser-sdk.git",
31+
"directory": "packages/rum-extra-slim"
32+
},
33+
"volta": {
34+
"extends": "../../package.json"
35+
},
36+
"publishConfig": {
37+
"access": "public"
38+
}
39+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { startSessionManager } from '../domain/sessionManager'
2+
import { trackNavigationTimings } from '../domain/collection/trackNavigationTimings'
3+
import { startTransportManager } from '../domain/transportManager'
4+
import { trackUrlChange } from '../domain/collection/trackUrls'
5+
6+
export function start() {
7+
const sessionManager = startSessionManager()
8+
const transportManager = startTransportManager(sessionManager)
9+
10+
function init() {
11+
trackUrlChange(transportManager)
12+
trackNavigationTimings(transportManager)
13+
}
14+
15+
return {
16+
init,
17+
}
18+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { RumPerformanceEntryType } from '@datadog/browser-rum-core'
2+
import { createPerformanceObservable } from '@datadog/browser-rum-core/src/browser/performanceObservable'
3+
import type { TransportManager } from '../transportManager'
4+
import type { NavigationTimingsEvent } from '../event'
5+
6+
export function trackNavigationTimings(transportManager: TransportManager) {
7+
const observable = createPerformanceObservable({} as any, {
8+
type: RumPerformanceEntryType.NAVIGATION,
9+
buffered: true,
10+
})
11+
12+
const subscription = observable.subscribe((entries) => {
13+
for (const entry of entries) {
14+
const data: NavigationTimingsEvent = {
15+
type: 'navigation_timings',
16+
...entry.toJSON(),
17+
}
18+
19+
transportManager.send(data)
20+
}
21+
})
22+
23+
return () => subscription.unsubscribe()
24+
}

0 commit comments

Comments
 (0)