Encountering problem with '@datadog/browser-rum' compilation related to the 'allowedTracingOrigins' attribute

I'm facing a typing problem with the @datadog/browser-rum library:

Error: node_modules/@datadog/browser-rum-core/src/domain/configuration.ts:100:3 
error TS2322: Type '{ applicationId: string; version: string; actionNameAttribute: string; premiumSampleRate: number; allowedTracingOrigins: readonly (string | RegExp)[]; tracingSampleRate: number; excludedActivityUrls: readonly (string | RegExp)[]; trackInteractions: boolean; trackFrustrations: boolean; trackViewsManually: boolean; de...' is not assignable to type 'RumConfiguration'.

Types of property 'allowedTracingOrigins' are incompatible.
The type 'readonly (string | RegExp)[]' is 'readonly' and cannot be assigned to the mutable type '(string | RegExp)[]'.

No TypeScript errors show up in my implementation, only in the library itself.

The dependencies used:

Angular@12
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4c38353c293f2f3e253c380c78627f6279">[email protected]</a>
@datadog/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="e381918c94908691ce91968ea3d7cdd2d4cdd1">[email protected]</a>
<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="06686962634637342834362834">[email protected]</a>

Here's the implementation:

import {
    APP_INITIALIZER,
    FactoryProvider,
} from '@angular/core';
import { Environment } from '@shared/base/class/environment.class';
import { RumEvent } from '@datadog/browser-rum-core/src/rumEvent.types';
import { RumEventDomainContext } from '@datadog/browser-rum-core/src/domainContext.types';
import { datadogRum } from '@datadog/browser-rum';

function factory(...dependencies: [Environment]) {
    return () => init(...dependencies);
}

function init(environment: Environment): Promise<void> {
    return new Promise((resolve) => {
        if (!environment.dataDog) {
            return resolve();
        }
        datadogRum.init({
            applicationId: environment?.dataDog?.applicationId,
            clientToken: environment?.dataDog?.clientToken,
            site: environment?.dataDog?.site,
            service: environment?.dataDog?.service,
            env: environment.env,
            version: environment.appVersion,
            sampleRate: environment?.dataDog?.sampleRate || 100,
            premiumSampleRate: environment?.dataDog?.premiumSampleRate || 100,
            trackInteractions: environment?.dataDog?.trackInteractions || false,
            allowedTracingOrigins: [] as ReadonlyArray<any>,
            beforeSend
        });
        datadogRum.onReady(() => resolve());
    });

    function beforeSend(event: RumEvent, context: RumEventDomainContext) {
        if (event.view.url.includes('?')) {
            event.view.url = event.view.url.split('?')[0];
        }
        if (event.type === 'resource' && event.resource.url.includes('?')) {
            event.resource.url = event.resource.url.split('?')[0];
        }
    }
}

export const DatadogInitializationProvider: FactoryProvider  = {
    provide: APP_INITIALIZER,
    useFactory: factory,
    deps: [Environment],
    multi: true,
};


Has anyone else faced this same issue before?

Thank you and have a wonderful day/evening!

Answer №1

The issue arises from the utilization of types from browser-rum-core rather than browser-rum:

import { RumEvent } from '@datadog/browser-rum-core/src/rumEvent.types';
import { RumEventDomainContext } from '@datadog/browser-rum-core/src/domainContext.types';
import { datadogRum } from '@datadog/browser-rum';

as opposed to

import { datadogRum, RumEventDomainContext, RumEvent } from '@datadog/browser-rum';

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Module or its corresponding type declarations not found in the specified location.ts(2307)

After creating my own npm package at https://www.npmjs.com/package/leon-theme?activeTab=code, I proceeded to set up a basic create-react-app project at https://github.com/leongaban/test-project. In the src/index.tsx file of my react app, I attempted to im ...

Utilize Angular's effect() function to reset a form when a specific signal becomes true

Is my approach to using signals correct in this scenario? I have a form that needs to reset when the success signal is true. I implemented this with an effect, but the Angular documentation is not very clear on this topic yet (refer to here). **Do you bel ...

What steps should I follow to include Sass compilation in my Angular CLI 6 project in the angular.json file?

I recently started working on a project in Angular using the latest version of Angular CLI 6.0. However, I need to enable Sass compilation for my existing project. Typically, you can specify this during project creation, but since mine is already set up wi ...

The specific structure does not match the generic format

