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

include response error data #1161

Merged
merged 6 commits into from Jan 27, 2020
Merged

Conversation

xiao-lix
Copy link
Contributor

Include response error data in part C on dependency event when ajax respond code is not 200.

Closes: #1156

@xiao-lix xiao-lix requested a review from a team as a code owner January 17, 2020 23:36
@@ -557,6 +559,11 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
}
}

if (_self._config.includeResponseErrorData && xhr.status !== 200) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_self._config.includeResponseErrorData && xhr.status !== 200 [](start = 16, length = 60)

Do we want to do this for all !=200 status codes or should we just check >=400 ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 we should only do this for status >= 400

As any response from 200 -> 299 is considered to be a success response, a common response is 204 == No Content.
And 300-> 399 are redirects

Copy link
Member

@ramthi ramthi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -557,6 +559,11 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
}
}

if (_self._config.includeResponseErrorData && xhr.status !== 200) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 we should only do this for status >= 400

As any response from 200 -> 299 is considered to be a success response, a common response is 204 == No Content.
And 300-> 399 are redirects

Copy link
Contributor

@markwolff markwolff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also add config option to README

@@ -557,6 +559,11 @@ export class AjaxMonitor extends BaseTelemetryPlugin implements IDependenciesPlu
}
}

if (_self._config.includeResponseErrorData && xhr.status !== 200) {
dependency.properties = dependency.properties || {};
dependency.properties.responseError = xhr.statusText + " - " + xhr.responseText;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: rename to responseMessage or responseText, to convey string type instead of Error.

@@ -61,6 +61,7 @@ export class ApplicationInsightsTests extends TestClass {
disableFetchTracking: false,
enableRequestHeaderTracking: true,
enableResponseHeaderTracking: true,
includeResponseErrorData: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be renamed to disableAjaxErrorStatusText since it seems like something we would want to enable by default.

@xiao-lix xiao-lix merged commit 322ebf6 into master Jan 27, 2020
@xiao-lix xiao-lix deleted the users/lxiao/response-error-data branch January 27, 2020 21:45
@@ -294,6 +294,14 @@ export interface IConfig {
*/
enableResponseHeaderTracking?: boolean;

/**
* @description An optional value that will track Resonse Error data through trackDependency function.
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small typo in description Resonse

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.

Allow to include response error data on failed requests
5 participants