Skip to content

Commit

Permalink
[Main][Task]27079894: Add a max retry count for Sender (#2324)
Browse files Browse the repository at this point in the history
* update

* update

* update

* update

* udpate

* update
  • Loading branch information
Karlie-777 committed Apr 12, 2024
1 parent db6f36c commit c7bb1c4
Show file tree
Hide file tree
Showing 12 changed files with 716 additions and 257 deletions.
8 changes: 4 additions & 4 deletions AISKU/Tests/Unit/src/AISKUSize.Tests.ts
Expand Up @@ -5,10 +5,10 @@ import { Snippet } from "../../../src/Snippet";
import { utlRemoveSessionStorage } from "@microsoft/applicationinsights-common";

export class AISKUSizeCheck extends AITestClass {
private readonly MAX_RAW_SIZE = 140;
private readonly MAX_BUNDLE_SIZE = 140;
private readonly MAX_RAW_DEFLATE_SIZE = 56;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 56;
private readonly MAX_RAW_SIZE = 141;
private readonly MAX_BUNDLE_SIZE = 141;
private readonly MAX_RAW_DEFLATE_SIZE = 57;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 57;
private readonly rawFilePath = "../dist/es5/applicationinsights-web.min.js";
// Automatically updated by version scripts
private readonly currentVer = "3.1.2";
Expand Down
12 changes: 10 additions & 2 deletions AISKU/Tests/Unit/src/SnippetInitialization.Tests.ts
Expand Up @@ -313,7 +313,11 @@ export class SnippetInitializationTests extends AITestClass {
if(this.successSpy.called) {
let currentCount: number = 0;
this.successSpy.args.forEach(call => {
call[0].forEach(message => {
call[0].forEach(item => {
let message = item;
if (typeof item !== "string") {
message = item.item;
}
// Ignore the internal SendBrowserInfoOnUserInit message (Only occurs when running tests in a browser)
if (!message || message.indexOf("AI (Internal): 72 ") == -1) {
currentCount ++;
Expand Down Expand Up @@ -1086,7 +1090,11 @@ export class SnippetInitializationTests extends AITestClass {
if(this.successSpy.called) {
let currentCount: number = 0;
this.successSpy.args.forEach(call => {
call[0].forEach(message => {
call[0].forEach(item => {
let message = item.item;
if (typeof item === "string") {
message = item;
}
// Ignore the internal SendBrowserInfoOnUserInit message (Only occurs when running tests in a browser)
if (!message || message.indexOf("AI (Internal): 72 ") == -1) {
currentCount ++;
Expand Down
4 changes: 2 additions & 2 deletions AISKU/Tests/Unit/src/sender.e2e.tests.ts
Expand Up @@ -7,8 +7,8 @@ import { Assert, AITestClass, PollingAssert} from "@microsoft/ai-test-framework"

export class SenderE2ETests extends AITestClass {
private readonly _instrumentationKey = 'b7170927-2d1c-44f1-acec-59f4e1751c11';
private readonly _bufferName = 'AI_buffer';
private readonly _sentBufferName = 'AI_sentBuffer';
private readonly _bufferName = 'AI_buffer_1';
private readonly _sentBufferName = 'AI_sentBuffer_1';

private _ai: IApplicationInsights;
private _sender: Sender;
Expand Down
6 changes: 5 additions & 1 deletion AISKU/Tests/Unit/src/validate.e2e.tests.ts
Expand Up @@ -138,7 +138,11 @@ export class ValidateE2ETests extends AITestClass {
.concat(() => {
let acceptedItems = 0;
this.successSpy.args.forEach(call => {
call[0].forEach(message => {
call[0].forEach(item => {
let message = item;
if (typeof item !== "string") {
message = item.item;
}
// Ignore the internal SendBrowserInfoOnUserInit message (Only occurs when running tests in a browser)
if (message.indexOf("AI (Internal): 72 ") == -1) {
acceptedItems ++;
Expand Down
4 changes: 2 additions & 2 deletions AISKULight/Tests/Unit/src/AISKULightSize.Tests.ts
Expand Up @@ -2,8 +2,8 @@ import { AITestClass, Assert } from "@microsoft/ai-test-framework";
import * as pako from "pako";

export class AISKULightSizeCheck extends AITestClass {
private readonly MAX_RAW_SIZE = 87;
private readonly MAX_BUNDLE_SIZE = 87;
private readonly MAX_RAW_SIZE = 88;
private readonly MAX_BUNDLE_SIZE = 88;
private readonly MAX_RAW_DEFLATE_SIZE = 36;
private readonly MAX_BUNDLE_DEFLATE_SIZE = 36;
private readonly rawFilePath = "../dist/es5/applicationinsights-web-basic.min.js";
Expand Down
364 changes: 301 additions & 63 deletions channels/applicationinsights-channel-js/Tests/Unit/src/Sender.tests.ts

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions channels/applicationinsights-channel-js/src/Interfaces.ts
@@ -1,6 +1,22 @@
import { IStorageBuffer } from "@microsoft/applicationinsights-common";
import { IXHROverride } from "@microsoft/applicationinsights-core-js";

/**
* Internal interface for sendBuffer, do not export it
* @internal
* @since 3.1.3
*/
export interface IInternalStorageItem {
/**
* serialized telemetry to be stored.
*/
item: string;
/**
* total retry count
*/
cnt?: number;
}

export interface ISenderConfig {
/**
* The url to which payloads will be sent
Expand Down Expand Up @@ -141,6 +157,15 @@ export interface ISenderConfig {
* @since 3.1.1
*/
retryCodes?: number[];

/**
* (Optional) The specific max retry count for each telemetry item.
* Default: 10
* if it is set to 0, means no retry allowed
* if it is set to undefined, means no limit for retry times
* @since 3.2.0
*/
maxRetryCnt?: number;
}

export interface IBackendResponse {
Expand Down

0 comments on commit c7bb1c4

Please sign in to comment.