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

Issue 1094 #1096

Merged
merged 6 commits into from
Nov 4, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions extensions/applicationinsights-dependencies-js/src/ajax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ export class AjaxMonitor implements ITelemetryPlugin, IDependenciesPlugin, IInst
protected _config: ICorrelationConfig;
protected _nextPlugin: ITelemetryPlugin;
protected _trackAjaxAttempts: number = 0;
private currentWindowHost;
private currentWindowHost: string;
private _context: ITelemetryContext;
private _isUsingW3CHeaders: boolean;
private _isUsingAIHeaders: boolean;

constructor() {
this.currentWindowHost = window && window.location && window.location.host && window.location.host.toLowerCase();
this.currentWindowHost = typeof window === 'object' && window.location && window.location.host && window.location.host.toLowerCase();
this.initialized = false;
this._fetchInitialized = false;
}
Expand Down Expand Up @@ -322,7 +322,9 @@ export class AjaxMonitor implements ITelemetryPlugin, IDependenciesPlugin, IInst
/// <returns>True if Ajax monitoring is supported on this page, otherwise false</returns>
private supportsAjaxMonitoring(): boolean {
let result = true;
if (CoreUtils.isNullOrUndefined(XMLHttpRequest) ||

if (typeof XMLHttpRequest !== 'function' ||
aaronpowell marked this conversation as resolved.
Show resolved Hide resolved
CoreUtils.isNullOrUndefined(XMLHttpRequest) ||
CoreUtils.isNullOrUndefined(XMLHttpRequest.prototype) ||
CoreUtils.isNullOrUndefined(XMLHttpRequest.prototype.open) ||
CoreUtils.isNullOrUndefined(XMLHttpRequest.prototype.send) ||
Expand Down Expand Up @@ -583,7 +585,7 @@ export class AjaxMonitor implements ITelemetryPlugin, IDependenciesPlugin, IInst

private supportsFetch(): boolean {
let result: boolean = true;
if (!window || CoreUtils.isNullOrUndefined((window as any).Request) ||
if (typeof window !== 'object' || CoreUtils.isNullOrUndefined((window as any).Request) ||
CoreUtils.isNullOrUndefined((window as any).Request.prototype) ||
CoreUtils.isNullOrUndefined(window.fetch)) {
result = false;
Expand Down
5 changes: 3 additions & 2 deletions legacy/JavaScript/JavaScriptSDK/ajax/ajax.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module Microsoft.ApplicationInsights {
private currentWindowHost;

constructor(appInsights: Microsoft.ApplicationInsights.AppInsights) {
this.currentWindowHost = window.location.host && window.location.host.toLowerCase();
this.currentWindowHost = typeof window == 'object' ? window.location.host && window.location.host.toLowerCase() : undefined;
aaronpowell marked this conversation as resolved.
Show resolved Hide resolved
this.appInsights = appInsights;
this.initialized = false;
this.Init();
Expand Down Expand Up @@ -63,7 +63,8 @@ module Microsoft.ApplicationInsights {
///<returns>True if Ajax monitoring is supported on this page, otherwise false</returns>
private supportsMonitoring(): boolean {
var result = true;
if (extensions.IsNullOrUndefined(XMLHttpRequest) ||
if (typeof XMLHttpRequest !== 'function' ||
extensions.IsNullOrUndefined(XMLHttpRequest) ||
extensions.IsNullOrUndefined(XMLHttpRequest.prototype) ||
extensions.IsNullOrUndefined(XMLHttpRequest.prototype.open) ||
extensions.IsNullOrUndefined(XMLHttpRequest.prototype.send) ||
Expand Down