mirror of
https://github.com/zhigang1992/react-native-code-push.git
synced 2026-06-11 08:04:23 +08:00
Merge pull request #178 from Microsoft/logs
Add logging and lift dev restriction on telemtry
This commit is contained in:
18
CodePush.js
18
CodePush.js
@@ -58,6 +58,10 @@ async function checkForUpdate(deploymentKey = null) {
|
||||
* client app is resilient to a potential issue with the update check.
|
||||
*/
|
||||
if (!update || update.updateAppVersion || (update.packageHash === localPackage.packageHash)) {
|
||||
if (update && update.updateAppVersion) {
|
||||
log("An update is available but it is targeting a newer binary version than you are currently running.");
|
||||
}
|
||||
|
||||
return null;
|
||||
} else {
|
||||
const remotePackage = { ...update, ...PackageMixins.remote(sdk.reportStatusDownload) };
|
||||
@@ -136,12 +140,7 @@ function log(message) {
|
||||
}
|
||||
|
||||
async function notifyApplicationReady() {
|
||||
await NativeCodePush.notifyApplicationReady();
|
||||
if (__DEV__) {
|
||||
// Don't report metrics if in DEV mode.
|
||||
return;
|
||||
}
|
||||
|
||||
await NativeCodePush.notifyApplicationReady();
|
||||
const statusReport = await NativeCodePush.getNewStatusReport();
|
||||
if (statusReport) {
|
||||
const config = await getConfiguration();
|
||||
@@ -254,7 +253,12 @@ async function sync(options = {}, syncStatusChangeCallback, downloadProgressCall
|
||||
return CodePush.SyncStatus.UPDATE_INSTALLED;
|
||||
};
|
||||
|
||||
if (!remotePackage || (remotePackage.failedInstall && syncOptions.ignoreFailedUpdates)) {
|
||||
const updateShouldBeIgnored = remotePackage && (remotePackage.failedInstall && syncOptions.ignoreFailedUpdates);
|
||||
if (!remotePackage || updateShouldBeIgnored) {
|
||||
if (updateShouldBeIgnored) {
|
||||
log("An update is available, but it is being ignored due to having been previously rolled back.");
|
||||
}
|
||||
|
||||
syncStatusChangeCallback(CodePush.SyncStatus.UP_TO_DATE);
|
||||
return CodePush.SyncStatus.UP_TO_DATE;
|
||||
} else if (syncOptions.updateDialog) {
|
||||
|
||||
@@ -511,13 +511,7 @@ RCT_EXPORT_METHOD(notifyApplicationReady:(RCTPromiseResolveBlock)resolve
|
||||
*/
|
||||
RCT_EXPORT_METHOD(getNewStatusReport:(RCTPromiseResolveBlock)resolve
|
||||
rejecter:(RCTPromiseRejectBlock)reject)
|
||||
{
|
||||
if ([_bridge.bundleURL.scheme hasPrefix:@"http"]) {
|
||||
// Do not report metrics if running bundle from packager.
|
||||
resolve(nil);
|
||||
return;
|
||||
}
|
||||
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
if (needToReportRollback) {
|
||||
needToReportRollback = NO;
|
||||
|
||||
@@ -25,8 +25,7 @@ module.exports = (NativeCodePush) => {
|
||||
// so that the client knows what the current package version is.
|
||||
try {
|
||||
const downloadedPackage = await NativeCodePush.downloadUpdate(this);
|
||||
// Don't report metrics if in DEV mode.
|
||||
!__DEV__ && reportStatusDownload && reportStatusDownload(this);
|
||||
reportStatusDownload && reportStatusDownload(this);
|
||||
return { ...downloadedPackage, ...local };
|
||||
} finally {
|
||||
downloadProgressSubscription && downloadProgressSubscription.remove();
|
||||
|
||||
Reference in New Issue
Block a user