Skip to content

Commit

Permalink
Merge branch 'main' into aymeric/webview-replay
Browse files Browse the repository at this point in the history
  • Loading branch information
amortemousque committed Feb 19, 2024
2 parents 52974bb + b9ebe46 commit c975407
Show file tree
Hide file tree
Showing 137 changed files with 5,169 additions and 4,117 deletions.
3 changes: 0 additions & 3 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -3,8 +3,5 @@
# Global
* @Datadog/rum-browser

# Replay
packages/rum @Datadog/rum-browser @DataDog/rum-session-replay

# Docs
*README.md @Datadog/rum-browser @DataDog/documentation
5 changes: 5 additions & 0 deletions .github/dependabot.yml
@@ -1,3 +1,5 @@
# Note: While we mainly use Renovate, Dependabot is used for security updates

version: 2
updates:
- package-ecosystem: github-actions
Expand All @@ -15,3 +17,6 @@ updates:
open-pull-requests-limit: 0
commit-message:
prefix: '👷'
ignore:
# update karma-webpack: RUM-3130
- dependency-name: 'karma-webpack'
7 changes: 4 additions & 3 deletions .gitlab-ci.yml
@@ -1,12 +1,12 @@
variables:
CURRENT_STAGING: staging-04
CURRENT_STAGING: staging-08
APP: 'browser-sdk'
CURRENT_CI_IMAGE: 57
CURRENT_CI_IMAGE: 58
BUILD_STABLE_REGISTRY: '486234852809.dkr.ecr.us-east-1.amazonaws.com'
CI_IMAGE: '$BUILD_STABLE_REGISTRY/ci/$APP:$CURRENT_CI_IMAGE'
GIT_REPOSITORY: 'git@github.com:DataDog/browser-sdk.git'
MAIN_BRANCH: 'main'
CHROME_PACKAGE_VERSION: 120.0.6099.62-1
CHROME_PACKAGE_VERSION: 121.0.6167.85-1

cache:
key:
Expand Down Expand Up @@ -140,6 +140,7 @@ build-and-lint:
- yarn build
- yarn lint
- node scripts/check-packages.js
- node scripts/export-bundles-sizes.js

build-bundle:
extends:
Expand Down
4 changes: 4 additions & 0 deletions .prettierrc.yml
Expand Up @@ -4,3 +4,7 @@ semi: false
singleQuote: true
tabWidth: 2
trailingComma: 'es5'
overrides:
- files: '*.json'
options:
trailingComma: 'none'
875 changes: 0 additions & 875 deletions .yarn/releases/yarn-3.7.0.cjs

This file was deleted.

875 changes: 875 additions & 0 deletions .yarn/releases/yarn-3.8.0.cjs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion .yarnrc.yml
@@ -1,3 +1,3 @@
yarnPath: .yarn/releases/yarn-3.7.0.cjs
yarnPath: .yarn/releases/yarn-3.8.0.cjs
defaultSemverRangePrefix: ''
nodeLinker: node-modules
10 changes: 10 additions & 0 deletions CHANGELOG.md
Expand Up @@ -16,6 +16,16 @@
---

## v5.9.0

-[Developer extension] npm setup override support ([#2304](https://github.com/DataDog/browser-sdk/pull/2304))
- 🐛 Fix LCP with size < previous LCP ([#2586](https://github.com/DataDog/browser-sdk/pull/2586))
- 🐛 [RUM-2940] fix normalize URL for relative paths ([#2576](https://github.com/DataDog/browser-sdk/pull/2576))
- ♻️ register setupBuilder.cleanup as a cleanup task ([#2590](https://github.com/DataDog/browser-sdk/pull/2590))
- ♻️ [RUM-2445] split RUM and Logs public APIs modules ([#2575](https://github.com/DataDog/browser-sdk/pull/2575))
- ⚡️ [RUM-2893] optimize getNodePrivacyLevel by adding a cache ([#2579](https://github.com/DataDog/browser-sdk/pull/2579))
- ♻️ [RUM-2203] Move record logic from startRecording to the record module ([#2574](https://github.com/DataDog/browser-sdk/pull/2574))

## v5.8.0

-[RUM-2729] collect connectivity data ([#2560](https://github.com/DataDog/browser-sdk/pull/2560))
Expand Down
22 changes: 11 additions & 11 deletions developer-extension/package.json
@@ -1,29 +1,29 @@
{
"name": "@datadog/browser-sdk-developer-extension",
"version": "5.8.0",
"version": "5.9.0",
"private": true,
"scripts": {
"build": "rm -rf dist && webpack --mode production",
"dev": "webpack --mode development --watch"
},
"devDependencies": {
"@tabler/icons-react": "2.45.0",
"@types/chrome": "0.0.256",
"@types/react": "18.2.47",
"@types/react-dom": "18.2.18",
"@tabler/icons-react": "2.47.0",
"@types/chrome": "0.0.260",
"@types/react": "18.2.55",
"@types/react-dom": "18.2.19",
"@webextension-toolbox/webpack-webextension-plugin": "3.3.1",
"copy-webpack-plugin": "11.0.0",
"css-loader": "6.8.1",
"copy-webpack-plugin": "12.0.2",
"css-loader": "6.10.0",
"html-webpack-plugin": "5.6.0",
"style-loader": "3.3.3",
"webpack": "5.89.0"
"style-loader": "3.3.4",
"webpack": "5.90.1"
},
"dependencies": {
"@datadog/browser-core": "workspace:*",
"@datadog/browser-logs": "workspace:*",
"@datadog/browser-rum": "workspace:*",
"@mantine/core": "7.4.0",
"@mantine/hooks": "7.4.0",
"@mantine/core": "7.5.2",
"@mantine/hooks": "7.5.2",
"clsx": "2.1.0",
"react": "18.2.0",
"react-dom": "18.2.0"
Expand Down
Expand Up @@ -11,6 +11,7 @@ import type {
RumLongTaskEvent,
RumResourceEvent,
RumViewEvent,
RumVitalEvent,
} from '../../../../../../packages/rum-core/src/rumEvent.types'
import type { SdkEvent } from '../../../sdkEvent'
import { isTelemetryEvent, isLogEvent, isRumEvent } from '../../../sdkEvent'
Expand All @@ -32,6 +33,7 @@ const RUM_EVENT_TYPE_COLOR = {
view: 'blue',
resource: 'cyan',
telemetry: 'teal',
vital: 'orange',
}

const LOG_STATUS_COLOR = {
Expand Down Expand Up @@ -260,6 +262,8 @@ export const EventDescription = React.memo(({ event }: { event: SdkEvent }) => {
return <ResourceDescription event={event} />
case 'action':
return <ActionDescription event={event} />
case 'vital':
return <VitalDescription event={event} />
}
} else if (isLogEvent(event)) {
return <LogDescription event={event} />
Expand Down Expand Up @@ -322,6 +326,17 @@ function LongTaskDescription({ event }: { event: RumLongTaskEvent }) {
)
}

function VitalDescription({ event }: { event: RumVitalEvent }) {
const vitalName = Object.keys(event.vital.custom!)[0]
const vitalValue = event.vital.custom![vitalName]
return (
<>
Custom <Emphasis>{event.vital.type}</Emphasis> vital: <Emphasis>{vitalName}</Emphasis> of{' '}
<Emphasis>{vitalValue}</Emphasis>
</>
)
}

function ErrorDescription({ event }: { event: RumErrorEvent }) {
return (
<>
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
@@ -1,4 +1,4 @@
{
"npmClient": "yarn",
"version": "5.8.0"
"version": "5.9.0"
}
34 changes: 17 additions & 17 deletions package.json
Expand Up @@ -30,22 +30,22 @@
},
"devDependencies": {
"@jsdevtools/coverage-istanbul-loader": "3.0.5",
"@types/chrome": "0.0.256",
"@types/chrome": "0.0.260",
"@types/connect-busboy": "1.0.3",
"@types/cors": "2.8.17",
"@types/express": "4.17.21",
"@types/jasmine": "3.10.18",
"@typescript-eslint/eslint-plugin": "6.18.0",
"@typescript-eslint/parser": "6.18.0",
"@wdio/browserstack-service": "8.27.1",
"@wdio/cli": "8.27.1",
"@wdio/jasmine-framework": "8.27.0",
"@wdio/junit-reporter": "8.27.0",
"@wdio/local-runner": "8.27.0",
"@wdio/spec-reporter": "8.27.0",
"@typescript-eslint/eslint-plugin": "6.21.0",
"@typescript-eslint/parser": "6.21.0",
"@wdio/browserstack-service": "8.31.1",
"@wdio/cli": "8.31.1",
"@wdio/jasmine-framework": "8.31.1",
"@wdio/junit-reporter": "8.31.1",
"@wdio/local-runner": "8.31.1",
"@wdio/spec-reporter": "8.31.1",
"ajv": "6.12.6",
"browserstack-local": "1.5.5",
"chrome-webstore-upload": "3.0.2",
"chrome-webstore-upload": "3.0.3",
"connect-busboy": "1.0.0",
"cors": "2.8.5",
"emoji-name-map": "1.2.9",
Expand All @@ -54,10 +54,10 @@
"eslint-module-utils": "2.8.0",
"eslint-plugin-import": "2.29.1",
"eslint-plugin-jasmine": "4.1.3",
"eslint-plugin-jsdoc": "48.0.2",
"eslint-plugin-jsdoc": "48.1.0",
"eslint-plugin-local-rules": "2.0.1",
"eslint-plugin-prefer-arrow": "1.2.3",
"eslint-plugin-unicorn": "50.0.1",
"eslint-plugin-unicorn": "51.0.1",
"express": "4.18.2",
"glob": "10.3.10",
"jasmine-core": "3.99.1",
Expand All @@ -71,18 +71,18 @@
"karma-sourcemap-loader": "0.4.0",
"karma-spec-reporter": "0.0.36",
"karma-webpack": "5.0.0",
"lerna": "8.0.2",
"lerna": "8.1.2",
"minimatch": "9.0.3",
"node-fetch": "3.3.2",
"npm-run-all": "4.1.5",
"prettier": "3.1.1",
"prettier": "3.2.5",
"terser-webpack-plugin": "5.3.10",
"ts-loader": "9.5.1",
"ts-node": "10.9.2",
"tsconfig-paths-webpack-plugin": "4.1.0",
"typescript": "5.3.3",
"webdriverio": "8.27.0",
"webpack": "5.89.0",
"webdriverio": "8.31.1",
"webpack": "5.90.1",
"webpack-cli": "5.1.4",
"webpack-dev-middleware": "7.0.0"
},
Expand All @@ -93,5 +93,5 @@
"node": "18.19.0",
"yarn": "1.22.21"
},
"packageManager": "yarn@3.7.0"
"packageManager": "yarn@3.8.0"
}
2 changes: 1 addition & 1 deletion packages/core/package.json
@@ -1,6 +1,6 @@
{
"name": "@datadog/browser-core",
"version": "5.8.0",
"version": "5.9.0",
"license": "Apache-2.0",
"main": "cjs/index.js",
"module": "esm/index.js",
Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/boot/displayAlreadyInitializedError.spec.ts
@@ -0,0 +1,18 @@
import type { InitConfiguration } from '../domain/configuration'
import { display } from '../tools/display'
import { displayAlreadyInitializedError } from './displayAlreadyInitializedError'

describe('displayAlreadyInitializedError', () => {
it('should display an error', () => {
const displayErrorSpy = spyOn(display, 'error')
displayAlreadyInitializedError('DD_RUM', {} as InitConfiguration)
expect(displayErrorSpy).toHaveBeenCalledTimes(1)
expect(displayErrorSpy).toHaveBeenCalledWith('DD_RUM is already initialized.')
})

it('should not display an error if the "silentMultipleInit" option is used', () => {
const displayErrorSpy = spyOn(display, 'error')
displayAlreadyInitializedError('DD_RUM', { silentMultipleInit: true } as InitConfiguration)
expect(displayErrorSpy).not.toHaveBeenCalled()
})
})
8 changes: 8 additions & 0 deletions packages/core/src/boot/displayAlreadyInitializedError.ts
@@ -0,0 +1,8 @@
import type { InitConfiguration } from '../domain/configuration'
import { display } from '../tools/display'

export function displayAlreadyInitializedError(sdkName: 'DD_RUM' | 'DD_LOGS', initConfiguration: InitConfiguration) {
if (!initConfiguration.silentMultipleInit) {
display.error(`${sdkName} is already initialized.`)
}
}
35 changes: 28 additions & 7 deletions packages/core/src/domain/configuration/configuration.spec.ts
Expand Up @@ -5,12 +5,19 @@ import {
isExperimentalFeatureEnabled,
resetExperimentalFeatures,
} from '../../tools/experimentalFeatures'
import { TrackingConsent } from '../trackingConsent'
import type { InitConfiguration } from './configuration'
import { validateAndBuildConfiguration } from './configuration'

describe('validateAndBuildConfiguration', () => {
const clientToken = 'some_client_token'

let displaySpy: jasmine.Spy<typeof display.error>

beforeEach(() => {
displaySpy = spyOn(display, 'error')
})

afterEach(() => {
resetExperimentalFeatures()
})
Expand Down Expand Up @@ -44,12 +51,6 @@ describe('validateAndBuildConfiguration', () => {
})

describe('validate init configuration', () => {
let displaySpy: jasmine.Spy<typeof display.error>

beforeEach(() => {
displaySpy = spyOn(display, 'error')
})

it('requires the InitConfiguration to be defined', () => {
expect(validateAndBuildConfiguration(undefined as unknown as InitConfiguration)).toBeUndefined()
expect(displaySpy).toHaveBeenCalledOnceWith('Client Token is not configured, we will not send any data.')
Expand Down Expand Up @@ -160,7 +161,6 @@ describe('validateAndBuildConfiguration', () => {
throw myError
}
const configuration = validateAndBuildConfiguration({ clientToken, beforeSend })!
const displaySpy = spyOn(display, 'error')
expect(configuration.beforeSend!(null, {})).toBeUndefined()
expect(displaySpy).toHaveBeenCalledWith('beforeSend threw an error:', myError)
})
Expand All @@ -186,4 +186,25 @@ describe('validateAndBuildConfiguration', () => {
).toBeTrue()
})
})

describe('trackingConsent', () => {
it('defaults to "granted"', () => {
expect(validateAndBuildConfiguration({ clientToken: 'yes' })!.trackingConsent).toBe(TrackingConsent.GRANTED)
})

it('is set to provided value', () => {
expect(
validateAndBuildConfiguration({ clientToken: 'yes', trackingConsent: TrackingConsent.NOT_GRANTED })!
.trackingConsent
).toBe(TrackingConsent.NOT_GRANTED)
expect(
validateAndBuildConfiguration({ clientToken: 'yes', trackingConsent: TrackingConsent.GRANTED })!.trackingConsent
).toBe(TrackingConsent.GRANTED)
})

it('rejects invalid values', () => {
expect(validateAndBuildConfiguration({ clientToken: 'yes', trackingConsent: 'foo' as any })).toBeUndefined()
expect(displaySpy).toHaveBeenCalledOnceWith('Tracking Consent should be either "granted" or "not-granted"')
})
})
})
12 changes: 12 additions & 0 deletions packages/core/src/domain/configuration/configuration.ts
Expand Up @@ -10,6 +10,7 @@ import { objectHasValue } from '../../tools/utils/objectUtils'
import { assign } from '../../tools/utils/polyfills'
import { selectSessionStoreStrategyType } from '../session/sessionStore'
import type { SessionStoreStrategyType } from '../session/storeStrategies/sessionStoreStrategy'
import { TrackingConsent } from '../trackingConsent'
import type { TransportConfiguration } from './transportConfiguration'
import { computeTransportConfiguration } from './transportConfiguration'

Expand All @@ -30,6 +31,7 @@ export interface InitConfiguration {
allowFallbackToLocalStorage?: boolean | undefined
allowUntrustedEvents?: boolean | undefined
storeContextsAcrossPages?: boolean | undefined
trackingConsent?: TrackingConsent | undefined

// transport options
proxy?: string | ProxyFn | undefined
Expand Down Expand Up @@ -84,6 +86,7 @@ export interface Configuration extends TransportConfiguration {
service: string | undefined
silentMultipleInit: boolean
allowUntrustedEvents: boolean
trackingConsent: TrackingConsent

// Event limits
eventRateLimiterThreshold: number // Limit the maximum number of actions, errors and logs per minutes
Expand Down Expand Up @@ -120,6 +123,14 @@ export function validateAndBuildConfiguration(initConfiguration: InitConfigurati
return
}

if (
initConfiguration.trackingConsent !== undefined &&
!objectHasValue(TrackingConsent, initConfiguration.trackingConsent)
) {
display.error('Tracking Consent should be either "granted" or "not-granted"')
return
}

// Set the experimental feature flags as early as possible, so we can use them in most places
if (Array.isArray(initConfiguration.enableExperimentalFeatures)) {
addExperimentalFeatures(
Expand All @@ -140,6 +151,7 @@ export function validateAndBuildConfiguration(initConfiguration: InitConfigurati
service: initConfiguration.service,
silentMultipleInit: !!initConfiguration.silentMultipleInit,
allowUntrustedEvents: !!initConfiguration.allowUntrustedEvents,
trackingConsent: initConfiguration.trackingConsent ?? TrackingConsent.GRANTED,

/**
* beacon payload max queue size implementation is 64kb
Expand Down

0 comments on commit c975407

Please sign in to comment.