@aws-amplify/notifications 2.0.1-api-v6-models.9351bcf.0 → 2.0.1-api-v6-models.891fe0d.0

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 (287) hide show
  1. package/in-app-messaging/package.json +4 -4
  2. package/lib/eventListeners/eventListeners.js +19 -37
  3. package/lib/eventListeners/index.js +4 -3
  4. package/lib/eventListeners/types.d.ts +2 -2
  5. package/lib/inAppMessaging/errors/InAppMessagingError.js +8 -11
  6. package/lib/inAppMessaging/errors/assertServiceError.js +3 -2
  7. package/lib/inAppMessaging/errors/assertValidationError.js +5 -4
  8. package/lib/inAppMessaging/errors/index.js +6 -5
  9. package/lib/inAppMessaging/errors/validation.js +7 -7
  10. package/lib/inAppMessaging/index.d.ts +2 -1
  11. package/lib/inAppMessaging/index.js +12 -10
  12. package/lib/inAppMessaging/providers/pinpoint/apis/clearMessages.d.ts +13 -0
  13. package/lib/inAppMessaging/providers/pinpoint/apis/clearMessages.js +26 -0
  14. package/lib/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +26 -38
  15. package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -1
  16. package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.js +24 -35
  17. package/lib/inAppMessaging/providers/pinpoint/apis/index.d.ts +1 -0
  18. package/lib/inAppMessaging/providers/pinpoint/apis/index.js +13 -10
  19. package/lib/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js +21 -21
  20. package/lib/inAppMessaging/providers/pinpoint/apis/notifyMessageInteraction.js +6 -6
  21. package/lib/inAppMessaging/providers/pinpoint/apis/onMessageActionTaken.js +5 -4
  22. package/lib/inAppMessaging/providers/pinpoint/apis/onMessageDismissed.js +5 -4
  23. package/lib/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.js +5 -4
  24. package/lib/inAppMessaging/providers/pinpoint/apis/onMessageReceived.js +5 -4
  25. package/lib/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +6 -6
  26. package/lib/inAppMessaging/providers/pinpoint/apis/syncMessages.js +46 -76
  27. package/lib/inAppMessaging/providers/pinpoint/index.d.ts +1 -1
  28. package/lib/inAppMessaging/providers/pinpoint/index.js +12 -10
  29. package/lib/inAppMessaging/providers/pinpoint/types/index.js +2 -1
  30. package/lib/inAppMessaging/providers/pinpoint/types/inputs.d.ts +8 -8
  31. package/lib/inAppMessaging/providers/pinpoint/types/options.d.ts +1 -1
  32. package/lib/inAppMessaging/providers/pinpoint/types/outputs.d.ts +4 -4
  33. package/lib/inAppMessaging/providers/pinpoint/types/types.d.ts +6 -6
  34. package/lib/inAppMessaging/providers/pinpoint/types/types.js +1 -0
  35. package/lib/inAppMessaging/providers/pinpoint/utils/constants.js +1 -0
  36. package/lib/inAppMessaging/providers/pinpoint/utils/helpers.d.ts +3 -3
  37. package/lib/inAppMessaging/providers/pinpoint/utils/helpers.js +114 -110
  38. package/lib/inAppMessaging/providers/pinpoint/utils/index.js +11 -10
  39. package/lib/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js +116 -191
  40. package/lib/inAppMessaging/providers/pinpoint/utils/resolveConfig.js +9 -8
  41. package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.d.ts +1 -1
  42. package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js +9 -15
  43. package/lib/inAppMessaging/providers/pinpoint/utils/userAgent.js +6 -5
  44. package/lib/inAppMessaging/types/event.d.ts +2 -2
  45. package/lib/inAppMessaging/types/inputs.d.ts +1 -1
  46. package/lib/inAppMessaging/types/message.d.ts +3 -3
  47. package/lib/inAppMessaging/types/options.d.ts +1 -1
  48. package/lib/inAppMessaging/utils/index.js +4 -3
  49. package/lib/inAppMessaging/utils/statusHelpers.js +8 -5
  50. package/lib/index.js +1 -0
  51. package/lib/pushNotifications/errors/PushNotificationError.js +8 -11
  52. package/lib/pushNotifications/errors/errorHelpers.js +14 -13
  53. package/lib/pushNotifications/errors/index.js +4 -3
  54. package/lib/pushNotifications/index.d.ts +1 -1
  55. package/lib/pushNotifications/index.js +13 -12
  56. package/lib/pushNotifications/providers/pinpoint/apis/getBadgeCount.js +4 -2
  57. package/lib/pushNotifications/providers/pinpoint/apis/getBadgeCount.native.js +9 -10
  58. package/lib/pushNotifications/providers/pinpoint/apis/getLaunchNotification.js +4 -2
  59. package/lib/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.js +7 -5
  60. package/lib/pushNotifications/providers/pinpoint/apis/getPermissionStatus.js +4 -2
  61. package/lib/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.js +7 -5
  62. package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.js +4 -2
  63. package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.native.js +25 -36
  64. package/lib/pushNotifications/providers/pinpoint/apis/index.js +12 -11
  65. package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.js +4 -2
  66. package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.d.ts +1 -1
  67. package/lib/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js +90 -115
  68. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationOpened.js +4 -2
  69. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationOpened.native.js +7 -5
  70. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.js +4 -2
  71. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.native.js +7 -5
  72. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.js +4 -2
  73. package/lib/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.native.js +7 -5
  74. package/lib/pushNotifications/providers/pinpoint/apis/onTokenReceived.js +4 -2
  75. package/lib/pushNotifications/providers/pinpoint/apis/onTokenReceived.native.js +7 -5
  76. package/lib/pushNotifications/providers/pinpoint/apis/requestPermissions.js +4 -2
  77. package/lib/pushNotifications/providers/pinpoint/apis/requestPermissions.native.js +7 -5
  78. package/lib/pushNotifications/providers/pinpoint/apis/setBadgeCount.js +4 -2
  79. package/lib/pushNotifications/providers/pinpoint/apis/setBadgeCount.native.js +7 -5
  80. package/lib/pushNotifications/providers/pinpoint/index.d.ts +1 -1
  81. package/lib/pushNotifications/providers/pinpoint/index.js +12 -11
  82. package/lib/pushNotifications/providers/pinpoint/types/analytics.d.ts +3 -3
  83. package/lib/pushNotifications/providers/pinpoint/types/apis.d.ts +11 -11
  84. package/lib/pushNotifications/providers/pinpoint/types/inputs.d.ts +7 -7
  85. package/lib/pushNotifications/providers/pinpoint/types/options.d.ts +1 -1
  86. package/lib/pushNotifications/providers/pinpoint/types/outputs.d.ts +8 -8
  87. package/lib/pushNotifications/providers/pinpoint/types/pushNotifications.d.ts +1 -1
  88. package/lib/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.d.ts +3 -2
  89. package/lib/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.js +33 -49
  90. package/lib/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.d.ts +3 -2
  91. package/lib/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js +17 -13
  92. package/lib/pushNotifications/providers/pinpoint/utils/getChannelType.d.ts +2 -1
  93. package/lib/pushNotifications/providers/pinpoint/utils/getChannelType.js +9 -7
  94. package/lib/pushNotifications/providers/pinpoint/utils/index.d.ts +2 -1
  95. package/lib/pushNotifications/providers/pinpoint/utils/index.js +7 -4
  96. package/lib/pushNotifications/providers/pinpoint/utils/resolveConfig.js +17 -0
  97. package/lib/pushNotifications/types/errors.js +1 -0
  98. package/lib/pushNotifications/types/index.d.ts +1 -0
  99. package/lib/pushNotifications/types/index.js +20 -2
  100. package/lib/pushNotifications/types/inputs.d.ts +9 -8
  101. package/lib/pushNotifications/types/module.d.ts +31 -0
  102. package/lib/pushNotifications/types/options.d.ts +1 -1
  103. package/lib/pushNotifications/types/outputs.d.ts +8 -8
  104. package/lib/pushNotifications/types/pushNotifications.d.ts +4 -5
  105. package/lib/pushNotifications/utils/getPushNotificationUserAgentString.js +11 -0
  106. package/lib/pushNotifications/utils/index.d.ts +1 -1
  107. package/lib/pushNotifications/utils/index.js +8 -7
  108. package/lib/pushNotifications/utils/initializationManager.js +8 -9
  109. package/lib/pushNotifications/utils/resolveCredentials.d.ts +1 -1
  110. package/lib/pushNotifications/utils/resolveCredentials.js +9 -15
  111. package/lib/pushNotifications/utils/tokenManager.js +6 -3
  112. package/lib/tsconfig.tsbuildinfo +1 -0
  113. package/lib-esm/eventListeners/eventListeners.js +15 -37
  114. package/lib-esm/eventListeners/types.d.ts +2 -2
  115. package/lib-esm/eventListeners/types.js +1 -0
  116. package/lib-esm/inAppMessaging/errors/InAppMessagingError.js +6 -11
  117. package/lib-esm/inAppMessaging/errors/assertValidationError.js +2 -2
  118. package/lib-esm/inAppMessaging/errors/validation.js +6 -7
  119. package/lib-esm/inAppMessaging/index.d.ts +2 -1
  120. package/lib-esm/inAppMessaging/index.js +1 -1
  121. package/lib-esm/inAppMessaging/providers/pinpoint/apis/clearMessages.d.ts +13 -0
  122. package/lib-esm/inAppMessaging/providers/pinpoint/apis/clearMessages.js +22 -0
  123. package/lib-esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +15 -31
  124. package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -1
  125. package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.js +18 -31
  126. package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.d.ts +1 -0
  127. package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.js +1 -0
  128. package/lib-esm/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js +5 -6
  129. package/lib-esm/inAppMessaging/providers/pinpoint/apis/notifyMessageInteraction.js +1 -2
  130. package/lib-esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +4 -5
  131. package/lib-esm/inAppMessaging/providers/pinpoint/apis/syncMessages.js +38 -69
  132. package/lib-esm/inAppMessaging/providers/pinpoint/index.d.ts +1 -1
  133. package/lib-esm/inAppMessaging/providers/pinpoint/index.js +1 -1
  134. package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.d.ts +8 -8
  135. package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.js +1 -0
  136. package/lib-esm/inAppMessaging/providers/pinpoint/types/options.d.ts +1 -1
  137. package/lib-esm/inAppMessaging/providers/pinpoint/types/options.js +1 -0
  138. package/lib-esm/inAppMessaging/providers/pinpoint/types/outputs.d.ts +4 -4
  139. package/lib-esm/inAppMessaging/providers/pinpoint/types/outputs.js +1 -0
  140. package/lib-esm/inAppMessaging/providers/pinpoint/types/types.d.ts +6 -6
  141. package/lib-esm/inAppMessaging/providers/pinpoint/utils/constants.js +4 -4
  142. package/lib-esm/inAppMessaging/providers/pinpoint/utils/helpers.d.ts +3 -3
  143. package/lib-esm/inAppMessaging/providers/pinpoint/utils/helpers.js +85 -97
  144. package/lib-esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js +111 -187
  145. package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveConfig.js +3 -4
  146. package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.d.ts +1 -1
  147. package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js +5 -13
  148. package/lib-esm/inAppMessaging/providers/pinpoint/utils/userAgent.js +2 -2
  149. package/lib-esm/inAppMessaging/types/event.d.ts +2 -2
  150. package/lib-esm/inAppMessaging/types/event.js +1 -0
  151. package/lib-esm/inAppMessaging/types/index.js +1 -0
  152. package/lib-esm/inAppMessaging/types/inputs.d.ts +1 -1
  153. package/lib-esm/inAppMessaging/types/inputs.js +1 -0
  154. package/lib-esm/inAppMessaging/types/message.d.ts +3 -3
  155. package/lib-esm/inAppMessaging/types/message.js +1 -0
  156. package/lib-esm/inAppMessaging/types/options.d.ts +1 -1
  157. package/lib-esm/inAppMessaging/types/options.js +1 -0
  158. package/lib-esm/inAppMessaging/utils/statusHelpers.js +3 -3
  159. package/lib-esm/index.js +1 -0
  160. package/lib-esm/pushNotifications/errors/PushNotificationError.js +6 -11
  161. package/lib-esm/pushNotifications/errors/errorHelpers.js +8 -9
  162. package/lib-esm/pushNotifications/index.d.ts +1 -1
  163. package/lib-esm/pushNotifications/providers/pinpoint/apis/getBadgeCount.js +1 -1
  164. package/lib-esm/pushNotifications/providers/pinpoint/apis/getBadgeCount.native.js +5 -8
  165. package/lib-esm/pushNotifications/providers/pinpoint/apis/getLaunchNotification.js +1 -1
  166. package/lib-esm/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.js +2 -2
  167. package/lib-esm/pushNotifications/providers/pinpoint/apis/getPermissionStatus.js +1 -1
  168. package/lib-esm/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.js +2 -2
  169. package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.js +1 -1
  170. package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.native.js +20 -33
  171. package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.js +1 -1
  172. package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.d.ts +1 -1
  173. package/lib-esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js +76 -103
  174. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationOpened.js +1 -1
  175. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationOpened.native.js +1 -1
  176. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.js +1 -1
  177. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.native.js +1 -1
  178. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.js +1 -1
  179. package/lib-esm/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.native.js +1 -1
  180. package/lib-esm/pushNotifications/providers/pinpoint/apis/onTokenReceived.js +1 -1
  181. package/lib-esm/pushNotifications/providers/pinpoint/apis/onTokenReceived.native.js +1 -1
  182. package/lib-esm/pushNotifications/providers/pinpoint/apis/requestPermissions.js +1 -1
  183. package/lib-esm/pushNotifications/providers/pinpoint/apis/requestPermissions.native.js +2 -2
  184. package/lib-esm/pushNotifications/providers/pinpoint/apis/setBadgeCount.js +1 -1
  185. package/lib-esm/pushNotifications/providers/pinpoint/apis/setBadgeCount.native.js +2 -2
  186. package/lib-esm/pushNotifications/providers/pinpoint/index.d.ts +1 -1
  187. package/lib-esm/pushNotifications/providers/pinpoint/types/analytics.d.ts +3 -3
  188. package/lib-esm/pushNotifications/providers/pinpoint/types/analytics.js +1 -0
  189. package/lib-esm/pushNotifications/providers/pinpoint/types/apis.d.ts +11 -11
  190. package/lib-esm/pushNotifications/providers/pinpoint/types/apis.js +1 -0
  191. package/lib-esm/pushNotifications/providers/pinpoint/types/index.js +1 -0
  192. package/lib-esm/pushNotifications/providers/pinpoint/types/inputs.d.ts +7 -7
  193. package/lib-esm/pushNotifications/providers/pinpoint/types/inputs.js +1 -0
  194. package/lib-esm/pushNotifications/providers/pinpoint/types/options.d.ts +1 -1
  195. package/lib-esm/pushNotifications/providers/pinpoint/types/options.js +1 -0
  196. package/lib-esm/pushNotifications/providers/pinpoint/types/outputs.d.ts +8 -8
  197. package/lib-esm/pushNotifications/providers/pinpoint/types/outputs.js +1 -0
  198. package/lib-esm/pushNotifications/providers/pinpoint/types/pushNotifications.d.ts +1 -1
  199. package/lib-esm/pushNotifications/providers/pinpoint/types/pushNotifications.js +1 -0
  200. package/lib-esm/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.d.ts +3 -2
  201. package/lib-esm/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.js +27 -45
  202. package/lib-esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.d.ts +3 -2
  203. package/lib-esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js +15 -13
  204. package/lib-esm/pushNotifications/providers/pinpoint/utils/getChannelType.d.ts +2 -1
  205. package/lib-esm/pushNotifications/providers/pinpoint/utils/getChannelType.js +5 -5
  206. package/lib-esm/pushNotifications/providers/pinpoint/utils/index.d.ts +2 -1
  207. package/lib-esm/pushNotifications/providers/pinpoint/utils/index.js +2 -1
  208. package/lib-esm/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.js +4 -5
  209. package/lib-esm/pushNotifications/types/index.d.ts +1 -0
  210. package/lib-esm/pushNotifications/types/index.js +5 -0
  211. package/lib-esm/pushNotifications/types/inputs.d.ts +9 -8
  212. package/lib-esm/pushNotifications/types/inputs.js +1 -0
  213. package/lib-esm/pushNotifications/types/module.d.ts +31 -0
  214. package/lib-esm/pushNotifications/{Platform/types.js → types/module.js} +1 -0
  215. package/lib-esm/pushNotifications/types/options.d.ts +1 -1
  216. package/lib-esm/pushNotifications/types/options.js +1 -0
  217. package/lib-esm/pushNotifications/types/outputs.d.ts +8 -8
  218. package/lib-esm/pushNotifications/types/outputs.js +1 -0
  219. package/lib-esm/pushNotifications/types/pushNotifications.d.ts +4 -5
  220. package/lib-esm/pushNotifications/types/pushNotifications.js +1 -0
  221. package/lib-esm/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.js +4 -6
  222. package/lib-esm/pushNotifications/utils/index.d.ts +1 -1
  223. package/lib-esm/pushNotifications/utils/index.js +1 -1
  224. package/lib-esm/pushNotifications/utils/initializationManager.js +5 -9
  225. package/lib-esm/pushNotifications/utils/resolveCredentials.d.ts +1 -1
  226. package/lib-esm/pushNotifications/utils/resolveCredentials.js +5 -13
  227. package/lib-esm/pushNotifications/utils/tokenManager.js +3 -3
  228. package/lib-esm/tsconfig.tsbuildinfo +1 -0
  229. package/package.json +63 -30
  230. package/src/inAppMessaging/index.ts +12 -0
  231. package/src/inAppMessaging/providers/pinpoint/apis/clearMessages.ts +26 -0
  232. package/src/inAppMessaging/providers/pinpoint/apis/index.ts +1 -0
  233. package/src/inAppMessaging/providers/pinpoint/index.ts +1 -0
  234. package/src/inAppMessaging/providers/pinpoint/utils/helpers.ts +38 -28
  235. package/src/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.ts +25 -9
  236. package/src/inAppMessaging/providers/pinpoint/utils/resolveConfig.ts +1 -1
  237. package/src/pushNotifications/index.ts +1 -0
  238. package/src/pushNotifications/providers/pinpoint/apis/getBadgeCount.ts +1 -1
  239. package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.ts +1 -1
  240. package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.ts +1 -1
  241. package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.ts +1 -1
  242. package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.ts +1 -1
  243. package/src/pushNotifications/providers/pinpoint/apis/identifyUser.native.ts +5 -2
  244. package/src/pushNotifications/providers/pinpoint/apis/identifyUser.ts +1 -1
  245. package/src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.ts +51 -41
  246. package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.native.ts +1 -1
  247. package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.ts +1 -1
  248. package/src/pushNotifications/providers/pinpoint/index.ts +1 -0
  249. package/src/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.ts +5 -4
  250. package/src/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.ts +7 -4
  251. package/src/pushNotifications/providers/pinpoint/utils/getChannelType.ts +1 -1
  252. package/src/pushNotifications/providers/pinpoint/utils/index.ts +2 -1
  253. package/src/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.ts +2 -2
  254. package/src/pushNotifications/types/index.ts +1 -0
  255. package/src/pushNotifications/types/inputs.ts +1 -1
  256. package/src/pushNotifications/types/module.ts +42 -0
  257. package/src/pushNotifications/types/outputs.ts +1 -1
  258. package/src/pushNotifications/types/pushNotifications.ts +2 -7
  259. package/src/pushNotifications/utils/index.ts +1 -1
  260. package/lib/inAppMessaging/providers/index.d.ts +0 -2
  261. package/lib/inAppMessaging/providers/index.js +0 -15
  262. package/lib/pushNotifications/Platform/index.d.ts +0 -2
  263. package/lib/pushNotifications/Platform/index.js +0 -25
  264. package/lib/pushNotifications/Platform/index.native.d.ts +0 -2
  265. package/lib/pushNotifications/Platform/index.native.js +0 -7
  266. package/lib/pushNotifications/Platform/types.d.ts +0 -5
  267. package/lib/pushNotifications/providers/pinpoint/utils/getPushNotificationUserAgentString.js +0 -11
  268. package/lib/pushNotifications/utils/resolveConfig.js +0 -16
  269. package/lib/tsconfig.build.tsbuildinfo +0 -8667
  270. package/lib-esm/inAppMessaging/providers/index.d.ts +0 -2
  271. package/lib-esm/inAppMessaging/providers/index.js +0 -3
  272. package/lib-esm/pushNotifications/Platform/index.d.ts +0 -2
  273. package/lib-esm/pushNotifications/Platform/index.js +0 -23
  274. package/lib-esm/pushNotifications/Platform/index.native.d.ts +0 -2
  275. package/lib-esm/pushNotifications/Platform/index.native.js +0 -5
  276. package/lib-esm/pushNotifications/Platform/types.d.ts +0 -5
  277. package/lib-esm/tsconfig.build.tsbuildinfo +0 -7115
  278. package/src/inAppMessaging/providers/index.ts +0 -38
  279. package/src/pushNotifications/Platform/index.native.ts +0 -9
  280. package/src/pushNotifications/Platform/index.ts +0 -22
  281. package/src/pushNotifications/Platform/types.ts +0 -15
  282. /package/lib/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.d.ts +0 -0
  283. /package/lib/pushNotifications/{Platform/types.js → types/module.js} +0 -0
  284. /package/lib/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.d.ts +0 -0
  285. /package/lib-esm/pushNotifications/{utils → providers/pinpoint/utils}/resolveConfig.d.ts +0 -0
  286. /package/lib-esm/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.d.ts +0 -0
  287. /package/src/pushNotifications/{providers/pinpoint/utils → utils}/getPushNotificationUserAgentString.ts +0 -0
