diff --git a/packages/rum-core/src/browser/performanceObservable.ts b/packages/rum-core/src/browser/performanceObservable.ts index bb2f97990d..b888260e7b 100644 --- a/packages/rum-core/src/browser/performanceObservable.ts +++ b/packages/rum-core/src/browser/performanceObservable.ts @@ -60,6 +60,7 @@ export interface RumPerformanceResourceTiming { encodedBodySize: number transferSize: number nextHopProtocol?: string + contentType?: string renderBlockingStatus?: string traceId?: string toJSON(): Omit diff --git a/packages/rum-core/src/domain/resource/resourceCollection.spec.ts b/packages/rum-core/src/domain/resource/resourceCollection.spec.ts index e36417cb59..03db33603d 100644 --- a/packages/rum-core/src/domain/resource/resourceCollection.spec.ts +++ b/packages/rum-core/src/domain/resource/resourceCollection.spec.ts @@ -80,6 +80,7 @@ describe('resourceCollection', () => { first_byte: jasmine.any(Object), status_code: 200, protocol: 'HTTP/1.0', + content_type: 'text/html', render_blocking_status: 'blocking', }, type: RumEventType.RESOURCE, @@ -118,6 +119,7 @@ describe('resourceCollection', () => { method: 'GET', status_code: 200, protocol: undefined, + content_type: undefined, type: ResourceType.XHR, url: 'https://resource.com/valid', }, @@ -232,6 +234,7 @@ describe('resourceCollection', () => { method: 'GET', status_code: 200, protocol: undefined, + content_type: undefined, type: ResourceType.FETCH, url: 'https://resource.com/valid', }, diff --git a/packages/rum-core/src/domain/resource/resourceCollection.ts b/packages/rum-core/src/domain/resource/resourceCollection.ts index f3e7bb8a71..087cf1b539 100644 --- a/packages/rum-core/src/domain/resource/resourceCollection.ts +++ b/packages/rum-core/src/domain/resource/resourceCollection.ts @@ -31,6 +31,7 @@ import { computeResourceEntryType, computeResourceEntrySize, computeResourceEntryProtocol, + computeResourceContentType, isResourceEntryRequestType, isLongDataUrl, sanitizeDataUrl, @@ -106,6 +107,7 @@ function processRequest( method: request.method, status_code: request.status, protocol: matchingTiming && computeResourceEntryProtocol(matchingTiming), + content_type: matchingTiming && computeResourceContentType(matchingTiming), url: isLongDataUrl(request.url) ? sanitizeDataUrl(request.url) : request.url, }, type: RumEventType.RESOURCE as const, @@ -155,6 +157,7 @@ function processResourceEntry( url: entry.name, status_code: discardZeroStatus(entry.responseStatus), protocol: computeResourceEntryProtocol(entry), + content_type: computeResourceContentType(entry), }, type: RumEventType.RESOURCE as const, _dd: { diff --git a/packages/rum-core/src/domain/resource/resourceUtils.ts b/packages/rum-core/src/domain/resource/resourceUtils.ts index 5b738bfd97..666247f215 100644 --- a/packages/rum-core/src/domain/resource/resourceUtils.ts +++ b/packages/rum-core/src/domain/resource/resourceUtils.ts @@ -186,6 +186,10 @@ export function computeResourceEntryProtocol(entry: RumPerformanceResourceTiming return entry.nextHopProtocol === '' ? undefined : entry.nextHopProtocol } +export function computeResourceContentType(entry: RumPerformanceResourceTiming) { + return entry.contentType === '' ? undefined : entry.contentType +} + export function computeResourceEntrySize(entry: RumPerformanceResourceTiming) { // Make sure a request actually occurred if (entry.startTime < entry.responseStart) { diff --git a/packages/rum-core/src/rawRumEvent.types.ts b/packages/rum-core/src/rawRumEvent.types.ts index 15f545431c..b58f074c78 100644 --- a/packages/rum-core/src/rawRumEvent.types.ts +++ b/packages/rum-core/src/rawRumEvent.types.ts @@ -49,6 +49,7 @@ export interface RawRumResourceEvent { first_byte?: ResourceEntryDetailsElement download?: ResourceEntryDetailsElement protocol?: string + content_type?: string } _dd: { trace_id?: string diff --git a/packages/rum-core/test/fixtures.ts b/packages/rum-core/test/fixtures.ts index 346959ea49..db92d30ea8 100644 --- a/packages/rum-core/test/fixtures.ts +++ b/packages/rum-core/test/fixtures.ts @@ -260,6 +260,7 @@ export function createPerformanceEntry( startTime: 200 as RelativeTime, responseStatus: 200, nextHopProtocol: 'HTTP/1.0', + contentType: 'text/html', }, overrides ) as EntryTypeToReturnType[T]