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

[Enhancement] Add a sender that uses fetch when XMLHttpRequest is not available #1556

Merged
merged 8 commits into from
Apr 29, 2021

Conversation

xiao-lix
Copy link
Contributor

@xiao-lix xiao-lix commented Apr 27, 2021

@xiao-lix xiao-lix requested a review from MSNev April 27, 2021 23:52
QUnit.assert.equal(0, this._getXhrRequests().length, "xhr sender is not called");
QUnit.assert.ok(fetchstub.called, "fetch sender is called");
// store it back
(window as any).XMLHttpRequest = fakeXMLHttpRequest;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Need to store the xhr request back to fake request - otherwise it impacts the following tests.

@@ -229,11 +237,17 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControlsAI {
_InternalMessageId.InvalidInstrumentationKey, "Invalid Instrumentation key "+config.instrumentationKey);
}

if (!isInternalApplicationInsightsEndpoint(_self._senderConfig.endpointUrl()) && _self._senderConfig.customHeaders() && _self._senderConfig.customHeaders().length > 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

customHeaders are only added to request when endpointUrl is not Breeze.

@xiao-lix xiao-lix requested a review from kryalama April 28, 2021 17:44
AISKU/src/Initialization.ts Outdated Show resolved Hide resolved
AISKU/src/Initialization.ts Outdated Show resolved Hide resolved
README.md Outdated
@@ -310,6 +310,7 @@ Most configuration fields are named such that they can be defaulted to falsey. A
| enablePerfMgr | boolean | false | [Optional] When enabled (true) this will create local perfEvents for code that has been instrumented to emit perfEvents (via the doPerf() helper). This can be used to identify performance issues within the SDK based on your usage or optionally within your own instrumented code. [More details are available by the basic documentation](./docs/PerformanceMonitoring.md). Since v2.5.7
| perfEvtsSendAll | boolean | false | [Optional] When _enablePerfMgr_ is enabled and the [IPerfManager](https://github.com/microsoft/ApplicationInsights-JS/blob/master/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IPerfManager.ts) fires a [INotificationManager](https://github.com/microsoft/ApplicationInsights-JS/blob/master/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/INotificationManager.ts).perfEvent() this flag determines whether an event is fired (and sent to all listeners) for all events (true) or only for 'parent' events (false &lt;default&gt;).<br />A parent [IPerfEvent](https://github.com/microsoft/ApplicationInsights-JS/blob/master/shared/AppInsightsCore/src/JavaScriptSDK.Interfaces/IPerfEvent.ts) is an event where no other IPerfEvent is still running at the point of this event being created and it's _parent_ property is not null or undefined. Since v2.5.7
| idLength | numeric | 22 | [Optional] Identifies the default length used to generate new random session and user id's. Defaults to 22, previous default value was 5 (v2.5.8 or less), if you need to keep the previous maximum length you should set this value to 5.
| customHeaders | `[{header: string, value: string}]` | undefined | [Optional] The ability for the user to provide extra headers when using a custom endpoint.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add new configuration here.

@MSNev MSNev added this to the 2.x.x (Next) milestone Apr 29, 2021
@MSNev
Copy link
Collaborator

MSNev commented Apr 29, 2021

I've updated the issues to tag them with the next milestone "2.x.x (Next Release)" as this makes it a LOT easier to keep track of the items for the release notes.

Also once this is checked in, please keep the issues Open (re-open if git-hub closes them) and add the tag "fixed - waiting for release" as again this is for tracking and it makes it obvious that the issue still exists in all released versions.

@xiao-lix xiao-lix merged commit dcd4c34 into master Apr 29, 2021
@MSNev MSNev deleted the lxiao/fetch-sender branch August 4, 2021 19:42
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.

3 participants