@@ -22,9 +22,9 @@ import { getInAppMessagingUserAgentString } from './userAgent';
22
22
 
23
23
  const DELIVERY_TYPE = 'IN_APP_MESSAGE';
24
24
 
25
- let eventNameMemo = {};
26
- let eventAttributesMemo = {};
27
- let eventMetricsMemo = {};
25
+ let eventNameMemo: Record<string, boolean> = {};
26
+ let eventAttributesMemo: Record<string, boolean> = {};
27
+ let eventMetricsMemo: Record<string, boolean> = {};
28
28
 
29
29
  export const logger = new ConsoleLogger('InAppMessaging.Pinpoint.Utils');
30
30
 
@@ -44,7 +44,8 @@ export const recordAnalyticsEvent = (
44
44
  event: {
45
45
  name: event,
46
46
  attributes: {
47
- campaign_id: id,
47
+ // only include campaign_id field if we have one
48
+ ...(id && { campaign_id: id }),
48
49
  delivery_type: DELIVERY_TYPE,
49
50
  treatment_id: metadata?.treatmentId,
50
51
  },
@@ -52,7 +53,7 @@ export const recordAnalyticsEvent = (
52
53
  identityId,
53
54
  region,
54
55
  userAgentValue: getInAppMessagingUserAgentString(
55
- InAppMessagingAction.DispatchEvent
56
+ InAppMessagingAction.NotifyMessageInteraction
56
57
  ),
57
58
  });
58
59
  })
