Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AISKU/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
"@microsoft/applicationinsights-core-js": "3.3.5",
"@microsoft/applicationinsights-dependencies-js": "3.3.5",
"@microsoft/applicationinsights-properties-js": "3.3.5",
"@nevware21/ts-utils": ">= 0.11.6 < 2.x",
"@nevware21/ts-utils": ">= 0.11.8 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion AISKULight/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"@microsoft/applicationinsights-common": "3.3.5",
"@microsoft/applicationinsights-channel-js": "3.3.5",
"@microsoft/applicationinsights-core-js": "3.3.5",
"@nevware21/ts-utils": ">= 0.11.6 < 2.x",
"@nevware21/ts-utils": ">= 0.11.8 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion channels/1ds-post-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/dynamicproto-js": "^2.0.3",
"@microsoft/1ds-core-js": "4.3.5",
"@nevware21/ts-utils": ">= 0.11.6 < 2.x",
"@nevware21/ts-utils": ">= 0.11.8 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x"
},
"devDependencies": {
Expand Down
10 changes: 5 additions & 5 deletions channels/1ds-post-js/src/PostChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
setProcessTelemetryTimings
} from "@microsoft/1ds-core-js";
import { IPromise, createPromise } from "@nevware21/ts-async";
import { ITimerHandler, isPromiseLike, objDeepFreeze } from "@nevware21/ts-utils";
import { ITimerHandler, isPromiseLike, mathCeil, mathMax, mathMin, objDeepFreeze } from "@nevware21/ts-utils";
import {
BE_PROFILE, EventBatchNotificationReason, IChannelConfiguration, IPostChannel, IPostTransmissionTelemetryItem, NRT_PROFILE, RT_PROFILE
} from "./DataModels";
Expand Down Expand Up @@ -500,7 +500,7 @@ export class PostChannel extends BaseTelemetryPlugin implements IChannelControls
// we round up so that it becomes a multiple.
if (profileValue[1] > 0 && profileValue[0] > 0) {
let timerMultiplier = profileValue[0] / profileValue[1];
profileValue[0] = Math.ceil(timerMultiplier) * profileValue[1];
profileValue[0] = mathCeil(timerMultiplier) * profileValue[1];
}

// Add back the direct profile timeout
Expand Down Expand Up @@ -942,8 +942,8 @@ export class PostChannel extends BaseTelemetryPlugin implements IChannelControls
}, () => ({ latency, sendType, sendReason }), !isAsync);
} else {
// remember the min latency so that we can re-trigger later
_delayedBatchSendLatency = _delayedBatchSendLatency >= 0 ? Math.min(_delayedBatchSendLatency, latency) : latency;
_delayedBatchReason = Math.max(_delayedBatchReason, sendReason);
_delayedBatchSendLatency = _delayedBatchSendLatency >= 0 ? mathMin(_delayedBatchSendLatency, latency) : latency;
_delayedBatchReason = mathMax(_delayedBatchReason, sendReason);
}

return eventsQueued;
Expand Down Expand Up @@ -1138,7 +1138,7 @@ export class PostChannel extends BaseTelemetryPlugin implements IChannelControls

function _setAutoLimits() {
if (!_disableAutoBatchFlushLimit) {
_autoFlushBatchLimit = Math.max(MaxNumberEventPerBatch * (MaxConnections + 1), _queueSizeLimit / 6);
_autoFlushBatchLimit = mathMax(MaxNumberEventPerBatch * (MaxConnections + 1), _queueSizeLimit / 6);
} else {
_autoFlushBatchLimit = 0;
}
Expand Down
6 changes: 4 additions & 2 deletions channels/1ds-post-js/src/RetryPolicy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { mathFloor, mathMin } from "@nevware21/ts-utils";

/**
* RetryPolicy.ts
* @author Abhilash Panwar (abpanwar)
Expand Down Expand Up @@ -40,7 +42,7 @@ export function retryPolicyGetMillisToBackoffForRetry(retriesSoFar: number): num
let waitDuration = 0;
let minBackoff = BaseBackoff * RandomizationLowerThreshold;
let maxBackoff = BaseBackoff * RandomizationUpperThreshold;
let randomBackoff = Math.floor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
let randomBackoff = mathFloor(Math.random() * (maxBackoff - minBackoff)) + minBackoff;
waitDuration = Math.pow(2, retriesSoFar) * randomBackoff;
return Math.min(waitDuration, MaxBackoff);
return mathMin(waitDuration, MaxBackoff);
}
4 changes: 2 additions & 2 deletions channels/1ds-post-js/src/Serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
import { IPostTransmissionTelemetryItem } from "./DataModels";
import { EventBatch } from "./EventBatch";
import { STR_EMPTY } from "./InternalConstants";
import { strSubstr } from "@nevware21/ts-utils";
import { mathMin, strSubstr } from "@nevware21/ts-utils";

/**
* Note: This is an optimization for V8-based browsers. When V8 concatenates a string,
Expand All @@ -33,7 +33,7 @@ const _MAX_STRING_JOINS = 20;
const RequestSizeLimitBytes = 3984588; // approx 3.8 Mb
const BeaconRequestSizeLimitBytes = 65000; // approx 64kb (the current Edge, Firefox and Chrome max limit)
const MaxRecordSize = 2000000; // approx 2 Mb
const MaxBeaconRecordSize = Math.min(MaxRecordSize, BeaconRequestSizeLimitBytes);
const MaxBeaconRecordSize = mathMin(MaxRecordSize, BeaconRequestSizeLimitBytes);
const metadata = "metadata";
const f = "f";
const rCheckDot = /\./;
Expand Down
4 changes: 2 additions & 2 deletions channels/1ds-post-js/test/Unit/src/FileSizeCheckTest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AITestClass } from "@microsoft/ai-test-framework";
import { dumpObj } from '@nevware21/ts-utils';
import { dumpObj, mathCeil } from '@nevware21/ts-utils';
import { createPromise, doAwait, IPromise } from '@nevware21/ts-async';
import * as pako from 'pako';

Expand Down Expand Up @@ -69,7 +69,7 @@ export class FileSizeCheckTest extends AITestClass {
let xhr = new XMLHttpRequest();
xhr.open('GET', '../bundle/es5/ms.post.min.js', true);
xhr.onload = () => {
let size = Math.ceil(pako.deflate(xhr.responseText).length / 1024);
let size = mathCeil(pako.deflate(xhr.responseText).length / 1024);
_checkSize("deflate", MAX_DEFLATE_SIZE, size, isNightly);
testCompleted();
};
Expand Down
2 changes: 1 addition & 1 deletion channels/applicationinsights-channel-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/applicationinsights-core-js": "3.3.5",
"@microsoft/applicationinsights-common": "3.3.5",
"@nevware21/ts-utils": ">= 0.11.6 < 2.x",
"@nevware21/ts-utils": ">= 0.11.8 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x"
},
"license": "MIT"
Expand Down
10 changes: 5 additions & 5 deletions channels/applicationinsights-channel-js/src/Sender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from "@microsoft/applicationinsights-core-js";
import { IPromise } from "@nevware21/ts-async";
import {
ITimerHandler, isNumber, isPromiseLike, isString, isTruthy, objDeepFreeze, objDefine, scheduleTimeout
ITimerHandler, isNumber, isPromiseLike, isString, isTruthy, mathFloor, mathMax, mathMin, objDeepFreeze, objDefine, scheduleTimeout
} from "@nevware21/ts-utils";
import {
DependencyEnvelopeCreator, EventEnvelopeCreator, ExceptionEnvelopeCreator, MetricEnvelopeCreator, PageViewEnvelopeCreator,
Expand Down Expand Up @@ -1188,9 +1188,9 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControls {
} else {
const backOffSlot = (Math.pow(2, _consecutiveErrors) - 1) / 2;
// tslint:disable-next-line:insecure-random
let backOffDelay = Math.floor(Math.random() * backOffSlot * SlotDelayInSeconds) + 1;
let backOffDelay = mathFloor(Math.random() * backOffSlot * SlotDelayInSeconds) + 1;
backOffDelay = linearFactor * backOffDelay;
delayInSeconds = Math.max(Math.min(backOffDelay, 3600), SlotDelayInSeconds);
delayInSeconds = mathMax(mathMin(backOffDelay, 3600), SlotDelayInSeconds);
}

// TODO: Log the backoff time like the C# version does.
Expand All @@ -1205,8 +1205,8 @@ export class Sender extends BaseTelemetryPlugin implements IChannelControls {
*/
function _setupTimer() {
if (!_timeoutHandle && !_paused) {
const retryInterval = _retryAt ? Math.max(0, _retryAt - dateNow()) : 0;
const timerValue = Math.max(_maxBatchInterval, retryInterval);
const retryInterval = _retryAt ? mathMax(0, _retryAt - dateNow()) : 0;
const timerValue = mathMax(_maxBatchInterval, retryInterval);

_timeoutHandle = scheduleTimeout(() => {
_timeoutHandle = null;
Expand Down
2 changes: 1 addition & 1 deletion channels/offline-channel-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/applicationinsights-core-js": "3.3.5",
"@microsoft/applicationinsights-common": "3.3.5",
"@nevware21/ts-utils": ">= 0.11.6 < 2.x",
"@nevware21/ts-utils": ">= 0.11.8 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x"
},
"peerDependencies": {
Expand Down
12 changes: 7 additions & 5 deletions channels/offline-channel-js/src/OfflineChannel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import {
eLoggingSeverity, mergeEvtNamespace, onConfigChange, runTargetUnload
} from "@microsoft/applicationinsights-core-js";
import { IPromise, ITaskScheduler, createAsyncPromise, createTaskScheduler } from "@nevware21/ts-async";
import { ITimerHandler, arrSlice, isFunction, isString, objDeepFreeze, objForEachKey, scheduleTimeout } from "@nevware21/ts-utils";
import {
ITimerHandler, arrSlice, isFunction, isString, mathFloor, mathMax, mathMin, objDeepFreeze, objForEachKey, scheduleTimeout
} from "@nevware21/ts-utils";
import {
EVT_DISCARD_STR, EVT_SENT_STR, EVT_STORE_STR, batchDropNotification, callNotification, isGreaterThanZero, isValidPersistenceLevel
} from "./Helpers/Utils";
Expand Down Expand Up @@ -442,8 +444,8 @@ export class OfflineChannel extends BaseTelemetryPlugin implements IChannelContr
let isOnline = _offlineListener && _offlineListener.isOnline();

if(!_sendNextBatchTimer) {
let retryInterval = _retryAt ? Math.max(0, _retryAt - dateNow()) : 0;
let timerValue = Math.max(_maxBatchInterval, retryInterval);
let retryInterval = _retryAt ? mathMax(0, _retryAt - dateNow()) : 0;
let timerValue = mathMax(_maxBatchInterval, retryInterval);
_sendNextBatchTimer = scheduleTimeout(() => {
if (isOnline) {
// is no isCompletelyIdle function is available, assume we can send
Expand Down Expand Up @@ -522,9 +524,9 @@ export class OfflineChannel extends BaseTelemetryPlugin implements IChannelContr
} else {
const backOffSlot = (Math.pow(2, _consecutiveErrors) - 1) / 2;
// tslint:disable-next-line:insecure-random
let backOffDelay = Math.floor(Math.random() * backOffSlot * SlotDelayInSeconds) + 1;
let backOffDelay = mathFloor(Math.random() * backOffSlot * SlotDelayInSeconds) + 1;
backOffDelay = linearFactor * backOffDelay;
delayInSeconds = Math.max(Math.min(backOffDelay, 3600), SlotDelayInSeconds);
delayInSeconds = mathMax(mathMin(backOffDelay, 3600), SlotDelayInSeconds);
}

// TODO: Log the backoff time like the C# version does.
Expand Down
2 changes: 1 addition & 1 deletion channels/tee-channel-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"@microsoft/applicationinsights-shims": "3.0.1",
"@microsoft/applicationinsights-core-js": "3.3.5",
"@microsoft/applicationinsights-common": "3.3.5",
"@nevware21/ts-utils": ">= 0.11.6 < 2.x",
"@nevware21/ts-utils": ">= 0.11.8 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x"
},
"license": "MIT"
Expand Down
2 changes: 1 addition & 1 deletion common/Tests/Framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
},
"dependencies": {
"@microsoft/dynamicproto-js": "^2.0.3",
"@nevware21/ts-utils": ">= 0.11.6 < 2.x",
"@nevware21/ts-utils": ">= 0.11.8 < 2.x",
"@nevware21/ts-async": ">= 0.5.4 < 2.x"
}
}
Loading
Loading