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

Allow ViewEvent.Context.additionalProperties to be mutable #958

Closed
lgvalle opened this issue Jun 22, 2022 · 2 comments
Closed

Allow ViewEvent.Context.additionalProperties to be mutable #958

lgvalle opened this issue Jun 22, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@lgvalle
Copy link

lgvalle commented Jun 22, 2022

Is your feature request related to a problem? Please describe.
The problem we're facing is we'd like to enrich ViewEvents with custom attributes but additionalProperties can't be modified

The approach we're following is to set up EventMapper<ViewEvent> to get a callback when a ViewEvent is generated.
As it's known you can't clone the viewEvent or it will be discarded. So only a few var properties can be modified. The Context.additionalProperties is a map that looks like the right place to add extra properties but unfortunately is not mutable.

Describe the solution you'd like
Change

public val additionalProperties: Map<String, Any?> = emptyMap(),

to

public var additionalProperties: Map<String, Any?> = emptyMap()

or alternatively to

public val additionalProperties: MutableMap<String, Any?> = mutableMapOf()

so extra properties can be added to ViewEvents

Describe alternatives you've considered
The alternative we've considered was to write a custom ViewTrackingStrategy that will create its own set of attributes to track, but it seems overkill for this

Additional context
Alternatively consider allowing the injection of custom rules on RumEventMapper regarding which events are dropped to, for example, allow events that are not the same instance (aka, allow .copy())

@lgvalle lgvalle added the enhancement New feature or request label Jun 22, 2022
@xgouchet
Copy link
Member

Hi @lgvalle , thanks alot for this feature request. Indeed for now we don't allow modification of the additional properties, but we are considering adding some APIs to allow enriching the view.
You can also add custom attributes through the GlobalRum.addAttribute() (and similar methods).

@0xnm
Copy link
Member

0xnm commented Nov 9, 2022

Hello @lgvalle! ViewEvent.Context.additionalProperties is now mutable (it has the type MutableMap<String, Any?>, this change was done in #1089) and was delivered in the release 1.15.0.

I'm closing this issue as your request was implemented, don't hesitate to re-open it if needed.

@0xnm 0xnm closed this as completed Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants