Skip to content

Commit 3fcc7af

Browse files
authored
✨[RUM-12672] Allow graphql variables field to be modifiable in beforeSend (#3949)
* allow graphql resource to be modifiable in before-send * Remove global object for specific field
1 parent a0f5d69 commit 3fcc7af

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

packages/rum-core/src/domain/assembly.spec.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,33 @@ describe('rum assembly', () => {
215215
})
216216
})
217217

218+
describe('field resource.graphql on Resource events', () => {
219+
it('should allow modification of resource.graphql.variables property', () => {
220+
const { lifeCycle, serverRumEvents } = setupAssemblyTestWithDefaults({
221+
partialConfiguration: {
222+
beforeSend: (event) => {
223+
if (event.resource!.graphql) {
224+
event.resource!.graphql.variables = '{"modified":"value"}'
225+
}
226+
},
227+
},
228+
})
229+
230+
notifyRawRumEvent(lifeCycle, {
231+
rawRumEvent: createRawRumEvent(RumEventType.RESOURCE, {
232+
resource: {
233+
graphql: {
234+
operationType: 'query',
235+
variables: '{"original":"value"}',
236+
},
237+
},
238+
}),
239+
})
240+
241+
expect((serverRumEvents[0] as RumResourceEvent).resource.graphql!.variables).toBe('{"modified":"value"}')
242+
})
243+
})
244+
218245
it('should reject modification of field not sensitive, context or customer provided', () => {
219246
const { lifeCycle, serverRumEvents } = setupAssemblyTestWithDefaults({
220247
partialConfiguration: {

packages/rum-core/src/domain/assembly.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ export function startRumAssembly(
5959
},
6060
[RumEventType.RESOURCE]: {
6161
'resource.url': 'string',
62+
'resource.graphql.variables': 'string',
6263
...USER_CUSTOMIZABLE_FIELD_PATHS,
6364
...VIEW_MODIFIABLE_FIELD_PATHS,
6465
...ROOT_MODIFIABLE_FIELD_PATHS,

0 commit comments

Comments
 (0)