@aws-amplify/notifications 1.6.6-api-v6-models.3f48fe3.0 → 2.0.1-console-preview.11cf989.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.
- package/README.md +3 -0
- package/lib/common/AWSPinpointProviderCommon/index.d.ts +6 -1
- package/lib/common/AWSPinpointProviderCommon/index.js +31 -17
- package/lib/common/AWSPinpointProviderCommon/index.js.map +1 -1
- package/lib/common/eventListeners/types.d.ts +2 -2
- package/lib/common/index.d.ts +0 -1
- package/lib/common/index.js +0 -2
- package/lib/common/index.js.map +1 -1
- package/lib/inAppMessaging/errors/InAppMessagingError.d.ts +7 -0
- package/lib/inAppMessaging/errors/InAppMessagingError.js +23 -0
- package/lib/inAppMessaging/errors/InAppMessagingError.js.map +1 -0
- package/lib/inAppMessaging/errors/assertServiceError.d.ts +2 -0
- package/lib/inAppMessaging/errors/assertServiceError.js +19 -0
- package/lib/inAppMessaging/errors/assertServiceError.js.map +1 -0
- package/lib/inAppMessaging/errors/assertValidationError.d.ts +5 -0
- package/lib/inAppMessaging/errors/assertValidationError.js +17 -0
- package/lib/inAppMessaging/errors/assertValidationError.js.map +1 -0
- package/lib/inAppMessaging/errors/index.d.ts +4 -0
- package/lib/inAppMessaging/errors/index.js +14 -0
- package/lib/inAppMessaging/errors/index.js.map +1 -0
- package/lib/inAppMessaging/errors/validation.d.ts +8 -0
- package/lib/inAppMessaging/errors/validation.js +27 -0
- package/lib/inAppMessaging/errors/validation.js.map +1 -0
- package/{lib-esm/InAppMessaging → lib/inAppMessaging}/index.d.ts +1 -1
- package/lib/{InAppMessaging → inAppMessaging}/index.js +3 -2
- package/lib/inAppMessaging/index.js.map +1 -0
- package/lib/inAppMessaging/providers/index.d.ts +1 -0
- package/lib/{PushNotification/Providers → inAppMessaging/providers}/index.js +3 -2
- package/lib/inAppMessaging/providers/index.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.js +9 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/index.js +9 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/index.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/syncMessages.d.ts +18 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/syncMessages.js +109 -0
- package/lib/inAppMessaging/providers/pinpoint/apis/syncMessages.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/index.d.ts +1 -0
- package/lib/{InAppMessaging/Providers → inAppMessaging/providers/pinpoint}/index.js +3 -2
- package/lib/inAppMessaging/providers/pinpoint/index.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/types/types.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/constants.d.ts +4 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/constants.js +9 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/constants.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/index.d.ts +4 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/index.js +16 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/index.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveConfig.d.ts +7 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveConfig.js +17 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveConfig.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.d.ts +12 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js +23 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js.map +1 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/userAgent.d.ts +4 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/userAgent.js +20 -0
- package/lib/inAppMessaging/providers/pinpoint/utils/userAgent.js.map +1 -0
- package/lib/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/utils}/utils.d.ts +3 -4
- package/lib/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/utils}/utils.js +16 -20
- package/lib/inAppMessaging/providers/pinpoint/utils/utils.js.map +1 -0
- package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.js +7 -8
- package/lib/inAppMessaging/sessionTracker/SessionTracker.js.map +1 -0
- package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.native.js +2 -2
- package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.native.js.map +1 -1
- package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/index.js.map +1 -1
- package/lib/inAppMessaging/sessionTracker/types.js.map +1 -0
- package/lib/{InAppMessaging → inAppMessaging}/types.js.map +1 -1
- package/lib/index.d.ts +2 -3
- package/lib/index.js +3 -5
- package/lib/index.js.map +1 -1
- package/lib/pushNotifications/NotEnabledError.js.map +1 -0
- package/lib/pushNotifications/Platform/index.js.map +1 -0
- package/lib/pushNotifications/Platform/index.native.js.map +1 -0
- package/lib/pushNotifications/Platform/types.js.map +1 -0
- package/lib/pushNotifications/PlatformNotSupportedError.js.map +1 -0
- package/lib/{PushNotification → pushNotifications}/index.d.ts +1 -1
- package/lib/{PushNotification → pushNotifications}/index.js +2 -2
- package/lib/pushNotifications/index.js.map +1 -0
- package/lib/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/index.js +3 -52
- package/lib/pushNotifications/providers/AWSPinpointProvider/index.js.map +1 -0
- package/lib/pushNotifications/providers/AWSPinpointProvider/types.js.map +1 -0
- package/{lib-esm/PushNotification/Providers → lib/pushNotifications/providers}/AWSPinpointProvider/utils.d.ts +1 -2
- package/lib/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/utils.js +2 -6
- package/lib/pushNotifications/providers/AWSPinpointProvider/utils.js.map +1 -0
- package/lib/pushNotifications/providers/index.d.ts +1 -0
- package/lib/pushNotifications/providers/index.js +7 -0
- package/lib/pushNotifications/providers/index.js.map +1 -0
- package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.d.ts +2 -0
- package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.js +9 -0
- package/lib/pushNotifications/providers/pinpoint/apis/identifyUser.js.map +1 -0
- package/lib/pushNotifications/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib/pushNotifications/providers/pinpoint/apis/index.js +7 -0
- package/lib/pushNotifications/providers/pinpoint/apis/index.js.map +1 -0
- package/lib/pushNotifications/providers/pinpoint/index.d.ts +1 -0
- package/lib/pushNotifications/providers/pinpoint/index.js +7 -0
- package/lib/pushNotifications/providers/pinpoint/index.js.map +1 -0
- package/lib/pushNotifications/types.js.map +1 -0
- package/lib/pushNotifications/utils.js.map +1 -0
- package/lib/types.d.ts +2 -2
- package/lib-esm/common/AWSPinpointProviderCommon/index.d.ts +6 -1
- package/lib-esm/common/AWSPinpointProviderCommon/index.js +24 -10
- package/lib-esm/common/AWSPinpointProviderCommon/index.js.map +1 -1
- package/lib-esm/common/eventListeners/types.d.ts +2 -2
- package/lib-esm/common/index.d.ts +0 -1
- package/lib-esm/common/index.js +0 -1
- package/lib-esm/common/index.js.map +1 -1
- package/lib-esm/inAppMessaging/errors/InAppMessagingError.d.ts +7 -0
- package/lib-esm/inAppMessaging/errors/InAppMessagingError.js +21 -0
- package/lib-esm/inAppMessaging/errors/InAppMessagingError.js.map +1 -0
- package/lib-esm/inAppMessaging/errors/assertServiceError.d.ts +2 -0
- package/lib-esm/inAppMessaging/errors/assertServiceError.js +16 -0
- package/lib-esm/inAppMessaging/errors/assertServiceError.js.map +1 -0
- package/lib-esm/inAppMessaging/errors/assertValidationError.d.ts +5 -0
- package/lib-esm/inAppMessaging/errors/assertValidationError.js +14 -0
- package/lib-esm/inAppMessaging/errors/assertValidationError.js.map +1 -0
- package/lib-esm/inAppMessaging/errors/index.d.ts +4 -0
- package/lib-esm/inAppMessaging/errors/index.js +7 -0
- package/lib-esm/inAppMessaging/errors/index.js.map +1 -0
- package/lib-esm/inAppMessaging/errors/validation.d.ts +8 -0
- package/lib-esm/inAppMessaging/errors/validation.js +25 -0
- package/lib-esm/inAppMessaging/errors/validation.js.map +1 -0
- package/{lib/InAppMessaging → lib-esm/inAppMessaging}/index.d.ts +1 -1
- package/lib-esm/{InAppMessaging → inAppMessaging}/index.js +1 -1
- package/lib-esm/inAppMessaging/index.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/index.d.ts +1 -0
- package/lib-esm/inAppMessaging/providers/index.js +4 -0
- package/lib-esm/inAppMessaging/providers/index.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.js +6 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.d.ts +2 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.js +5 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/index.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/syncMessages.d.ts +18 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/syncMessages.js +106 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/apis/syncMessages.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/index.d.ts +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/index.js +4 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/index.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/types/types.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/constants.d.ts +4 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/constants.js +7 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/constants.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/index.d.ts +4 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/index.js +7 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/index.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveConfig.d.ts +7 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveConfig.js +15 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveConfig.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.d.ts +12 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js +21 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/resolveCredentials.js.map +1 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/userAgent.d.ts +4 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/userAgent.js +16 -0
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/userAgent.js.map +1 -0
- package/lib-esm/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/utils}/utils.d.ts +3 -4
- package/lib-esm/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/utils}/utils.js +15 -19
- package/lib-esm/inAppMessaging/providers/pinpoint/utils/utils.js.map +1 -0
- package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.js +1 -2
- package/lib-esm/inAppMessaging/sessionTracker/SessionTracker.js.map +1 -0
- package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.native.js +1 -1
- package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.native.js.map +1 -1
- package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/index.js.map +1 -1
- package/lib-esm/inAppMessaging/sessionTracker/types.js.map +1 -0
- package/lib-esm/{InAppMessaging → inAppMessaging}/types.js.map +1 -1
- package/lib-esm/index.d.ts +2 -3
- package/lib-esm/index.js +2 -3
- package/lib-esm/index.js.map +1 -1
- package/lib-esm/pushNotifications/NotEnabledError.js.map +1 -0
- package/lib-esm/pushNotifications/Platform/index.js.map +1 -0
- package/lib-esm/pushNotifications/Platform/index.native.js.map +1 -0
- package/lib-esm/pushNotifications/Platform/types.js.map +1 -0
- package/lib-esm/pushNotifications/PlatformNotSupportedError.js.map +1 -0
- package/lib-esm/{PushNotification → pushNotifications}/index.d.ts +1 -1
- package/lib-esm/{PushNotification → pushNotifications}/index.js +1 -1
- package/lib-esm/pushNotifications/index.js.map +1 -0
- package/lib-esm/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/index.js +4 -53
- package/lib-esm/pushNotifications/providers/AWSPinpointProvider/index.js.map +1 -0
- package/lib-esm/pushNotifications/providers/AWSPinpointProvider/types.js.map +1 -0
- package/{lib/PushNotification/Providers → lib-esm/pushNotifications/providers}/AWSPinpointProvider/utils.d.ts +1 -2
- package/lib-esm/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/utils.js +1 -5
- package/lib-esm/pushNotifications/providers/AWSPinpointProvider/utils.js.map +1 -0
- package/lib-esm/pushNotifications/providers/index.d.ts +1 -0
- package/lib-esm/pushNotifications/providers/index.js +4 -0
- package/lib-esm/pushNotifications/providers/index.js.map +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.d.ts +2 -0
- package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.js +6 -0
- package/lib-esm/pushNotifications/providers/pinpoint/apis/identifyUser.js.map +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/apis/index.d.ts +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/apis/index.js +4 -0
- package/lib-esm/pushNotifications/providers/pinpoint/apis/index.js.map +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/index.d.ts +1 -0
- package/lib-esm/pushNotifications/providers/pinpoint/index.js +4 -0
- package/lib-esm/pushNotifications/providers/pinpoint/index.js.map +1 -0
- package/lib-esm/pushNotifications/types.js.map +1 -0
- package/lib-esm/pushNotifications/utils.js.map +1 -0
- package/lib-esm/types.d.ts +2 -2
- package/package.json +127 -76
- package/src/common/AWSPinpointProviderCommon/index.ts +25 -11
- package/src/common/eventListeners/types.ts +2 -2
- package/src/common/index.ts +0 -1
- package/src/inAppMessaging/errors/InAppMessagingError.ts +21 -0
- package/src/inAppMessaging/errors/assertServiceError.ts +24 -0
- package/src/inAppMessaging/errors/assertValidationError.ts +22 -0
- package/src/inAppMessaging/errors/index.ts +10 -0
- package/src/inAppMessaging/errors/validation.ts +27 -0
- package/src/{InAppMessaging → inAppMessaging}/index.ts +1 -1
- package/src/{InAppMessaging/Providers → inAppMessaging/providers}/index.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/apis/identifyUser.ts +11 -0
- package/src/inAppMessaging/providers/pinpoint/apis/index.ts +5 -0
- package/src/inAppMessaging/providers/pinpoint/apis/syncMessages.ts +108 -0
- package/src/{PushNotification/Providers → inAppMessaging/providers/pinpoint}/index.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/utils/constants.ts +6 -0
- package/src/inAppMessaging/providers/pinpoint/utils/index.ts +12 -0
- package/src/inAppMessaging/providers/pinpoint/utils/resolveConfig.ts +19 -0
- package/src/inAppMessaging/providers/pinpoint/utils/resolveCredentials.ts +20 -0
- package/src/inAppMessaging/providers/pinpoint/utils/userAgent.ts +25 -0
- package/src/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/utils}/utils.ts +17 -30
- package/src/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.native.ts +1 -1
- package/src/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.ts +4 -2
- package/src/index.ts +2 -4
- package/src/{PushNotification → pushNotifications}/index.ts +1 -1
- package/src/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/index.ts +4 -41
- package/src/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/utils.ts +1 -15
- package/src/pushNotifications/providers/index.ts +4 -0
- package/src/pushNotifications/providers/pinpoint/apis/identifyUser.ts +11 -0
- package/src/pushNotifications/providers/pinpoint/apis/index.ts +4 -0
- package/src/pushNotifications/providers/pinpoint/index.ts +4 -0
- package/src/types.ts +2 -2
- package/lib/InAppMessaging/InAppMessaging.d.ts +0 -57
- package/lib/InAppMessaging/InAppMessaging.js +0 -340
- package/lib/InAppMessaging/InAppMessaging.js.map +0 -1
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.d.ts +0 -31
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.js +0 -266
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/index.js.map +0 -1
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/types.js.map +0 -1
- package/lib/InAppMessaging/Providers/AWSPinpointProvider/utils.js.map +0 -1
- package/lib/InAppMessaging/Providers/index.d.ts +0 -1
- package/lib/InAppMessaging/Providers/index.js.map +0 -1
- package/lib/InAppMessaging/SessionTracker/SessionTracker.js.map +0 -1
- package/lib/InAppMessaging/SessionTracker/types.js.map +0 -1
- package/lib/InAppMessaging/index.js.map +0 -1
- package/lib/Notifications.d.ts +0 -24
- package/lib/Notifications.js +0 -94
- package/lib/Notifications.js.map +0 -1
- package/lib/PushNotification/NotEnabledError.js.map +0 -1
- package/lib/PushNotification/Platform/index.js.map +0 -1
- package/lib/PushNotification/Platform/index.native.js.map +0 -1
- package/lib/PushNotification/Platform/types.js.map +0 -1
- package/lib/PushNotification/PlatformNotSupportedError.js.map +0 -1
- package/lib/PushNotification/Providers/AWSPinpointProvider/index.js.map +0 -1
- package/lib/PushNotification/Providers/AWSPinpointProvider/types.js.map +0 -1
- package/lib/PushNotification/Providers/AWSPinpointProvider/utils.js.map +0 -1
- package/lib/PushNotification/Providers/index.d.ts +0 -1
- package/lib/PushNotification/Providers/index.js.map +0 -1
- package/lib/PushNotification/PushNotification.d.ts +0 -39
- package/lib/PushNotification/PushNotification.js +0 -91
- package/lib/PushNotification/PushNotification.js.map +0 -1
- package/lib/PushNotification/PushNotification.native.d.ts +0 -63
- package/lib/PushNotification/PushNotification.native.js +0 -332
- package/lib/PushNotification/PushNotification.native.js.map +0 -1
- package/lib/PushNotification/index.js.map +0 -1
- package/lib/PushNotification/types.js.map +0 -1
- package/lib/PushNotification/utils.js.map +0 -1
- package/lib/common/constants.d.ts +0 -1
- package/lib/common/constants.js +0 -8
- package/lib/common/constants.js.map +0 -1
- package/lib-esm/InAppMessaging/InAppMessaging.d.ts +0 -57
- package/lib-esm/InAppMessaging/InAppMessaging.js +0 -338
- package/lib-esm/InAppMessaging/InAppMessaging.js.map +0 -1
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.d.ts +0 -31
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.js +0 -264
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/index.js.map +0 -1
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/types.js.map +0 -1
- package/lib-esm/InAppMessaging/Providers/AWSPinpointProvider/utils.js.map +0 -1
- package/lib-esm/InAppMessaging/Providers/index.d.ts +0 -1
- package/lib-esm/InAppMessaging/Providers/index.js +0 -4
- package/lib-esm/InAppMessaging/Providers/index.js.map +0 -1
- package/lib-esm/InAppMessaging/SessionTracker/SessionTracker.js.map +0 -1
- package/lib-esm/InAppMessaging/SessionTracker/types.js.map +0 -1
- package/lib-esm/InAppMessaging/index.js.map +0 -1
- package/lib-esm/Notifications.d.ts +0 -24
- package/lib-esm/Notifications.js +0 -92
- package/lib-esm/Notifications.js.map +0 -1
- package/lib-esm/PushNotification/NotEnabledError.js.map +0 -1
- package/lib-esm/PushNotification/Platform/index.js.map +0 -1
- package/lib-esm/PushNotification/Platform/index.native.js.map +0 -1
- package/lib-esm/PushNotification/Platform/types.js.map +0 -1
- package/lib-esm/PushNotification/PlatformNotSupportedError.js.map +0 -1
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/index.js.map +0 -1
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/types.js.map +0 -1
- package/lib-esm/PushNotification/Providers/AWSPinpointProvider/utils.js.map +0 -1
- package/lib-esm/PushNotification/Providers/index.d.ts +0 -1
- package/lib-esm/PushNotification/Providers/index.js +0 -4
- package/lib-esm/PushNotification/Providers/index.js.map +0 -1
- package/lib-esm/PushNotification/PushNotification.d.ts +0 -39
- package/lib-esm/PushNotification/PushNotification.js +0 -89
- package/lib-esm/PushNotification/PushNotification.js.map +0 -1
- package/lib-esm/PushNotification/PushNotification.native.d.ts +0 -63
- package/lib-esm/PushNotification/PushNotification.native.js +0 -330
- package/lib-esm/PushNotification/PushNotification.native.js.map +0 -1
- package/lib-esm/PushNotification/index.js.map +0 -1
- package/lib-esm/PushNotification/types.js.map +0 -1
- package/lib-esm/PushNotification/utils.js.map +0 -1
- package/lib-esm/common/constants.d.ts +0 -1
- package/lib-esm/common/constants.js +0 -6
- package/lib-esm/common/constants.js.map +0 -1
- package/src/InAppMessaging/InAppMessaging.ts +0 -321
- package/src/InAppMessaging/Providers/AWSPinpointProvider/index.ts +0 -323
- package/src/Notifications.ts +0 -90
- package/src/PushNotification/PushNotification.native.ts +0 -386
- package/src/PushNotification/PushNotification.ts +0 -107
- package/src/common/constants.ts +0 -7
- /package/lib/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/types}/types.d.ts +0 -0
- /package/lib/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/types}/types.js +0 -0
- /package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.d.ts +0 -0
- /package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.native.d.ts +0 -0
- /package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/index.d.ts +0 -0
- /package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/index.js +0 -0
- /package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/types.d.ts +0 -0
- /package/lib/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/types.js +0 -0
- /package/lib/{InAppMessaging → inAppMessaging}/types.d.ts +0 -0
- /package/lib/{InAppMessaging → inAppMessaging}/types.js +0 -0
- /package/lib/{PushNotification → pushNotifications}/NotEnabledError.d.ts +0 -0
- /package/lib/{PushNotification → pushNotifications}/NotEnabledError.js +0 -0
- /package/lib/{PushNotification → pushNotifications}/Platform/index.d.ts +0 -0
- /package/lib/{PushNotification → pushNotifications}/Platform/index.js +0 -0
- /package/lib/{PushNotification → pushNotifications}/Platform/index.native.d.ts +0 -0
- /package/lib/{PushNotification → pushNotifications}/Platform/index.native.js +0 -0
- /package/lib/{PushNotification → pushNotifications}/Platform/types.d.ts +0 -0
- /package/lib/{PushNotification → pushNotifications}/Platform/types.js +0 -0
- /package/lib/{PushNotification → pushNotifications}/PlatformNotSupportedError.d.ts +0 -0
- /package/lib/{PushNotification → pushNotifications}/PlatformNotSupportedError.js +0 -0
- /package/lib/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/index.d.ts +0 -0
- /package/lib/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/types.d.ts +0 -0
- /package/lib/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/types.js +0 -0
- /package/lib/{PushNotification → pushNotifications}/types.d.ts +0 -0
- /package/lib/{PushNotification → pushNotifications}/types.js +0 -0
- /package/lib/{PushNotification → pushNotifications}/utils.d.ts +0 -0
- /package/lib/{PushNotification → pushNotifications}/utils.js +0 -0
- /package/lib-esm/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/types}/types.d.ts +0 -0
- /package/lib-esm/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/types}/types.js +0 -0
- /package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.d.ts +0 -0
- /package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/SessionTracker.native.d.ts +0 -0
- /package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/index.d.ts +0 -0
- /package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/index.js +0 -0
- /package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/types.d.ts +0 -0
- /package/lib-esm/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/types.js +0 -0
- /package/lib-esm/{InAppMessaging → inAppMessaging}/types.d.ts +0 -0
- /package/lib-esm/{InAppMessaging → inAppMessaging}/types.js +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/NotEnabledError.d.ts +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/NotEnabledError.js +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/Platform/index.d.ts +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/Platform/index.js +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/Platform/index.native.d.ts +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/Platform/index.native.js +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/Platform/types.d.ts +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/Platform/types.js +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/PlatformNotSupportedError.d.ts +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/PlatformNotSupportedError.js +0 -0
- /package/lib-esm/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/index.d.ts +0 -0
- /package/lib-esm/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/types.d.ts +0 -0
- /package/lib-esm/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/types.js +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/types.d.ts +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/types.js +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/utils.d.ts +0 -0
- /package/lib-esm/{PushNotification → pushNotifications}/utils.js +0 -0
- /package/src/{InAppMessaging/Providers/AWSPinpointProvider → inAppMessaging/providers/pinpoint/types}/types.ts +0 -0
- /package/src/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/index.ts +0 -0
- /package/src/{InAppMessaging/SessionTracker → inAppMessaging/sessionTracker}/types.ts +0 -0
- /package/src/{InAppMessaging → inAppMessaging}/types.ts +0 -0
- /package/src/{PushNotification → pushNotifications}/NotEnabledError.ts +0 -0
- /package/src/{PushNotification → pushNotifications}/Platform/index.native.ts +0 -0
- /package/src/{PushNotification → pushNotifications}/Platform/index.ts +0 -0
- /package/src/{PushNotification → pushNotifications}/Platform/types.ts +0 -0
- /package/src/{PushNotification → pushNotifications}/PlatformNotSupportedError.ts +0 -0
- /package/src/{PushNotification/Providers → pushNotifications/providers}/AWSPinpointProvider/types.ts +0 -0
- /package/src/{PushNotification → pushNotifications}/types.ts +0 -0
- /package/src/{PushNotification → pushNotifications}/utils.ts +0 -0
|
@@ -1,321 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
ConsoleLogger as Logger,
|
|
6
|
-
HubCallback,
|
|
7
|
-
HubCapsule,
|
|
8
|
-
Hub,
|
|
9
|
-
StorageHelper,
|
|
10
|
-
} from '@aws-amplify/core';
|
|
11
|
-
import flatten from 'lodash/flatten';
|
|
12
|
-
|
|
13
|
-
import {
|
|
14
|
-
addEventListener,
|
|
15
|
-
EventListener,
|
|
16
|
-
notifyEventListeners,
|
|
17
|
-
} from '../common';
|
|
18
|
-
import { UserInfo } from '../types';
|
|
19
|
-
import { AWSPinpointProvider } from './Providers';
|
|
20
|
-
import {
|
|
21
|
-
InAppMessage,
|
|
22
|
-
InAppMessageInteractionEvent,
|
|
23
|
-
InAppMessagingInterface,
|
|
24
|
-
InAppMessagingConfig,
|
|
25
|
-
InAppMessageConflictHandler,
|
|
26
|
-
InAppMessagingEvent,
|
|
27
|
-
InAppMessagingProvider,
|
|
28
|
-
NotificationsSubCategory,
|
|
29
|
-
OnMessageInteractionEventHandler,
|
|
30
|
-
} from './types';
|
|
31
|
-
|
|
32
|
-
const STORAGE_KEY_SUFFIX = '_inAppMessages';
|
|
33
|
-
|
|
34
|
-
const logger = new Logger('Notifications.InAppMessaging');
|
|
35
|
-
|
|
36
|
-
export default class InAppMessaging implements InAppMessagingInterface {
|
|
37
|
-
private config: Record<string, any> = {};
|
|
38
|
-
private conflictHandler: InAppMessageConflictHandler;
|
|
39
|
-
private listeningForAnalyticEvents = false;
|
|
40
|
-
private pluggables: InAppMessagingProvider[] = [];
|
|
41
|
-
private storageSynced = false;
|
|
42
|
-
|
|
43
|
-
constructor() {
|
|
44
|
-
this.config = { storage: new StorageHelper().getStorage() };
|
|
45
|
-
this.setConflictHandler(this.defaultConflictHandler);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Configure InAppMessaging
|
|
50
|
-
* @param {Object} config - InAppMessaging configuration object
|
|
51
|
-
*/
|
|
52
|
-
configure = ({
|
|
53
|
-
listenForAnalyticsEvents = true,
|
|
54
|
-
...config
|
|
55
|
-
}: InAppMessagingConfig = {}): InAppMessagingConfig => {
|
|
56
|
-
this.config = { ...this.config, ...config };
|
|
57
|
-
|
|
58
|
-
logger.debug('configure InAppMessaging', this.config);
|
|
59
|
-
|
|
60
|
-
this.pluggables.forEach(pluggable => {
|
|
61
|
-
pluggable.configure(this.config[pluggable.getProviderName()]);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
if (this.pluggables.length === 0) {
|
|
65
|
-
this.addPluggable(new AWSPinpointProvider());
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
if (listenForAnalyticsEvents && !this.listeningForAnalyticEvents) {
|
|
69
|
-
Hub.listen('analytics', this.analyticsListener);
|
|
70
|
-
this.listeningForAnalyticEvents = true;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return this.config;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Get the name of this module
|
|
78
|
-
* @returns {string} name of this module
|
|
79
|
-
*/
|
|
80
|
-
getModuleName(): NotificationsSubCategory {
|
|
81
|
-
return 'InAppMessaging';
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Get a plugin from added plugins
|
|
86
|
-
* @param {string} providerName - the name of the plugin to get
|
|
87
|
-
*/
|
|
88
|
-
getPluggable = (providerName: string): InAppMessagingProvider => {
|
|
89
|
-
const pluggable =
|
|
90
|
-
this.pluggables.find(
|
|
91
|
-
pluggable => pluggable.getProviderName() === providerName
|
|
92
|
-
) ?? null;
|
|
93
|
-
|
|
94
|
-
if (!pluggable) {
|
|
95
|
-
logger.debug(`No plugin found with name ${providerName}`);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return pluggable;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
/**
|
|
102
|
-
* Add plugin into InAppMessaging
|
|
103
|
-
* @param {InAppMessagingProvider} pluggable - an instance of the plugin
|
|
104
|
-
*/
|
|
105
|
-
addPluggable = (pluggable: InAppMessagingProvider): void => {
|
|
106
|
-
if (
|
|
107
|
-
pluggable &&
|
|
108
|
-
pluggable.getCategory() === 'Notifications' &&
|
|
109
|
-
pluggable.getSubCategory() === 'InAppMessaging'
|
|
110
|
-
) {
|
|
111
|
-
if (this.getPluggable(pluggable.getProviderName())) {
|
|
112
|
-
throw new Error(
|
|
113
|
-
`Pluggable ${pluggable.getProviderName()} has already been added.`
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
this.pluggables.push(pluggable);
|
|
117
|
-
pluggable.configure(this.config[pluggable.getProviderName()]);
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* Remove a plugin from added plugins
|
|
123
|
-
* @param {string} providerName - the name of the plugin to remove
|
|
124
|
-
*/
|
|
125
|
-
removePluggable = (providerName: string): void => {
|
|
126
|
-
const index = this.pluggables.findIndex(
|
|
127
|
-
pluggable => pluggable.getProviderName() === providerName
|
|
128
|
-
);
|
|
129
|
-
if (index === -1) {
|
|
130
|
-
logger.debug(`No plugin found with name ${providerName}`);
|
|
131
|
-
} else {
|
|
132
|
-
this.pluggables.splice(index, 1);
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
/**
|
|
137
|
-
* Get the map resources that are currently available through the provider
|
|
138
|
-
* @param {string} provider
|
|
139
|
-
* @returns - Array of available map resources
|
|
140
|
-
*/
|
|
141
|
-
syncMessages = (): Promise<void[]> =>
|
|
142
|
-
Promise.all<void>(
|
|
143
|
-
this.pluggables.map(async pluggable => {
|
|
144
|
-
try {
|
|
145
|
-
const messages = await pluggable.getInAppMessages();
|
|
146
|
-
const key = `${pluggable.getProviderName()}${STORAGE_KEY_SUFFIX}`;
|
|
147
|
-
await this.setMessages(key, messages);
|
|
148
|
-
} catch (err) {
|
|
149
|
-
logger.error('Failed to sync messages', err);
|
|
150
|
-
throw err;
|
|
151
|
-
}
|
|
152
|
-
})
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
clearMessages = (): Promise<void[]> =>
|
|
156
|
-
Promise.all<void>(
|
|
157
|
-
this.pluggables.map(async pluggable => {
|
|
158
|
-
const key = `${pluggable.getProviderName()}${STORAGE_KEY_SUFFIX}`;
|
|
159
|
-
await this.removeMessages(key);
|
|
160
|
-
})
|
|
161
|
-
);
|
|
162
|
-
|
|
163
|
-
dispatchEvent = async (event: InAppMessagingEvent): Promise<void> => {
|
|
164
|
-
const messages: InAppMessage[][] = await Promise.all<InAppMessage[]>(
|
|
165
|
-
this.pluggables.map(async pluggable => {
|
|
166
|
-
const key = `${pluggable.getProviderName()}${STORAGE_KEY_SUFFIX}`;
|
|
167
|
-
const messages = await this.getMessages(key);
|
|
168
|
-
return pluggable.processInAppMessages(messages, event);
|
|
169
|
-
})
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
const flattenedMessages = flatten(messages);
|
|
173
|
-
|
|
174
|
-
if (flattenedMessages.length) {
|
|
175
|
-
notifyEventListeners(
|
|
176
|
-
InAppMessageInteractionEvent.MESSAGE_RECEIVED,
|
|
177
|
-
this.conflictHandler(flattenedMessages)
|
|
178
|
-
);
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
identifyUser = (userId: string, userInfo: UserInfo): Promise<void[]> =>
|
|
183
|
-
Promise.all<void>(
|
|
184
|
-
this.pluggables.map(async pluggable => {
|
|
185
|
-
try {
|
|
186
|
-
await pluggable.identifyUser(userId, userInfo);
|
|
187
|
-
} catch (err) {
|
|
188
|
-
logger.error('Failed to identify user', err);
|
|
189
|
-
throw err;
|
|
190
|
-
}
|
|
191
|
-
})
|
|
192
|
-
);
|
|
193
|
-
|
|
194
|
-
onMessageReceived = (
|
|
195
|
-
handler: OnMessageInteractionEventHandler
|
|
196
|
-
): EventListener<OnMessageInteractionEventHandler> =>
|
|
197
|
-
addEventListener(InAppMessageInteractionEvent.MESSAGE_RECEIVED, handler);
|
|
198
|
-
|
|
199
|
-
onMessageDisplayed = (
|
|
200
|
-
handler: OnMessageInteractionEventHandler
|
|
201
|
-
): EventListener<OnMessageInteractionEventHandler> =>
|
|
202
|
-
addEventListener(InAppMessageInteractionEvent.MESSAGE_DISPLAYED, handler);
|
|
203
|
-
|
|
204
|
-
onMessageDismissed = (
|
|
205
|
-
handler: OnMessageInteractionEventHandler
|
|
206
|
-
): EventListener<OnMessageInteractionEventHandler> =>
|
|
207
|
-
addEventListener(InAppMessageInteractionEvent.MESSAGE_DISMISSED, handler);
|
|
208
|
-
|
|
209
|
-
onMessageActionTaken = (
|
|
210
|
-
handler: OnMessageInteractionEventHandler
|
|
211
|
-
): EventListener<OnMessageInteractionEventHandler> =>
|
|
212
|
-
addEventListener(
|
|
213
|
-
InAppMessageInteractionEvent.MESSAGE_ACTION_TAKEN,
|
|
214
|
-
handler
|
|
215
|
-
);
|
|
216
|
-
|
|
217
|
-
notifyMessageInteraction = (
|
|
218
|
-
message: InAppMessage,
|
|
219
|
-
type: InAppMessageInteractionEvent
|
|
220
|
-
): void => {
|
|
221
|
-
notifyEventListeners(type, message);
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
setConflictHandler = (handler: InAppMessageConflictHandler): void => {
|
|
225
|
-
this.conflictHandler = handler;
|
|
226
|
-
};
|
|
227
|
-
|
|
228
|
-
private analyticsListener: HubCallback = ({ payload }: HubCapsule) => {
|
|
229
|
-
const { event, data } = payload;
|
|
230
|
-
switch (event) {
|
|
231
|
-
case 'record': {
|
|
232
|
-
this.dispatchEvent(data);
|
|
233
|
-
break;
|
|
234
|
-
}
|
|
235
|
-
default:
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
private syncStorage = async (): Promise<void> => {
|
|
241
|
-
const { storage } = this.config;
|
|
242
|
-
try {
|
|
243
|
-
// Only run sync() if it's available (i.e. React Native)
|
|
244
|
-
if (typeof storage.sync === 'function') {
|
|
245
|
-
await storage.sync();
|
|
246
|
-
}
|
|
247
|
-
this.storageSynced = true;
|
|
248
|
-
} catch (err) {
|
|
249
|
-
logger.error('Failed to sync storage', err);
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
private getMessages = async (key: string): Promise<any> => {
|
|
254
|
-
try {
|
|
255
|
-
if (!this.storageSynced) {
|
|
256
|
-
await this.syncStorage();
|
|
257
|
-
}
|
|
258
|
-
const { storage } = this.config;
|
|
259
|
-
const storedMessages = storage.getItem(key);
|
|
260
|
-
return storedMessages ? JSON.parse(storedMessages) : [];
|
|
261
|
-
} catch (err) {
|
|
262
|
-
logger.error('Failed to retrieve in-app messages from storage', err);
|
|
263
|
-
}
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
private setMessages = async (
|
|
267
|
-
key: string,
|
|
268
|
-
messages: InAppMessage[]
|
|
269
|
-
): Promise<void> => {
|
|
270
|
-
if (!messages) {
|
|
271
|
-
return;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
try {
|
|
275
|
-
if (!this.storageSynced) {
|
|
276
|
-
await this.syncStorage();
|
|
277
|
-
}
|
|
278
|
-
const { storage } = this.config;
|
|
279
|
-
storage.setItem(key, JSON.stringify(messages));
|
|
280
|
-
} catch (err) {
|
|
281
|
-
logger.error('Failed to store in-app messages', err);
|
|
282
|
-
}
|
|
283
|
-
};
|
|
284
|
-
|
|
285
|
-
private removeMessages = async (key: string): Promise<void> => {
|
|
286
|
-
try {
|
|
287
|
-
if (!this.storageSynced) {
|
|
288
|
-
await this.syncStorage();
|
|
289
|
-
}
|
|
290
|
-
const { storage } = this.config;
|
|
291
|
-
storage.removeItem(key);
|
|
292
|
-
} catch (err) {
|
|
293
|
-
logger.error('Failed to remove in-app messages from storage', err);
|
|
294
|
-
}
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
private defaultConflictHandler = (messages: InAppMessage[]): InAppMessage => {
|
|
298
|
-
// default behavior is to return the message closest to expiry
|
|
299
|
-
// this function assumes that messages processed by providers already filters out expired messages
|
|
300
|
-
const sorted = messages.sort((a, b) => {
|
|
301
|
-
const endDateA = a.metadata?.endDate;
|
|
302
|
-
const endDateB = b.metadata?.endDate;
|
|
303
|
-
// if both message end dates are falsy or have the same date string, treat them as equal
|
|
304
|
-
if (endDateA === endDateB) {
|
|
305
|
-
return 0;
|
|
306
|
-
}
|
|
307
|
-
// if only message A has an end date, treat it as closer to expiry
|
|
308
|
-
if (endDateA && !endDateB) {
|
|
309
|
-
return -1;
|
|
310
|
-
}
|
|
311
|
-
// if only message B has an end date, treat it as closer to expiry
|
|
312
|
-
if (!endDateA && endDateB) {
|
|
313
|
-
return 1;
|
|
314
|
-
}
|
|
315
|
-
// otherwise, compare them
|
|
316
|
-
return new Date(endDateA) < new Date(endDateB) ? -1 : 1;
|
|
317
|
-
});
|
|
318
|
-
// always return the top sorted
|
|
319
|
-
return sorted[0];
|
|
320
|
-
};
|
|
321
|
-
}
|
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
|
-
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
getInAppMessages,
|
|
6
|
-
GetInAppMessagesInput,
|
|
7
|
-
GetInAppMessagesOutput,
|
|
8
|
-
InAppMessageCampaign as PinpointInAppMessage,
|
|
9
|
-
} from '@aws-amplify/core/internals/aws-clients/pinpoint';
|
|
10
|
-
|
|
11
|
-
import { addEventListener, AWSPinpointProviderCommon } from '../../../common';
|
|
12
|
-
import SessionTracker, {
|
|
13
|
-
SessionState,
|
|
14
|
-
SessionStateChangeHandler,
|
|
15
|
-
} from '../../SessionTracker';
|
|
16
|
-
import {
|
|
17
|
-
InAppMessage,
|
|
18
|
-
InAppMessageInteractionEvent,
|
|
19
|
-
InAppMessagingEvent,
|
|
20
|
-
InAppMessagingProvider,
|
|
21
|
-
NotificationsSubCategory,
|
|
22
|
-
} from '../../types';
|
|
23
|
-
import {
|
|
24
|
-
AWSPinpointMessageEvent,
|
|
25
|
-
DailyInAppMessageCounter,
|
|
26
|
-
InAppMessageCountMap,
|
|
27
|
-
InAppMessageCounts,
|
|
28
|
-
} from './types';
|
|
29
|
-
import {
|
|
30
|
-
clearMemo,
|
|
31
|
-
dispatchInAppMessagingEvent,
|
|
32
|
-
extractContent,
|
|
33
|
-
extractMetadata,
|
|
34
|
-
getStartOfDay,
|
|
35
|
-
interpretLayout,
|
|
36
|
-
isBeforeEndDate,
|
|
37
|
-
logger,
|
|
38
|
-
matchesAttributes,
|
|
39
|
-
matchesEventType,
|
|
40
|
-
matchesMetrics,
|
|
41
|
-
recordAnalyticsEvent,
|
|
42
|
-
} from './utils';
|
|
43
|
-
|
|
44
|
-
const MESSAGE_DAILY_COUNT_KEY = 'pinpointProvider_inAppMessages_dailyCount';
|
|
45
|
-
const MESSAGE_TOTAL_COUNT_KEY = 'pinpointProvider_inAppMessages_totalCount';
|
|
46
|
-
|
|
47
|
-
export default class AWSPinpointProvider
|
|
48
|
-
extends AWSPinpointProviderCommon
|
|
49
|
-
implements InAppMessagingProvider
|
|
50
|
-
{
|
|
51
|
-
static subCategory: NotificationsSubCategory = 'InAppMessaging';
|
|
52
|
-
|
|
53
|
-
private configured = false;
|
|
54
|
-
private sessionMessageCountMap: InAppMessageCountMap;
|
|
55
|
-
private sessionTracker: SessionTracker;
|
|
56
|
-
|
|
57
|
-
constructor() {
|
|
58
|
-
super(logger);
|
|
59
|
-
this.sessionMessageCountMap = {};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* get the sub-category of the plugin
|
|
64
|
-
*/
|
|
65
|
-
getSubCategory() {
|
|
66
|
-
return AWSPinpointProvider.subCategory;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
configure = (config = {}): Record<string, any> => {
|
|
70
|
-
this.config = {
|
|
71
|
-
...super.configure(config),
|
|
72
|
-
endpointInfo: { channelType: 'IN_APP' },
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
// some configuration steps should not be re-run even if provider is re-configured for some reason
|
|
76
|
-
if (!this.configured) {
|
|
77
|
-
this.sessionTracker = new SessionTracker(this.sessionStateChangeHandler);
|
|
78
|
-
this.sessionTracker.start();
|
|
79
|
-
// wire up default Pinpoint message event handling
|
|
80
|
-
addEventListener(
|
|
81
|
-
InAppMessageInteractionEvent.MESSAGE_DISPLAYED,
|
|
82
|
-
(message: InAppMessage) => {
|
|
83
|
-
this.recordMessageEvent(
|
|
84
|
-
message,
|
|
85
|
-
AWSPinpointMessageEvent.MESSAGE_DISPLAYED
|
|
86
|
-
);
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
addEventListener(
|
|
90
|
-
InAppMessageInteractionEvent.MESSAGE_DISMISSED,
|
|
91
|
-
(message: InAppMessage) => {
|
|
92
|
-
this.recordMessageEvent(
|
|
93
|
-
message,
|
|
94
|
-
AWSPinpointMessageEvent.MESSAGE_DISMISSED
|
|
95
|
-
);
|
|
96
|
-
}
|
|
97
|
-
);
|
|
98
|
-
addEventListener(
|
|
99
|
-
InAppMessageInteractionEvent.MESSAGE_ACTION_TAKEN,
|
|
100
|
-
(message: InAppMessage) => {
|
|
101
|
-
this.recordMessageEvent(
|
|
102
|
-
message,
|
|
103
|
-
AWSPinpointMessageEvent.MESSAGE_ACTION_TAKEN
|
|
104
|
-
);
|
|
105
|
-
}
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
this.configured = true;
|
|
110
|
-
dispatchInAppMessagingEvent('pinpointProvider_configured', null);
|
|
111
|
-
return this.config;
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
getInAppMessages = async () => {
|
|
115
|
-
if (!this.initialized) {
|
|
116
|
-
await this.init();
|
|
117
|
-
}
|
|
118
|
-
// There is no way to granuarly reconcile the filter memoization as the keys are composited from a message id and
|
|
119
|
-
// event properties thus opting to just clear them out when getting messages rather than leave potentially
|
|
120
|
-
// obsolete entries that will no longer serve any purpose.
|
|
121
|
-
clearMemo();
|
|
122
|
-
try {
|
|
123
|
-
await this.updateEndpoint();
|
|
124
|
-
// The credentials exists assuming `updateEndpoint()` is always called before.
|
|
125
|
-
const { appId, credentials, endpointId, region } = this.config;
|
|
126
|
-
const input: GetInAppMessagesInput = {
|
|
127
|
-
ApplicationId: appId,
|
|
128
|
-
EndpointId: endpointId,
|
|
129
|
-
};
|
|
130
|
-
this.logger.debug('getting in-app messages');
|
|
131
|
-
const response: GetInAppMessagesOutput = await getInAppMessages(
|
|
132
|
-
{ credentials, region },
|
|
133
|
-
input
|
|
134
|
-
);
|
|
135
|
-
const { InAppMessageCampaigns: messages } =
|
|
136
|
-
response.InAppMessagesResponse;
|
|
137
|
-
dispatchInAppMessagingEvent('getInAppMessages', messages);
|
|
138
|
-
return messages;
|
|
139
|
-
} catch (err) {
|
|
140
|
-
this.logger.error('Error getting in-app messages', err);
|
|
141
|
-
throw err;
|
|
142
|
-
}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
processInAppMessages = async (
|
|
146
|
-
messages: any[],
|
|
147
|
-
event: InAppMessagingEvent
|
|
148
|
-
): Promise<InAppMessage[]> => {
|
|
149
|
-
if (!this.initialized) {
|
|
150
|
-
await this.init();
|
|
151
|
-
}
|
|
152
|
-
let highestPrioritySeen;
|
|
153
|
-
return this.normalizeMessages(
|
|
154
|
-
(messages as PinpointInAppMessage[]).reduce((acc, message) => {
|
|
155
|
-
const messageQualifies =
|
|
156
|
-
matchesEventType(message, event) &&
|
|
157
|
-
matchesAttributes(message, event) &&
|
|
158
|
-
matchesMetrics(message, event) &&
|
|
159
|
-
isBeforeEndDate(message) &&
|
|
160
|
-
this.isBelowCap(message);
|
|
161
|
-
// filter all qualifying messages returning only those that are of (relative) highest priority
|
|
162
|
-
if (messageQualifies) {
|
|
163
|
-
// have not yet encountered message with priority
|
|
164
|
-
if (!highestPrioritySeen) {
|
|
165
|
-
// this message has priority, so reset the accumulator with this message only
|
|
166
|
-
if (message.Priority) {
|
|
167
|
-
highestPrioritySeen = message.Priority;
|
|
168
|
-
return [message];
|
|
169
|
-
} else {
|
|
170
|
-
// this message also has no priority, so just add this message to accumulator
|
|
171
|
-
acc.push(message);
|
|
172
|
-
}
|
|
173
|
-
// have previously encountered message with priority, so only messages with priority matter now
|
|
174
|
-
} else if (message.Priority) {
|
|
175
|
-
// this message has higher priority (lower number), so reset the accumulator with this message only
|
|
176
|
-
if (message.Priority < highestPrioritySeen) {
|
|
177
|
-
highestPrioritySeen = message.Priority;
|
|
178
|
-
return [message];
|
|
179
|
-
// this message has the same priority, so just add this message to accumulator
|
|
180
|
-
} else if (message.Priority === highestPrioritySeen) {
|
|
181
|
-
acc.push(message);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
return acc;
|
|
186
|
-
}, [])
|
|
187
|
-
);
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
private sessionStateChangeHandler: SessionStateChangeHandler = (
|
|
191
|
-
state: SessionState
|
|
192
|
-
) => {
|
|
193
|
-
if (state === 'started') {
|
|
194
|
-
// reset all session counts
|
|
195
|
-
this.sessionMessageCountMap = {};
|
|
196
|
-
}
|
|
197
|
-
};
|
|
198
|
-
|
|
199
|
-
private isBelowCap = ({
|
|
200
|
-
CampaignId,
|
|
201
|
-
SessionCap,
|
|
202
|
-
DailyCap,
|
|
203
|
-
TotalCap,
|
|
204
|
-
}: PinpointInAppMessage): boolean => {
|
|
205
|
-
const { sessionCount, dailyCount, totalCount } =
|
|
206
|
-
this.getMessageCounts(CampaignId);
|
|
207
|
-
return (
|
|
208
|
-
(!SessionCap || sessionCount < SessionCap) &&
|
|
209
|
-
(!DailyCap || dailyCount < DailyCap) &&
|
|
210
|
-
(!TotalCap || totalCount < TotalCap)
|
|
211
|
-
);
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
// Use the current session count in memory or initialize as empty count
|
|
215
|
-
private getSessionCount = (messageId: string): number =>
|
|
216
|
-
this.sessionMessageCountMap[messageId] || 0;
|
|
217
|
-
|
|
218
|
-
private getDailyCount = (): number => {
|
|
219
|
-
const { storage } = this.config;
|
|
220
|
-
const today = getStartOfDay();
|
|
221
|
-
const item = storage.getItem(MESSAGE_DAILY_COUNT_KEY);
|
|
222
|
-
// Parse stored count or initialize as empty count
|
|
223
|
-
const counter: DailyInAppMessageCounter = item
|
|
224
|
-
? JSON.parse(item)
|
|
225
|
-
: { count: 0, lastCountTimestamp: today };
|
|
226
|
-
// If the stored counter timestamp is today, use it as the count, otherwise reset to 0
|
|
227
|
-
return counter.lastCountTimestamp === today ? counter.count : 0;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
private getTotalCountMap = (): InAppMessageCountMap => {
|
|
231
|
-
const { storage } = this.config;
|
|
232
|
-
const item = storage.getItem(MESSAGE_TOTAL_COUNT_KEY);
|
|
233
|
-
// Parse stored count map or initialize as empty
|
|
234
|
-
return item ? JSON.parse(item) : {};
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
private getTotalCount = (messageId: string): number => {
|
|
238
|
-
const countMap = this.getTotalCountMap();
|
|
239
|
-
// Return stored count or initialize as empty count
|
|
240
|
-
return countMap[messageId] || 0;
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
private getMessageCounts = (messageId: string): InAppMessageCounts => {
|
|
244
|
-
try {
|
|
245
|
-
return {
|
|
246
|
-
sessionCount: this.getSessionCount(messageId),
|
|
247
|
-
dailyCount: this.getDailyCount(),
|
|
248
|
-
totalCount: this.getTotalCount(messageId),
|
|
249
|
-
};
|
|
250
|
-
} catch (err) {
|
|
251
|
-
this.logger.error('Failed to get message counts from storage', err);
|
|
252
|
-
}
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
private setSessionCount = (messageId: string, count: number): void => {
|
|
256
|
-
this.sessionMessageCountMap[messageId] = count;
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
private setDailyCount = (count: number): void => {
|
|
260
|
-
const { storage } = this.config;
|
|
261
|
-
const dailyCount: DailyInAppMessageCounter = {
|
|
262
|
-
count,
|
|
263
|
-
lastCountTimestamp: getStartOfDay(),
|
|
264
|
-
};
|
|
265
|
-
try {
|
|
266
|
-
storage.setItem(MESSAGE_DAILY_COUNT_KEY, JSON.stringify(dailyCount));
|
|
267
|
-
} catch (err) {
|
|
268
|
-
this.logger.error('Failed to save daily message count to storage', err);
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
private setTotalCountMap = (countMap: InAppMessageCountMap): void => {
|
|
273
|
-
const { storage } = this.config;
|
|
274
|
-
try {
|
|
275
|
-
storage.setItem(MESSAGE_TOTAL_COUNT_KEY, JSON.stringify(countMap));
|
|
276
|
-
} catch (err) {
|
|
277
|
-
this.logger.error('Failed to save total count to storage', err);
|
|
278
|
-
}
|
|
279
|
-
};
|
|
280
|
-
|
|
281
|
-
private setTotalCount = (messageId: string, count: number): void => {
|
|
282
|
-
const updatedMap = {
|
|
283
|
-
...this.getTotalCountMap(),
|
|
284
|
-
[messageId]: count,
|
|
285
|
-
};
|
|
286
|
-
this.setTotalCountMap(updatedMap);
|
|
287
|
-
};
|
|
288
|
-
|
|
289
|
-
private incrementCounts = async (messageId: string): Promise<void> => {
|
|
290
|
-
const { sessionCount, dailyCount, totalCount } =
|
|
291
|
-
this.getMessageCounts(messageId);
|
|
292
|
-
this.setSessionCount(messageId, sessionCount + 1);
|
|
293
|
-
this.setDailyCount(dailyCount + 1);
|
|
294
|
-
this.setTotalCount(messageId, totalCount + 1);
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
private normalizeMessages = (
|
|
298
|
-
messages: PinpointInAppMessage[]
|
|
299
|
-
): InAppMessage[] => {
|
|
300
|
-
return messages.map(message => {
|
|
301
|
-
const { CampaignId, InAppMessage } = message;
|
|
302
|
-
return {
|
|
303
|
-
id: CampaignId,
|
|
304
|
-
content: extractContent(message),
|
|
305
|
-
layout: interpretLayout(InAppMessage.Layout),
|
|
306
|
-
metadata: extractMetadata(message),
|
|
307
|
-
};
|
|
308
|
-
});
|
|
309
|
-
};
|
|
310
|
-
|
|
311
|
-
private recordMessageEvent = async (
|
|
312
|
-
message: InAppMessage,
|
|
313
|
-
event: AWSPinpointMessageEvent
|
|
314
|
-
): Promise<void> => {
|
|
315
|
-
if (!this.initialized) {
|
|
316
|
-
await this.init();
|
|
317
|
-
}
|
|
318
|
-
recordAnalyticsEvent(event, message);
|
|
319
|
-
if (event === AWSPinpointMessageEvent.MESSAGE_DISPLAYED) {
|
|
320
|
-
await this.incrementCounts(message.id);
|
|
321
|
-
}
|
|
322
|
-
};
|
|
323
|
-
}
|