push neon reactor

This commit is contained in:
2026-07-12 15:11:38 +02:00
parent 172e72dbcd
commit aeab5f7820
9597 changed files with 2407488 additions and 0 deletions
@@ -0,0 +1,9 @@
# Microsoft Open Source Code of Conduct
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
Resources:
- [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
- [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
- Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
@@ -0,0 +1,14 @@
# Contributing
This project welcomes contributions and suggestions. Most contributions require you to
agree to a Contributor License Agreement (CLA) declaring that you have the right to,
and actually do, grant us the rights to use your contribution. For details, visit
https://cla.microsoft.com.
When you submit a pull request, a CLA-bot will automatically determine whether you need
to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the
instructions provided by the bot. You will only need to do this once across all repositories using our CLA.
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
+21
View File
@@ -0,0 +1,21 @@
The MIT License (MIT)
Copyright (c) Microsoft Corporation
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+17
View File
@@ -0,0 +1,17 @@
NOTICES AND INFORMATION
Do Not Translate or Localize
This software incorporates material from third parties. Microsoft makes certain
open source code available at https://3rdpartysource.microsoft.com, or you may
send a check or money order for US $5.00, including the product name, the open
source component name, and version number, to:
Source Code Compliance Team
Microsoft Corporation
One Microsoft Way
Redmond, WA 98052
USA
Notwithstanding any other terms, you may reverse engineer this software to the
extent required to debug changes to any libraries licensed under the GNU Lesser
General Public License.
+3
View File
@@ -0,0 +1,3 @@
# Data Collection
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsofts privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
+355
View File
@@ -0,0 +1,355 @@
# Microsoft 1DS Web SDK Post Plugin
## Description
1DS Web SDK Post Channel main functionality is to send data to OneCollector using POST, currently supporting XMLHttpRequest, fetch API and XDomainRequest.
## npm
Packages available [here](https://www.npmjs.com/package/@microsoft/1ds-post-js).
## Basic Usage
### Setup
```js
import { AppInsightsCore, IExtendedConfiguration } from '@microsoft/1ds-core-js';
import { PostChannel, IChannelConfiguration } from '@microsoft/1ds-post-js';
```
```js
var appInsightsCore: AppInsightsCore = new AppInsightsCore();
var postChannel: PostChannel = new PostChannel();
var coreConfig: IExtendedConfiguration = {
instrumentationKey: "YOUR_TENANT_KEY",
extensions: [
postChannel
],
extensionConfig: {}
};
var postChannelConfig: IChannelConfiguration = {
eventsLimitInMem: 5000
};
coreConfig.extensionConfig[postChannel.identifier] = postChannelConfig;
//Initialize SDK
appInsightsCore.initialize(coreConfig, []);
```
## Configuration
### [IChannelConfiguration](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html)
| Config | Description | Type
|----------------|--------------|----
| [eventsLimitInMem](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#eventsLimitInMem) | The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.|number
| [immediateEventLimit](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#immediateEventLimit) | [Optional] Sets the maximum number of immediate latency events that will be cached in memory before the SDK starts to drop other immediate events only, does not drop normal and real time latency events as immediate events have their own internal queue. Under normal situations immediate events are scheduled to be sent in the next Javascript execution cycle, so the typically number of immediate events is small (~1), the only time more than one event may be present is when the channel is paused or immediate send is disabled (via manual transmit profile). By default max number of events is 500 and the default transmit time is 0ms. Added in v3.1.1 | number
| [autoFlushEventsLimit](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#autoFlushEventsLimit) | [Optional] If defined, once this number of events has been queued the system perform a flush() to send the queued events without waiting for the normal schedule timers. Default is undefined | number
| [httpXHROverride](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#httpXHROverride) |The HTTP override that should be used to send requests, request properties and headers should be added to the request to maintain correct functionality with other plugins.|IXHROverride
| [overrideInstrumentationKey](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#overrideInstrumentationKey) |Override for Instrumentation key.|string
| [overrideEndpointUrl](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#overrideEndpointUrl) |Override for Endpoint where telemetry data is sent.|string
| [disableTelemetry](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#disableTelemetry) |The master off switch. Do not send any data if set to TRUE.|boolean
| [ignoreMc1Ms0CookieProcessing](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#ignoreMc1Ms0CookieProcessing) |MC1 and MSFPC cookies will not be provided. Default is false.|boolean
| [payloadPreprocessor](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#payloadPreprocessor) |POST channel preprocessing function. Can be used to gzip the payload (and set appropriate HTTP headers) before transmission. |[Function](./src/DataModels.ts)
| [payloadListener](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#payloadListener) |POST channel function hook to listen to events being sent, called after the batched events have been committed to be sent. Also used by Remote DDV Channel to send requests. |[Function](./src/DataModels.ts)
| [disableEventTimings](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#disableEventTimings) | [Optional] By default additional timing metrics details are added to each event after they are sent to allow you to review how long it took to create serialized request. As not all users require this level of detail and it's now possible to get the same metrics via the IPerfManager and IPerfEvent, so you can now disabled this previous level. Default value is false to retain the previous behavior, if you are not using these metrics and performance is a concern then it is recommended to set this value to true. | boolean
| [valueSanitizer](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#valueSanitizer) | [Optional] The value sanitizer to use while constructing the envelope, if not provided the default sanitizeProperty() method is called to validate and convert the fields for serialization. The path / fields names are based on the format of the envelope (serialized object) as defined via the [Common Schema 4.0](https://aka.ms/CommonSchema) specification. | IValueSanitizer
| [stringifyObjects](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#stringifyObjects) | [Optional] During serialization, when an object is identified should the object serialized by true => JSON.stringify(theObject); otherwise theObject.toString(). Defaults to false. | boolean
| [enableCompoundKey](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#enableCompoundKey) | [Optional] Enables support for objects with compound keys which indirectly represent an object eg. event: { "somedata.embeddedvalue": 123 } where the "key" of the object contains a "." as part of it's name. Defaults to false. | boolean
| [disableOptimizeObj](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#disableOptimizeObj) | [Optional] Switch to disable the v8 `optimizeObject()` calls used to provide better serialization performance. Defaults to false. | boolean
| [transports](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#transports) | [Optional] Either an array or single value identifying the requested `TransportType` (const enum) type that should be used. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided. | number or number[]
| [useSendBeacon](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#useSendBeacon) | [Optional] A flag to enable or disable the usage of the sendBeacon() API if available by the runtime. If running on ReactNative this defaults to `false` for all other cases it defaults to `true`.
| [disableFetchKeepAlive](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#disableFetchKeepAlive) | [Optional] A flag to disable the usage of the [fetch with keep-alive](https://javascript.info/fetch-api#keepalive) support.
| [unloadTransports](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#unloadTransports) | [Optional] Either an array or single value identifying the requested TransportType type(s) that should be used during unload or events marked as sendBeacon. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided and alwaysUseXhrOverride is true.
| [avoidOptions](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#avoidOptions)<br/><sub><i>(Since 3.1.10+)</i></sub><br /><sub>Default: false (Since 3.2.0)<br />Previously true</sub> | [Optional] Avoid adding request headers to the outgoing request that would cause a pre-flight (OPTIONS) request to be sent for each request. | boolean
| [xhrTimeout](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#xhrTimeout)<br/><sub><i>(Since 3.1.11+)</i></sub> | [Optional] Specify a timeout (in ms) to apply to requests when sending requests using XHR or fetch() requests only, does not affect sendBeacon() or XDR (XDomainRequest) usage. Defaults to undefined and therefore the runtime defaults (normally zero for browser environments) | number
| [disableXhrSync](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#disableXhrSync)<br/><sub><i>(Since 3.1.11+)</i></sub> | [Optional] When using [Xhr](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) for sending requests disable sending as synchronous during unload or synchronous flush. __You should enable this feature for IE (when there is no sendBeacon() or fetch (with keep-alive) support) and you have clients that end up blocking the UI during page unloading__. <span style="color:red">This will cause ALL XHR requests to be sent asynchronously which during page unload may result in the lose of telemetry</span>. This does not affect any other request type (fetch(), sendBeacon() or XDR (XDomainRequest)) | boolean<br/>Default: undefined
| [alwaysUseXhrOverride](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#alwaysUseXhrOverride)<br /><sub><i>(Since 3.1.11+)</i></sub> | [Optional] By default during unload (or when you specify to use sendBeacon() or sync fetch (with keep-alive) for an event) the SDK ignores any provided httpXhrOverride and attempts to use sendBeacon() or fetch(with keep-alive) when they are available. When this configuration option is true any provided httpXhrOverride will always be used, so any provided httpXhrOverride will also need to "handle" the synchronous unload scenario. | boolean<br /> Default: false
| [maxEventRetryAttempts](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#maxEventRetryAttempts)<br /><sub><i>(Since 3.1.11+)</i></sub> | [Optional] Identifies the number of times any single event will be retried if it receives a failed (retirable) response, this causes the event to be internally "requeued" and resent in the next batch. As each normal batched send request is retried at least once before starting to increase the internal backoff send interval, normally batched events will generally be attempted the next nearest even number of times. This means that the total number of actual send attempts will almost always be even (setting to 5 will cause 6 requests), unless using manual synchronous flushing (calling flush(false)) which is not subject to request level retry attempts. | number<br/>Default: 6
| [maxUnloadEventRetryAttempts](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#maxUnloadEventRetryAttempts)<br /><sub><i>(Since 3.1.11+)</i></sub> | [Optional] Identifies the number of times any single event will be retried if it receives a failed (retriable) response as part of processing / flushing events once a page unload state has been detected, this causes the event to be internally "requeued" and resent in the next batch, which during page unload. Unlike the normal batching process, send requests are never retried, so the value listed here is always the maximum number of attempts for any single event.<br/>Notes: The SDK by default will use the sendBeacon() API if it exists which is treated as a fire and forget successful response, so for environments that support or supply this API the events won't be retried (because they will be deeded to be successfully sent). When an environment (IE) doesn't support sendBeacon(), this will cause multiple synchronous (by default) XMLHttpRequests to be sent, which will block the UI until a response is received. You can disable ALL synchronous XHR requests by setting the 'disableXhrSync' configuration setting and/or changing this value to 0 or 1. | number<br/>Default: 2
| [addNoResponse](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#addNoResponse) <br /><sub><i>(Since 3.2.8+)</i></sub> | [Optional] flag to indicate whether the sendBeacon and fetch (with keep-alive flag) should add the "NoResponseBody" query string value to indicate that the server should return a 204 for successful requests. | boolean<br/>Default: true
| [disableZip](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IChannelConfiguration.html#disableZip) <br /><sub><i>(Since 4.3.7+)</i></sub> | [Optional] flag to use CompressionStream API to compress the payload. Compression will only occur if the event is asynchronous. For events like unloads, compression will not be applied. * Note: if user set payloadPreprocessor, this zip compression will not be applied. | boolean<br/>Default: true
### [IXHROverride](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IXHROverride.html)
| Config | Description | Type
|----------------|----------------------------------------|----|
| [sendPOST](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/interfaces/IXHROverride.html#sendPOST) |This method sends data to the specified URI using a POST request. If sync is true then the request is sent synchronously. The <i>oncomplete</i> function should always be called after the request is completed (either successfully or timed out or failed due to errors).|function
### Payload Preprocessors
```ts
interface IPayloadData {
urlString: string;
data: Uint8Array | string;
headers?: { [name: string]: string };
timeout?: number; // Optional value supplied by the xhrTimeout configuration option
disableXhrSync?: boolean; // Optional value supplied by the disableXhrSync configuration option
}
type PayloadPreprocessorFunction = (payload: IPayloadData, callback: (modifiedBuffer: IPayloadData) => void) => void;
```
To perform some preprocessing operation on your payload before it is sent over the wire, you can supply the POST channel config with a `payloadPreprocessor` function. A typical usage of it would be to gzip your payloads.
```ts
const zlib = require('zlib');
const gzipFn: PayloadPreprocessorFunction = (payload: IPayloadData, cb) => {
zlib.gzip(payload.data, (err, dataToSend) => {
if (err) return cb(payload); // send original payload on error
const payloadToSend = {
...payload,
headers: { ...payload.headers, 'Content-Encoding': 'gzip' };
data: dataToSend,
};
cb(payloadToSend);
});
}
```
### XHR Override
```ts
/**
* SendPOSTFunction type defines how an HTTP POST request is sent to an ingestion server
* @param payload - The payload object that should be sent, contains the url, bytes/string and headers for the request
* @param oncomplete - The function to call once the request has completed whether a success, failure or timeout
* @param sync - A boolean flag indicating whether the request should be sent as a synchronous request.
*/
export type SendPOSTFunction = (payload: IPayloadData, oncomplete: (status: number, headers: { [headerName: string]: string; }, response?: string) => void, sync?: boolean) => void;
/**
* The IXHROverride interface overrides the way HTTP requests are sent.
*/
export interface IXHROverride {
/**
* This method sends data to the specified URI using a POST request. If sync is true,
* then the request is sent synchronously. The <i>oncomplete</i> function should always be called after the request is
* completed (either successfully or timed out or failed due to errors).
*/
sendPOST: SendPOSTFunction;
}
```
#### Example using node.js Https module
```ts
const oneDs = require('@microsoft/1ds-analytics-js');
const https = require('https');
// XHR override using node.js https module
var customHttpXHROverride= {
sendPOST: (payload: IPayloadData, oncomplete) => {
var options = {
method: 'POST',
headers: {
...payload.headers,
"Content-Type": "application/json",
"Content-Length": Buffer.byteLength(payload.data)
}
};
const req = https.request(payload.urlString, options, res => {
res.on('data', function (responseData) {
oncomplete(res.statusCode, res.headers, responseData.toString());
});
});
req.write(payload.data);
req.end();
}
};
var postChannelConfig: IChannelConfiguration = {
httpXHROverride: customHttpXHROverride
};
```
#### Example always using fetch API
This example is using the [fetch() API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch) for all requests, include synchronous requests and assumes that the browser environment supports the (currently) experimental keepalive option (for chromium).
```ts
function fetchHttpXHROverride(payload: IPayloadData, onComplete: OnCompleteCallback, sync?: boolean) {
let ignoreResponse = false;
let responseHandled = false;
let requestInit: RequestInit = {
body: payload.data,
method: Method,
headers: payload.headers,
[DisabledPropertyName]: true,
credentials: "include"
};
if (sync) {
// You should validate whether the runtime environment supports this flag and if not you should use either sendBeacon or a synchronous XHR request
requestInit.keepalive = true;
if (sync) {
// As a sync request (during unload), it is unlikely that we will get a chance to process the response so
// just like beacon send assume that the events have been accepted and processed
ignoreResponse = true;
}
}
fetch(payload.urlString, requestInit).then((response) => {
let headerMap = {};
let responseText = "";
if (response.headers) {
response.headers.forEach((value: string, name: string) => {
headerMap[name] = value;
});
}
if (response.body) {
response.text().then(function(text) {
responseText = text;
});
}
if (!responseHandled) {
responseHandled = true;
onComplete(response.status, headerMap, responseText);
}
}).catch((error) => {
// In case there is an error in the request. Set the status to 0
// so that the events can be retried later.
if (!responseHandled) {
responseHandled = true;
onComplete(0, {});
}
});
// If we are treating this as a synchronous (keepAlive) we need to assume success during unload processing
if (ignoreResponse && !responseHandled) {
responseHandled = true;
onComplete(200, {});
}
// Simulate timeout if a timeout was supplied
if (!responseHandled && payload.timeout > 0) {
setTimeout(() => {
if (!responseHandled) {
// Assume a 500 response (which will cause a retry)
responseHandled = true;
onComplete(500, {});
}
}, payload.timeout);
}
}
let postChannelConfig: IChannelConfiguration = {
httpXHROverride: fetchHttpXHROverride,
// Enable this flag to cause the SDK to ALWAYS call your override otherwise during page unload the SDK will using it's internal
// sendPost implementation using sendBeacon() or fetch (with keepalive support) whichever is the first supported
//alwaysUseXhrOverride: true,
// If you want to specify a timeout this value is passed on the payload object as `payload.timeout`
//xhrTimeout: 20000,
};
```
## IValueSanitizer Paths / Fields which are excluded
To ensure that the service can continue to accept events that are sent from the SDK, some paths and fields are explicitly blocked and are never processed
via any configured valueSanitizer. These fields are blocked at the serialization level and cannot be overridden.
The path / fields names are based on the format of the envelope (serialized object) as defined via the [Common Schema 4.0](https://aka.ms/CommonSchema) specification, so the path / field names used for the IValueSanitizer are based on how the data is serialized to the service (CS 4.0 location) and not specifically the location
on the event object you pass into the track methods (unless they are the same).
The currently configured set of fields include
### Excluded Part A fields
- All direct top-level fields of the envelope, this includes "ver"; "name"; "time" and "iKey". see [Common Schema 4.0 - Part A](https://aka.ms/CommonSchema/PartA) for all defined fields. Note: This exclusion does does not match sub-keys (objects) like "ext", "data" and "properties".
- All fields of the web extension, this includes all fields and sub keys of "ext.web" (example fields include "ext.web.browser"; "ext.web.domain"; "ext.web.consentDetails"). see [Common Schema 4.0 - Part A Extension - web](https://aka.ms/CommonSchema/PartA/Web) for the complete set of defined fields.
- All fields and paths of the metadata extension, this includes all fields and sub keys of "ext.metadata". see [Common Schema 4.0 - Part A Extension - metadata](https://aka.ms/CommonSchema/PartA/MetaData) for the complete set of defined fields.
## Synchronous Events
By default events are batched and sent asynchronously, there are times when you want to send events immediately during the same JavaScript execution cycle.
To support this you can set the ```sync``` property on an event to tell the PostChannel to skip the normal event batching and send this event now within it's own outbound connection. Because each ```sync``` event will cause a new request / connection (per event) you should use this approach SPARINGLY to avoid creating an excessive number of requests from the users browser which may have a negative impact on their experience.
Note: If the initial synchronous request fails (not the normal case) any sync event will be queued for resending as an asynchronous batch (unless an "unload" event has been detected).
### Supported Sync values
Supported event ```sync``` values to cause an event to be sent immediately during the same JavaScript execution cycle.
In the case of the sendBeacon() and fetch() [with keepalive] (SyncFetch) both of these API's have a maximum payload size defined as 64Kb, as such if the size of the serialized (JSON) events are larger than this the events will be dropped as there is no safe way to send the event.
| Name | Value | Description
|----------|-------|-------------------
| Batched | undefined,<br />false,<br />0 | This is the default situation and will cause the event to be Batched and sent asynchronously.
| Synchronous | true,<br />1 | Attempt to send the request using the default synchronous method.<br />This will use the first available transport option:<br/>- httpXHROverride;<br/>-XMLHttpRequest (with sync flag);<br/>-fetch() [with keepalive] (Since v3.1.3);<br/>-sendBeacon() (Since v3.1.3)
| SendBeacon | 2 | (Since v3.1.3) Attempt to send the event synchronously with a preference for the sendBeacon() API.<br />This will use the first available transport option:<br/>-sendBeacon();<br/>-fetch() [with keepalive];<br/>-XMLHttpRequest (with sync flag);<br/>-httpXHROverride
| SyncFetch | 3 | (Since v3.1.3) Attempt to send the event synchronously with a preference for the fetch() API with the keepalive flag, the SDK checks to ensure that the fetch() implementation supports the 'keepalive' flag and if not it will skip this transport option.<br />This will use the first available transport option:<br/>-fetch() [with keepalive];<br/>-sendBeacon();<br/>-XMLHttpRequest (with sync flag);<br/>-httpXHROverride
The named values are available in TypeScript via the ```EventSendType``` const enum class since v3.1.3.
> Note: The SDK explicitly checks for ```keepalive``` support for fetch() via the ```Request``` class, so if not available this transport will not be used. [Browsers natively supporting fetch() keepalive](https://caniuse.com/?search=keepalive), as such any polyfill would also need to support this flag for it to be used.
___Special sendBeacon() Note___
As the sendBeacon() API does not provide any response handling, any events sent via this method are considered to have been successfully sent, even if the browser fails to send the requests. The only exception is that if the browser returns false indicating that it can't accept the sendBeacon() request, in this case the SDK will send a dropped event notification.
### When to use 'sync' events
Events that cause a page navigation can cause a race condition that could result in either event loss or duplication. This happens when any previously batched events have been sent (the request is in-flight) and the browser subsequently cancels the request before a response is processed AND it also triggers the JavaScript "cancel" or "abort" event, normally only during the unload process.
The SDK listens to all supported "unload" events (```unload```, ```beforeunload``` and ```pagehide```) and when any one of these are detected it will immediately send all (unsent) batched events via the "SendBeacon" (and fallback) methods above. This successfully mitigates the event loss case above, but it can compound the event duplication case for some scenarios as the SDK works to ensure that all events are sent and acknowledged.
This situation has become more prevalent with the enforcement by modern browsers to disallow, cancel or abort the usage of synchronous Xhr requests during page "unload" event.
There are effectively 2 scenarios where you should consider adding the `sync` property to an event (using the asynchronous SendBeacon and SyncFetch values) to remove the possibility of event duplication (the WebAnalytics extension already handles these cases).
1) You want to send your own event during the page "unload" events and you have hooked the "unload" events yourself (before) initializing the SDK.
- When you listen to the events "before" the SDK initializes, there is a small window of time where any "batched" event may get sent (and therefore become in-flight) before the SDK receives and processes the "unload" events, thus the potential race condition.
- If you attach to the "unload" events "after" the SDK is initialized, it will now (since v3.1.3) automatically convert all received event(s) into "sync" (SendBeacon) events to ensure delivery.
2) You want to send you own telemetry event(s) based on some user action after which a page-navigation immediately occurs, either via an anchor &lt;a /&gt; containing a href and letting the event bubble or by directly causing a navigation via a form Post or location change.
- This is because because the href / post / location change will eventually cause an "unload" event to occur and therefore (potentially) any outbound (in-flight) requests may get canceled and cause event to be duplicated.
- While this situation can occur with any other batched events, it is more likely to occur when events are created during these know situations that are known to directly trigger the "unload" cycle.
## API documentation
[Typedoc generated API reference](https://microsoft.github.io/ApplicationInsights-JS/webSdk/1ds-post-js/index.html)
## Learn More
You can learn more in [1DS First party getting started](https://aka.ms/1dsjs).
## Data Collection
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at [https://go.microsoft.com/fwlink/?LinkID=824704](https://go.microsoft.com/fwlink/?LinkID=824704). You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
To turn off sending telemetry to Microsoft, ensure that the POST channel is not configured in the extensions. See below configuration for example:
```js
var coreConfig: IExtendedConfiguration = {
instrumentationKey: "YOUR_TENANT_KEY",
extensions: [
postChannel // << REMOVE THIS EXTENSION TO STOP SENDING TELEMETRY TO MICROSOFT
],
extensionConfig: {}
};
```
## Contributing
Read our [contributing guide](./CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes to Application Insights.
## Data Collection
As this SDK is designed to enable applications to perform data collection which is sent to the Microsoft collection endpoints the following is required to identify our privacy statement.
The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsofts privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.
## Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsofts Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-partys policies.
## License
[MIT](./LICENSE.TXT)
+41
View File
@@ -0,0 +1,41 @@
<!-- BEGIN MICROSOFT SECURITY.MD V0.0.7 BLOCK -->
## Security
Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
## Reporting Security Issues
**Please do not report security vulnerabilities through public GitHub issues.**
Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
* Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
* Full paths of source file(s) related to the manifestation of the issue
* The location of the affected source code (tag/branch/commit or direct URL)
* Any special configuration required to reproduce the issue
* Step-by-step instructions to reproduce the issue
* Proof-of-concept or exploit code (if possible)
* Impact of the issue, including how an attacker might exploit the issue
This information will help us triage your report more quickly.
If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
## Preferred Languages
We prefer all communications to be in English.
## Policy
Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
<!-- END MICROSOFT SECURITY.MD BLOCK -->
+14
View File
@@ -0,0 +1,14 @@
# Support
## How to file issues and get help
This project uses GitHub Issues to track bugs and feature requests. Please search the existing
issues before filing new issues to avoid duplicates. For new issues, file your bug or
feature request as a new Issue.
For help and questions about using this project, please create a Support request issue on
https://github.com/microsoft/ApplicationInsights-JS/issues.
## Microsoft Support Policy
Support for this **PROJECT or PRODUCT** is limited to the resources listed above.
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,46 @@
{
"name": "ms.post",
"version": "4.3.11",
"ext": {
"@gbl.js": {
"file": "ms.post-4.3.11.gbl.js",
"type": "text/javascript; charset=utf-8",
"integrity": "sha256-rpCq8yvxE1UchUOEsf+4BYZOtFZ/zAI6k0SpXgsdGFM= sha384-3AXVB2BKYZSsYmnPZXSV2gdlC+/MV2izoq+GQkJkuA4ylNu0csI9mdszB+zNffBz sha512-a6DKbVV5rRQnaTjRlXIzaWihurp9D0dlBoXzaDxEV+orNCP1AoyxeDEkTohRrM+Siv9r4TXibVzoydKO1uV3uA==",
"hashes": {
"sha256": "rpCq8yvxE1UchUOEsf+4BYZOtFZ/zAI6k0SpXgsdGFM=",
"sha384": "3AXVB2BKYZSsYmnPZXSV2gdlC+/MV2izoq+GQkJkuA4ylNu0csI9mdszB+zNffBz",
"sha512": "a6DKbVV5rRQnaTjRlXIzaWihurp9D0dlBoXzaDxEV+orNCP1AoyxeDEkTohRrM+Siv9r4TXibVzoydKO1uV3uA=="
}
},
"@gbl.min.js": {
"file": "ms.post-4.3.11.gbl.min.js",
"type": "text/javascript; charset=utf-8",
"integrity": "sha256-lI2J8ZWW+7lMNur0ufWLk1yqY83Dm+9EJCG4q/WdMXg= sha384-mAerKbxZTOV1Nz34A324oUv1/bRadMnWoFIbsIP8GV8tU/1qz/Nid8e0Fs9FZ/7o sha512-5cFTX9prhAJA9OQSFGJlJEYICT8FiXH6sj3l3Pxbz1DiqUkQWVGQaNsLx9wiChi9PR5PIq5FToeK4DrvnKao/g==",
"hashes": {
"sha256": "lI2J8ZWW+7lMNur0ufWLk1yqY83Dm+9EJCG4q/WdMXg=",
"sha384": "mAerKbxZTOV1Nz34A324oUv1/bRadMnWoFIbsIP8GV8tU/1qz/Nid8e0Fs9FZ/7o",
"sha512": "5cFTX9prhAJA9OQSFGJlJEYICT8FiXH6sj3l3Pxbz1DiqUkQWVGQaNsLx9wiChi9PR5PIq5FToeK4DrvnKao/g=="
}
},
"@js": {
"file": "ms.post-4.3.11.js",
"type": "text/javascript; charset=utf-8",
"integrity": "sha256-0/5008gBqqv0rZYrTy2D89mXrBrsN7Cv1u8EZut46N8= sha384-KRIMjTLa3GELMbKGC+1jA0CNfb9gh3k0QjV7TsuSWKKuc2ZK5qrY3iUK5jJcybji sha512-s4krP9BnAge+pFj1lPb1yser/GG/b640sIefm6Cf6njL7LeofctilMkqmiRAfFDLV1FiRJvEM5pJnyWGUu3E4Q==",
"hashes": {
"sha256": "0/5008gBqqv0rZYrTy2D89mXrBrsN7Cv1u8EZut46N8=",
"sha384": "KRIMjTLa3GELMbKGC+1jA0CNfb9gh3k0QjV7TsuSWKKuc2ZK5qrY3iUK5jJcybji",
"sha512": "s4krP9BnAge+pFj1lPb1yser/GG/b640sIefm6Cf6njL7LeofctilMkqmiRAfFDLV1FiRJvEM5pJnyWGUu3E4Q=="
}
},
"@min.js": {
"file": "ms.post-4.3.11.min.js",
"type": "text/javascript; charset=utf-8",
"integrity": "sha256-dwzFb51yY09vBytS2q5RvCulmCy5SsgNIBSOPO8jRsw= sha384-BS2c8mnEoIF0gvGQIwPKnZlgiTYjvbaUM48Meaox9zjmiTbaBJpn3U85Rwif2H8A sha512-kxNBpU3FtvfHL2mABmHb/e7ZMg3wd+TcWSkzXEvIUysboPlTaR/YUbjpHiNE68N5O3Q+MYrPBm2qS6AlUrD7Pg==",
"hashes": {
"sha256": "dwzFb51yY09vBytS2q5RvCulmCy5SsgNIBSOPO8jRsw=",
"sha384": "BS2c8mnEoIF0gvGQIwPKnZlgiTYjvbaUM48Meaox9zjmiTbaBJpn3U85Rwif2H8A",
"sha512": "kxNBpU3FtvfHL2mABmHb/e7ZMg3wd+TcWSkzXEvIUysboPlTaR/YUbjpHiNE68N5O3Q+MYrPBm2qS6AlUrD7Pg=="
}
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,46 @@
{
"name": "ms.post",
"version": "4.3.11",
"ext": {
"@gbl.js": {
"file": "ms.post.gbl.js",
"type": "text/javascript; charset=utf-8",
"integrity": "sha256-OZu4V5DXWpQxGiM8SY4R+ZIt/9RaO8ppSngEMQWiZ2Y= sha384-hJgRIhvhEpwJNzdz2M+qvWSJWXAkS+H6WuzAIFZxrRRFgFm4QT17FaOtbD5HGnJQ sha512-VeGk5QAuxGaihq+U/DRCeuro3hGCyb5B6roz4FdiLnMbmBh7MhGkgBlYqLA/AtPPvKc8Hu8CbSCvlwPTNdswcQ==",
"hashes": {
"sha256": "OZu4V5DXWpQxGiM8SY4R+ZIt/9RaO8ppSngEMQWiZ2Y=",
"sha384": "hJgRIhvhEpwJNzdz2M+qvWSJWXAkS+H6WuzAIFZxrRRFgFm4QT17FaOtbD5HGnJQ",
"sha512": "VeGk5QAuxGaihq+U/DRCeuro3hGCyb5B6roz4FdiLnMbmBh7MhGkgBlYqLA/AtPPvKc8Hu8CbSCvlwPTNdswcQ=="
}
},
"@gbl.min.js": {
"file": "ms.post.gbl.min.js",
"type": "text/javascript; charset=utf-8",
"integrity": "sha256-L1N1iybXFcLJZ0xrYpLFyRli3/u3EFpZmXqEu/8hTk8= sha384-dk52S4JCPHQ1Sr5OpPNksiPnilJZ2LrU7oZ6ZfYlge2rhp29zNb6wPDRlJtk6KuL sha512-SLxpi2MwQoocZySaYkjfqfUhxv12xA5vlkb95+SRfkGdULDZuIXEla/8e80+5Z9WVT+XOFtRevKj3vE0WJNr3g==",
"hashes": {
"sha256": "L1N1iybXFcLJZ0xrYpLFyRli3/u3EFpZmXqEu/8hTk8=",
"sha384": "dk52S4JCPHQ1Sr5OpPNksiPnilJZ2LrU7oZ6ZfYlge2rhp29zNb6wPDRlJtk6KuL",
"sha512": "SLxpi2MwQoocZySaYkjfqfUhxv12xA5vlkb95+SRfkGdULDZuIXEla/8e80+5Z9WVT+XOFtRevKj3vE0WJNr3g=="
}
},
"@js": {
"file": "ms.post.js",
"type": "text/javascript; charset=utf-8",
"integrity": "sha256-ZpkOObttmXB4ObP3X+pIJZIRnVBMVquiMoURlKRv0oA= sha384-ka96y2bQEtwPbCmI22J7eFqTBW2M6N+r2JRWp3rjWNPPmMeCUrCuvwQ7hjjnb/dX sha512-CIqG9k3ZKc6Cta0Zwb8/fv30pkzqtdFcHbBCwUY5nvGAmwed3HTjbqZfRoTmY01AMSCWxHXktvRC5WWtBTYUYw==",
"hashes": {
"sha256": "ZpkOObttmXB4ObP3X+pIJZIRnVBMVquiMoURlKRv0oA=",
"sha384": "ka96y2bQEtwPbCmI22J7eFqTBW2M6N+r2JRWp3rjWNPPmMeCUrCuvwQ7hjjnb/dX",
"sha512": "CIqG9k3ZKc6Cta0Zwb8/fv30pkzqtdFcHbBCwUY5nvGAmwed3HTjbqZfRoTmY01AMSCWxHXktvRC5WWtBTYUYw=="
}
},
"@min.js": {
"file": "ms.post.min.js",
"type": "text/javascript; charset=utf-8",
"integrity": "sha256-GX6CMRhuMcoKf0P2Dwl7ePtIQuuW+qHLOFcrcQmjsns= sha384-evRJiV++YzKi8iY7bM2TP8b9J7UgLTdEwoAvjOK6Y8UdnuK0LiuM+QRqb219WVt1 sha512-Wt98qjn2SIQlLEH5slsiQ+9zUn9evkOZlUii3pzgNdMqHN0FPmSW53JwJPSrteK6XsiAo5I7+Q8jOTfpMYp96Q==",
"hashes": {
"sha256": "GX6CMRhuMcoKf0P2Dwl7ePtIQuuW+qHLOFcrcQmjsns=",
"sha384": "evRJiV++YzKi8iY7bM2TP8b9J7UgLTdEwoAvjOK6Y8UdnuK0LiuM+QRqb219WVt1",
"sha512": "Wt98qjn2SIQlLEH5slsiQ+9zUn9evkOZlUii3pzgNdMqHN0FPmSW53JwJPSrteK6XsiAo5I7+Q8jOTfpMYp96Q=="
}
}
}
}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,7 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
export {};
//# sourceMappingURL=BatchNotificationActions.js.map
@@ -0,0 +1 @@
{"version":3,"file":"BatchNotificationActions.js.map","sources":["BatchNotificationActions.js"],"sourcesContent":["export {};\r\n//# sourceMappingURL=BatchNotificationActions.js.map"],"names":[],"mappings":";;;;;AAAA;AACA"}
@@ -0,0 +1,92 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
/**
* ClockSkewManager.ts
* @author Abhilash Panwar (abpanwar)
* @copyright Microsoft 2018
*/
import dynamicProto from "@microsoft/dynamicproto-js";
import { _DYN_ALLOW_REQUEST_SENDIN0, _DYN_GET_CLOCK_SKEW_HEADE2, _DYN_SET_CLOCK_SKEW, _DYN_SHOULD_ADD_CLOCK_SKE1 } from "./__DynamicConstants";
/**
* Class to manage clock skew correction.
*/
var ClockSkewManager = /** @class */ (function () {
function ClockSkewManager() {
var _allowRequestSending = true;
var _shouldAddClockSkewHeaders = true;
var _isFirstRequest = true;
var _clockSkewHeaderValue = "use-collector-delta";
var _clockSkewSet = false;
dynamicProto(ClockSkewManager, this, function (_self) {
/**
* Determine if requests can be sent.
* @returns True if requests can be sent, false otherwise.
*/
_self[_DYN_ALLOW_REQUEST_SENDIN0 /* @min:%2eallowRequestSending */] = function () {
return _allowRequestSending;
};
/**
* Tells the ClockSkewManager that it should assume that the first request has now been sent,
* If this method had not yet been called AND the clock Skew had not been set this will set
* allowRequestSending to false until setClockSet() is called.
*/
_self.firstRequestSent = function () {
if (_isFirstRequest) {
_isFirstRequest = false;
if (!_clockSkewSet) {
// Block sending until we get the first clock Skew
_allowRequestSending = false;
}
}
};
/**
* Determine if clock skew headers should be added to the request.
* @returns True if clock skew headers should be added, false otherwise.
*/
_self[_DYN_SHOULD_ADD_CLOCK_SKE1 /* @min:%2eshouldAddClockSkewHeaders */] = function () {
return _shouldAddClockSkewHeaders;
};
/**
* Gets the clock skew header value.
* @returns The clock skew header value.
*/
_self[_DYN_GET_CLOCK_SKEW_HEADE2 /* @min:%2egetClockSkewHeaderValue */] = function () {
return _clockSkewHeaderValue;
};
/**
* Sets the clock skew header value. Once clock skew is set this method
* is no-op.
* @param timeDeltaInMillis - Time delta to be saved as the clock skew header value.
*/
_self[_DYN_SET_CLOCK_SKEW /* @min:%2esetClockSkew */] = function (timeDeltaInMillis) {
if (!_clockSkewSet) {
if (timeDeltaInMillis) {
_clockSkewHeaderValue = timeDeltaInMillis;
_shouldAddClockSkewHeaders = true;
_clockSkewSet = true;
}
else {
_shouldAddClockSkewHeaders = false;
}
// Unblock sending
_allowRequestSending = true;
}
};
});
}
// Removed Stub for ClockSkewManager.prototype.allowRequestSending.
// Removed Stub for ClockSkewManager.prototype.firstRequestSent.
// Removed Stub for ClockSkewManager.prototype.shouldAddClockSkewHeaders.
// Removed Stub for ClockSkewManager.prototype.getClockSkewHeaderValue.
// Removed Stub for ClockSkewManager.prototype.setClockSkew.
// This is a workaround for an IE bug when using dynamicProto() with classes that don't have any
// non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
ClockSkewManager.__ieDyn=1;
return ClockSkewManager;
}());
export { ClockSkewManager };
//# sourceMappingURL=ClockSkewManager.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,21 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
/**
* Real Time profile (default profile). RealTime Latency events are sent every 1 sec and
* Normal Latency events are sent every 2 sec.
*/
export var RT_PROFILE = "REAL_TIME";
/**
* Near Real Time profile. RealTime Latency events are sent every 3 sec and
* Normal Latency events are sent every 6 sec.
*/
export var NRT_PROFILE = "NEAR_REAL_TIME";
/**
* Best Effort. RealTime Latency events are sent every 9 sec and
* Normal Latency events are sent every 18 sec.
*/
export var BE_PROFILE = "BEST_EFFORT";
//# sourceMappingURL=DataModels.js.map
@@ -0,0 +1 @@
{"version":3,"file":"DataModels.js.map","sources":["DataModels.js"],"sourcesContent":["/**\r\n * Real Time profile (default profile). RealTime Latency events are sent every 1 sec and\r\n * Normal Latency events are sent every 2 sec.\r\n */\r\nexport var RT_PROFILE = \"REAL_TIME\";\r\n/**\r\n * Near Real Time profile. RealTime Latency events are sent every 3 sec and\r\n * Normal Latency events are sent every 6 sec.\r\n */\r\nexport var NRT_PROFILE = \"NEAR_REAL_TIME\";\r\n/**\r\n * Best Effort. RealTime Latency events are sent every 9 sec and\r\n * Normal Latency events are sent every 18 sec.\r\n */\r\nexport var BE_PROFILE = \"BEST_EFFORT\";\r\n//# sourceMappingURL=DataModels.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,93 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
/**
* EventBatch.ts
* @author Nev Wylie (newylie)
* @copyright Microsoft 2020
*/
import { isNullOrUndefined, isValueAssigned } from "@microsoft/1ds-core-js";
import { STR_EMPTY, STR_MSFPC } from "./InternalConstants";
import { _DYN_CONCAT, _DYN_COUNT, _DYN_EVENTS, _DYN_I_KEY, _DYN_LENGTH, _DYN_PUSH, _DYN_SPLIT } from "./__DynamicConstants";
function _getEventMsfpc(theEvent) {
var intWeb = ((theEvent.ext || {})["intweb"]);
if (intWeb && isValueAssigned(intWeb[STR_MSFPC])) {
return intWeb[STR_MSFPC];
}
return null;
}
function _getMsfpc(theEvents) {
var msfpc = null;
for (var lp = 0; msfpc === null && lp < theEvents[_DYN_LENGTH /* @min:%2elength */]; lp++) {
msfpc = _getEventMsfpc(theEvents[lp]);
}
return msfpc;
}
/**
* This class defines a "batch" events related to a specific iKey, it is used by the PostChannel and HttpManager
* to collect and transfer ownership of events without duplicating them in-memory. This reduces the previous
* array duplication and shared ownership issues that occurred due to race conditions caused by the async nature
* of sending requests.
*/
var EventBatch = /** @class */ (function () {
/**
* Private constructor so that caller is forced to use the static create method.
* @param iKey - The iKey to associate with the events (not validated)
* @param addEvents - The optional collection of events to assign to this batch - defaults to an empty array.
*/
function EventBatch(iKey, addEvents) {
var events = addEvents ? [][_DYN_CONCAT /* @min:%2econcat */](addEvents) : [];
var _self = this;
var _msfpc = _getMsfpc(events);
_self[_DYN_I_KEY /* @min:%2eiKey */] = function () {
return iKey;
};
_self.Msfpc = function () {
// return the cached value unless it's undefined -- used to avoid cpu
return _msfpc || STR_EMPTY;
};
_self[_DYN_COUNT /* @min:%2ecount */] = function () {
return events[_DYN_LENGTH /* @min:%2elength */];
};
_self[_DYN_EVENTS /* @min:%2eevents */] = function () {
return events;
};
_self.addEvent = function (theEvent) {
if (theEvent) {
events[_DYN_PUSH /* @min:%2epush */](theEvent);
if (!_msfpc) {
// Not found so try and find one
_msfpc = _getEventMsfpc(theEvent);
}
return true;
}
return false;
};
_self[_DYN_SPLIT /* @min:%2esplit */] = function (fromEvent, numEvents) {
// Create a new batch with the same iKey
var theEvents;
if (fromEvent < events[_DYN_LENGTH /* @min:%2elength */]) {
var cnt = events[_DYN_LENGTH /* @min:%2elength */] - fromEvent;
if (!isNullOrUndefined(numEvents)) {
cnt = numEvents < cnt ? numEvents : cnt;
}
theEvents = events.splice(fromEvent, cnt);
// reset the fetched msfpc value
_msfpc = _getMsfpc(events);
}
return new EventBatch(iKey, theEvents);
};
}
/**
* Creates a new Event Batch object
* @param iKey - The iKey associated with this batch of events
*/
EventBatch.create = function (iKey, theEvents) {
return new EventBatch(iKey, theEvents);
};
return EventBatch;
}());
export { EventBatch };
//# sourceMappingURL=EventBatch.js.map
@@ -0,0 +1 @@
{"version":3,"file":"EventBatch.js.map","sources":["EventBatch.js"],"sourcesContent":["/**\r\n* EventBatch.ts\r\n* @author Nev Wylie (newylie)\r\n* @copyright Microsoft 2020\r\n*/\r\nimport { isNullOrUndefined, isValueAssigned } from \"@microsoft/1ds-core-js\";\r\nimport { STR_EMPTY, STR_MSFPC } from \"./InternalConstants\";\r\nimport { _DYN_CONCAT, _DYN_COUNT, _DYN_EVENTS, _DYN_I_KEY, _DYN_LENGTH, _DYN_PUSH, _DYN_SPLIT } from \"./__DynamicConstants\";\r\nfunction _getEventMsfpc(theEvent) {\r\n var intWeb = ((theEvent.ext || {})[\"intweb\"]);\r\n if (intWeb && isValueAssigned(intWeb[STR_MSFPC])) {\r\n return intWeb[STR_MSFPC];\r\n }\r\n return null;\r\n}\r\nfunction _getMsfpc(theEvents) {\r\n var msfpc = null;\r\n for (var lp = 0; msfpc === null && lp < theEvents[_DYN_LENGTH /* @min:%2elength */]; lp++) {\r\n msfpc = _getEventMsfpc(theEvents[lp]);\r\n }\r\n return msfpc;\r\n}\r\n/**\r\n* This class defines a \"batch\" events related to a specific iKey, it is used by the PostChannel and HttpManager\r\n* to collect and transfer ownership of events without duplicating them in-memory. This reduces the previous\r\n* array duplication and shared ownership issues that occurred due to race conditions caused by the async nature\r\n* of sending requests.\r\n*/\r\nvar EventBatch = /** @class */ (function () {\r\n /**\r\n * Private constructor so that caller is forced to use the static create method.\r\n * @param iKey - The iKey to associate with the events (not validated)\r\n * @param addEvents - The optional collection of events to assign to this batch - defaults to an empty array.\r\n */\r\n function EventBatch(iKey, addEvents) {\r\n var events = addEvents ? [][_DYN_CONCAT /* @min:%2econcat */](addEvents) : [];\r\n var _self = this;\r\n var _msfpc = _getMsfpc(events);\r\n _self[_DYN_I_KEY /* @min:%2eiKey */] = function () {\r\n return iKey;\r\n };\r\n _self.Msfpc = function () {\r\n // return the cached value unless it's undefined -- used to avoid cpu\r\n return _msfpc || STR_EMPTY;\r\n };\r\n _self[_DYN_COUNT /* @min:%2ecount */] = function () {\r\n return events[_DYN_LENGTH /* @min:%2elength */];\r\n };\r\n _self[_DYN_EVENTS /* @min:%2eevents */] = function () {\r\n return events;\r\n };\r\n _self.addEvent = function (theEvent) {\r\n if (theEvent) {\r\n events[_DYN_PUSH /* @min:%2epush */](theEvent);\r\n if (!_msfpc) {\r\n // Not found so try and find one\r\n _msfpc = _getEventMsfpc(theEvent);\r\n }\r\n return true;\r\n }\r\n return false;\r\n };\r\n _self[_DYN_SPLIT /* @min:%2esplit */] = function (fromEvent, numEvents) {\r\n // Create a new batch with the same iKey\r\n var theEvents;\r\n if (fromEvent < events[_DYN_LENGTH /* @min:%2elength */]) {\r\n var cnt = events[_DYN_LENGTH /* @min:%2elength */] - fromEvent;\r\n if (!isNullOrUndefined(numEvents)) {\r\n cnt = numEvents < cnt ? numEvents : cnt;\r\n }\r\n theEvents = events.splice(fromEvent, cnt);\r\n // reset the fetched msfpc value\r\n _msfpc = _getMsfpc(events);\r\n }\r\n return new EventBatch(iKey, theEvents);\r\n };\r\n }\r\n /**\r\n * Creates a new Event Batch object\r\n * @param iKey - The iKey associated with this batch of events\r\n */\r\n EventBatch.create = function (iKey, theEvents) {\r\n return new EventBatch(iKey, theEvents);\r\n };\r\n return EventBatch;\r\n}());\r\nexport { EventBatch };\r\n//# sourceMappingURL=EventBatch.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,15 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
/**
* @name Index.ts
* @author Abhilash Panwar (abpanwar)
* @copyright Microsoft 2018
* File to export public classes.
*/
import { BE_PROFILE, NRT_PROFILE, RT_PROFILE } from "./DataModels";
import { PostChannel } from "./PostChannel";
export { PostChannel, BE_PROFILE, NRT_PROFILE, RT_PROFILE };
//# sourceMappingURL=Index.js.map
@@ -0,0 +1 @@
{"version":3,"file":"Index.js.map","sources":["Index.js"],"sourcesContent":["/**\r\n* @name Index.ts\r\n* @author Abhilash Panwar (abpanwar)\r\n* @copyright Microsoft 2018\r\n* File to export public classes.\r\n*/\r\nimport { BE_PROFILE, NRT_PROFILE, RT_PROFILE } from \"./DataModels\";\r\nimport { PostChannel } from \"./PostChannel\";\r\nexport { PostChannel, BE_PROFILE, NRT_PROFILE, RT_PROFILE };\r\n//# sourceMappingURL=Index.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,42 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
// Licensed under the MIT License.
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Generally you should only put values that are used more than 2 times and then only if not already exposed as a constant (such as SdkCoreNames)
// as when using "short" named values from here they will be will be minified smaller than the SdkCoreNames[eSdkCoreNames.xxxx] value.
export var STR_EMPTY = "";
export var STR_POST_METHOD = "POST";
export var STR_DISABLED_PROPERTY_NAME = "Microsoft_ApplicationInsights_BypassAjaxInstrumentation";
export var STR_DROPPED = "drop";
export var STR_SENDING = "send";
export var STR_REQUEUE = "requeue";
export var STR_RESPONSE_FAIL = "rspFail";
export var STR_OTHER = "oth";
export var DEFAULT_CACHE_CONTROL = "no-cache, no-store";
export var DEFAULT_CONTENT_TYPE = "application/x-json-stream";
export var STR_CACHE_CONTROL = "cache-control";
export var STR_CONTENT_TYPE_HEADER = "content-type";
export var STR_KILL_TOKENS_HEADER = "kill-tokens";
export var STR_KILL_DURATION_HEADER = "kill-duration";
export var STR_KILL_DURATION_SECONDS_HEADER = "kill-duration-seconds";
export var STR_TIME_DELTA_HEADER = "time-delta-millis";
export var STR_CLIENT_VERSION = "client-version";
export var STR_CLIENT_ID = "client-id";
export var STR_TIME_DELTA_TO_APPLY = "time-delta-to-apply-millis";
export var STR_UPLOAD_TIME = "upload-time";
export var STR_API_KEY = "apikey";
export var STR_MSA_DEVICE_TICKET = "AuthMsaDeviceTicket";
export var STR_AUTH_WEB_TOKEN = "WebAuthToken";
export var STR_AUTH_XTOKEN = "AuthXToken";
export var STR_SDK_VERSION = "sdk-version";
export var STR_NO_RESPONSE_BODY = "NoResponseBody";
export var STR_MSFPC = "msfpc";
export var STR_TRACE = "trace";
export var STR_USER = "user";
//# sourceMappingURL=InternalConstants.js.map
@@ -0,0 +1 @@
{"version":3,"file":"InternalConstants.js.map","sources":["InternalConstants.js"],"sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved.\r\n// Licensed under the MIT License.\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n// Note: DON'T Export these const from the package as we are still targeting ES3 this will export a mutable variables that someone could change!!!\r\n// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n// Generally you should only put values that are used more than 2 times and then only if not already exposed as a constant (such as SdkCoreNames)\r\n// as when using \"short\" named values from here they will be will be minified smaller than the SdkCoreNames[eSdkCoreNames.xxxx] value.\r\nexport var STR_EMPTY = \"\";\r\nexport var STR_POST_METHOD = \"POST\";\r\nexport var STR_DISABLED_PROPERTY_NAME = \"Microsoft_ApplicationInsights_BypassAjaxInstrumentation\";\r\nexport var STR_DROPPED = \"drop\";\r\nexport var STR_SENDING = \"send\";\r\nexport var STR_REQUEUE = \"requeue\";\r\nexport var STR_RESPONSE_FAIL = \"rspFail\";\r\nexport var STR_OTHER = \"oth\";\r\nexport var DEFAULT_CACHE_CONTROL = \"no-cache, no-store\";\r\nexport var DEFAULT_CONTENT_TYPE = \"application/x-json-stream\";\r\nexport var STR_CACHE_CONTROL = \"cache-control\";\r\nexport var STR_CONTENT_TYPE_HEADER = \"content-type\";\r\nexport var STR_KILL_TOKENS_HEADER = \"kill-tokens\";\r\nexport var STR_KILL_DURATION_HEADER = \"kill-duration\";\r\nexport var STR_KILL_DURATION_SECONDS_HEADER = \"kill-duration-seconds\";\r\nexport var STR_TIME_DELTA_HEADER = \"time-delta-millis\";\r\nexport var STR_CLIENT_VERSION = \"client-version\";\r\nexport var STR_CLIENT_ID = \"client-id\";\r\nexport var STR_TIME_DELTA_TO_APPLY = \"time-delta-to-apply-millis\";\r\nexport var STR_UPLOAD_TIME = \"upload-time\";\r\nexport var STR_API_KEY = \"apikey\";\r\nexport var STR_MSA_DEVICE_TICKET = \"AuthMsaDeviceTicket\";\r\nexport var STR_AUTH_WEB_TOKEN = \"WebAuthToken\";\r\nexport var STR_AUTH_XTOKEN = \"AuthXToken\";\r\nexport var STR_SDK_VERSION = \"sdk-version\";\r\nexport var STR_NO_RESPONSE_BODY = \"NoResponseBody\";\r\nexport var STR_MSFPC = \"msfpc\";\r\nexport var STR_TRACE = \"trace\";\r\nexport var STR_USER = \"user\";\r\n//# sourceMappingURL=InternalConstants.js.map"],"names":[],"mappings":";;;;;AAA4D;AAC5D;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,69 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
/**
* KillSwitch.ts
* @author Abhilash Panwar (abpanwar)
* @copyright Microsoft 2018
*/
import dynamicProto from "@microsoft/dynamicproto-js";
import { arrForEach, dateNow, strTrim } from "@microsoft/1ds-core-js";
import { _DYN_IS_TENANT_KILLED, _DYN_LENGTH, _DYN_PUSH, _DYN_SET_KILL_SWITCH_TENA11, _DYN_SPLIT } from "./__DynamicConstants";
var SecToMsMultiplier = 1000;
/**
* Class to stop certain tenants sending events.
*/
var KillSwitch = /** @class */ (function () {
function KillSwitch() {
var _killedTokenDictionary = {};
function _normalizeTenants(values) {
var result = [];
if (values) {
arrForEach(values, function (value) {
result[_DYN_PUSH /* @min:%2epush */](strTrim(value));
});
}
return result;
}
dynamicProto(KillSwitch, this, function (_self) {
_self[_DYN_SET_KILL_SWITCH_TENA11 /* @min:%2esetKillSwitchTenants */] = function (killTokens, killDuration) {
if (killTokens && killDuration) {
try {
var killedTokens = _normalizeTenants(killTokens[_DYN_SPLIT /* @min:%2esplit */](","));
if (killDuration === "this-request-only") {
return killedTokens;
}
var durationMs = parseInt(killDuration, 10) * SecToMsMultiplier;
for (var i = 0; i < killedTokens[_DYN_LENGTH /* @min:%2elength */]; ++i) {
_killedTokenDictionary[killedTokens[i]] = dateNow() + durationMs;
}
}
catch (ex) {
return [];
}
}
return [];
};
_self[_DYN_IS_TENANT_KILLED /* @min:%2eisTenantKilled */] = function (tenantToken) {
var killDictionary = _killedTokenDictionary;
var name = strTrim(tenantToken);
if (killDictionary[name] !== undefined && killDictionary[name] > dateNow()) {
return true;
}
delete killDictionary[name];
return false;
};
});
}
// Removed Stub for KillSwitch.prototype.setKillSwitchTenants.
// Removed Stub for KillSwitch.prototype.isTenantKilled.
// This is a workaround for an IE bug when using dynamicProto() with classes that don't have any
// non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
KillSwitch.__ieDyn=1;
return KillSwitch;
}());
export { KillSwitch };
//# sourceMappingURL=KillSwitch.js.map
@@ -0,0 +1 @@
{"version":3,"file":"KillSwitch.js.map","sources":["KillSwitch.js"],"sourcesContent":["/**\r\n* KillSwitch.ts\r\n* @author Abhilash Panwar (abpanwar)\r\n* @copyright Microsoft 2018\r\n*/\r\nimport dynamicProto from \"@microsoft/dynamicproto-js\";\r\nimport { arrForEach, dateNow, strTrim } from \"@microsoft/1ds-core-js\";\r\nimport { _DYN_IS_TENANT_KILLED, _DYN_LENGTH, _DYN_PUSH, _DYN_SET_KILL_SWITCH_TENA11, _DYN_SPLIT } from \"./__DynamicConstants\";\r\nvar SecToMsMultiplier = 1000;\r\n/**\r\n* Class to stop certain tenants sending events.\r\n*/\r\nvar KillSwitch = /** @class */ (function () {\r\n function KillSwitch() {\r\n var _killedTokenDictionary = {};\r\n function _normalizeTenants(values) {\r\n var result = [];\r\n if (values) {\r\n arrForEach(values, function (value) {\r\n result[_DYN_PUSH /* @min:%2epush */](strTrim(value));\r\n });\r\n }\r\n return result;\r\n }\r\n dynamicProto(KillSwitch, this, function (_self) {\r\n _self[_DYN_SET_KILL_SWITCH_TENA11 /* @min:%2esetKillSwitchTenants */] = function (killTokens, killDuration) {\r\n if (killTokens && killDuration) {\r\n try {\r\n var killedTokens = _normalizeTenants(killTokens[_DYN_SPLIT /* @min:%2esplit */](\",\"));\r\n if (killDuration === \"this-request-only\") {\r\n return killedTokens;\r\n }\r\n var durationMs = parseInt(killDuration, 10) * SecToMsMultiplier;\r\n for (var i = 0; i < killedTokens[_DYN_LENGTH /* @min:%2elength */]; ++i) {\r\n _killedTokenDictionary[killedTokens[i]] = dateNow() + durationMs;\r\n }\r\n }\r\n catch (ex) {\r\n return [];\r\n }\r\n }\r\n return [];\r\n };\r\n _self[_DYN_IS_TENANT_KILLED /* @min:%2eisTenantKilled */] = function (tenantToken) {\r\n var killDictionary = _killedTokenDictionary;\r\n var name = strTrim(tenantToken);\r\n if (killDictionary[name] !== undefined && killDictionary[name] > dateNow()) {\r\n return true;\r\n }\r\n delete killDictionary[name];\r\n return false;\r\n };\r\n });\r\n }\r\n /**\r\n * Set the tenants that are to be killed along with the duration. If the duration is\r\n * a special value identifying that the tokens are too be killed for only this request, then\r\n * a array of tokens is returned.\r\n * @param killedTokens - Tokens that are too be marked to be killed.\r\n * @param killDuration - The duration for which the tokens are to be killed.\r\n * @returns The tokens that are killed only for this given request.\r\n */\r\n KillSwitch.prototype.setKillSwitchTenants = function (killTokens, killDuration) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return [];\r\n };\r\n /**\r\n * Determing if the given tenant token has been killed for the moment.\r\n * @param tenantToken - The token to be checked.\r\n * @returns True if token has been killed, false otherwise.\r\n */\r\n KillSwitch.prototype.isTenantKilled = function (tenantToken) {\r\n // @DynamicProtoStub - DO NOT add any code as this will be removed during packaging\r\n return false;\r\n };\r\n return KillSwitch;\r\n}());\r\nexport { KillSwitch };\r\n//# sourceMappingURL=KillSwitch.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;wDAoBM,CAAC;;;;;sBACe;AACtB;AACA;AACA"}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,51 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
import { mathFloor, mathMin } from "@nevware21/ts-utils";
/**
* RetryPolicy.ts
* @author Abhilash Panwar (abpanwar)
* @copyright Microsoft 2018
*/
var RandomizationLowerThreshold = 0.8;
var RandomizationUpperThreshold = 1.2;
var BaseBackoff = 3000;
var MaxBackoff = 600000;
/**
* Determine if the request should be retried for the given status code.
* The below expression reads that we should only retry for:
* - HttpStatusCodes that are smaller than 300.
* - HttpStatusCodes greater or equal to 500 (except for 501-NotImplement
* and 505-HttpVersionNotSupport).
* - HttpStatusCode 408-RequestTimeout.
* - HttpStatusCode 429.
* This is based on Microsoft.WindowsAzure.Storage.RetryPolicies.ExponentialRetry class
* @param httpStatusCode - The status code returned for the request.
* @returns True if request should be retried, false otherwise.
*/
export function retryPolicyShouldRetryForStatus(httpStatusCode) {
/* tslint:disable:triple-equals */
// Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value
return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 429)
|| (httpStatusCode == 501)
|| (httpStatusCode == 505));
/* tslint:enable:triple-equals */
}
/**
* Gets the number of milliseconds to back off before retrying the request. The
* back off duration is exponentially scaled based on the number of retries already
* done for the request.
* @param retriesSoFar - The number of times the request has already been retried.
* @returns The back off duration for the request before it can be retried.
*/
export function retryPolicyGetMillisToBackoffForRetry(retriesSoFar) {
var waitDuration = 0;
var minBackoff = BaseBackoff * RandomizationLowerThreshold;
var maxBackoff = BaseBackoff * RandomizationUpperThreshold;
var randomBackoff = mathFloor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;
return mathMin(waitDuration, MaxBackoff);
}
//# sourceMappingURL=RetryPolicy.js.map
@@ -0,0 +1 @@
{"version":3,"file":"RetryPolicy.js.map","sources":["RetryPolicy.js"],"sourcesContent":["import { mathFloor, mathMin } from \"@nevware21/ts-utils\";\r\n/**\r\n* RetryPolicy.ts\r\n* @author Abhilash Panwar (abpanwar)\r\n* @copyright Microsoft 2018\r\n*/\r\nvar RandomizationLowerThreshold = 0.8;\r\nvar RandomizationUpperThreshold = 1.2;\r\nvar BaseBackoff = 3000;\r\nvar MaxBackoff = 600000;\r\n/**\r\n * Determine if the request should be retried for the given status code.\r\n * The below expression reads that we should only retry for:\r\n * - HttpStatusCodes that are smaller than 300.\r\n * - HttpStatusCodes greater or equal to 500 (except for 501-NotImplement\r\n * and 505-HttpVersionNotSupport).\r\n * - HttpStatusCode 408-RequestTimeout.\r\n * - HttpStatusCode 429.\r\n * This is based on Microsoft.WindowsAzure.Storage.RetryPolicies.ExponentialRetry class\r\n * @param httpStatusCode - The status code returned for the request.\r\n * @returns True if request should be retried, false otherwise.\r\n */\r\nexport function retryPolicyShouldRetryForStatus(httpStatusCode) {\r\n /* tslint:disable:triple-equals */\r\n // Disabling triple-equals rule to avoid httpOverrides from failing because they are returning a string value\r\n return !((httpStatusCode >= 300 && httpStatusCode < 500 && httpStatusCode != 429)\r\n || (httpStatusCode == 501)\r\n || (httpStatusCode == 505));\r\n /* tslint:enable:triple-equals */\r\n}\r\n/**\r\n * Gets the number of milliseconds to back off before retrying the request. The\r\n * back off duration is exponentially scaled based on the number of retries already\r\n * done for the request.\r\n * @param retriesSoFar - The number of times the request has already been retried.\r\n * @returns The back off duration for the request before it can be retried.\r\n */\r\nexport function retryPolicyGetMillisToBackoffForRetry(retriesSoFar) {\r\n var waitDuration = 0;\r\n var minBackoff = BaseBackoff * RandomizationLowerThreshold;\r\n var maxBackoff = BaseBackoff * RandomizationUpperThreshold;\r\n var randomBackoff = mathFloor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;\r\n waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;\r\n return mathMin(waitDuration, MaxBackoff);\r\n}\r\n//# sourceMappingURL=RetryPolicy.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,360 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
/**
* Serializer.ts
* @author Abhilash Panwar (abpanwar); Hector Hernandez (hectorh); Nev Wylie (newylie)
* @copyright Microsoft 2018-2020
*/
// @skip-file-minify
import dynamicProto from "@microsoft/dynamicproto-js";
import { arrIndexOf, doPerf, getCommonSchemaMetaData, getTenantId, isArray, isValueAssigned, objForEachKey, sanitizeProperty, strStartsWith } from "@microsoft/1ds-core-js";
import { EventBatch } from "./EventBatch";
import { STR_EMPTY } from "./InternalConstants";
import { mathMin, strSubstr } from "@nevware21/ts-utils";
/**
* Note: This is an optimization for V8-based browsers. When V8 concatenates a string,
* the strings are only joined logically using a "cons string" or "constructed/concatenated
* string". These containers keep references to one another and can result in very large
* memory usage. For example, if a 2MB string is constructed by concatenating 4 bytes
* together at a time, the memory usage will be ~44MB; so ~22x increase. The strings are
* only joined together when an operation requiring their joining takes place, such as
* substr(). This function is called when adding data to this buffer to ensure these
* types of strings are periodically joined to reduce the memory footprint.
* Setting to every 20 events as the JSON.stringify() may have joined many strings
* and calling this too much causes a minor delay while processing.
*/
var _MAX_STRING_JOINS = 20;
// Max Size set by One Collector: https://msazure.visualstudio.com/OneDsCollector/_git/Collector?path=/Services/Azure/CollectorWorkerRoleAzure/ServiceConfiguration.Cloud.cscfg
var RequestSizeLimitBytes = 3145728; // approx 3.15 Mb
var BeaconRequestSizeLimitBytes = 65000; // approx 64kb (the current Edge, Firefox and Chrome max limit)
var MaxRecordSize = 2000000; // approx 2 Mb
var MaxBeaconRecordSize = mathMin(MaxRecordSize, BeaconRequestSizeLimitBytes);
var metadata = "metadata";
var f = "f";
var rCheckDot = /\./;
/**
* Class to handle serialization of event and request.
* Currently uses Bond for serialization. Please note that this may be subject to change.
*/
var Serializer = /** @class */ (function () {
/**
* Constructs a new instance of the Serializer class
* @param perfManager - The performance manager to use for tracking performance
* @param valueSanitizer - The value sanitizer to use for sanitizing field values
* @param stringifyObjects - Should objects be stringified before being sent
* @param enableCompoundKey - Should compound keys be enabled (defaults to false)
* @param getEncodedTypeOverride - The callback to get the encoded type for a property defaults to ({@link getCommonSchemaMetaData }(...))
* @param excludeCsMetaData - (!DANGER!) Should metadata be populated when encoding the event blob (defaults to false) - PII data will NOT be tagged as PII for backend processing
* @param cfg channel cfg for setting request and record size limit
*/
function Serializer(perfManager, valueSanitizer, stringifyObjects, enableCompoundKey, getEncodedTypeOverride, excludeCsMetaData, cfg) {
var strData = "data";
var strBaseData = "baseData";
var strExt = "ext";
var _checkForCompoundkey = !!enableCompoundKey;
var _processSubKeys = true;
var _theSanitizer = valueSanitizer;
var _isReservedCache = {};
var _excludeCsMetaData = !!excludeCsMetaData;
var _getEncodedType = getEncodedTypeOverride || getCommonSchemaMetaData;
var _sizeCfg = _getSizeLimtCfg(cfg);
var _requestSizeLimitBytes = _validateSizeLimit(_sizeCfg.requestLimit, RequestSizeLimitBytes, 0);
var _beaconRequestSizeLimitBytes = _validateSizeLimit(_sizeCfg.requestLimit, BeaconRequestSizeLimitBytes, 1);
var _maxRecordSize = _validateSizeLimit(_sizeCfg.recordLimit, MaxRecordSize, 0);
var _maxBeaconRecordSize = Math.min(_validateSizeLimit(_sizeCfg.recordLimit, MaxBeaconRecordSize, 1), _beaconRequestSizeLimitBytes);
dynamicProto(Serializer, this, function (_self) {
_self.createPayload = function (retryCnt, isTeardown, isSync, isReducedPayload, sendReason, sendType) {
return {
apiKeys: [],
payloadBlob: STR_EMPTY,
overflow: null,
sizeExceed: [],
failedEvts: [],
batches: [],
numEvents: 0,
retryCnt: retryCnt,
isTeardown: isTeardown,
isSync: isSync,
isBeacon: isReducedPayload,
sendType: sendType,
sendReason: sendReason
};
};
_self.appendPayload = function (payload, theBatch, maxEventsPerBatch) {
var canAddEvents = payload && theBatch && !payload.overflow;
if (canAddEvents) {
doPerf(perfManager, function () { return "Serializer:appendPayload"; }, function () {
var theEvents = theBatch.events();
var payloadBlob = payload.payloadBlob;
var payloadEvents = payload.numEvents;
var eventsAdded = false;
var sizeExceeded = [];
var failedEvts = [];
var isBeaconPayload = payload.isBeacon;
var requestMaxSize = isBeaconPayload ? _beaconRequestSizeLimitBytes : _requestSizeLimitBytes;
var recordMaxSize = isBeaconPayload ? _maxBeaconRecordSize : _maxRecordSize;
var lp = 0;
var joinCount = 0;
while (lp < theEvents.length) {
var theEvent = theEvents[lp];
if (theEvent) {
if (payloadEvents >= maxEventsPerBatch) {
// Maximum events per payload reached, so don't add any more
payload.overflow = theBatch.split(lp);
break;
}
var eventBlob = _self.getEventBlob(theEvent);
if (eventBlob && eventBlob.length <= recordMaxSize) {
// This event will fit into the payload
var blobLength = eventBlob.length;
var currentSize = payloadBlob.length;
if (currentSize + blobLength > requestMaxSize) {
// Request or batch size exceeded, so don't add any more to the payload
payload.overflow = theBatch.split(lp);
break;
}
if (payloadBlob) {
payloadBlob += "\n";
}
payloadBlob += eventBlob;
joinCount++;
// v8 memory optimization only
if (joinCount > _MAX_STRING_JOINS) {
// this substr() should cause the constructed string to join
strSubstr(payloadBlob, 0, 1);
joinCount = 0;
}
eventsAdded = true;
payloadEvents++;
}
else {
if (eventBlob) {
// Single event size exceeded so remove from the batch
sizeExceeded.push(theEvent);
}
else {
failedEvts.push(theEvent);
}
// We also need to remove this event from the existing array, otherwise a notification will be sent
// indicating that it was successfully sent
theEvents.splice(lp, 1);
lp--;
}
}
lp++;
}
if (sizeExceeded.length > 0) {
payload.sizeExceed.push(EventBatch.create(theBatch.iKey(), sizeExceeded));
// Remove the exceeded events from the batch
}
if (failedEvts.length > 0) {
payload.failedEvts.push(EventBatch.create(theBatch.iKey(), failedEvts));
// Remove the failed events from the batch
}
if (eventsAdded) {
payload.batches.push(theBatch);
payload.payloadBlob = payloadBlob;
payload.numEvents = payloadEvents;
var apiKey = theBatch.iKey();
if (arrIndexOf(payload.apiKeys, apiKey) === -1) {
payload.apiKeys.push(apiKey);
}
}
}, function () { return ({ payload: payload, theBatch: { iKey: theBatch.iKey(), evts: theBatch.events() }, max: maxEventsPerBatch }); });
}
return canAddEvents;
};
_self.getEventBlob = function (eventData) {
try {
return doPerf(perfManager, function () { return "Serializer.getEventBlob"; }, function () {
var serializedEvent = {};
// Adding as dynamic keys for v8 performance
serializedEvent.name = eventData.name;
serializedEvent.time = eventData.time;
serializedEvent.ver = eventData.ver;
serializedEvent.iKey = "o:" + getTenantId(eventData.iKey);
// Assigning local var so usage in part b/c don't throw if there is no ext
var serializedExt = {};
var _addMetadataCallback;
if (!_excludeCsMetaData) {
_addMetadataCallback = function (pathKeys, key, value) {
_addJSONPropertyMetaData(_getEncodedType, serializedExt, pathKeys, key, value);
};
}
// Part A
var eventExt = eventData[strExt];
if (eventExt) {
// Only assign ext if the event had one (There are tests covering this use case)
serializedEvent[strExt] = serializedExt;
objForEachKey(eventExt, function (key, value) {
var data = serializedExt[key] = {};
// Don't include a metadata callback as we don't currently set metadata Part A fields
_processPathKeys(value, data, "ext." + key, true, null, null, true);
});
}
var serializedData = serializedEvent[strData] = {};
serializedData.baseType = eventData.baseType;
var serializedBaseData = serializedData[strBaseData] = {};
// Part B
_processPathKeys(eventData.baseData, serializedBaseData, strBaseData, false, [strBaseData], _addMetadataCallback, _processSubKeys);
// Part C
_processPathKeys(eventData.data, serializedData, strData, false, [], _addMetadataCallback, _processSubKeys);
return JSON.stringify(serializedEvent);
}, function () { return ({ item: eventData }); });
}
catch (e) {
return null;
}
};
function _isReservedField(path, name) {
var result = _isReservedCache[path];
if (result === undefined) {
if (path.length >= 7) {
// Do not allow the changing of fields located in the ext.metadata or ext.web extension
result = strStartsWith(path, "ext.metadata") || strStartsWith(path, "ext.web");
}
_isReservedCache[path] = result;
}
return result;
}
function _processPathKeys(srcObj, target, thePath, checkReserved, metadataPathKeys, metadataCallback, processSubKeys) {
objForEachKey(srcObj, function (key, srcValue) {
var prop = null;
if (srcValue || isValueAssigned(srcValue)) {
var path = thePath;
var name_1 = key;
var theMetaPathKeys = metadataPathKeys;
var destObj = target;
// Handle keys with embedded '.', like "TestObject.testProperty"
if (_checkForCompoundkey && !checkReserved && rCheckDot.test(key)) {
var subKeys = key.split(".");
var keyLen = subKeys.length;
if (keyLen > 1) {
if (theMetaPathKeys) {
// Create a copy of the meta path keys so we can add the extra ones
theMetaPathKeys = theMetaPathKeys.slice();
}
for (var lp = 0; lp < keyLen - 1; lp++) {
var subKey = subKeys[lp];
// Add/reuse the sub key object
destObj = destObj[subKey] = destObj[subKey] || {};
path += "." + subKey;
if (theMetaPathKeys) {
theMetaPathKeys.push(subKey);
}
}
name_1 = subKeys[keyLen - 1];
}
}
var isReserved = checkReserved && _isReservedField(path, name_1);
if (!isReserved && _theSanitizer && _theSanitizer.handleField(path, name_1)) {
prop = _theSanitizer.value(path, name_1, srcValue, stringifyObjects);
}
else {
prop = sanitizeProperty(name_1, srcValue, stringifyObjects);
}
if (prop) {
// Set the value
var newValue = prop.value;
destObj[name_1] = newValue;
if (metadataCallback) {
metadataCallback(theMetaPathKeys, name_1, prop);
}
if (processSubKeys && typeof newValue === "object" && !isArray(newValue)) {
var newPath = theMetaPathKeys;
if (newPath) {
newPath = newPath.slice();
newPath.push(name_1);
}
// Make sure we process sub objects as well (for value sanitization and metadata)
_processPathKeys(srcValue, newValue, path + "." + name_1, checkReserved, newPath, metadataCallback, processSubKeys);
}
}
}
});
}
});
}
// Removed Stub for Serializer.prototype.createPayload.
// Removed Stub for Serializer.prototype.appendPayload.
// Removed Stub for Serializer.prototype.getEventBlob.
// Removed Stub for Serializer.prototype.handleField.
// Removed Stub for Serializer.prototype.getSanitizer.
// This is a workaround for an IE bug when using dynamicProto() with classes that don't have any
// non-dynamic functions or static properties/functions when using uglify-js to minify the resulting code.
Serializer.__ieDyn=1;
return Serializer;
}());
export { Serializer };
function _validateSizeLimit(cfgVal, defaultVal, idx) {
if (isArray(cfgVal)) {
var val = cfgVal[idx];
if (val > 0 && val <= defaultVal) {
return val;
}
}
return defaultVal;
}
function _getSizeLimtCfg(cfg) {
var defaultCfg = {};
if (cfg && cfg.requestLimit) {
return cfg.requestLimit;
}
return defaultCfg;
}
/**
* @ignore
* @param getEncodedType - The function to get the encoded type for the property
* @param json - The json object to add the metadata to
* @param propKeys - The property keys to add to the metadata
* @param name - The name of the property
* @param propertyValue - The property value
*/
function _addJSONPropertyMetaData(getEncodedType, json, propKeys, name, propertyValue) {
if (propertyValue && json) {
var encodedTypeValue = getEncodedType(propertyValue.value, propertyValue.kind, propertyValue.propertyType);
if (encodedTypeValue > -1) {
// Add the root metadata
var metaData = json[metadata];
if (!metaData) {
// Sets the root 'f'
metaData = json[metadata] = { f: {} };
}
var metaTarget = metaData[f];
if (!metaTarget) {
// This can occur if someone has manually added an ext.metadata object
// Such as ext.metadata.privLevel and ext.metadata.privTags
metaTarget = metaData[f] = {};
}
// Traverse the metadata path and build each object (contains an 'f' key) -- if required
if (propKeys) {
for (var lp = 0; lp < propKeys.length; lp++) {
var key = propKeys[lp];
if (!metaTarget[key]) {
metaTarget[key] = { f: {} };
}
var newTarget = metaTarget[key][f];
if (!newTarget) {
// Not expected, but can occur if the metadata context was pre-created as part of the event
newTarget = metaTarget[key][f] = {};
}
metaTarget = newTarget;
}
}
metaTarget = metaTarget[name] = {};
if (isArray(propertyValue.value)) {
metaTarget["a"] = {
t: encodedTypeValue
};
}
else {
metaTarget["t"] = encodedTypeValue;
}
}
}
}
//# sourceMappingURL=Serializer.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,24 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
/**
* TimeoutOverrideWrapper.ts
* @author Nev Wylie (newylie)
* @copyright Microsoft 2022
* Simple internal timeout wrapper
*/
import { scheduleTimeoutWith } from "@nevware21/ts-utils";
export function createTimeoutWrapper(argSetTimeout, argClearTimeout) {
return {
set: function (callback, ms) {
var args = [];
for (var _i = 2; _i < arguments.length; _i++) {
args[_i - 2] = arguments[_i];
}
return scheduleTimeoutWith([argSetTimeout, argClearTimeout], callback, ms, args);
}
};
}
//# sourceMappingURL=TimeoutOverrideWrapper.js.map
@@ -0,0 +1 @@
{"version":3,"file":"TimeoutOverrideWrapper.js.map","sources":["TimeoutOverrideWrapper.js"],"sourcesContent":["/**\r\n* TimeoutOverrideWrapper.ts\r\n* @author Nev Wylie (newylie)\r\n* @copyright Microsoft 2022\r\n* Simple internal timeout wrapper\r\n*/\r\nimport { scheduleTimeoutWith } from \"@nevware21/ts-utils\";\r\nexport function createTimeoutWrapper(argSetTimeout, argClearTimeout) {\r\n return {\r\n set: function (callback, ms) {\r\n var args = [];\r\n for (var _i = 2; _i < arguments.length; _i++) {\r\n args[_i - 2] = arguments[_i];\r\n }\r\n return scheduleTimeoutWith([argSetTimeout, argClearTimeout], callback, ms, args);\r\n }\r\n };\r\n}\r\n//# sourceMappingURL=TimeoutOverrideWrapper.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA"}
@@ -0,0 +1,73 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
// Licensed under the MIT License.
// @skip-file-minify
// ##############################################################
// AUTO GENERATED FILE: This file is Auto Generated during build.
// ##############################################################
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// Note: DON'T Export these const from the package as we are still targeting ES5 which can result in a mutable variables that someone could change!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
export var _DYN_ALLOW_REQUEST_SENDIN0 = "allowRequestSending"; // Count: 3
export var _DYN_SHOULD_ADD_CLOCK_SKE1 = "shouldAddClockSkewHeaders"; // Count: 2
export var _DYN_GET_CLOCK_SKEW_HEADE2 = "getClockSkewHeaderValue"; // Count: 2
export var _DYN_SET_CLOCK_SKEW = "setClockSkew"; // Count: 3
export var _DYN_LENGTH = "length"; // Count: 38
export var _DYN_CONCAT = "concat"; // Count: 7
export var _DYN_I_KEY = "iKey"; // Count: 10
export var _DYN_COUNT = "count"; // Count: 19
export var _DYN_EVENTS = "events"; // Count: 8
export var _DYN_PUSH = "push"; // Count: 15
export var _DYN_SPLIT = "split"; // Count: 6
export var _DYN_TO_LOWER_CASE = "toLowerCase"; // Count: 3
export var _DYN_HDRS = "hdrs"; // Count: 7
export var _DYN_USE_HDRS = "useHdrs"; // Count: 4
export var _DYN_INITIALIZE = "initialize"; // Count: 5
export var _DYN_SET_TIMEOUT_OVERRIDE = "setTimeoutOverride"; // Count: 3
export var _DYN_CLEAR_TIMEOUT_OVERRI3 = "clearTimeoutOverride"; // Count: 3
export var _DYN_PAYLOAD_PREPROCESSOR = "payloadPreprocessor"; // Count: 2
export var _DYN_OVERRIDE_ENDPOINT_UR4 = "overrideEndpointUrl"; // Count: 3
export var _DYN_AVOID_OPTIONS = "avoidOptions"; // Count: 3
export var _DYN_DISABLE_EVENT_TIMING5 = "disableEventTimings"; // Count: 2
export var _DYN_ENABLE_COMPOUND_KEY = "enableCompoundKey"; // Count: 4
export var _DYN_DISABLE_XHR_SYNC = "disableXhrSync"; // Count: 6
export var _DYN_DISABLE_FETCH_KEEP_A6 = "disableFetchKeepAlive"; // Count: 7
export var _DYN_ADD_NO_RESPONSE = "addNoResponse"; // Count: 3
export var _DYN_USE_SEND_BEACON = "useSendBeacon"; // Count: 3
export var _DYN_FETCH_CREDENTIALS = "fetchCredentials"; // Count: 4
export var _DYN_ALWAYS_USE_XHR_OVERR7 = "alwaysUseXhrOverride"; // Count: 3
export var _DYN_SERIALIZE_OFFLINE_EV8 = "serializeOfflineEvt"; // Count: 2
export var _DYN_GET_OFFLINE_REQUEST_9 = "getOfflineRequestDetails"; // Count: 2
export var _DYN_CREATE_PAYLOAD = "createPayload"; // Count: 4
export var _DYN_CREATE_ONE_DSPAYLOAD = "createOneDSPayload"; // Count: 4
export var _DYN_PAYLOAD_BLOB = "payloadBlob"; // Count: 3
export var _DYN_HEADERS = "headers"; // Count: 10
export var _DYN__THE_PAYLOAD = "_thePayload"; // Count: 5
export var _DYN_BATCHES = "batches"; // Count: 15
export var _DYN_SEND_TYPE = "sendType"; // Count: 13
export var _DYN_CAN_SEND_REQUEST = "canSendRequest"; // Count: 3
export var _DYN_SEND_QUEUED_REQUESTS = "sendQueuedRequests"; // Count: 5
export var _DYN_SET_UNLOADING = "setUnloading"; // Count: 3
export var _DYN_IS_TENANT_KILLED = "isTenantKilled"; // Count: 3
export var _DYN_SEND_SYNCHRONOUS_BAT10 = "sendSynchronousBatch"; // Count: 2
export var _DYN__TRANSPORT = "_transport"; // Count: 3
export var _DYN_GET_WPARAM = "getWParam"; // Count: 4
export var _DYN_IS_BEACON = "isBeacon"; // Count: 4
export var _DYN_TIMINGS = "timings"; // Count: 4
export var _DYN_IS_TEARDOWN = "isTeardown"; // Count: 3
export var _DYN__SEND_REASON = "_sendReason"; // Count: 3
export var _DYN_SET_KILL_SWITCH_TENA11 = "setKillSwitchTenants"; // Count: 2
export var _DYN__BACK_OFF_TRANSMISSI12 = "_backOffTransmission"; // Count: 2
export var _DYN_IDENTIFIER = "identifier"; // Count: 4
export var _DYN_IGNORE_MC1_MS0_COOKI13 = "ignoreMc1Ms0CookieProcessing"; // Count: 2
export var _DYN_AUTO_FLUSH_EVENTS_LI14 = "autoFlushEventsLimit"; // Count: 2
export var _DYN_DISABLE_AUTO_BATCH_F15 = "disableAutoBatchFlushLimit"; // Count: 2
export var _DYN_OVERRIDE_INSTRUMENTA16 = "overrideInstrumentationKey"; // Count: 2
export var _DYN_SEND_ATTEMPT = "sendAttempt"; // Count: 4
export var _DYN_LATENCY = "latency"; // Count: 7
export var _DYN_SYNC = "sync"; // Count: 7
//# sourceMappingURL=__DynamicConstants.js.map
File diff suppressed because one or more lines are too long
@@ -0,0 +1,11 @@
/*
* 1DS JS SDK POST plugin, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
* (Microsoft Internal Only)
*/
export {};
// export declare var XDomainRequest: {
// prototype: IXDomainRequest;
// new (): IXDomainRequest;
// };
//# sourceMappingURL=XDomainRequest.js.map
@@ -0,0 +1 @@
{"version":3,"file":"XDomainRequest.js.map","sources":["XDomainRequest.js"],"sourcesContent":["export {};\r\n// export declare var XDomainRequest: {\r\n// prototype: IXDomainRequest;\r\n// new (): IXDomainRequest;\r\n// };\r\n//# sourceMappingURL=XDomainRequest.js.map"],"names":[],"mappings":";;;;;AAAA;AACA;AACA;AACA;AACA;AACA"}
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+64
View File
@@ -0,0 +1,64 @@
{
"name": "@microsoft/1ds-post-js",
"version": "4.3.11",
"description": "Microsoft Application Insights JavaScript SDK - 1ds-post-channel-js",
"author": "Microsoft Application Insights Team",
"homepage": "https://github.com/microsoft/ApplicationInsights-JS#readme",
"license": "MIT",
"sideEffects": false,
"scripts": {
"clean": "git clean -xdf",
"build": "npm run build:esm && npm run build:browser && npm run dtsgen && npm run sri",
"build:esm": "grunt 1dsPostBuild",
"build:browser": "npx rollup -c rollup.config.js --bundleConfigAsCjs",
"rebuild": "npm run build",
"ai-min": "grunt 1dsPost-min",
"ai-restore": "grunt 1dsPost-restore",
"dtsgen": "api-extractor run --local && node ../../scripts/dtsgen.js \"1DS JS SDK Post Channel\" -oneDs",
"test": "grunt 1dsPostTest",
"mintest": "grunt adsPostMinTest",
"perftest": "",
"makePublicPackage": "node ../../tools/makePublic/makePublicPackage.js ./package.json && npm pack",
"publishPackage": "npm publish",
"sri": "node ../../tools/subResourceIntegrity/generateIntegrityFile.js",
"npm-pack": "npm pack",
"api-docs": "typedoc"
},
"dependencies": {
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/dynamicproto-js": "^2.0.3",
"@microsoft/1ds-core-js": "4.3.11",
"@nevware21/ts-utils": ">= 0.11.8 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x"
},
"devDependencies": {
"@microsoft/ai-test-framework": "0.0.1",
"@microsoft/applicationinsights-rollup-plugin-uglify3-js": "1.0.0",
"@microsoft/applicationinsights-rollup-es5": "1.0.2",
"@microsoft/api-extractor": "^7.40.0",
"globby": "^11.0.0",
"grunt": "^1.5.3",
"sinon": "^7.3.1",
"@rollup/plugin-commonjs": "^24.0.0",
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.2",
"rollup": "^3.20.0",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-sourcemaps": "^0.6.3",
"typedoc": "^0.26.6",
"typescript": "^4.9.3",
"pako": "^2.0.3"
},
"repository": {
"type": "git",
"url": "https://github.com/microsoft/ApplicationInsights-JS/tree/main/channels/1ds-post-js"
},
"main": "dist/es5/ms.post.js",
"module": "dist-es5/Index.js",
"types": "types/1ds-post-js.d.ts",
"keywords": [
"1DS",
"Js",
"SDK"
]
}
+27
View File
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"sourceMap": true,
"inlineSources": true,
"module": "es6",
"moduleResolution": "Node",
"target": "es5",
"alwaysStrict": true,
"strictNullChecks": false,
"suppressImplicitAnyIndexErrors": true,
"allowSyntheticDefaultImports": true,
"importHelpers": true,
"noEmitHelpers": true,
"forceConsistentCasingInFileNames": true,
"declaration": true,
"declarationDir": "build/types",
"removeComments": false,
"outDir": "dist-es5/",
"rootDir": "./src"
},
"include": [
"./src/**/*.ts"
],
"exclude": [
"node_modules/"
]
}
@@ -0,0 +1,456 @@
/*
* 1DS JS SDK Post Channel, 4.3.11
* Copyright (c) Microsoft and contributors. All rights reserved.
*
* Microsoft Application Insights Team
* https://github.com/microsoft/ApplicationInsights-JS#readme
*
* ---------------------------------------------------------------------------
* This is a single combined (rollup) declaration file for the package,
* if you require a namespace wrapped version it is also available.
* - Namespaced version: types/1ds-post-js.namespaced.d.ts
* ---------------------------------------------------------------------------
*/
import { BaseTelemetryPlugin } from '@microsoft/1ds-core-js';
import { IAppInsightsCore } from '@microsoft/1ds-core-js';
import { IChannelControls } from '@microsoft/1ds-core-js';
import { IDiagnosticLogger } from '@microsoft/1ds-core-js';
import { IExtendedConfiguration } from '@microsoft/1ds-core-js';
import { IInternalOfflineSupport } from '@microsoft/1ds-core-js';
import { IPayloadData } from '@microsoft/1ds-core-js';
import { IPlugin } from '@microsoft/1ds-core-js';
import { IProcessTelemetryContext } from '@microsoft/1ds-core-js';
import { IPromise } from '@nevware21/ts-async';
import { ITelemetryItem } from '@microsoft/1ds-core-js';
import { ITelemetryPlugin } from '@microsoft/1ds-core-js';
import { IUnloadHook } from '@microsoft/1ds-core-js';
import { IValueSanitizer } from '@microsoft/1ds-core-js';
import { IXHROverride } from '@microsoft/1ds-core-js';
import { OnCompleteCallback } from '@microsoft/1ds-core-js';
import { SendPOSTFunction } from '@microsoft/1ds-core-js';
import { SendRequestReason } from '@microsoft/1ds-core-js';
/**
* Best Effort. RealTime Latency events are sent every 9 sec and
* Normal Latency events are sent every 18 sec.
*/
export declare const BE_PROFILE = "BEST_EFFORT";
/**
* The IChannelConfiguration interface holds the configuration details passed to Post module.
*/
export declare interface IChannelConfiguration {
/**
* [Optional] The number of events that can be kept in memory before the SDK starts to drop events. By default, this is 10,000.
*/
eventsLimitInMem?: number;
/**
* [Optional] Sets the maximum number of immediate latency events that will be cached in memory before the SDK starts to drop other
* immediate events only, does not drop normal and real time latency events as immediate events have their own internal queue. Under
* normal situations immediate events are scheduled to be sent in the next Javascript execution cycle, so the typically number of
* immediate events is small (~1), the only time more than one event may be present is when the channel is paused or immediate send
* is disabled (via manual transmit profile). By default max number of events is 500 and the default transmit time is 0ms.
*/
immediateEventLimit?: number;
/**
* [Optional] If defined, when the number of queued events reaches or exceeded this limit this will cause the queue to be immediately
* flushed rather than waiting for the normal timers. Defaults to undefined.
*/
autoFlushEventsLimit?: number;
/**
* [Optional] If defined allows you to disable the auto batch (iKey set of requests) flushing logic. This is in addition to the
* default transmission profile timers, autoFlushEventsLimit and eventsLimitInMem config values.
*/
disableAutoBatchFlushLimit?: boolean;
/**
* [Optional] Sets the record and request size limit in bytes for serializer.
* Default for record size (sync) is 65000, record size (async) is 2000000.
* Default for request size (sync) is 65000, request size (async) is 3145728.
* @since 3.3.7
*/
requestLimit?: IRequestSizeLimit;
/**
* [Optional] Sets the limit number of events per batch.
* Default is 500
* @since 3.3.7
*/
maxEvtPerBatch?: number;
/**
* [Optional] The HTTP override that should be used to send requests, as an IXHROverride object.
* By default during the unload of a page or if the event specifies that it wants to use sendBeacon() or sync fetch (with keep-alive),
* this override will NOT be called. You can now change this behavior by enabling the 'alwaysUseXhrOverride' configuration value.
* The payload data (first argument) now also includes any configured 'timeout' (defaults to undefined) and whether you should avoid
* creating any synchronous XHR requests 'disableXhrSync' (defaults to false/undefined)
*/
httpXHROverride?: IXHROverride;
/**
* Override for Instrumentation key
*/
overrideInstrumentationKey?: string;
/**
* Override for Endpoint where telemetry data is sent
*/
overrideEndpointUrl?: string;
/**
* The master off switch. Do not send any data if set to TRUE
*/
disableTelemetry?: boolean;
/**
* MC1 and MS0 cookies will not be returned from Collector endpoint.
*/
ignoreMc1Ms0CookieProcessing?: boolean;
/**
* Override for setTimeout
*/
setTimeoutOverride?: typeof setTimeout;
/**
* Override for clearTimeout
*/
clearTimeoutOverride?: typeof clearTimeout;
/**
* [Optional] POST channel preprocessing function. Can be used to gzip the payload before transmission and to set the appropriate
* Content-Encoding header. The preprocessor is explicitly not called during teardown when using the sendBeacon() API.
*/
payloadPreprocessor?: PayloadPreprocessorFunction;
/**
* [Optional] POST channel listener function, used for enabling logging or reporting (RemoteDDVChannel) of the payload that is being sent.
*/
payloadListener?: PayloadListenerFunction;
/**
* [Optional] By default additional timing metrics details are added to each event after they are sent to allow you to review how long it took
* to create serialized request. As not all implementations require this level of detail and it's now possible to get the same metrics via
* the IPerfManager and IPerfEvent we are enabling these details to be disabled. Default value is false to retain the previous behavior,
* if you are not using these metrics and performance is a concern then it is recommended to set this value to true.
*/
disableEventTimings?: boolean;
/**
* [Optional] The value sanitizer to use while constructing the envelope.
*/
valueSanitizer?: IValueSanitizer;
/**
* [Optional] During serialization, when an object is identified, should the object be serialized by JSON.stringify(theObject); (when true) otherwise by theObject.toString().
* Defaults to false
*/
stringifyObjects?: boolean;
/**
* [Optional] Enables support for objects with compound keys which indirectly represent an object where the "key" of the object contains a "." as part of it's name.
* @example
* ```typescript
* event: { "somedata.embeddedvalue": 123 }
* ```
*/
enableCompoundKey?: boolean;
/**
* [Optional] Switch to disable the v8 optimizeObject() calls used to provide better serialization performance. Defaults to false.
*/
disableOptimizeObj?: boolean;
/**
* [Optional] By default a "Cache-Control" header will be added to the outbound payloads with the value "no-cache, no-store", this is to
* avoid instances where Chrome can "Stall" requests which use the same outbound URL.
*/
/**
* [Optional] Either an array or single value identifying the requested TransportType type that should be used.
* This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride is provided.
*/
transports?: number | number[];
/**
* [Optional] Either an array or single value identifying the requested TransportType type(s) that should be used during unload or events
* marked as sendBeacon. This is used during initialization to identify the requested send transport, it will be ignored if a httpXHROverride
* is provided and alwaysUseXhrOverride is true.
*/
unloadTransports?: number | number[];
/**
* [Optional] A flag to enable or disable the usage of the sendBeacon() API (if available). If running on ReactNative this defaults
* to `false` for all other cases it defaults to `true`.
*/
useSendBeacon?: boolean;
/**
* [Optional] A flag to disable the usage of the [fetch with keep-alive](https://javascript.info/fetch-api#keepalive) support.
*/
disableFetchKeepAlive?: boolean;
/**
* [Optional] Avoid adding request headers to the outgoing request that would cause a pre-flight (OPTIONS) request to be sent for each request.
* This currently defaults to false. This is changed as the collector enables Access-Control-Max-Age to allow the browser to better cache any
* previous OPTIONS response. Hence, we moved some of the current dynamic values sent on the query string to a header.
*/
avoidOptions?: boolean;
/**
* [Optional] Specify a timeout (in ms) to apply to requests when sending requests using XHR, XDR or fetch requests. Defaults to undefined
* and therefore the runtime defaults (normally zero for browser environments)
*/
xhrTimeout?: number;
/**
* [Optional] When using Xhr for sending requests disable sending as synchronous during unload or synchronous flush.
* You should enable this feature for IE (when there is no sendBeacon() or fetch (with keep-alive)) and you have clients
* that end up blocking the UI during page unloading. This will cause ALL XHR requests to be sent asynchronously which
* during page unload may result in the lose of telemetry.
*/
disableXhrSync?: boolean;
/**
* [Optional] By default during unload (or when you specify to use sendBeacon() or sync fetch (with keep-alive) for an event) the SDK
* ignores any provided httpXhrOverride and attempts to use sendBeacon() or fetch(with keep-alive) when they are available.
* When this configuration option is true any provided httpXhrOverride will always be used, so any provided httpXhrOverride will
* also need to "handle" the synchronous unload scenario.
*/
alwaysUseXhrOverride?: boolean;
/**
* [Optional] Identifies the number of times any single event will be retried if it receives a failed (retirable) response, this
* causes the event to be internally "requeued" and resent in the next batch. As each normal batched send request is retried at
* least once before starting to increase the internal backoff send interval, normally batched events will generally be attempted
* the next nearest even number of times. This means that the total number of actual send attempts will almost always be even
* (setting to 5 will cause 6 requests), unless using manual synchronous flushing (calling flush(false)) which is not subject to
* request level retry attempts.
* Defaults to 6 times.
*/
maxEventRetryAttempts?: number;
/**
* [Optional] Identifies the number of times any single event will be retried if it receives a failed (retriable) response as part
* of processing / flushing events once a page unload state has been detected, this causes the event to be internally "requeued"
* and resent in the next batch, which during page unload. Unlike the normal batching process, send requests are never retried,
* so the value listed here is always the maximum number of attempts for any single event.
* Defaults to 2 times.
* Notes:
* The SDK by default will use the sendBeacon() API if it exists which is treated as a fire and forget successful response, so for
* environments that support or supply this API the events won't be retried (because they will be deeded to be successfully sent).
* When an environment (IE) doesn't support sendBeacon(), this will cause multiple synchronous (by default) XMLHttpRequests to be sent,
* which will block the UI until a response is received. You can disable ALL synchronous XHR requests by setting the 'disableXhrSync'
* configuration setting and/or changing this value to 0 or 1.
*/
maxUnloadEventRetryAttempts?: number;
/**
* [Optional] flag to indicate whether the sendBeacon and fetch (with keep-alive flag) should add the "NoResponseBody" query string
* value to indicate that the server should return a 204 for successful requests. Defaults to true
*/
addNoResponse?: boolean;
/**
* :warning: DO NOT USE THIS FLAG UNLESS YOU KNOW THAT PII DATA WILL NEVER BE INCLUDED IN THE EVENT!
*
* [Optional] Flag to indicate whether the SDK should include the common schema metadata in the payload. Defaults to true.
* This flag is only applicable to the POST channel and will cause the SDK to exclude the common schema metadata from the payload,
* while this will reduce the size of the payload, also means that the data marked as PII will not be processed as PII by the backend
* and will not be included in the PII data purge process.
* @since 4.1.0
*/
excludeCsMetaData?: boolean;
/**
* [Optional] Specify whether cross-site Access-Control fetch requests should include credentials such as cookies,
* authentication headers, or TLS client certificates.
*
* Possible values:
* - "omit": never send credentials in the request or include credentials in the response.
* - "include": always include credentials, even cross-origin.
* - "same-origin": only send and include credentials for same-origin requests.
*
* If not set, the default value will be "include".
*
* For more information, refer to:
* - [Fetch API - Using Fetch](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch#including_credentials)
* @since 3.3.1
*/
fetchCredentials?: RequestCredentials;
}
export { IPayloadData }
/**
* Post channel interface
*/
export declare interface IPostChannel extends ITelemetryPlugin {
/**
* Diagnostic logger
*/
diagLog: (itemCtx?: IProcessTelemetryContext) => IDiagnosticLogger;
/**
* Override for setTimeout
*/
_setTimeoutOverride?: (callback: (...args: any[]) => void, ms: number, ...args: any[]) => any;
/**
* Backs off transmission. This exponentially increases all the timers.
*/
_backOffTransmission(): void;
/**
* Clears back off for transmission.
*/
_clearBackOff(): void;
/**
* Add handler to be executed with request response text.
*/
addResponseHandler(responseHandler: (responseText: string) => void): IUnloadHook;
}
export declare interface IRequestSizeLimit {
/**
* Request size limit in bytes for serializer.
* The value should be two numbers array, with format [async request size limit, sync request size limit]
*/
requestLimit?: number[];
/**
* Record size limit in bytes for serializer.
* The value should be two numbers array, with format [async record size limit, sync record size limit]
*/
recordLimit?: number[];
}
export { IXHROverride }
/**
* Near Real Time profile. RealTime Latency events are sent every 3 sec and
* Normal Latency events are sent every 6 sec.
*/
export declare const NRT_PROFILE = "NEAR_REAL_TIME";
export { OnCompleteCallback }
/**
* Defines the function signature of a payload listener, which is called after the payload has been sent to the server. The listener is passed
* both the initial payload object and any altered (modified) payload from a preprocessor so it can determine what payload it may want to log or send.
* Used by the Remove DDV extension to listen to server send events.
* @param orgPayload - The initially constructed payload object
* @param sendPayload - The alternative (possibly modified by a preprocessor) payload
* @param isSync - A boolean flag indicating whether this request was initiated as part of a sync response (unload / flush request), this is for informative only.
* @param isBeaconSend - A boolean flag indicating whether the payload was sent using the navigator.sendBeacon() API.
*/
export declare type PayloadListenerFunction = (orgPayload: IPayloadData, sendPayload?: IPayloadData, isSync?: boolean, isBeaconSend?: boolean) => void;
/**
* Defines the function signature for the Payload Preprocessor.
* @param payload - The Initial constructed payload that if not modified should be passed onto the callback function.
* @param callback - The preprocessor MUST call the callback function to ensure that the events are sent to the server, failing to call WILL result in dropped events.
* The modifiedBuffer argument can be either the original payload or may be modified by performing GZipping of the payload and adding the content header.
* @param isSync - A boolean flag indicating whether this request was initiated as part of a sync response (unload / flush request), this is for informative only.
* e.g the preprocessor may wish to not perform any GZip operations if the request was a sync request which is normally called as part of an unload request.
*/
export declare type PayloadPreprocessorFunction = (payload: IPayloadData, callback: (modifiedBuffer: IPayloadData) => void, isSync?: boolean) => void;
/**
* Class that manages adding events to inbound queues and batching of events
* into requests.
* @group Classes
* @group Entrypoint
*/
export declare class PostChannel extends BaseTelemetryPlugin implements IChannelControls, IPostChannel {
identifier: string;
priority: number;
version: string;
constructor();
/**
* Start the queue manager to batch and send events via post.
* @param config - The core configuration.
*/
initialize(coreConfig: IExtendedConfiguration, core: IAppInsightsCore, extensions: IPlugin[]): void;
/**
* Add an event to the appropriate inbound queue based on its latency.
* @param ev - The event to be added to the queue.
* @param itemCtx - This is the context for the current request, ITelemetryPlugin instances
* can optionally use this to access the current core instance or define / pass additional information
* to later plugins (vs appending items to the telemetry item)
*/
processTelemetry(ev: ITelemetryItem, itemCtx?: IProcessTelemetryContext): void;
/**
* Sets the event queue limits at runtime (after initialization), if the number of queued events is greater than the
* eventLimit or autoFlushLimit then a flush() operation will be scheduled.
* @param eventLimit - The number of events that can be kept in memory before the SDK starts to drop events. If the value passed is less than or
* equal to zero the value will be reset to the default (10,000).
* @param autoFlushLimit - When defined, once this number of events has been queued the system perform a flush() to send the queued events
* without waiting for the normal schedule timers. Passing undefined, null or a value less than or equal to zero will disable the auto flush.
*/
setEventQueueLimits(eventLimit: number, autoFlushLimit?: number): void;
/**
* Pause the transmission of any requests
*/
pause(): void;
/**
* Resumes transmission of events.
*/
resume(): void;
/**
* Add handler to be executed with request response text.
*/
addResponseHandler(responseHanlder: (responseText: string) => void): IUnloadHook;
/**
* Flush to send data immediately; channel should default to sending data asynchronously. If executing asynchronously (the default) and
* you DO NOT pass a callback function then a [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html)
* will be returned which will resolve once the flush is complete. The actual implementation of the `IPromise`
* will be a native Promise (if supported) or the default as supplied by [ts-async library](https://github.com/nevware21/ts-async)
* @param isAsync - send data asynchronously when true
* @param callBack - if specified, notify caller when send is complete, the channel should return true to indicate to the caller that it will be called.
* If the caller doesn't return true the caller should assume that it may never be called.
* @param sendReason - specify the reason that you are calling "flush" defaults to ManualFlush (1) if not specified
* @returns - If a callback is provided `true` to indicate that callback will be called after the flush is complete otherwise the caller
* should assume that any provided callback will never be called, Nothing or if occurring asynchronously a
* [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) which will be resolved once the unload is complete,
* the [IPromise](https://nevware21.github.io/ts-async/typedoc/interfaces/IPromise.html) will only be returned when no callback is provided
* and isAsync is true.
*/
flush(isAsync?: boolean, callBack?: (flushComplete?: boolean) => void, sendReason?: SendRequestReason): boolean | void | IPromise<boolean>;
/**
* Set AuthMsaDeviceTicket header
* @param ticket - Ticket value.
*/
setMsaAuthTicket(ticket: string): void;
/**
* Set setAuthPluginHeader header
* @param token - token value.
*/
setAuthPluginHeader(token: string): void;
/**
* remove AuthPlugin Header
* @param token - token value.
*/
removeAuthPluginHeader(token: string): void;
/**
* Check if there are any events waiting to be scheduled for sending.
* @returns True if there are events, false otherwise.
*/
hasEvents(): boolean;
/**
* Load custom transmission profiles. Each profile should have timers for real time, and normal and can
* optionally specify the immediate latency time in ms (defaults to 0 when not defined). Each profile should
* make sure that a each normal latency timer is a multiple of the real-time latency and the immediate
* is smaller than the real-time.
* Setting the timer value to -1 means that the events for that latency will not be scheduled to be sent.
* Note that once a latency has been set to not send, all latencies below it will also not be sent. The
* timers should be in the form of [normal, high, [immediate]].
* e.g Custom:
* [10,5] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 0ms
* [10,5,1] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 1ms
* [10,5,0] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate will default to 0ms
* [10,5,-1] - Sets the normal latency time to 10 seconds and real-time to 5 seconds; Immediate events will not be
* scheduled on their own and but they will be included with real-time or normal events as the first events in a batch.
* This also removes any previously loaded custom profiles.
* @param profiles - A dictionary containing the transmit profiles.
*/
_loadTransmitProfiles(profiles: {
[profileName: string]: number[];
}): void;
/**
* Set the transmit profile to be used. This will change the transmission timers
* based on the transmit profile.
* @param profileName - The name of the transmit profile to be used.
*/
_setTransmitProfile(profileName: string): void;
/**
* Backs off transmission. This exponentially increases all the timers.
*/
_backOffTransmission(): void;
/**
* Clears backoff for transmission.
*/
_clearBackOff(): void;
/**
* Get Offline support
* @returns internal Offline support interface IInternalOfflineSupport
*/
getOfflineSupport(): IInternalOfflineSupport;
}
/**
* Real Time profile (default profile). RealTime Latency events are sent every 1 sec and
* Normal Latency events are sent every 2 sec.
*/
export declare const RT_PROFILE = "REAL_TIME";
export { SendPOSTFunction }
export { }
File diff suppressed because it is too large Load Diff