Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable api calls #851

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Disable api calls #851

wants to merge 9 commits into from

Conversation

DordeDimitrijev
Copy link
Contributor

@DordeDimitrijev DordeDimitrijev commented Nov 14, 2024

Description

Implemented feature for stopping api calls from being sent after unsuccessful response. This behavior is aligned with other appcenter SDKs. Disabling of api calls occurs only per session after first failed request.

Related PRs or issues

AB#107980

src/test/acquisition-sdk.ts Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/test/acquisition-sdk.ts Show resolved Hide resolved
src/script/acquisition-sdk.ts Show resolved Hide resolved
@DordeDimitrijev DordeDimitrijev marked this pull request as ready for review November 19, 2024 08:39
@DordeDimitrijev DordeDimitrijev requested a review from a team as a code owner November 19, 2024 08:39
src/script/acquisition-sdk.ts Show resolved Hide resolved
src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
src/script/acquisition-sdk.ts Show resolved Hide resolved
@@ -58,14 +58,15 @@ export class AcquisitionStatus {
}

export class AcquisitionManager {
private readonly BASER_URL_PART = "appcenter.ms"
Copy link
Contributor

Choose a reason for hiding this comment

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

;, and check other places.

src/script/acquisition-sdk.ts Outdated Show resolved Hide resolved
assert.strictEqual(acquisitionSdk.AcquisitionManager.apiCallsDisabled, false);
}))

acquisition.reportStatusDownload(templateCurrentPackage, ((error: Error, parameter: void): void => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about queryUpdateWithCurrentPackage?

configuration = { ...configuration, serverUrl: "https://codepush.appcenter.ms" }
var acquisition = new acquisitionSdk.AcquisitionManager(new mockApi.CustomResponseHttpRequester(invalidJsonResponse), configuration);

acquisition.queryUpdateWithCurrentPackage(templateCurrentPackage, (error: Error, returnPackage: acquisitionSdk.RemotePackage | acquisitionSdk.NativeUpdateNotification) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

what about reportStatusDeploy and reportStatusDownload?

private _appVersion: string;
private _clientUniqueId: string;
private _deploymentKey: string;
private _httpRequester: Http.Requester;
private _ignoreAppVersion: boolean;
private _serverUrl: string;
private _publicPrefixUrl: string = "v0.1/public/codepush/";

private static _apiCallsDisabled: boolean = false;
constructor(httpRequester: Http.Requester, configuration: Configuration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

empty line

src/script/acquisition-sdk.ts Show resolved Hide resolved
});

acquisition.queryUpdateWithCurrentPackage(templateCurrentPackage, (error: Error, returnPackage: acquisitionSdk.RemotePackage | acquisitionSdk.NativeUpdateNotification) => {
assert.notStrictEqual(returnPackage, null)
Copy link
Contributor

Choose a reason for hiding this comment

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

;

src/test/acquisition-sdk.ts Show resolved Hide resolved
assert.strictEqual(acquisitionSdk.AcquisitionManager.apiCallsDisabled, true);
});

acquisition.reportStatusDeploy(templateCurrentPackage, acquisitionSdk.AcquisitionStatus.DeploymentSucceeded, "1.5.0", mockApi.validDeploymentKey, ((error: Error, parameter: void): void => {
Copy link
Contributor

Choose a reason for hiding this comment

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

before calling this method apiCallsDisabled is already true as a result of previous method invocation. We need to refresh the context before testing this and the next method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants