Skip to content

Commit

Permalink
Merge pull request #178 from Microsoft/logs
Browse files Browse the repository at this point in the history
Add logging and lift dev restriction on telemtry
  • Loading branch information
lostintangent committed Feb 3, 2016
2 parents 326d8d3 + 4610e06 commit 9d4341a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 16 deletions.
18 changes: 11 additions & 7 deletions CodePush.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) };
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down
8 changes: 1 addition & 7 deletions CodePush.m
Original file line number Diff line number Diff line change
Expand Up @@ -511,13 +511,7 @@ - (void)savePendingUpdate:(NSString *)packageHash
*/
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;
Expand Down
3 changes: 1 addition & 2 deletions package-mixins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9d4341a

Please sign in to comment.