@appzung/react-native-code-push 10.1.1 → 10.2.1

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.
Files changed (195) hide show
  1. package/android/app/src/main/java/com/appzung/codepush/react/CodePushConstants.java +2 -0
  2. package/android/app/src/main/java/com/appzung/codepush/react/CodePushNativeModule.java +62 -0
  3. package/ios/CodePush/CodePush.h +2 -0
  4. package/ios/CodePush/CodePush.m +28 -0
  5. package/ios/CodePush/CodePushConfig.m +50 -0
  6. package/lib/commonjs/CodePush.js +5 -0
  7. package/lib/commonjs/CodePush.js.map +1 -1
  8. package/lib/commonjs/allowRestart.js +4 -2
  9. package/lib/commonjs/allowRestart.js.map +1 -1
  10. package/lib/commonjs/checkForUpdates.js +3 -2
  11. package/lib/commonjs/checkForUpdates.js.map +1 -1
  12. package/lib/commonjs/clearUpdates.js +4 -2
  13. package/lib/commonjs/clearUpdates.js.map +1 -1
  14. package/lib/commonjs/dataTransmission.js +28 -0
  15. package/lib/commonjs/dataTransmission.js.map +1 -0
  16. package/lib/commonjs/disallowRestart.js +4 -2
  17. package/lib/commonjs/disallowRestart.js.map +1 -1
  18. package/lib/commonjs/enums/LogLevel.enum.js +17 -0
  19. package/lib/commonjs/enums/LogLevel.enum.js.map +1 -0
  20. package/lib/commonjs/index.js +60 -0
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/internals/CodePushApiSdk.js +23 -1
  23. package/lib/commonjs/internals/CodePushApiSdk.js.map +1 -1
  24. package/lib/commonjs/internals/CodePushApiSdk.types.js.map +1 -1
  25. package/lib/commonjs/internals/RemotePackageImplementation.js +2 -1
  26. package/lib/commonjs/internals/RemotePackageImplementation.js.map +1 -1
  27. package/lib/commonjs/internals/logger.js +51 -0
  28. package/lib/commonjs/internals/logger.js.map +1 -0
  29. package/lib/commonjs/internals/shouldUpdateBeIgnored.js +6 -5
  30. package/lib/commonjs/internals/shouldUpdateBeIgnored.js.map +1 -1
  31. package/lib/commonjs/internals/utils/log.js +10 -3
  32. package/lib/commonjs/internals/utils/log.js.map +1 -1
  33. package/lib/commonjs/internals/utils/requestFetchAdapter.js +5 -0
  34. package/lib/commonjs/internals/utils/requestFetchAdapter.js.map +1 -1
  35. package/lib/commonjs/internals/version.js +1 -1
  36. package/lib/commonjs/logLevel.js +15 -0
  37. package/lib/commonjs/logLevel.js.map +1 -0
  38. package/lib/commonjs/logger.js +19 -0
  39. package/lib/commonjs/logger.js.map +1 -0
  40. package/lib/commonjs/notifyAppReady.js +17 -8
  41. package/lib/commonjs/notifyAppReady.js.map +1 -1
  42. package/lib/commonjs/restartApp.js +2 -2
  43. package/lib/commonjs/restartApp.js.map +1 -1
  44. package/lib/commonjs/sync.js +32 -27
  45. package/lib/commonjs/sync.js.map +1 -1
  46. package/lib/commonjs/telemetry.js +28 -0
  47. package/lib/commonjs/telemetry.js.map +1 -0
  48. package/lib/module/CodePush.js +5 -0
  49. package/lib/module/CodePush.js.map +1 -1
  50. package/lib/module/allowRestart.js +3 -1
  51. package/lib/module/allowRestart.js.map +1 -1
  52. package/lib/module/checkForUpdates.js +3 -2
  53. package/lib/module/checkForUpdates.js.map +1 -1
  54. package/lib/module/clearUpdates.js +3 -1
  55. package/lib/module/clearUpdates.js.map +1 -1
  56. package/lib/module/dataTransmission.js +24 -0
  57. package/lib/module/dataTransmission.js.map +1 -0
  58. package/lib/module/disallowRestart.js +3 -1
  59. package/lib/module/disallowRestart.js.map +1 -1
  60. package/lib/module/enums/LogLevel.enum.js +13 -0
  61. package/lib/module/enums/LogLevel.enum.js.map +1 -0
  62. package/lib/module/index.js +5 -0
  63. package/lib/module/index.js.map +1 -1
  64. package/lib/module/internals/CodePushApiSdk.js +23 -1
  65. package/lib/module/internals/CodePushApiSdk.js.map +1 -1
  66. package/lib/module/internals/CodePushApiSdk.types.js.map +1 -1
  67. package/lib/module/internals/RemotePackageImplementation.js +2 -1
  68. package/lib/module/internals/RemotePackageImplementation.js.map +1 -1
  69. package/lib/module/internals/logger.js +44 -0
  70. package/lib/module/internals/logger.js.map +1 -0
  71. package/lib/module/internals/shouldUpdateBeIgnored.js +6 -5
  72. package/lib/module/internals/shouldUpdateBeIgnored.js.map +1 -1
  73. package/lib/module/internals/utils/log.js +11 -3
  74. package/lib/module/internals/utils/log.js.map +1 -1
  75. package/lib/module/internals/utils/requestFetchAdapter.js +5 -0
  76. package/lib/module/internals/utils/requestFetchAdapter.js.map +1 -1
  77. package/lib/module/internals/version.js +1 -1
  78. package/lib/module/logLevel.js +9 -0
  79. package/lib/module/logLevel.js.map +1 -0
  80. package/lib/module/logger.js +4 -0
  81. package/lib/module/logger.js.map +1 -0
  82. package/lib/module/notifyAppReady.js +17 -8
  83. package/lib/module/notifyAppReady.js.map +1 -1
  84. package/lib/module/restartApp.js +2 -2
  85. package/lib/module/restartApp.js.map +1 -1
  86. package/lib/module/sync.js +32 -27
  87. package/lib/module/sync.js.map +1 -1
  88. package/lib/module/telemetry.js +24 -0
  89. package/lib/module/telemetry.js.map +1 -0
  90. package/lib/typescript/commonjs/src/CodePush.d.ts.map +1 -1
  91. package/lib/typescript/commonjs/src/allowRestart.d.ts +1 -1
  92. package/lib/typescript/commonjs/src/allowRestart.d.ts.map +1 -1
  93. package/lib/typescript/commonjs/src/checkForUpdates.d.ts.map +1 -1
  94. package/lib/typescript/commonjs/src/clearUpdates.d.ts +1 -1
  95. package/lib/typescript/commonjs/src/clearUpdates.d.ts.map +1 -1
  96. package/lib/typescript/commonjs/src/dataTransmission.d.ts +13 -0
  97. package/lib/typescript/commonjs/src/dataTransmission.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/disallowRestart.d.ts +1 -1
  99. package/lib/typescript/commonjs/src/disallowRestart.d.ts.map +1 -1
  100. package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts +10 -0
  101. package/lib/typescript/commonjs/src/enums/LogLevel.enum.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/index.d.ts +5 -0
  103. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  104. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts +3 -1
  105. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.d.ts.map +1 -1
  106. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts +2 -0
  107. package/lib/typescript/commonjs/src/internals/CodePushApiSdk.types.d.ts.map +1 -1
  108. package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts +4 -0
  109. package/lib/typescript/commonjs/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
  110. package/lib/typescript/commonjs/src/internals/RemotePackageImplementation.d.ts.map +1 -1
  111. package/lib/typescript/commonjs/src/internals/logger.d.ts +33 -0
  112. package/lib/typescript/commonjs/src/internals/logger.d.ts.map +1 -0
  113. package/lib/typescript/commonjs/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
  114. package/lib/typescript/commonjs/src/internals/utils/log.d.ts +2 -1
  115. package/lib/typescript/commonjs/src/internals/utils/log.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/src/internals/utils/requestFetchAdapter.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/src/internals/version.d.ts +1 -1
  118. package/lib/typescript/commonjs/src/logLevel.d.ts +4 -0
  119. package/lib/typescript/commonjs/src/logLevel.d.ts.map +1 -0
  120. package/lib/typescript/commonjs/src/logger.d.ts +3 -0
  121. package/lib/typescript/commonjs/src/logger.d.ts.map +1 -0
  122. package/lib/typescript/commonjs/src/notifyAppReady.d.ts +2 -0
  123. package/lib/typescript/commonjs/src/notifyAppReady.d.ts.map +1 -1
  124. package/lib/typescript/commonjs/src/restartApp.d.ts.map +1 -1
  125. package/lib/typescript/commonjs/src/sync.d.ts +2 -0
  126. package/lib/typescript/commonjs/src/sync.d.ts.map +1 -1
  127. package/lib/typescript/commonjs/src/telemetry.d.ts +13 -0
  128. package/lib/typescript/commonjs/src/telemetry.d.ts.map +1 -0
  129. package/lib/typescript/module/src/CodePush.d.ts.map +1 -1
  130. package/lib/typescript/module/src/allowRestart.d.ts +1 -1
  131. package/lib/typescript/module/src/allowRestart.d.ts.map +1 -1
  132. package/lib/typescript/module/src/checkForUpdates.d.ts.map +1 -1
  133. package/lib/typescript/module/src/clearUpdates.d.ts +1 -1
  134. package/lib/typescript/module/src/clearUpdates.d.ts.map +1 -1
  135. package/lib/typescript/module/src/dataTransmission.d.ts +13 -0
  136. package/lib/typescript/module/src/dataTransmission.d.ts.map +1 -0
  137. package/lib/typescript/module/src/disallowRestart.d.ts +1 -1
  138. package/lib/typescript/module/src/disallowRestart.d.ts.map +1 -1
  139. package/lib/typescript/module/src/enums/LogLevel.enum.d.ts +10 -0
  140. package/lib/typescript/module/src/enums/LogLevel.enum.d.ts.map +1 -0
  141. package/lib/typescript/module/src/index.d.ts +5 -0
  142. package/lib/typescript/module/src/index.d.ts.map +1 -1
  143. package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts +3 -1
  144. package/lib/typescript/module/src/internals/CodePushApiSdk.d.ts.map +1 -1
  145. package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts +2 -0
  146. package/lib/typescript/module/src/internals/CodePushApiSdk.types.d.ts.map +1 -1
  147. package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts +4 -0
  148. package/lib/typescript/module/src/internals/RNAppZungCodePushModuleSpec.d.ts.map +1 -1
  149. package/lib/typescript/module/src/internals/RemotePackageImplementation.d.ts.map +1 -1
  150. package/lib/typescript/module/src/internals/logger.d.ts +33 -0
  151. package/lib/typescript/module/src/internals/logger.d.ts.map +1 -0
  152. package/lib/typescript/module/src/internals/shouldUpdateBeIgnored.d.ts.map +1 -1
  153. package/lib/typescript/module/src/internals/utils/log.d.ts +2 -1
  154. package/lib/typescript/module/src/internals/utils/log.d.ts.map +1 -1
  155. package/lib/typescript/module/src/internals/utils/requestFetchAdapter.d.ts.map +1 -1
  156. package/lib/typescript/module/src/internals/version.d.ts +1 -1
  157. package/lib/typescript/module/src/logLevel.d.ts +4 -0
  158. package/lib/typescript/module/src/logLevel.d.ts.map +1 -0
  159. package/lib/typescript/module/src/logger.d.ts +3 -0
  160. package/lib/typescript/module/src/logger.d.ts.map +1 -0
  161. package/lib/typescript/module/src/notifyAppReady.d.ts +2 -0
  162. package/lib/typescript/module/src/notifyAppReady.d.ts.map +1 -1
  163. package/lib/typescript/module/src/restartApp.d.ts.map +1 -1
  164. package/lib/typescript/module/src/sync.d.ts +2 -0
  165. package/lib/typescript/module/src/sync.d.ts.map +1 -1
  166. package/lib/typescript/module/src/telemetry.d.ts +13 -0
  167. package/lib/typescript/module/src/telemetry.d.ts.map +1 -0
  168. package/package.json +23 -14
  169. package/scripts/generateBundledResourcesHash.js +73 -68
  170. package/scripts/getFilesInFolder.js +12 -12
  171. package/scripts/recordFilesBeforeBundleCommand.js +19 -20
  172. package/src/CodePush.tsx +6 -0
  173. package/src/allowRestart.ts +3 -1
  174. package/src/checkForUpdates.ts +3 -2
  175. package/src/clearUpdates.ts +3 -1
  176. package/src/dataTransmission.ts +21 -0
  177. package/src/disallowRestart.ts +3 -1
  178. package/src/enums/LogLevel.enum.ts +9 -0
  179. package/src/index.ts +5 -0
  180. package/src/internals/CodePushApiSdk.ts +27 -0
  181. package/src/internals/CodePushApiSdk.types.ts +2 -0
  182. package/src/internals/RNAppZungCodePushModuleSpec.ts +6 -0
  183. package/src/internals/RemotePackageImplementation.ts +2 -1
  184. package/src/internals/logger.ts +46 -0
  185. package/src/internals/shouldUpdateBeIgnored.ts +6 -5
  186. package/src/internals/utils/log.ts +13 -3
  187. package/src/internals/utils/requestFetchAdapter.ts +8 -0
  188. package/src/internals/version.ts +1 -1
  189. package/src/logLevel.ts +9 -0
  190. package/src/logger.ts +2 -0
  191. package/src/notifyAppReady.ts +19 -7
  192. package/src/restartApp.ts +2 -2
  193. package/src/sync.ts +38 -26
  194. package/src/telemetry.ts +21 -0
  195. package/typedoc.json +0 -9
@@ -0,0 +1,9 @@
1
+ import { LogLevel } from './enums/LogLevel.enum';
2
+
3
+ let logLevel = LogLevel.INFO;
4
+
5
+ export const setLogLevel = (level: LogLevel) => {
6
+ logLevel = level;
7
+ };
8
+
9
+ export const getLogLevel = () => logLevel;
package/src/logger.ts ADDED
@@ -0,0 +1,2 @@
1
+ export { setLogger, resetLogger } from './internals/logger';
2
+ export type { LoggerFunction } from './internals/logger';
@@ -1,4 +1,5 @@
1
1
  import { AppState, type NativeEventSubscription } from 'react-native';
2
+ import { LogLevel } from './enums/LogLevel.enum';
2
3
  import { CodePushApiSdk } from './internals/CodePushApiSdk';
3
4
  import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePushModule';
4
5
  import { getConfiguration } from './internals/getConfiguration';
@@ -7,6 +8,8 @@ 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.
11
14
  *
12
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.
@@ -26,9 +29,17 @@ export const notifyAppReady = (() => {
26
29
  })();
27
30
 
28
31
  async function notifyApplicationReadyInternal() {
32
+ log(LogLevel.DEBUG, 'notifyApplicationReady');
33
+
29
34
  await NativeRNAppZungCodePushModule.notifyApplicationReady();
30
35
  const statusReport = await NativeRNAppZungCodePushModule.getNewStatusReport();
31
- statusReport && tryReportStatus(statusReport); // Don't wait for this to complete.
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
+ }
32
43
 