type Identity = <T>(input: T) => T const identity: Identity = (input: number) => input; When using generics like this, it results in a compiler error: Type '(input: number) => number' is not compatible with type 'Identity&a ...

Mastering the Art of Concise Writing: Tips to

Is there a way to write more concisely, maybe even in a single line? this.xxx = smt.filter(item => item.Id === this.smtStatus.ONE); this.yyy = smt.filter(item => item.Id === this.smtStatus.TWO); this.zzz = smt.filter(item => item.Id == ...

Avoiding redundant API requests in transclusion by ensuring that only one instance of the duplicated component is displayed

In my Angular project, I am utilizing transclusion to create a fixed view template with slots for dynamic content. The component I'm working with is called app-filter-details and here is its template: <div id="details-wrapper"> <div cla ...

Exploring the concept of data model inheritance in Angular 2

In my Angular2 and ASP.NET Core project, I have set up the following: My C# .NET Core API returns the following classes: public class fighter { public int id { get; set; } public string name { get; set; } public datetime birthdate { get; set; } p ...

Is it possible to use TypeScript in a React Native project with a JavaScript file?

Currently, I am learning React Native by working on app clones like Instagram and YouTube. I have recently started an AirBnb clone project, but I'm facing some issues with the initial build. One issue I noticed is that in 'App.js', the temp ...

Printing the HTML Template of a widget with multiple loops results in a blank first page being displayed

I have encountered an issue while working with a table and ng-repeat loops in my report widget. The table displays fine on the screen, but when I try to print it, there is always a blank page at the beginning. Interestingly, if I remove the second and thir ...

Manipulating a MongoDB object using node.js

Within my server.js file, I have defined a database model to be used for a POST request: var department = mongoose.model('department', { departmentName: String, rooms: [{ roomNumber: String, width: Number, height: Number, pos ...

What is the process for transforming a nested dictionary in JSON into a nested array in AngularJS?

I am looking to create a form that can extract field values from existing JSON data. The JSON I have is nested with dictionary structures, but I would like to convert them into arrays. Is there a way to write a recursive function that can retrieve the key ...

"Running older versions of Angular-CLI on your local machine

My current setup includes the latest version of angular-cli installed globally. Here are the details: C:\Users\W055013\kumar\learn\rx>ng --version As a forewarning, we are moving the CLI npm package to "@angular/cli" with the n ...

Unable to locate the module from my personal library in Typescript

The Query Why is my ng2-orm package not importing or being recognized by vscode when I try to import Config from 'ng2-orm'; import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser&a ...

How can we limit the CSS properties that can be used in an interpolated manner by defining a restricted TS type for CSS props based on emotions?

When dealing with emotions, how can we specify a restricted TS type for the css prop to only allow certain css properties to be interpolated? For instance, consider the following scenario: // This is considered valid css = {{ color: 'white', ...

Incorporate a CSS class name with a TypeScript property in Angular version 7

Struggling with something seemingly simple... All I need is for my span tag to take on a class called "store" from a variable in my .ts file: <span [ngClass]="{'flag-icon': true, 'my_property_in_TS': true}"></span> I&apos ...

Stylishly incorporating components in higher-order components

Trying to enhance my component wrapper with styles using a higher order component has led to Typescript flagging an error with ComponentWithAdddedColors. type Props = { bg?: string; }; function withColors<TProps>( Component: React.ComponentType ...

"Update your Chart.js to version 3.7.1 to eliminate the vertical scale displaying values on the left

https://i.sstatic.net/7CzRg.png Is there a way to disable the scale with additional marks from 0 to 45000 as shown in the screenshot? I've attempted various solutions, including updating chartjs to the latest version, but I'm specifically intere ...

Issue encountered with Vue.js build configuration not being loaded while running on the build test server

I am working on a Vue 2 project and facing an issue with loading configuration settings from a config.json file. My router\index.ts file has the line: Vue.prototype.$config = require('/public/config.json') The config.json file contains imp ...

Utilizing generic type and union types effectively in TypeScript

When initializing my class, I often pass in either a value or an object containing information about the value. For instance: new Field<string>('test') new Field<string>({value: 'test', inactive: 'preview'}) Howev ...

Attempting to create a bar graph using Angular framework

I'm currently working on developing a dashboard in Angular that includes a chart feature. Within my Firebase Firestore database, I have two collections: 'mechanicQualifications' and 'mecanicos'. The 'mechanicQualifications&apo ...