@@ -72,19 +73,19 @@ export const matchesEventType = (
72
73
  { CampaignId, Schedule }: PinpointInAppMessage,
73
74
  { name: eventType }: InAppMessagingEvent
74
75
  ) => {
75
- const { EventType } = Schedule?.EventFilter?.Dimensions;
76
+ const { EventType } = Schedule?.EventFilter?.Dimensions ?? {};
76
77
  const memoKey = `${CampaignId}:${eventType}`;
77
78
  if (!eventNameMemo.hasOwnProperty(memoKey)) {
78
- eventNameMemo[memoKey] = !!EventType?.Values.includes(eventType);
79
+ eventNameMemo[memoKey] = !!EventType?.Values?.includes(eventType);
79
80
  }
80
81
  return eventNameMemo[memoKey];
81
82
  };
82
83
 
83
84
  export const matchesAttributes = (
84
85
  { CampaignId, Schedule }: PinpointInAppMessage,
85
- { attributes }: InAppMessagingEvent
86
+ { attributes = {} }: InAppMessagingEvent
86
87
  ): boolean => {
87
- const { Attributes } = Schedule?.EventFilter?.Dimensions;
88
+ const { Attributes } = Schedule?.EventFilter?.Dimensions ?? {};
88
89
  if (isEmpty(Attributes)) {
89
90
  // if message does not have attributes defined it does not matter what attributes are on the event
90
91
  return true;
@@ -95,18 +96,20 @@ export const matchesAttributes = (
95
96
  }
96
97
  const memoKey = `${CampaignId}:${JSON.stringify(attributes)}`;
97
98
  if (!eventAttributesMemo.hasOwnProperty(memoKey)) {
98
- eventAttributesMemo[memoKey] = Object.entries(Attributes).every(
99
- ([key, { Values }]) => Values.includes(attributes[key])
100
- );
99
+ eventAttributesMemo[memoKey] =
100
+ !Attributes ||
101
+ Object.entries(Attributes).every(([key, { Values }]) =>
102
+ Values?.includes(attributes[key])
103
+ );
101
104
  }
102
105
  return eventAttributesMemo[memoKey];
103
106
  };
104
107
 
105
108
  export const matchesMetrics = (
106
109
  { CampaignId, Schedule }: PinpointInAppMessage,
107
- { metrics }: InAppMessagingEvent
110
+ { metrics = {} }: InAppMessagingEvent
108
111
  ): boolean => {
109
- const { Metrics } = Schedule?.EventFilter?.Dimensions;
112
+ const { Metrics } = Schedule?.EventFilter?.Dimensions ?? {};
110
113
  if (isEmpty(Metrics)) {
111
114
  // if message does not have metrics defined it does not matter what metrics are on the event
112
115
  return true;
@@ -117,18 +120,20 @@ export const matchesMetrics = (
117
120
  }
118
121
  const memoKey = `${CampaignId}:${JSON.stringify(metrics)}`;
119
122
  if (!eventMetricsMemo.hasOwnProperty(memoKey)) {
120
- eventMetricsMemo[memoKey] = Object.entries(Metrics).every(
121
- ([key, { ComparisonOperator, Value }]) => {
123
+ eventMetricsMemo[memoKey] =
124
+ !Metrics ||
125
+ Object.entries(Metrics).every(([key, { ComparisonOperator, Value }]) => {
122
126
  const compare = getComparator(ComparisonOperator);
123
127
  // if there is some unknown comparison operator, treat as a comparison failure
124
- return compare ? compare(Value, metrics[key]) : false;
125
- }
126
- );
128
+ return compare && !!Value ? compare(Value, metrics[key]) : false;
129
+ });
127
130
  }
128
131
  return eventMetricsMemo[memoKey];
129
132
  };
130
133
 
131
- export const getComparator = (operator: string): MetricsComparator => {
134
+ export const getComparator = (
135
+ operator?: string
136
+ ): MetricsComparator | undefined => {
132
137
  switch (operator) {
133
138
  case 'EQUAL':
134
139
  return (metricsVal, eventVal) => metricsVal === eventVal;
@@ -141,7 +146,7 @@ export const getComparator = (operator: string): MetricsComparator => {
141
146
  case 'LESS_THAN_OR_EQUAL':
142
147
  return (metricsVal, eventVal) => metricsVal >= eventVal;
143
148
  default:
144
- return null;
149
+ return undefined;
145
150
  }
146
151
  };
147
152
 
@@ -218,8 +223,9 @@ export const clearMemo = () => {
218
223
  // - 1. the usage of MOBILE_FEED and OVERLAYS as values for message layouts are not leaked
219
224
  // outside the Pinpoint provider
220
225
  // - 2. Amplify correctly handles the legacy layout values from Pinpoint after they are updated
226
+
221
227
  export const interpretLayout = (
222
- layout: PinpointInAppMessage['InAppMessage']['Layout']
228
+ layout: NonNullable<PinpointInAppMessage['InAppMessage']>['Layout']
223
229
  ): InAppMessageLayout => {
224
230
  if (layout === 'MOBILE_FEED') {
225
231
  return 'MODAL';
@@ -258,21 +264,23 @@ export const extractContent = ({
258
264
  }
259
265
  if (HeaderConfig) {
260
266
  extractedContent.header = {
261
- content: HeaderConfig.Header,
267
+ // Default to empty string in rare cases we don't have a Header value
268
+ content: HeaderConfig.Header ?? '',
262
269
  style: {
263
270
  color: HeaderConfig.TextColor,
264
271
  textAlign:
265
- HeaderConfig.Alignment.toLowerCase() as InAppMessageTextAlign,
272
+ HeaderConfig.Alignment?.toLowerCase() as InAppMessageTextAlign,
266
273
  },
267
274
  };
268
275
  }
269
276
  if (BodyConfig) {
270
277
  extractedContent.body = {
271
- content: BodyConfig.Body,
278
+ // Default to empty string in rare cases we don't have a Body value
279
+ content: BodyConfig.Body ?? '',
272
280
  style: {
273
281
  color: BodyConfig.TextColor,
274
282
  textAlign:
275
- BodyConfig.Alignment.toLowerCase() as InAppMessageTextAlign,
283
+ BodyConfig.Alignment?.toLowerCase() as InAppMessageTextAlign,
276
284
  },
277
285
  };
278
286
  }
@@ -283,7 +291,8 @@ export const extractContent = ({
283
291
  }
284
292
  if (defaultPrimaryButton) {
285
293
  extractedContent.primaryButton = {
286
- title: defaultPrimaryButton.Text,
294
+ // Default to empty string in rare cases we don't have a Text value
295
+ title: defaultPrimaryButton.Text ?? '',
287
296
  action: defaultPrimaryButton.ButtonAction as InAppMessageAction,
288
297
  url: defaultPrimaryButton.Link,
289
298
  style: {
@@ -295,7 +304,8 @@ export const extractContent = ({
295
304
  }
296
305
  if (defaultSecondaryButton) {
297
306
  extractedContent.secondaryButton = {
298
- title: defaultSecondaryButton.Text,
307
+ // Default to empty string in rare cases we don't have a Text value
308
+ title: defaultSecondaryButton.Text ?? '',
299
309
  action: defaultSecondaryButton.ButtonAction as InAppMessageAction,
300
310
  url: defaultSecondaryButton.Link,
301
311
  style: {
@@ -30,7 +30,7 @@ export async function processInAppMessages(
30
30
  messages: PinpointInAppMessage[],
31
31
  event: InAppMessagingEvent
32
32
  ): Promise<InAppMessage[]> {
33
- let highestPrioritySeen: number;
33
+ let highestPrioritySeen: number | undefined;
34
34
  let acc: PinpointInAppMessage[] = [];
35
35
  for (let index = 0; index < messages.length; index++) {
36
36
  const message = messages[index];
@@ -88,9 +88,13 @@ function normalizeMessages(messages: PinpointInAppMessage[]): InAppMessage[] {
88
88
  return messages.map(message => {
89
89
  const { CampaignId, InAppMessage } = message;
90
90
  return {
91
- id: CampaignId,
91
+ // Default to empty string in rare cases we don't have a campaignId
92
+ id: CampaignId ?? '',
92
93
  content: extractContent(message),
93
- layout: interpretLayout(InAppMessage.Layout),
94
+ // Default to TOP_BANNER layout in rare cases we don't have a Layout
95
+ layout: InAppMessage?.Layout
96
+ ? interpretLayout(InAppMessage.Layout)
97
+ : 'TOP_BANNER',
94
98
  metadata: extractMetadata(message),
95
99
  };
96
100
  });
@@ -114,16 +118,28 @@ async function isBelowCap({
114
118
  }
115
119
 
116
120
  async function getMessageCounts(
117
- messageId: string
121
+ messageId?: string
118
122
  ): Promise<InAppMessageCounts> {
123
+ let messageCounts = {
124
+ sessionCount: 0,
125
+ dailyCount: 0,
126
+ totalCount: 0,
127
+ };
119
128
  try {
120
- return {
121
- sessionCount: getSessionCount(messageId),
122
- dailyCount: await getDailyCount(),
123
- totalCount: await getTotalCount(messageId),
124
- };
129
+ // only return true counts if there is a messageId else default to 0
130
+ if (messageId)
131
+ messageCounts = {
132
+ sessionCount: getSessionCount(messageId),
133
+ dailyCount: await getDailyCount(),
134
+ totalCount: await getTotalCount(messageId),
135
+ };
136
+ return messageCounts;
125
137
  } catch (err) {
126
138
  logger.error('Failed to get message counts from storage', err);
139
+
140
+ // If there are no cached counts or there is an error,
141
+ // we default to 0 allowing all the messages to be eligible
142
+ return messageCounts;
127
143
  }
128
144
  }
129
145
 
@@ -12,7 +12,7 @@ import {
12
12
  */
13
13
  export const resolveConfig = () => {
14
14
  const { appId, region } =
15
- Amplify.getConfig().Notifications?.InAppMessaging.Pinpoint ?? {};
15
+ Amplify.getConfig().Notifications?.InAppMessaging?.Pinpoint ?? {};
16
16
  assertValidationError(!!appId, InAppMessagingValidationErrorCode.NoAppId);
17
17
  assertValidationError(!!region, InAppMessagingValidationErrorCode.NoRegion);
18
18
  return { appId, region };
@@ -3,6 +3,7 @@
3
3
 
4
4
  export {
5
5
  getBadgeCount,
6
+ GetBadgeCountOutput,
6
7
  getLaunchNotification,
7
8
  GetLaunchNotificationOutput,
8
9
  getPermissionStatus,
@@ -16,6 +16,6 @@ import { GetBadgeCount } from '../types';
16
16
  * const badgeCount = await getBadgeCount();
17
17
  * ```
18
18
  */
19
- export const getBadgeCount: GetBadgeCount = () => {
19
+ export const getBadgeCount: GetBadgeCount = async () => {
20
20
  throw new PlatformNotSupportedError();
21
21
  };
@@ -8,7 +8,7 @@ import { GetLaunchNotification } from '../types';
8
8
  const { getLaunchNotification: getLaunchNotificationNative } =
9
9
  loadAmplifyPushNotification();
10
10
 
11
- export const getLaunchNotification: GetLaunchNotification = () => {
11
+ export const getLaunchNotification: GetLaunchNotification = async () => {
12
12
  assertIsInitialized();
13
13
  return getLaunchNotificationNative();
14
14
  };
@@ -21,6 +21,6 @@ import { GetLaunchNotification, GetLaunchNotificationOutput } from '../types';
21
21
  * const launchNotification = await getLaunchNotification();
22
22
  * ```
23
23
  */
24
- export const getLaunchNotification: GetLaunchNotification = () => {
24
+ export const getLaunchNotification: GetLaunchNotification = async () => {
25
25
  throw new PlatformNotSupportedError();
26
26
  };
@@ -8,7 +8,7 @@ import { GetPermissionStatus } from '../types';
8
8
  const { getPermissionStatus: getPermissionStatusNative } =
9
9
  loadAmplifyPushNotification();
10
10
 
11
- export const getPermissionStatus: GetPermissionStatus = () => {
11
+ export const getPermissionStatus: GetPermissionStatus = async () => {
12
12
  assertIsInitialized();
13
13
  return getPermissionStatusNative();
14
14
  };
@@ -29,6 +29,6 @@ import { GetPermissionStatus, GetPermissionStatusOutput } from '../types';
29
29
  * ```ts
30
30
  * const permissionStatus = await getPermissionStatus();
31
31
  */
32
- export const getPermissionStatus: GetPermissionStatus = () => {
32
+ export const getPermissionStatus: GetPermissionStatus = async () => {
33
33
  throw new PlatformNotSupportedError();
34
34
  };
@@ -4,8 +4,11 @@
4
4
  import { PushNotificationAction } from '@aws-amplify/core/internals/utils';
5
5
  import { updateEndpoint } from '@aws-amplify/core/internals/providers/pinpoint';
6
6
  import { assertIsInitialized } from '../../../errors/errorHelpers';
7
- import { resolveConfig, resolveCredentials } from '../../../utils';
8
- import { getChannelType, getPushNotificationUserAgentString } from '../utils';
7
+ import {
8
+ getPushNotificationUserAgentString,
9
+ resolveCredentials,
10
+ } from '../../../utils';
11
+ import { getChannelType, resolveConfig } from '../utils';
9
12
  import { IdentifyUser } from '../types';
10
13
 
11
14
  export const identifyUser: IdentifyUser = async ({
@@ -57,6 +57,6 @@ import { IdentifyUser, IdentifyUserInput } from '../types';
57
57
  * },
58
58
  * });
59
59
  */
60
- export const identifyUser: IdentifyUser = () => {
60
+ export const identifyUser: IdentifyUser = async () => {
61
61
  throw new PlatformNotSupportedError();
62
62
  };
@@ -12,17 +12,17 @@ import {
12
12
  notifyEventListenersAndAwaitHandlers,
13
13
  } from '../../../../eventListeners';
14
14
  import {
15
+ getPushNotificationUserAgentString,
15
16
  getToken,
16
17
  initialize,
17
18
  isInitialized,
18
- resolveConfig,
19
19
  resolveCredentials,
20
20
  setToken,
21
21
  } from '../../../utils';
22
22
  import {
23
23
  createMessageEventRecorder,
24
24
  getChannelType,
25
- getPushNotificationUserAgentString,
25
+ resolveConfig,
26
26
  } from '../utils';
27
27
 
28
28
  const {
@@ -37,7 +37,7 @@ const logger = new ConsoleLogger('Notifications.PushNotification');
37
37
 
38
38
  const BACKGROUND_TASK_TIMEOUT = 25; // seconds
39
39
 
40
- export const initializePushNotifications = (): Promise<void> => {
40
+ export const initializePushNotifications = (): void => {
41
41
  if (isInitialized()) {
42
42
  logger.info('Push notifications have already been enabled');
43
43
  return;
@@ -47,37 +47,10 @@ export const initializePushNotifications = (): Promise<void> => {
47
47
  initialize();
48
48
  };
49
49
 
50
- const addAnalyticsListeners = (): void => {
51
- let launchNotificationOpenedListenerRemover: EventListenerRemover;
52
-
53
- // wire up default Pinpoint message event handling
54
- addEventListener(
55
- 'backgroundMessageReceived',
56
- createMessageEventRecorder('backgroundMessageReceived')
57
- );
58
- addEventListener(
59
- 'foregroundMessageReceived',
60
- createMessageEventRecorder('foregroundMessageReceived')
61
- );
62
- launchNotificationOpenedListenerRemover = addEventListener(
63
- 'launchNotificationsOpened',
64
- createMessageEventRecorder(
65
- 'notificationOpened',
66
- // once we are done with it we can remove the listener
67
- launchNotificationOpenedListenerRemover?.remove
68
- )
69
- );
70
- addEventListener(
71
- 'notificationOpened',
72
- createMessageEventRecorder(
73
- 'notificationOpened',
74
- // if we are in this state, we no longer need the listener as the app was launched via some other means
75
- launchNotificationOpenedListenerRemover?.remove
76
- )
77
- );
78
- };
79
-
80
50
  const addNativeListeners = (): void => {
51
+ let launchNotificationOpenedListener: ReturnType<
52
+ typeof addMessageEventListener
53
+ > | null;
81
54
  const { NativeEvent, NativeHeadlessTaskKey } = getConstants();
82
55
  const {
83
56
  BACKGROUND_MESSAGE_RECEIVED,
@@ -126,7 +99,9 @@ const addNativeListeners = (): void => {
126
99
  logger.error(err);
127
100
  } finally {
128
101
  // notify native module that handlers have completed their work (or timed out)
129
- completeNotification(completionHandlerId);
102
+ if (completionHandlerId) {
103
+ completeNotification(completionHandlerId);
104
+ }
130
105
  }
131
106
  }
132
107
  );
@@ -140,14 +115,14 @@ const addNativeListeners = (): void => {
140
115
  }
141
116
  );
142
117
 
143
- const launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED
118
+ launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED
144
119
  ? addMessageEventListener(
145
120
  // listen for native notification opened app (user tapped on notification, opening the app from quit -
146
121
  // not background - state) event. This is broadcasted to an internal listener only as it is not intended
147
122
  // for use otherwise as it produces inconsistent results when used within React Native app context
148
123
  LAUNCH_NOTIFICATION_OPENED,
149
124
  message => {
150
- notifyEventListeners('launchNotificationsOpened', message);
125
+ notifyEventListeners('launchNotificationOpened', message);
151
126
  // once we are done with it we can remove the listener
152
127
  launchNotificationOpenedListener?.remove();
153
128
  }
@@ -169,23 +144,58 @@ const addNativeListeners = (): void => {
169
144
  // listen for native new token event, automatically re-register device with provider using new token and
170
145
  // broadcast to library listeners
171
146
  TOKEN_RECEIVED,
172
- token => {
147
+ async token => {
173
148
  // avoid a race condition where two endpoints are created with the same token on a fresh install
174
149
  if (getToken() === token) {
175
150
  return;
176
151
  }
177
152
  setToken(token);
178
- registerDevice();
179
153
  notifyEventListeners('tokenReceived', token);
154
+ try {
155
+ await registerDevice(token);
156
+ } catch (err) {
157
+ logger.error('Failed to register device for push notifications', err);
158
+ throw err;
159
+ }
180
160
  }
181
161
  );
182
162
  };
183
163
 
184
- const registerDevice = async (): Promise<void> => {
164
+ const addAnalyticsListeners = (): void => {
165
+ let launchNotificationOpenedListenerRemover: EventListenerRemover | undefined;
166
+
167
+ // wire up default Pinpoint message event handling
168
+ addEventListener(
169
+ 'backgroundMessageReceived',
170
+ createMessageEventRecorder('received_background')
171
+ );
172
+ addEventListener(
173
+ 'foregroundMessageReceived',
174
+ createMessageEventRecorder('received_foreground')
175
+ );
176
+ launchNotificationOpenedListenerRemover = addEventListener(
177
+ 'launchNotificationOpened',
178
+ createMessageEventRecorder(
179
+ 'opened_notification',
180
+ // once we are done with it we can remove the listener
181
+ launchNotificationOpenedListenerRemover?.remove
182
+ )
183
+ );
184
+ addEventListener(
185
+ 'notificationOpened',
186
+ createMessageEventRecorder(
187
+ 'opened_notification',
188
+ // if we are in this state, we no longer need the listener as the app was launched via some other means
189
+ launchNotificationOpenedListenerRemover?.remove
190
+ )
191
+ );
192
+ };
193
+
194
+ const registerDevice = async (address: string): Promise<void> => {
185
195
  const { credentials, identityId } = await resolveCredentials();
186
196
  const { appId, region } = resolveConfig();
187
- return updateEndpoint({
188
- address: getToken(),
197
+ await updateEndpoint({
198
+ address,
189
199
  appId,
190
200
  category: 'PushNotification',
191
201
  credentials,
@@ -8,7 +8,7 @@ import { RequestPermissions } from '../types';
8
8
  const { requestPermissions: requestPermissionsNative } =
9
9
  loadAmplifyPushNotification();
10
10
 
11
- export const requestPermissions: RequestPermissions = input => {
11
+ export const requestPermissions: RequestPermissions = async input => {
12
12
  assertIsInitialized();
13
13
  return requestPermissionsNative(input);
14
14
  };
@@ -34,6 +34,6 @@ import { RequestPermissions } from '../types';
34
34
  * });
35
35
  * ```
36
36
  */
37
- export const requestPermissions: RequestPermissions = () => {
37
+ export const requestPermissions: RequestPermissions = async () => {
38
38
  throw new PlatformNotSupportedError();
39
39
  };
@@ -24,6 +24,7 @@ export {
24
24
  SetBadgeCountInput,
25
25
  } from './types/inputs';
26
26
  export {
27
+ GetBadgeCountOutput,
27
28
  GetLaunchNotificationOutput,
28
29
  GetPermissionStatusOutput,
29
30
  OnNotificationOpenedOutput,
@@ -4,14 +4,15 @@
4
4
  import { record } from '@aws-amplify/core/internals/providers/pinpoint';
5
5
  import { ConsoleLogger } from '@aws-amplify/core';
6
6
  import { AWSCredentials } from '@aws-amplify/core/internals/utils';
7
+ import { PinpointMessageEvent } from '../types';
7
8
  import {
8
9
  OnPushNotificationMessageHandler,
9
- PushNotificationEvent,
10
10
  PushNotificationMessage,
11
11
  } from '../../../types';
12
+ import { resolveCredentials } from '../../../utils';
12
13
  import { getAnalyticsEvent } from './getAnalyticsEvent';
13
14
  import { getChannelType } from './getChannelType';
14
- import { resolveConfig, resolveCredentials } from '../../../utils';
15
+ import { resolveConfig } from './resolveConfig';
15
16
 
16
17
  const logger = new ConsoleLogger('PushNotification.recordMessageEvent');
17
18
 
@@ -20,7 +21,7 @@ const logger = new ConsoleLogger('PushNotification.recordMessageEvent');
20
21
  */
21
22
  export const createMessageEventRecorder =
22
23
  (
23
- event: PushNotificationEvent,
24
+ event: PinpointMessageEvent,
24
25
  callback?: Function
25
26
  ): OnPushNotificationMessageHandler =>
26
27
  async message => {
@@ -45,7 +46,7 @@ const recordMessageEvent = async ({
45
46
  }: {
46
47
  appId: string;
47
48
  credentials: AWSCredentials;
48
- event: PushNotificationEvent;
49
+ event: PinpointMessageEvent;
49
50
  message: PushNotificationMessage;
50
51
  region: string;
51
52
  }): Promise<void> => {
@@ -2,8 +2,8 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { PinpointAnalyticsEvent } from '@aws-amplify/core/internals/providers/pinpoint';
5
- import { AnalyticsEventAttributes } from '../types';
6
- import { PushNotificationEvent, PushNotificationMessage } from '../../../types';
5
+ import { AnalyticsEventAttributes, PinpointMessageEvent } from '../types';
6
+ import { PushNotificationMessage } from '../../../types';
7
7
 
8
8
  const ANDROID_CAMPAIGN_ACTIVITY_ID_KEY =
9
9
  'pinpoint.campaign.campaign_activity_id';
@@ -15,7 +15,7 @@ const ANDROID_CAMPAIGN_TREATMENT_ID_KEY = 'pinpoint.campaign.treatment_id';
15
15
  */
16
16
  export const getAnalyticsEvent = (
17
17
  { data }: PushNotificationMessage,
18
- event: PushNotificationEvent
18
+ event: PinpointMessageEvent
19
19
  ): PinpointAnalyticsEvent | null => {
20
20
  if (!data) {
21
21
  return null;
@@ -33,7 +33,10 @@ export const getAnalyticsEvent = (
33
33
 
34
34
  const getAnalyticsEventAttributes = (
35
35
  data: PushNotificationMessage['data']
36
- ): AnalyticsEventAttributes => {
36
+ ): AnalyticsEventAttributes | undefined => {
37
+ if (!data) {
38
+ return;
39
+ }
37
40
  if (data.hasOwnProperty(ANDROID_CAMPAIGN_ID_KEY)) {
38
41
  return {
39
42
  source: '_campaign',
@@ -19,7 +19,7 @@ export const getChannelType = (): ChannelType => {
19
19
  }
20
20
  if (isIos) {
21
21
  // If building in debug mode, use the APNs sandbox
22
- return global['__DEV__'] ? 'APNS_SANDBOX' : 'APNS';
22
+ return __DEV__ ? 'APNS_SANDBOX' : 'APNS';
23
23
  }
24
24
  throw new PlatformNotSupportedError();
25
25
  };
@@ -2,5 +2,6 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export { createMessageEventRecorder } from './createMessageEventRecorder';
5
+ export { getAnalyticsEvent } from './getAnalyticsEvent';
5
6
  export { getChannelType } from './getChannelType';
6
- export { getPushNotificationUserAgentString } from './getPushNotificationUserAgentString';
7
+ export { resolveConfig } from './resolveConfig';
@@ -2,14 +2,14 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { Amplify } from '@aws-amplify/core';
5
- import { assert, PushNotificationValidationErrorCode } from '../errors';
5
+ import { assert, PushNotificationValidationErrorCode } from '../../../errors';
6
6
 
7
7
  /**
8
8
  * @internal
9
9
  */
10
10
  export const resolveConfig = () => {
11
11
  const { appId, region } =
12
- Amplify.getConfig().Notifications?.PushNotification.Pinpoint ?? {};
12
+ Amplify.getConfig().Notifications?.PushNotification?.Pinpoint ?? {};
13
13
  assert(!!appId, PushNotificationValidationErrorCode.NoAppId);
14
14
  assert(!!region, PushNotificationValidationErrorCode.NoRegion);
15
15
  return { appId, region };
@@ -3,6 +3,7 @@
3
3
 
4
4
  export * from './errors';
5
5
  export * from './inputs';
6
+ export * from './module';
6
7
  export * from './options';
7
8
  export * from './outputs';
8
9
  export * from './pushNotifications';
@@ -3,10 +3,10 @@
3
3
 
4
4
  import { UserProfile } from '@aws-amplify/core';
5
5
  import { PushNotificationServiceOptions } from './options';
6
+ import { PushNotificationPermissions } from './module';
6
7
  import {
7
8
  OnPushNotificationMessageHandler,
8
9
  OnTokenReceivedHandler,
9
- PushNotificationPermissions,
10
10
  } from './pushNotifications';
11
11
 
12
12
  export type PushNotificationIdentifyUserInput<