Windows: Implemented TelemetryManager (#812)

* Examples updated to RNW 0.43.0

* Initial implementation

* interim commit

* getUpdateReport - completed

* getBinaryUpdateReport - completed

* getRetryStatusReport - completed

* getRollbackReport - completed

* recordStatusReported - completed
saveStatusReportForRetry - completed

* Commented unused variables

* Fixed telemetry report

* Optimization: run telemetry in async mode

* neat fixes

* react-native-windows updated to 0.43.0-rc.0

* neat fix

* added async to some ReactMEthod calls
This commit is contained in:
Alexander Bodalevsky
2017-06-16 13:58:52 +03:00
committed by Sergey Akhalkov
parent 6a1d1ffcac
commit d132593458
10 changed files with 486 additions and 13 deletions

View File

@@ -21,7 +21,8 @@ namespace CodePush.ReactNative
private MinimumBackgroundListener _minimumBackgroundListener;
private ReactContext _reactContext;
public CodePushNativeModule(ReactContext reactContext, CodePushReactPackage codePush) : base(reactContext)
public CodePushNativeModule(ReactContext reactContext, CodePushReactPackage codePush)
: base(reactContext)
{
_reactContext = reactContext;
_codePush = codePush;
@@ -174,10 +175,60 @@ namespace CodePush.ReactNative
[ReactMethod]
public void getNewStatusReport(IPromise promise)
public async void getNewStatusReport(IPromise promise)
{
// TODO implement this
promise.Resolve("");
await Task.Run(() =>
{
if (_codePush.NeedToReportRollback)
{
_codePush.NeedToReportRollback = false;
var failedUpdates = SettingsManager.GetFailedUpdates();
if (failedUpdates != null && failedUpdates.Count > 0)
{
var lastFailedPackage = (JObject)failedUpdates[failedUpdates.Count - 1];
var failedStatusReport = TelemetryManager.GetRollbackReport(lastFailedPackage);
if (failedStatusReport != null)
{
promise.Resolve(failedStatusReport);
return;
}
}
}
else if (_codePush.DidUpdate)
{
var currentPackage = _codePush.UpdateManager.GetCurrentPackageAsync().Result;
if (currentPackage != null)
{
var newPackageStatusReport = TelemetryManager.GetUpdateReport(currentPackage);
if (newPackageStatusReport != null)
{
promise.Resolve(newPackageStatusReport);
return;
}
}
}
else if (_codePush.IsRunningBinaryVersion)
{
var newAppVersionStatusReport = TelemetryManager.GetBinaryUpdateReport(_codePush.AppVersion);
if (newAppVersionStatusReport != null)
{
promise.Resolve(newAppVersionStatusReport);
return;
}
}
else
{
var retryStatusReport = TelemetryManager.GetRetryStatusReport();
if (retryStatusReport != null)
{
promise.Resolve(retryStatusReport);
return;
}
}
promise.Resolve("");
}).ConfigureAwait(false);
}
[ReactMethod]
@@ -245,6 +296,18 @@ namespace CodePush.ReactNative
}
}
[ReactMethod]
public async void recordStatusReported(JObject statusReport)
{
await Task.Run(() => TelemetryManager.RecordStatusReported(statusReport)).ConfigureAwait(false);
}
[ReactMethod]
public async void saveStatusReportForRetry(JObject statusReport)
{
await Task.Run(() => TelemetryManager.SaveStatusReportForRetry(statusReport)).ConfigureAwait(false);
}
internal async Task LoadBundleAsync()
{
// #1) Get the private ReactInstanceManager, which is what includes