Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [RUM-1016] allow to change "view.name" #2396

Merged
merged 3 commits into from
Sep 7, 2023

Conversation

arichard-info
Copy link
Contributor

@arichard-info arichard-info commented Aug 29, 2023

Motivation

It would be very useful to be able to easily define the view.name field rather than letting datadog group the fields. This is the case, for example, if you have complex urls that datadog is unable to group :

/amazing-tee-shirt_P765231C097654
/green-hoodie_P209588C068396
/yellow-jacket_P999300C459483
/men_009890
/women_007865
/all_005432

Of these 6 urls, datadog groups them in the same way: /?, whereas in my application, the first three correspond to one type of page (regex : ^/[\w\-\.]+_P[0-9]+C([0-9]+)[^/]*$), and the last three to another (regex : ^/([\w\-\.]+_[0-9]+)([^/]*)$). I'd like to be able to name them explicitly.

As explained in the documentation, currently the only way to change the name of a RUM view is to set trackViewsManually to true when initializing the SDK. You then need to call datadogRum.startView manually.

On an application already in production, which already uses datadog for the RUM, this represents a major implementation change, and there may be differences in the way it works with the default, and therefore differences in the metrics.

For example, in the default mode (trackViewsManually=false), the loading_type is distinguished between initial_load and route_change. If you call datadogRum.startView manually, the value is always initial_load

To avoid these side effects, the aim would be to be able to define the name of a view without having to call the startView itself. We keep the native way of working, no need to make a custom implementation on the route.

My change is a proposal: I don't know why it's impossible to edit this field and I don't know exactly what the implications of this addition are.

Changes

Possibility to set event.view.name in the beforeSend callback :

      beforeSend: (event) => {
        if (event.type === "view") {
          event.view.name = getViewName(event.view?.url);
        }
      },

Testing

  • Local
  • Staging
  • Unit
  • End to end

I have gone over the contributing documentation.

@bits-bot
Copy link

bits-bot commented Aug 29, 2023

CLA assistant check
All committers have signed the CLA.

@arichard-info arichard-info marked this pull request as ready for review August 29, 2023 12:58
@arichard-info arichard-info requested a review from a team as a code owner August 29, 2023 12:58
@arichard-info arichard-info changed the title Add view.name to customizable field paths ✨ add "view.name" to customizable field paths Aug 29, 2023
@arichard-info arichard-info changed the title ✨ add "view.name" to customizable field paths ✨ allow to change "view.name" Aug 29, 2023
@bcaudan bcaudan changed the title ✨ allow to change "view.name" ✨ [RUM-1016] allow to change "view.name" Sep 6, 2023
@bcaudan bcaudan merged commit a4126ec into DataDog:main Sep 7, 2023
@bcaudan
Copy link
Contributor

bcaudan commented Sep 13, 2023

Released in v4.49.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants