@appzung/react-native-code-push 11.0.0-rc1 → 11.0.0-rc10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CodePush.podspec +3 -5
- package/README.md +26 -24
- package/android/app/proguard-rules.pro +5 -0
- package/android/app/src/main/java/com/appzung/codepush/react/CodePush.java +4 -0
- package/android/app/src/main/java/com/appzung/codepush/react/CodePushConstants.java +2 -0
- package/android/app/src/main/java/com/appzung/codepush/react/CodePushNativeModule.java +86 -4
- package/android/app/src/main/java/com/appzung/codepush/react/ExpoUtils.java +22 -0
- package/ios/CodePush/CodePush.h +11 -6
- package/ios/CodePush/{CodePush.m → CodePush.mm} +132 -141
- package/ios/CodePush/CodePushConfig.m +54 -0
- package/ios/CodePush.xcodeproj/project.pbxproj +6 -6
- package/lib/commonjs/CodePush.js +11 -2
- package/lib/commonjs/CodePush.js.map +1 -1
- package/lib/commonjs/allowRestart.js +6 -2
- package/lib/commonjs/allowRestart.js.map +1 -1
- package/lib/commonjs/checkForUpdates.js +25 -26
- package/lib/commonjs/checkForUpdates.js.map +1 -1
- package/lib/commonjs/clearUpdates.js +6 -3
- package/lib/commonjs/clearUpdates.js.map +1 -1
- package/lib/commonjs/dataTransmission.js +28 -0
- package/lib/commonjs/dataTransmission.js.map +1 -0
- package/lib/commonjs/disallowRestart.js +6 -2
- package/lib/commonjs/disallowRestart.js.map +1 -1
- package/lib/commonjs/enums/CheckFrequency.enum.js +2 -2
- package/lib/commonjs/enums/InstallMode.enum.js +7 -3
- package/lib/commonjs/enums/InstallMode.enum.js.map +1 -1
- package/lib/commonjs/enums/LogLevel.enum.js +17 -0
- package/lib/commonjs/enums/LogLevel.enum.js.map +1 -0
- package/lib/commonjs/enums/SyncStatus.enum.js +7 -7
- package/lib/commonjs/enums/UpdateState.enum.js +7 -6
- package/lib/commonjs/enums/UpdateState.enum.js.map +1 -1
- package/lib/commonjs/getClientUniqueId.js +16 -0
- package/lib/commonjs/getClientUniqueId.js.map +1 -0
- package/lib/commonjs/index.js +90 -9
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/internals/CodePushApiSdk.errors.js +26 -0
- package/lib/commonjs/internals/CodePushApiSdk.errors.js.map +1 -0
- package/lib/commonjs/internals/CodePushApiSdk.js +122 -0
- package/lib/commonjs/internals/CodePushApiSdk.js.map +1 -0
- package/lib/commonjs/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +3 -2
- package/lib/commonjs/internals/CodePushApiSdk.types.js.map +1 -0
- package/lib/commonjs/internals/CodePushEventEmitter.js +10 -0
- package/lib/commonjs/internals/CodePushEventEmitter.js.map +1 -0
- package/lib/commonjs/internals/RemotePackageImplementation.js +9 -8
- package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -1
- package/lib/commonjs/internals/getConfiguration.js +4 -0
- package/lib/commonjs/internals/getConfiguration.js.map +1 -1
- package/lib/commonjs/internals/logger.js +51 -0
- package/lib/commonjs/internals/logger.js.map +1 -0
- package/lib/commonjs/internals/shouldUpdateBeIgnored.js +6 -5
- package/lib/commonjs/internals/shouldUpdateBeIgnored.js.map +1 -1
- package/lib/commonjs/internals/utils/fetchRetry.js +59 -0
- package/lib/commonjs/internals/utils/fetchRetry.js.map +1 -0
- package/lib/commonjs/internals/utils/log.js +10 -3
- package/lib/commonjs/internals/utils/log.js.map +1 -1
- package/lib/commonjs/internals/utils/queryStringify.js +25 -0
- package/lib/commonjs/internals/utils/queryStringify.js.map +1 -0
- package/lib/commonjs/internals/utils/requestFetchAdapter.js +38 -0
- package/lib/commonjs/internals/utils/requestFetchAdapter.js.map +1 -0
- package/lib/commonjs/internals/version.js +1 -1
- package/lib/commonjs/internals/version.js.map +1 -1
- package/lib/commonjs/logLevel.js +15 -0
- package/lib/commonjs/logLevel.js.map +1 -0
- package/lib/commonjs/logger.js +19 -0
- package/lib/commonjs/logger.js.map +1 -0
- package/lib/commonjs/notifyAppReady.js +26 -15
- package/lib/commonjs/notifyAppReady.js.map +1 -1
- package/lib/commonjs/resetClientUniqueId.js +18 -0
- package/lib/commonjs/resetClientUniqueId.js.map +1 -0
- package/lib/commonjs/restartApp.js +4 -2
- package/lib/commonjs/restartApp.js.map +1 -1
- package/lib/commonjs/sync.js +35 -28
- package/lib/commonjs/sync.js.map +1 -1
- package/lib/commonjs/telemetry.js +28 -0
- package/lib/commonjs/telemetry.js.map +1 -0
- package/lib/module/CodePush.js +11 -2
- package/lib/module/CodePush.js.map +1 -1
- package/lib/module/allowRestart.js +5 -1
- package/lib/module/allowRestart.js.map +1 -1
- package/lib/module/checkForUpdates.js +25 -26
- package/lib/module/checkForUpdates.js.map +1 -1
- package/lib/module/clearUpdates.js +5 -2
- package/lib/module/clearUpdates.js.map +1 -1
- package/lib/module/dataTransmission.js +24 -0
- package/lib/module/dataTransmission.js.map +1 -0
- package/lib/module/disallowRestart.js +5 -1
- package/lib/module/disallowRestart.js.map +1 -1
- package/lib/module/enums/CheckFrequency.enum.js +2 -2
- package/lib/module/enums/InstallMode.enum.js +7 -3
- package/lib/module/enums/InstallMode.enum.js.map +1 -1
- package/lib/module/enums/LogLevel.enum.js +13 -0
- package/lib/module/enums/LogLevel.enum.js.map +1 -0
- package/lib/module/enums/SyncStatus.enum.js +7 -7
- package/lib/module/enums/UpdateState.enum.js +7 -6
- package/lib/module/enums/UpdateState.enum.js.map +1 -1
- package/lib/module/getClientUniqueId.js +12 -0
- package/lib/module/getClientUniqueId.js.map +1 -0
- package/lib/module/index.js +8 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/internals/CodePushApiSdk.errors.js +20 -0
- package/lib/module/internals/CodePushApiSdk.errors.js.map +1 -0
- package/lib/module/internals/CodePushApiSdk.js +118 -0
- package/lib/module/internals/CodePushApiSdk.js.map +1 -0
- package/lib/module/{enums/DeploymentStatus.enum.js → internals/CodePushApiSdk.types.js} +2 -1
- package/lib/module/internals/CodePushApiSdk.types.js.map +1 -0
- package/lib/module/internals/CodePushEventEmitter.js +6 -0
- package/lib/module/internals/CodePushEventEmitter.js.map +1 -0
- package/lib/module/internals/RemotePackageImplementation.js +9 -8
- package/lib/module/internals/RemotePackageImplementation.js.map +1 -1
- package/lib/module/internals/getConfiguration.js +3 -0
- package/lib/module/internals/getConfiguration.js.map +1 -1
- package/lib/module/internals/logger.js +44 -0
- package/lib/module/internals/logger.js.map +1 -0
- package/lib/module/internals/shouldUpdateBeIgnored.js +6 -5
- package/lib/module/internals/shouldUpdateBeIgnored.js.map +1 -1
- package/lib/module/internals/utils/fetchRetry.js +55 -0
- package/lib/module/internals/utils/fetchRetry.js.map +1 -0
- package/lib/module/internals/utils/log.js +11 -3
- package/lib/module/internals/utils/log.js.map +1 -1
- package/lib/module/internals/utils/queryStringify.js +21 -0
- package/lib/module/internals/utils/queryStringify.js.map +1 -0
- package/lib/module/internals/utils/requestFetchAdapter.js +34 -0
- package/lib/module/internals/utils/requestFetchAdapter.js.map +1 -0
- package/lib/module/internals/version.js +1 -1
- package/lib/module/internals/version.js.map +1 -1
- package/lib/module/logLevel.js +9 -0
- package/lib/module/logLevel.js.map +1 -0
- package/lib/module/logger.js +4 -0
- package/lib/module/logger.js.map +1 -0
- package/lib/module/notifyAppReady.js +26 -15
- package/lib/module/notifyAppReady.js.map +1 -1
- package/lib/module/resetClientUniqueId.js +14 -0
- package/lib/module/resetClientUniqueId.js.map +1 -0
- package/lib/module/restartApp.js +4 -2
- package/lib/module/restartApp.js.map +1 -1
- package/lib/module/sync.js +35 -28
- package/lib/module/sync.js.map +1 -1
- package/lib/module/telemetry.js +24 -0
- package/lib/module/telemetry.js.map +1 -0
- package/lib/typescript/commonjs/src/CodePush.d.ts +10 -5
- package/lib/typescript/commonjs/src/CodePush.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/allowRestart.d.ts +3 -1
- package/lib/typescript/commonjs/src/allowRestart.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/clearUpdates.d.ts +3 -2
- package/lib/typescript/commonjs/src/clearUpdates.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/dataTransmission.d.ts +13 -0
- package/lib/typescript/commonjs/src/dataTransmission.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/disallowRestart.d.ts +3 -1
- package/lib/typescript/commonjs/src/disallowRestart.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/enums/CheckFrequency.enum.d.ts +2 -2
- package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts +7 -3
- package/lib/typescript/commonjs/src/enums/InstallMode.enum.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts +10 -0
- package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/enums/SyncStatus.enum.d.ts +7 -7
- package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts +7 -6
- package/lib/typescript/commonjs/src/enums/UpdateState.enum.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/getClientUniqueId.d.ts +5 -0
- package/lib/typescript/commonjs/src/getClientUniqueId.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +8 -1
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts +15 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts +9 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts +103 -0
- package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/CodePushEventEmitter.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/CodePushEventEmitter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts +5 -0
- package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts +2 -2
- package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts +1 -0
- package/lib/typescript/commonjs/src/internals/getConfiguration.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/logger.d.ts +33 -0
- package/lib/typescript/commonjs/src/internals/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/types.d.ts +2 -2
- package/lib/typescript/commonjs/src/internals/types.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts +9 -0
- package/lib/typescript/commonjs/src/internals/utils/fetchRetry.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts +2 -1
- package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts +4 -0
- package/lib/typescript/commonjs/src/internals/utils/queryStringify.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts +3 -0
- package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/internals/version.d.ts +1 -1
- package/lib/typescript/commonjs/src/internals/version.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/logLevel.d.ts +4 -0
- package/lib/typescript/commonjs/src/logLevel.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/logger.d.ts +3 -0
- package/lib/typescript/commonjs/src/logger.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts +4 -0
- package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/resetClientUniqueId.d.ts +5 -0
- package/lib/typescript/commonjs/src/resetClientUniqueId.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/restartApp.d.ts +2 -0
- package/lib/typescript/commonjs/src/restartApp.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/sync.d.ts +5 -1
- package/lib/typescript/commonjs/src/sync.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/telemetry.d.ts +13 -0
- package/lib/typescript/commonjs/src/telemetry.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/types.d.ts +72 -29
- package/lib/typescript/commonjs/src/types.d.ts.map +1 -1
- package/lib/typescript/module/src/CodePush.d.ts +10 -5
- package/lib/typescript/module/src/CodePush.d.ts.map +1 -1
- package/lib/typescript/module/src/allowRestart.d.ts +3 -1
- package/lib/typescript/module/src/allowRestart.d.ts.map +1 -1
- package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -1
- package/lib/typescript/module/src/clearUpdates.d.ts +3 -2
- package/lib/typescript/module/src/clearUpdates.d.ts.map +1 -1
- package/lib/typescript/module/src/dataTransmission.d.ts +13 -0
- package/lib/typescript/module/src/dataTransmission.d.ts.map +1 -0
- package/lib/typescript/module/src/disallowRestart.d.ts +3 -1
- package/lib/typescript/module/src/disallowRestart.d.ts.map +1 -1
- package/lib/typescript/module/src/enums/CheckFrequency.enum.d.ts +2 -2
- package/lib/typescript/module/src/enums/InstallMode.enum.d.ts +7 -3
- package/lib/typescript/module/src/enums/InstallMode.enum.d.ts.map +1 -1
- package/lib/typescript/module/src/enums/LogLevel.enum.d.ts +10 -0
- package/lib/typescript/module/src/enums/LogLevel.enum.d.ts.map +1 -0
- package/lib/typescript/module/src/enums/SyncStatus.enum.d.ts +7 -7
- package/lib/typescript/module/src/enums/UpdateState.enum.d.ts +7 -6
- package/lib/typescript/module/src/enums/UpdateState.enum.d.ts.map +1 -1
- package/lib/typescript/module/src/getClientUniqueId.d.ts +5 -0
- package/lib/typescript/module/src/getClientUniqueId.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +8 -1
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts +15 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts +9 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.errors.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts +103 -0
- package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/CodePushEventEmitter.d.ts +3 -0
- package/lib/typescript/module/src/internals/CodePushEventEmitter.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts +5 -0
- package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts +2 -2
- package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/getConfiguration.d.ts +1 -0
- package/lib/typescript/module/src/internals/getConfiguration.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/logger.d.ts +33 -0
- package/lib/typescript/module/src/internals/logger.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/types.d.ts +2 -2
- package/lib/typescript/module/src/internals/types.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts +9 -0
- package/lib/typescript/module/src/internals/utils/fetchRetry.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/log.d.ts +2 -1
- package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -1
- package/lib/typescript/module/src/internals/utils/queryStringify.d.ts +4 -0
- package/lib/typescript/module/src/internals/utils/queryStringify.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts +3 -0
- package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts.map +1 -0
- package/lib/typescript/module/src/internals/version.d.ts +1 -1
- package/lib/typescript/module/src/internals/version.d.ts.map +1 -1
- package/lib/typescript/module/src/logLevel.d.ts +4 -0
- package/lib/typescript/module/src/logLevel.d.ts.map +1 -0
- package/lib/typescript/module/src/logger.d.ts +3 -0
- package/lib/typescript/module/src/logger.d.ts.map +1 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts +4 -0
- package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -1
- package/lib/typescript/module/src/resetClientUniqueId.d.ts +5 -0
- package/lib/typescript/module/src/resetClientUniqueId.d.ts.map +1 -0
- package/lib/typescript/module/src/restartApp.d.ts +2 -0
- package/lib/typescript/module/src/restartApp.d.ts.map +1 -1
- package/lib/typescript/module/src/sync.d.ts +5 -1
- package/lib/typescript/module/src/sync.d.ts.map +1 -1
- package/lib/typescript/module/src/telemetry.d.ts +13 -0
- package/lib/typescript/module/src/telemetry.d.ts.map +1 -0
- package/lib/typescript/module/src/types.d.ts +72 -29
- package/lib/typescript/module/src/types.d.ts.map +1 -1
- package/package.json +24 -13
- package/scripts/generateBundledResourcesHash.js +73 -68
- package/scripts/getFilesInFolder.js +12 -12
- package/scripts/recordFilesBeforeBundleCommand.js +19 -20
- package/src/CodePush.tsx +20 -5
- package/src/allowRestart.ts +5 -1
- package/src/checkForUpdates.ts +26 -24
- package/src/clearUpdates.ts +5 -2
- package/src/dataTransmission.ts +21 -0
- package/src/disallowRestart.ts +5 -1
- package/src/enums/CheckFrequency.enum.ts +2 -2
- package/src/enums/InstallMode.enum.ts +7 -3
- package/src/enums/LogLevel.enum.ts +9 -0
- package/src/enums/SyncStatus.enum.ts +7 -7
- package/src/enums/UpdateState.enum.ts +7 -6
- package/src/getClientUniqueId.ts +9 -0
- package/src/index.ts +8 -1
- package/src/internals/CodePushApiSdk.errors.ts +22 -0
- package/src/internals/CodePushApiSdk.ts +160 -0
- package/src/internals/CodePushApiSdk.types.ts +117 -0
- package/src/internals/CodePushEventEmitter.ts +4 -0
- package/src/internals/RNAppZungCodePushModuleSpec.ts +7 -0
- package/src/internals/RemotePackageImplementation.ts +11 -10
- package/src/internals/getConfiguration.ts +4 -0
- package/src/internals/logger.ts +46 -0
- package/src/internals/shouldUpdateBeIgnored.ts +6 -5
- package/src/internals/types.ts +2 -2
- package/src/internals/utils/fetchRetry.ts +72 -0
- package/src/internals/utils/log.ts +13 -3
- package/src/internals/utils/queryStringify.ts +22 -0
- package/src/internals/utils/requestFetchAdapter.ts +36 -0
- package/src/internals/version.ts +1 -1
- package/src/logLevel.ts +9 -0
- package/src/logger.ts +2 -0
- package/src/notifyAppReady.ts +29 -18
- package/src/resetClientUniqueId.ts +11 -0
- package/src/restartApp.ts +4 -2
- package/src/sync.ts +41 -27
- package/src/telemetry.ts +21 -0
- package/src/types.ts +72 -29
- package/android/app/.gradle/config.properties +0 -2
- package/android/app/local.properties +0 -8
- package/docs/advanced-usage.md +0 -56
- package/docs/api-android.md +0 -22
- package/docs/api-ios.md +0 -19
- package/docs/api-js.md +0 -557
- package/docs/code-signing.md +0 -62
- package/docs/migrating-to-v10.md +0 -31
- package/docs/setup-android.md +0 -81
- package/docs/setup-ios.md +0 -108
- package/docs/setup-windows.md +0 -55
- package/lib/commonjs/enums/DeploymentStatus.enum.js.map +0 -1
- package/lib/commonjs/internals/AcquisitionSdk.js +0 -9
- package/lib/commonjs/internals/AcquisitionSdk.js.map +0 -1
- package/lib/commonjs/internals/getPromisifiedSdk.js +0 -49
- package/lib/commonjs/internals/getPromisifiedSdk.js.map +0 -1
- package/lib/commonjs/internals/utils/request-fetch-adapter.js +0 -50
- package/lib/commonjs/internals/utils/request-fetch-adapter.js.map +0 -1
- package/lib/module/enums/DeploymentStatus.enum.js.map +0 -1
- package/lib/module/internals/AcquisitionSdk.js +0 -5
- package/lib/module/internals/AcquisitionSdk.js.map +0 -1
- package/lib/module/internals/getPromisifiedSdk.js +0 -45
- package/lib/module/internals/getPromisifiedSdk.js.map +0 -1
- package/lib/module/internals/utils/request-fetch-adapter.js +0 -46
- package/lib/module/internals/utils/request-fetch-adapter.js.map +0 -1
- package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts +0 -14
- package/lib/typescript/commonjs/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts +0 -3
- package/lib/typescript/commonjs/src/internals/AcquisitionSdk.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts +0 -13
- package/lib/typescript/commonjs/src/internals/getPromisifiedSdk.d.ts.map +0 -1
- package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts +0 -3
- package/lib/typescript/commonjs/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
- package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts +0 -14
- package/lib/typescript/module/src/enums/DeploymentStatus.enum.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts +0 -3
- package/lib/typescript/module/src/internals/AcquisitionSdk.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts +0 -13
- package/lib/typescript/module/src/internals/getPromisifiedSdk.d.ts.map +0 -1
- package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts +0 -3
- package/lib/typescript/module/src/internals/utils/request-fetch-adapter.d.ts.map +0 -1
- package/src/enums/DeploymentStatus.enum.ts +0 -14
- package/src/internals/AcquisitionSdk.ts +0 -3
- package/src/internals/getPromisifiedSdk.ts +0 -72
- package/src/internals/utils/request-fetch-adapter.ts +0 -58
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export async function fetchRetry(url: string, options: FetchRetryOptions = {}, attempt = 0): Promise<Response> {
|
|
2
|
+
const {
|
|
3
|
+
maxRetries = 3,
|
|
4
|
+
initialBackoff = 1000,
|
|
5
|
+
backoffMultiplier = 2,
|
|
6
|
+
maxRetryDelay = 30000,
|
|
7
|
+
...fetchOptions
|
|
8
|
+
} = options;
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
const response = await fetch(url, fetchOptions);
|
|
12
|
+
if (response.ok || !(response.status === 429 || response.status >= 500)) {
|
|
13
|
+
return response;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (attempt >= maxRetries) {
|
|
17
|
+
return response;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const retryAfter = parseRetryAfterHeader(response);
|
|
21
|
+
if (retryAfter && retryAfter > maxRetryDelay) {
|
|
22
|
+
return response;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const delay = retryAfter ?? addJitter(initialBackoff * Math.pow(backoffMultiplier, attempt));
|
|
26
|
+
|
|
27
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
28
|
+
|
|
29
|
+
return fetchRetry(url, options, attempt + 1);
|
|
30
|
+
} catch (error) {
|
|
31
|
+
if (attempt >= maxRetries) {
|
|
32
|
+
throw error;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const delay = addJitter(initialBackoff * Math.pow(backoffMultiplier, attempt));
|
|
36
|
+
|
|
37
|
+
await new Promise((resolve) => setTimeout(resolve, delay));
|
|
38
|
+
|
|
39
|
+
return fetchRetry(url, options, attempt + 1);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
interface FetchRetryOptions extends RequestInit {
|
|
44
|
+
maxRetries?: number;
|
|
45
|
+
initialBackoff?: number;
|
|
46
|
+
backoffMultiplier?: number;
|
|
47
|
+
maxRetryDelay?: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function parseRetryAfterHeader(response: Response): number | null {
|
|
51
|
+
const retryAfter = response.headers.get('Retry-After');
|
|
52
|
+
if (!retryAfter) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!isNaN(Number(retryAfter))) {
|
|
57
|
+
return parseInt(retryAfter, 10) * 1000;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
const retryDate = new Date(retryAfter).getTime();
|
|
62
|
+
const now = Date.now();
|
|
63
|
+
return retryDate > now ? retryDate - now : 0;
|
|
64
|
+
} catch (e) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function addJitter(delay: number): number {
|
|
70
|
+
const jitterFactor = 0.5 + Math.random() * 0.5;
|
|
71
|
+
return Math.floor(delay * jitterFactor);
|
|
72
|
+
}
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { LogLevel } from '../../enums/LogLevel.enum';
|
|
2
|
+
import { getLogLevel } from '../../logLevel';
|
|
3
|
+
import { getLogger } from '../logger';
|
|
4
|
+
|
|
5
|
+
/* Logs messages using the configured logger */
|
|
6
|
+
export function log(level: LogLevel, message: string): void {
|
|
7
|
+
const currentLogLevel = getLogLevel();
|
|
8
|
+
if (level < currentLogLevel) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const logger = getLogger();
|
|
13
|
+
logger(level, message);
|
|
4
14
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export function queryStringify(object: { [key: string]: any }): string {
|
|
2
|
+
let queryString = '';
|
|
3
|
+
let isFirst = true;
|
|
4
|
+
|
|
5
|
+
for (const property in object) {
|
|
6
|
+
if (object.hasOwnProperty(property)) {
|
|
7
|
+
const value = object[property];
|
|
8
|
+
if (value !== null && typeof value !== 'undefined') {
|
|
9
|
+
if (!isFirst) {
|
|
10
|
+
queryString += '&';
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
queryString += encodeURIComponent(property) + '=';
|
|
14
|
+
queryString += encodeURIComponent(value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
isFirst = false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
return queryString;
|
|
22
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { LogLevel } from '../../enums/LogLevel.enum';
|
|
2
|
+
import type { Http } from '../CodePushApiSdk.types';
|
|
3
|
+
import { version } from '../version';
|
|
4
|
+
import { fetchRetry } from './fetchRetry';
|
|
5
|
+
import { log } from './log';
|
|
6
|
+
|
|
7
|
+
export const requestFetchAdapter: Http.Requester = {
|
|
8
|
+
async request(method, url, requestBody) {
|
|
9
|
+
const headers = {
|
|
10
|
+
Accept: 'application/json',
|
|
11
|
+
'Content-Type': 'application/json',
|
|
12
|
+
'X-CodePush-Plugin-Name': '@appzung/react-native-code-push',
|
|
13
|
+
'X-CodePush-Plugin-Version': version,
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
if (requestBody && typeof requestBody === 'object') {
|
|
17
|
+
requestBody = JSON.stringify(requestBody);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const requestId = Math.round(Math.random() * 10000);
|
|
21
|
+
log(LogLevel.DEBUG, `[${requestId}] Will fetch ${method} ${url}`);
|
|
22
|
+
|
|
23
|
+
const response = await fetchRetry(url, {
|
|
24
|
+
method,
|
|
25
|
+
headers,
|
|
26
|
+
body: requestBody,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const statusCode = response.status;
|
|
30
|
+
|
|
31
|
+
log(LogLevel.DEBUG, `[${requestId}] Done fetching with status code ${statusCode}`);
|
|
32
|
+
|
|
33
|
+
const body = await response.text();
|
|
34
|
+
return { statusCode, body };
|
|
35
|
+
},
|
|
36
|
+
};
|
package/src/internals/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '11.0.0-
|
|
2
|
+
export const version = '11.0.0-rc10';
|
package/src/logLevel.ts
ADDED
package/src/logger.ts
ADDED
package/src/notifyAppReady.ts
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import { AppState, type NativeEventSubscription } from 'react-native';
|
|
2
|
+
import { LogLevel } from './enums/LogLevel.enum';
|
|
3
|
+
import { CodePushApiSdk } from './internals/CodePushApiSdk';
|
|
2
4
|
import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
|
|
3
5
|
import { getConfiguration } from './internals/getConfiguration';
|
|
4
|
-
import { getPromisifiedSdk } from './internals/getPromisifiedSdk';
|
|
5
6
|
import { log } from './internals/utils/log';
|
|
6
|
-
import { requestFetchAdapter } from './internals/utils/
|
|
7
|
+
import { requestFetchAdapter } from './internals/utils/requestFetchAdapter';
|
|
7
8
|
import type { StatusReport } from './types';
|
|
8
9
|
|
|
9
10
|
/**
|
|
11
|
+
* @function
|
|
12
|
+
*
|
|
10
13
|
* Notifies the CodePush runtime that an installed update is considered successful.
|
|
14
|
+
*
|
|
15
|
+
* If you are manually checking for and installing updates (i.e. not using the `sync` method to handle it all for you), then this method **MUST** be called; otherwise CodePush will treat the update as failed and rollback to the previous version when the app next restarts.
|
|
11
16
|
*/
|
|
12
17
|
export const notifyAppReady = (() => {
|
|
13
18
|
// This ensures that notifyApplicationReadyInternal is only called once
|
|
@@ -24,32 +29,35 @@ export const notifyAppReady = (() => {
|
|
|
24
29
|
})();
|
|
25
30
|
|
|
26
31
|
async function notifyApplicationReadyInternal() {
|
|
32
|
+
log(LogLevel.DEBUG, 'notifyApplicationReady');
|
|
33
|
+
|
|
27
34
|
await NativeRNAppZungCodePushModule.notifyApplicationReady();
|
|
28
35
|
const statusReport = await NativeRNAppZungCodePushModule.getNewStatusReport();
|
|
29
|
-
|
|
36
|
+
if (statusReport) {
|
|
37
|
+
log(LogLevel.DEBUG, `tryReportStatus ${statusReport.status || '(no update)'}`);
|
|
38
|
+
|
|
39
|
+
tryReportStatus(statusReport); // Don't wait for this to complete.
|
|
40
|
+
} else {
|
|
41
|
+
log(LogLevel.DEBUG, `Nothing to report`);
|
|
42
|
+
}
|
|
30
43
|
|
|
31
44
|
return statusReport;
|
|
32
45
|
}
|
|
33
46
|
|
|
34
47
|
async function tryReportStatus(statusReport: StatusReport, retryOnAppResume?: NativeEventSubscription) {
|
|
35
48
|
const config = await getConfiguration();
|
|
36
|
-
const previousLabelOrAppVersion = statusReport.previousLabelOrAppVersion;
|
|
49
|
+
const previousLabelOrAppVersion = statusReport.previousLabelOrAppVersion ?? null;
|
|
37
50
|
const previousReleaseChannelPublicId = statusReport.previousReleaseChannelPublicId || config.releaseChannelPublicId;
|
|
38
51
|
try {
|
|
39
52
|
if (statusReport.appVersion) {
|
|
40
|
-
log(`Reporting binary update (${statusReport.appVersion})`);
|
|
53
|
+
log(LogLevel.INFO, `Reporting binary update (${statusReport.appVersion})`);
|
|
41
54
|
|
|
42
55
|
if (!config.releaseChannelPublicId) {
|
|
43
56
|
throw new Error('Release channel is missing');
|
|
44
57
|
}
|
|
45
58
|
|
|
46
|
-
const sdk =
|
|
47
|
-
await sdk.reportStatusDeploy(
|
|
48
|
-
/* deployedPackage */ undefined,
|
|
49
|
-
/* status */ undefined,
|
|
50
|
-
previousLabelOrAppVersion,
|
|
51
|
-
previousReleaseChannelPublicId,
|
|
52
|
-
);
|
|
59
|
+
const sdk = new CodePushApiSdk(requestFetchAdapter, log, config);
|
|
60
|
+
await sdk.reportStatusDeploy(null, previousLabelOrAppVersion, previousReleaseChannelPublicId);
|
|
53
61
|
} else {
|
|
54
62
|
if (!statusReport.package) {
|
|
55
63
|
throw new Error('Missing package in status report');
|
|
@@ -57,17 +65,19 @@ async function tryReportStatus(statusReport: StatusReport, retryOnAppResume?: Na
|
|
|
57
65
|
|
|
58
66
|
const label = statusReport.package.label;
|
|
59
67
|
if (statusReport.status === 'DeploymentSucceeded') {
|
|
60
|
-
log(`Reporting CodePush update success (${label})`);
|
|
68
|
+
log(LogLevel.INFO, `Reporting CodePush update success (${label})`);
|
|
61
69
|
} else {
|
|
62
|
-
log(`Reporting CodePush update rollback (${label})`);
|
|
70
|
+
log(LogLevel.INFO, `Reporting CodePush update rollback (${label})`);
|
|
63
71
|
await NativeRNAppZungCodePushModule.setLatestRollbackInfo(statusReport.package.packageHash);
|
|
64
72
|
}
|
|
65
73
|
|
|
66
74
|
config.releaseChannelPublicId = statusReport.package.releaseChannelPublicId;
|
|
67
|
-
const sdk =
|
|
75
|
+
const sdk = new CodePushApiSdk(requestFetchAdapter, log, config);
|
|
68
76
|
await sdk.reportStatusDeploy(
|
|
69
|
-
{
|
|
70
|
-
|
|
77
|
+
{
|
|
78
|
+
package: statusReport.package,
|
|
79
|
+
status: statusReport.status,
|
|
80
|
+
},
|
|
71
81
|
previousLabelOrAppVersion,
|
|
72
82
|
previousReleaseChannelPublicId,
|
|
73
83
|
);
|
|
@@ -76,7 +86,7 @@ async function tryReportStatus(statusReport: StatusReport, retryOnAppResume?: Na
|
|
|
76
86
|
NativeRNAppZungCodePushModule.recordStatusReported(statusReport);
|
|
77
87
|
retryOnAppResume && retryOnAppResume.remove();
|
|
78
88
|
} catch (e) {
|
|
79
|
-
log(`Report status failed: ${JSON.stringify(statusReport)}`);
|
|
89
|
+
log(LogLevel.WARN, `Report status failed: ${JSON.stringify(statusReport)}`);
|
|
80
90
|
NativeRNAppZungCodePushModule.saveStatusReportForRetry(statusReport);
|
|
81
91
|
// Try again when the app resumes
|
|
82
92
|
if (!retryOnAppResume) {
|
|
@@ -84,6 +94,7 @@ async function tryReportStatus(statusReport: StatusReport, retryOnAppResume?: Na
|
|
|
84
94
|
if (newState !== 'active') return;
|
|
85
95
|
const refreshedStatusReport = await NativeRNAppZungCodePushModule.getNewStatusReport();
|
|
86
96
|
if (refreshedStatusReport) {
|
|
97
|
+
log(LogLevel.DEBUG, `tryReportStatus on active appState ${statusReport.status || '(no update)'}`);
|
|
87
98
|
tryReportStatus(refreshedStatusReport, resumeListener);
|
|
88
99
|
} else {
|
|
89
100
|
resumeListener && resumeListener.remove();
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
|
|
2
|
+
import { reloadCachedConfiguration } from './internals/getConfiguration';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Resets the client's unique ID. You may use this in some GDPR compliance scenarios. Note that this will create a new MAU if a new request is sent later.
|
|
6
|
+
*/
|
|
7
|
+
export const resetClientUniqueId = async () => {
|
|
8
|
+
const newId = await NativeRNAppZungCodePushModule.resetClientUniqueId();
|
|
9
|
+
await reloadCachedConfiguration();
|
|
10
|
+
return newId;
|
|
11
|
+
};
|
package/src/restartApp.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePu
|
|
|
3
3
|
/**
|
|
4
4
|
* Immediately restarts the app.
|
|
5
5
|
*
|
|
6
|
+
* If there is an update pending, it will be immediately displayed to the end user. Otherwise, calling this method simply has the same behavior as the end user killing and restarting the process.
|
|
7
|
+
*
|
|
6
8
|
* @param onlyIfUpdateIsPending Indicates whether you want the restart to no-op if there isn't currently a pending update.
|
|
7
9
|
*/
|
|
8
|
-
export
|
|
9
|
-
NativeRNAppZungCodePushModule.restartApp(onlyIfUpdateIsPending);
|
|
10
|
+
export function restartApp(onlyIfUpdateIsPending = false) {
|
|
11
|
+
return NativeRNAppZungCodePushModule.restartApp(onlyIfUpdateIsPending);
|
|
10
12
|
}
|
package/src/sync.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Alert, type AlertButton, Platform } from 'react-native';
|
|
2
2
|
import { checkForUpdate } from './checkForUpdates';
|
|
3
3
|
import { InstallMode } from './enums/InstallMode.enum';
|
|
4
|
+
import { LogLevel } from './enums/LogLevel.enum';
|
|
4
5
|
import { SyncStatus } from './enums/SyncStatus.enum';
|
|
5
6
|
import { getCurrentPackage } from './internals/getCurrentPackage';
|
|
6
7
|
import { shouldUpdateBeIgnored } from './internals/shouldUpdateBeIgnored';
|
|
@@ -62,38 +63,39 @@ async function syncInternal(
|
|
|
62
63
|
: (syncStatus: SyncStatus) => {
|
|
63
64
|
switch (syncStatus) {
|
|
64
65
|
case SyncStatus.CHECKING_FOR_UPDATE:
|
|
65
|
-
log('Checking for update.');
|
|
66
|
+
log(LogLevel.INFO, 'Checking for update.');
|
|
66
67
|
break;
|
|
67
68
|
case SyncStatus.AWAITING_USER_ACTION:
|
|
68
|
-
log('Awaiting user action.');
|
|
69
|
+
log(LogLevel.INFO, 'Awaiting user action.');
|
|
69
70
|
break;
|
|
70
71
|
case SyncStatus.DOWNLOADING_PACKAGE:
|
|
71
|
-
log('Downloading package.');
|
|
72
|
+
log(LogLevel.INFO, 'Downloading package.');
|
|
72
73
|
break;
|
|
73
74
|
case SyncStatus.INSTALLING_UPDATE:
|
|
74
|
-
log('Installing update.');
|
|
75
|
+
log(LogLevel.INFO, 'Installing update.');
|
|
75
76
|
break;
|
|
76
77
|
case SyncStatus.UP_TO_DATE:
|
|
77
|
-
log('App is up to date.');
|
|
78
|
+
log(LogLevel.INFO, 'App is up to date.');
|
|
78
79
|
break;
|
|
79
80
|
case SyncStatus.UPDATE_IGNORED:
|
|
80
|
-
log('User cancelled the update.');
|
|
81
|
+
log(LogLevel.INFO, 'User cancelled the update.');
|
|
81
82
|
break;
|
|
82
83
|
case SyncStatus.UPDATE_INSTALLED:
|
|
83
|
-
if (resolvedInstallMode
|
|
84
|
-
log('Update is installed and will be run on the next app restart.');
|
|
85
|
-
} else if (resolvedInstallMode
|
|
86
|
-
if (
|
|
84
|
+
if (resolvedInstallMode === InstallMode.ON_NEXT_RESTART) {
|
|
85
|
+
log(LogLevel.INFO, 'Update is installed and will be run on the next app restart.');
|
|
86
|
+
} else if (resolvedInstallMode === InstallMode.ON_NEXT_RESUME) {
|
|
87
|
+
if (syncOptions.minimumBackgroundDuration) {
|
|
87
88
|
log(
|
|
89
|
+
LogLevel.INFO,
|
|
88
90
|
`Update is installed and will be run after the app has been in the background for at least ${syncOptions.minimumBackgroundDuration} seconds.`,
|
|
89
91
|
);
|
|
90
92
|
} else {
|
|
91
|
-
log('Update is installed and will be run when the app next resumes.');
|
|
93
|
+
log(LogLevel.INFO, 'Update is installed and will be run when the app next resumes.');
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
break;
|
|
95
97
|
case SyncStatus.UNKNOWN_ERROR:
|
|
96
|
-
log('An unknown error occurred.');
|
|
98
|
+
log(LogLevel.ERROR, 'An unknown error occurred.');
|
|
97
99
|
break;
|
|
98
100
|
}
|
|
99
101
|
};
|
|
@@ -127,7 +129,10 @@ async function syncInternal(
|
|
|
127
129
|
|
|
128
130
|
if (!remotePackage || updateShouldBeIgnored) {
|
|
129
131
|
if (updateShouldBeIgnored) {
|
|
130
|
-
log(
|
|
132
|
+
log(
|
|
133
|
+
LogLevel.INFO,
|
|
134
|
+
'An update is available, but it is being ignored due to having been previously rolled back.',
|
|
135
|
+
);
|
|
131
136
|
}
|
|
132
137
|
|
|
133
138
|
const currentPackage = await getCurrentPackage();
|
|
@@ -195,6 +200,7 @@ async function syncInternal(
|
|
|
195
200
|
} catch (error) {
|
|
196
201
|
syncStatusChangeCallback(SyncStatus.UNKNOWN_ERROR);
|
|
197
202
|
log(
|
|
203
|
+
LogLevel.ERROR,
|
|
198
204
|
error != null && typeof error === 'object' && 'message' in error && typeof error.message === 'string'
|
|
199
205
|
? error.message
|
|
200
206
|
: 'Unknown',
|
|
@@ -204,8 +210,12 @@ async function syncInternal(
|
|
|
204
210
|
}
|
|
205
211
|
|
|
206
212
|
/**
|
|
213
|
+
* @function
|
|
214
|
+
*
|
|
207
215
|
* Allows checking for an update, downloading it and installing it, all with a single call.
|
|
208
216
|
*
|
|
217
|
+
* Unless you need custom UI and/or behavior, we recommend most developers to use this method when integrating CodePush into their apps, if they are not using the `withCodePush` HOC.
|
|
218
|
+
*
|
|
209
219
|
* @param options Options used to configure the end-user update experience (e.g. show a prompt?, install the update immediately?).
|
|
210
220
|
* @param syncStatusChangedCallback An optional callback that allows tracking the status of the sync operation, as opposed to simply checking the resolved state via the returned Promise.
|
|
211
221
|
* @param downloadProgressCallback An optional callback that allows tracking the progress of an update while it is being downloaded.
|
|
@@ -222,29 +232,33 @@ export const sync = (() => {
|
|
|
222
232
|
|
|
223
233
|
return (
|
|
224
234
|
options?: SyncOptions,
|
|
225
|
-
|
|
235
|
+
syncStatusChangedCallback?: SyncStatusChangedCallback,
|
|
226
236
|
downloadProgressCallback?: DownloadProgressCallback,
|
|
227
237
|
handleBinaryVersionMismatchCallback?: HandleBinaryVersionMismatchCallback,
|
|
228
238
|
): Promise<SyncStatus> => {
|
|
229
|
-
|
|
230
|
-
let downloadProgressCallbackWithTryCatch: DownloadProgressCallback | undefined;
|
|
239
|
+
log(LogLevel.DEBUG, `sync start`);
|
|
231
240
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
}
|
|
239
|
-
};
|
|
240
|
-
}
|
|
241
|
+
let syncStatusCallbackWithTryCatch: SyncStatusChangedCallback = (status) => {
|
|
242
|
+
log(LogLevel.DEBUG, `sync status ${SyncStatus[status]}`);
|
|
243
|
+
|
|
244
|
+
if (typeof syncStatusChangedCallback !== 'function') {
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
241
247
|
|
|
248
|
+
try {
|
|
249
|
+
syncStatusChangedCallback(status);
|
|
250
|
+
} catch (error) {
|
|
251
|
+
log(LogLevel.ERROR, `An error has occurred : ${error instanceof Error ? error.stack : 'unknown'}`);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
|
|
255
|
+
let downloadProgressCallbackWithTryCatch: DownloadProgressCallback | undefined;
|
|
242
256
|
if (typeof downloadProgressCallback === 'function') {
|
|
243
257
|
downloadProgressCallbackWithTryCatch = (...args) => {
|
|
244
258
|
try {
|
|
245
259
|
downloadProgressCallback(...args);
|
|
246
260
|
} catch (error) {
|
|
247
|
-
log(`An error has occurred: ${error instanceof Error ? error.stack : 'unknown'}`);
|
|
261
|
+
log(LogLevel.ERROR, `An error has occurred: ${error instanceof Error ? error.stack : 'unknown'}`);
|
|
248
262
|
}
|
|
249
263
|
};
|
|
250
264
|
}
|
|
@@ -252,7 +266,7 @@ export const sync = (() => {
|
|
|
252
266
|
if (syncInProgress) {
|
|
253
267
|
typeof syncStatusCallbackWithTryCatch === 'function'
|
|
254
268
|
? syncStatusCallbackWithTryCatch(SyncStatus.SYNC_IN_PROGRESS)
|
|
255
|
-
: log('Sync already in progress.');
|
|
269
|
+
: log(LogLevel.WARN, 'Sync already in progress.');
|
|
256
270
|
return Promise.resolve(SyncStatus.SYNC_IN_PROGRESS);
|
|
257
271
|
}
|
|
258
272
|
|
package/src/telemetry.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
|
|
2
|
+
import { reloadCachedConfiguration } from './internals/getConfiguration';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Controls telemetry reporting.
|
|
6
|
+
*
|
|
7
|
+
* @param enabled - When false, updates on this device will stop appearing as failed, pending or succeeded in analytics.
|
|
8
|
+
*/
|
|
9
|
+
export async function setTelemetryEnabled(enabled: boolean): Promise<void> {
|
|
10
|
+
await NativeRNAppZungCodePushModule.setTelemetryEnabled(enabled);
|
|
11
|
+
await reloadCachedConfiguration();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Gets the current telemetry enabled status.
|
|
16
|
+
*
|
|
17
|
+
* When setTelemetryEnabled has never been enabled, returns the default value set in your configuration.
|
|
18
|
+
*/
|
|
19
|
+
export function getTelemetryEnabled(): Promise<boolean> {
|
|
20
|
+
return NativeRNAppZungCodePushModule.getTelemetryEnabled();
|
|
21
|
+
}
|