33
44
  return statusReport;
34
45
  }
@@ -39,13 +50,13 @@ async function tryReportStatus(statusReport: StatusReport, retryOnAppResume?: Na
39
50
  const previousReleaseChannelPublicId = statusReport.previousReleaseChannelPublicId || config.releaseChannelPublicId;
40
51
  try {
41
52
  if (statusReport.appVersion) {
42
- log(`Reporting binary update (${statusReport.appVersion})`);
53
+ log(LogLevel.INFO, `Reporting binary update (${statusReport.appVersion})`);
43
54
 
44
55
  if (!config.releaseChannelPublicId) {
45
56
  throw new Error('Release channel is missing');
46
57
  }
47
58
 
48
- const sdk = new CodePushApiSdk(requestFetchAdapter, config);
59
+ const sdk = new CodePushApiSdk(requestFetchAdapter, log, config);
49
60
  await sdk.reportStatusDeploy(null, previousLabelOrAppVersion, previousReleaseChannelPublicId);
50
61
  } else {
51
62
  if (!statusReport.package) {
@@ -54,14 +65,14 @@ async function tryReportStatus(statusReport: StatusReport, retryOnAppResume?: Na
54
65
 
55
66
  const label = statusReport.package.label;
56
67
  if (statusReport.status === 'DeploymentSucceeded') {
57
- log(`Reporting CodePush update success (${label})`);
68
+ log(LogLevel.INFO, `Reporting CodePush update success (${label})`);
58
69
  } else {
59
- log(`Reporting CodePush update rollback (${label})`);
70
+ log(LogLevel.INFO, `Reporting CodePush update rollback (${label})`);
60
71
  await NativeRNAppZungCodePushModule.setLatestRollbackInfo(statusReport.package.packageHash);
61
72
  }
62
73
 
63
74
  config.releaseChannelPublicId = statusReport.package.releaseChannelPublicId;
64
- const sdk = new CodePushApiSdk(requestFetchAdapter, config);
75
+ const sdk = new CodePushApiSdk(requestFetchAdapter, log, config);
65
76
  await sdk.reportStatusDeploy(
66
77
  {
67
78
  package: statusReport.package,
@@ -75,7 +86,7 @@ async function tryReportStatus(statusReport: StatusReport, retryOnAppResume?: Na
75
86
  NativeRNAppZungCodePushModule.recordStatusReported(statusReport);
76
87
  retryOnAppResume && retryOnAppResume.remove();
77
88
  } catch (e) {
78
- log(`Report status failed: ${JSON.stringify(statusReport)}`);
89
+ log(LogLevel.WARN, `Report status failed: ${JSON.stringify(statusReport)}`);
79
90
  NativeRNAppZungCodePushModule.saveStatusReportForRetry(statusReport);
80
91
  // Try again when the app resumes
81
92
  if (!retryOnAppResume) {
@@ -83,6 +94,7 @@ async function tryReportStatus(statusReport: StatusReport, retryOnAppResume?: Na
83
94
  if (newState !== 'active') return;
84
95
  const refreshedStatusReport = await NativeRNAppZungCodePushModule.getNewStatusReport();
85
96
  if (refreshedStatusReport) {
97
+ log(LogLevel.DEBUG, `tryReportStatus on active appState ${statusReport.status || '(no update)'}`);
86
98
  tryReportStatus(refreshedStatusReport, resumeListener);
87
99
  } else {
88
100
  resumeListener && resumeListener.remove();
package/src/restartApp.ts CHANGED
@@ -7,6 +7,6 @@ import { NativeRNAppZungCodePushModule } from './internals/NativeRNAppZungCodePu
7
7
  *
8
8
  * @param onlyIfUpdateIsPending Indicates whether you want the restart to no-op if there isn't currently a pending update.
9
9
  */
10
- export async function restartApp(onlyIfUpdateIsPending = false) {
11
- NativeRNAppZungCodePushModule.restartApp(onlyIfUpdateIsPending);
10
+ export function restartApp(onlyIfUpdateIsPending = false) {
11
+ return NativeRNAppZungCodePushModule.restartApp(onlyIfUpdateIsPending);
12
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 == InstallMode.ON_NEXT_RESTART) {
84
- log('Update is installed and will be run on the next app restart.');
85
- } else if (resolvedInstallMode == InstallMode.ON_NEXT_RESUME) {
86
- if (!!syncOptions.minimumBackgroundDuration) {
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('An update is available, but it is being ignored due to having been previously rolled back.');
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,6 +210,8 @@ 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
  *
209
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.
@@ -228,25 +236,29 @@ export const sync = (() => {
228
236
  downloadProgressCallback?: DownloadProgressCallback,
229
237
  handleBinaryVersionMismatchCallback?: HandleBinaryVersionMismatchCallback,
230
238
  ): Promise<SyncStatus> => {
231
- let syncStatusCallbackWithTryCatch: SyncStatusChangedCallback | undefined;
232
- let downloadProgressCallbackWithTryCatch: DownloadProgressCallback | undefined;
239
+ log(LogLevel.DEBUG, `sync start`);
233
240
 
234
- if (typeof syncStatusChangedCallback === 'function') {
235
- syncStatusCallbackWithTryCatch = (...args) => {
236
- try {
237
- syncStatusChangedCallback(...args);
238
- } catch (error) {
239
- log(`An error has occurred : ${error instanceof Error ? error.stack : 'unknown'}`);
240
- }
241
- };
242
- }
241
+ let syncStatusCallbackWithTryCatch: SyncStatusChangedCallback = (status) => {
242
+ log(LogLevel.DEBUG, `sync status ${SyncStatus[status]}`);
243
+
244
+ if (typeof syncStatusChangedCallback !== 'function') {
245
+ return;
246
+ }
243
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;
244
256
  if (typeof downloadProgressCallback === 'function') {
245
257
  downloadProgressCallbackWithTryCatch = (...args) => {
246
258
  try {
247
259
  downloadProgressCallback(...args);
248
260
  } catch (error) {
249
- 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'}`);
250
262
  }
251
263
  };
252
264
  }
@@ -254,7 +266,7 @@ export const sync = (() => {
254
266
  if (syncInProgress) {
255
267
  typeof syncStatusCallbackWithTryCatch === 'function'
256
268
  ? syncStatusCallbackWithTryCatch(SyncStatus.SYNC_IN_PROGRESS)
257
- : log('Sync already in progress.');
269
+ : log(LogLevel.WARN, 'Sync already in progress.');
258
270
  return Promise.resolve(SyncStatus.SYNC_IN_PROGRESS);
259
271
  }
260
272
 
@@ -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
+ }
package/typedoc.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "plugin": ["typedoc-plugin-markdown"],
3
- "entryPoints": ["./src/index.ts"],
4
- "out": "./docs/api-js",
5
- "readme": "none",
6
- "formatWithPrettier": true,
7
- "includeVersion": true,
8
- "disableSources": true
9
- }