Skip to content

Commit fe2d362

Browse files
authored
Add response error graphql properties (#308)
* Add response error graphql tracking in rum event format * Typo and description * Nitpick
1 parent 6429a4b commit fe2d362

File tree

4 files changed

+213
-0
lines changed

4 files changed

+213
-0
lines changed

lib/cjs/generated/rum.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,42 @@ export declare type RumResourceEvent = CommonProperties & ActionChildProperties
769769
* String representation of the operation variables
770770
*/
771771
variables?: string;
772+
/**
773+
* Number of GraphQL errors in the response
774+
*/
775+
readonly error_count?: number;
776+
/**
777+
* Array of GraphQL errors from the response
778+
*/
779+
readonly errors?: {
780+
/**
781+
* Error message
782+
*/
783+
readonly message: string;
784+
/**
785+
* Error code (used by some providers)
786+
*/
787+
readonly code?: string;
788+
/**
789+
* Array of error locations in the GraphQL query
790+
*/
791+
readonly locations?: {
792+
/**
793+
* Line number where the error occurred
794+
*/
795+
readonly line: number;
796+
/**
797+
* Column number where the error occurred
798+
*/
799+
readonly column: number;
800+
[k: string]: unknown;
801+
}[];
802+
/**
803+
* Path to the field that caused the error
804+
*/
805+
readonly path?: (string | number)[];
806+
[k: string]: unknown;
807+
}[];
772808
[k: string]: unknown;
773809
};
774810
[k: string]: unknown;

lib/esm/generated/rum.d.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,42 @@ export declare type RumResourceEvent = CommonProperties & ActionChildProperties
769769
* String representation of the operation variables
770770
*/
771771
variables?: string;
772+
/**
773+
* Number of GraphQL errors in the response
774+
*/
775+
readonly error_count?: number;
776+
/**
777+
* Array of GraphQL errors from the response
778+
*/
779+
readonly errors?: {
780+
/**
781+
* Error message
782+
*/
783+
readonly message: string;
784+
/**
785+
* Error code (used by some providers)
786+
*/
787+
readonly code?: string;
788+
/**
789+
* Array of error locations in the GraphQL query
790+
*/
791+
readonly locations?: {
792+
/**
793+
* Line number where the error occurred
794+
*/
795+
readonly line: number;
796+
/**
797+
* Column number where the error occurred
798+
*/
799+
readonly column: number;
800+
[k: string]: unknown;
801+
}[];
802+
/**
803+
* Path to the field that caused the error
804+
*/
805+
readonly path?: (string | number)[];
806+
[k: string]: unknown;
807+
}[];
772808
[k: string]: unknown;
773809
};
774810
[k: string]: unknown;
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"type": "resource",
3+
"date": 1591284175328,
4+
"application": {
5+
"id": "ac8218cf-498b-4d33-bd44-151095959547"
6+
},
7+
"session": {
8+
"id": "cacbf45c-3a05-48ce-b066-d76349460599",
9+
"type": "user"
10+
},
11+
"source": "browser",
12+
"view": {
13+
"id": "623d50fd-75cf-4025-97d2-e51ff94171f6",
14+
"referrer": "",
15+
"url": "https://app.datadoghq.com/rum/explorer?live=1h&query=&tab=view"
16+
},
17+
"resource": {
18+
"id": "b83a5d82-cdd1-468d-9bc9-3aa9e54d957a",
19+
"type": "fetch",
20+
"method": "POST",
21+
"url": "https://api.example.com/graphql",
22+
"status_code": 200,
23+
"duration": 246580000,
24+
"size": 3599,
25+
"encoded_body_size": 1599,
26+
"decoded_body_size": 3599,
27+
"transfer_size": 3699,
28+
"render_blocking_status": "non-blocking",
29+
"protocol": "HTTP/1.1",
30+
"delivery_type": "cache",
31+
"graphql": {
32+
"operationType": "query",
33+
"operationName": "GetUserProfile",
34+
"variables": "{\"userId\": \"123\"}",
35+
"payload": "query GetUserProfile($userId: ID!) { user(id: $userId) { name email } }",
36+
"error_count": 2,
37+
"errors": [
38+
{
39+
"message": "User not found",
40+
"code": "USER_NOT_FOUND",
41+
"locations": [
42+
{
43+
"line": 1,
44+
"column": 15
45+
}
46+
],
47+
"path": ["user", 1]
48+
},
49+
{
50+
"message": "Invalid email format",
51+
"code": "INVALID_EMAIL",
52+
"locations": [
53+
{
54+
"line": 1,
55+
"column": 25
56+
}
57+
],
58+
"path": ["user", "email"]
59+
}
60+
]
61+
}
62+
},
63+
"action": {
64+
"id": "ae3a5d82-cdd1-468d-9bc9-3aa9e54d953c"
65+
},
66+
"_dd": {
67+
"format_version": 2,
68+
"span_id": "12345",
69+
"parent_span_id": "67890",
70+
"trace_id": "7890"
71+
}
72+
}

schemas/rum/resource-schema.json

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,75 @@
307307
"type": "string",
308308
"description": "String representation of the operation variables",
309309
"readOnly": false
310+
},
311+
"error_count": {
312+
"type": "integer",
313+
"description": "Number of GraphQL errors in the response",
314+
"minimum": 0,
315+
"readOnly": true
316+
},
317+
"errors": {
318+
"type": "array",
319+
"description": "Array of GraphQL errors from the response",
320+
"items": {
321+
"type": "object",
322+
"description": "GraphQL error details",
323+
"required": ["message"],
324+
"properties": {
325+
"message": {
326+
"type": "string",
327+
"description": "Error message",
328+
"readOnly": true
329+
},
330+
"code": {
331+
"type": "string",
332+
"description": "Error code (used by some providers)",
333+
"readOnly": true
334+
},
335+
"locations": {
336+
"type": "array",
337+
"description": "Array of error locations in the GraphQL query",
338+
"items": {
339+
"type": "object",
340+
"description": "Error location",
341+
"required": ["line", "column"],
342+
"properties": {
343+
"line": {
344+
"type": "integer",
345+
"description": "Line number where the error occurred",
346+
"minimum": 1,
347+
"readOnly": true
348+
},
349+
"column": {
350+
"type": "integer",
351+
"description": "Column number where the error occurred",
352+
"minimum": 1,
353+
"readOnly": true
354+
}
355+
},
356+
"readOnly": true
357+
},
358+
"readOnly": true
359+
},
360+
"path": {
361+
"type": "array",
362+
"description": "Path to the field that caused the error",
363+
"items": {
364+
"oneOf": [
365+
{
366+
"type": "string"
367+
},
368+
{
369+
"type": "integer"
370+
}
371+
]
372+
},
373+
"readOnly": true
374+
}
375+
},
376+
"readOnly": true
377+
},
378+
"readOnly": true
310379
}
311380
},
312381
"readOnly": true

0 commit comments

Comments
 (0)