@aws-amplify/notifications 2.0.17 → 2.0.18-experimental-lerna-test.d2b0b08.55
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/dist/cjs/eventListeners/eventListeners.js +4 -7
- package/dist/cjs/eventListeners/eventListeners.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/clearMessages.js +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/clearMessages.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js +11 -8
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/dispatchEvent.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/identifyUser.js +3 -2
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/identifyUser.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js +2 -2
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.js +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js +7 -28
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/setConflictHandler.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/syncMessages.js +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/apis/syncMessages.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.js +50 -0
- package/dist/cjs/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.js.map +1 -0
- package/dist/cjs/inAppMessaging/providers/pinpoint/utils/helpers.js +8 -8
- package/dist/cjs/inAppMessaging/providers/pinpoint/utils/helpers.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/utils/index.js +4 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/utils/index.js.map +1 -1
- package/dist/cjs/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js +5 -6
- package/dist/cjs/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.js.map +1 -1
- package/dist/cjs/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js +14 -5
- package/dist/cjs/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.js.map +1 -1
- package/dist/cjs/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js +1 -1
- package/dist/cjs/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.js.map +1 -1
- package/dist/esm/eventListeners/eventListeners.d.ts +2 -2
- package/dist/esm/eventListeners/eventListeners.mjs +4 -7
- package/dist/esm/eventListeners/eventListeners.mjs.map +1 -1
- package/dist/esm/eventListeners/types.d.ts +6 -5
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/clearMessages.mjs +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/clearMessages.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.d.ts +4 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.mjs +9 -5
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/dispatchEvent.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +2 -2
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/identifyUser.mjs +3 -2
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/identifyUser.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.mjs +2 -2
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.d.ts +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.mjs +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.d.ts +5 -3
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.mjs +11 -28
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/setConflictHandler.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/syncMessages.mjs +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/apis/syncMessages.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/types/inputs.d.ts +3 -3
- package/dist/esm/inAppMessaging/providers/pinpoint/types/types.d.ts +4 -4
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.d.ts +13 -0
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.mjs +46 -0
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.mjs.map +1 -0
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/helpers.d.ts +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/helpers.mjs +8 -8
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/helpers.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/index.d.ts +1 -0
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/index.mjs +1 -0
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/index.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.d.ts +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.mjs +5 -6
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.mjs.map +1 -1
- package/dist/esm/inAppMessaging/providers/pinpoint/utils/userAgent.mjs.map +1 -1
- package/dist/esm/inAppMessaging/types/event.d.ts +2 -2
- package/dist/esm/inAppMessaging/types/inputs.d.ts +2 -2
- package/dist/esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.mjs +14 -5
- package/dist/esm/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.mjs.map +1 -1
- package/dist/esm/pushNotifications/providers/pinpoint/types/analytics.d.ts +2 -2
- package/dist/esm/pushNotifications/providers/pinpoint/types/inputs.d.ts +1 -1
- package/dist/esm/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.d.ts +1 -1
- package/dist/esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.mjs +1 -1
- package/dist/esm/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.mjs.map +1 -1
- package/dist/esm/pushNotifications/providers/pinpoint/utils/resolveConfig.mjs.map +1 -1
- package/dist/esm/pushNotifications/types/inputs.d.ts +2 -2
- package/dist/esm/pushNotifications/utils/resolveCredentials.mjs.map +1 -1
- package/package.json +104 -103
- package/src/eventListeners/eventListeners.ts +16 -9
- package/src/eventListeners/types.ts +7 -5
- package/src/inAppMessaging/errors/assertServiceError.ts +1 -0
- package/src/inAppMessaging/providers/pinpoint/apis/clearMessages.ts +3 -2
- package/src/inAppMessaging/providers/pinpoint/apis/dispatchEvent.ts +19 -9
- package/src/inAppMessaging/providers/pinpoint/apis/identifyUser.ts +5 -7
- package/src/inAppMessaging/providers/pinpoint/apis/initializeInAppMessaging.ts +5 -3
- package/src/inAppMessaging/providers/pinpoint/apis/notifyMessageInteraction.ts +1 -0
- package/src/inAppMessaging/providers/pinpoint/apis/onMessageActionTaken.ts +2 -0
- package/src/inAppMessaging/providers/pinpoint/apis/onMessageDismissed.ts +2 -0
- package/src/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.ts +3 -1
- package/src/inAppMessaging/providers/pinpoint/apis/onMessageReceived.ts +2 -0
- package/src/inAppMessaging/providers/pinpoint/apis/setConflictHandler.ts +8 -32
- package/src/inAppMessaging/providers/pinpoint/apis/syncMessages.ts +12 -10
- package/src/inAppMessaging/providers/pinpoint/types/inputs.ts +8 -7
- package/src/inAppMessaging/providers/pinpoint/types/types.ts +4 -4
- package/src/inAppMessaging/providers/pinpoint/utils/conflictHandlerManager.ts +54 -0
- package/src/inAppMessaging/providers/pinpoint/utils/helpers.ts +19 -9
- package/src/inAppMessaging/providers/pinpoint/utils/index.ts +4 -0
- package/src/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.ts +19 -11
- package/src/inAppMessaging/providers/pinpoint/utils/resolveConfig.ts +2 -0
- package/src/inAppMessaging/providers/pinpoint/utils/resolveCredentials.ts +2 -0
- package/src/inAppMessaging/providers/pinpoint/utils/userAgent.ts +2 -2
- package/src/inAppMessaging/types/event.ts +2 -2
- package/src/inAppMessaging/types/inputs.ts +4 -3
- package/src/pushNotifications/errors/errorHelpers.ts +2 -0
- package/src/pushNotifications/providers/pinpoint/apis/getBadgeCount.native.ts +2 -0
- package/src/pushNotifications/providers/pinpoint/apis/getBadgeCount.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.native.ts +2 -0
- package/src/pushNotifications/providers/pinpoint/apis/getLaunchNotification.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.native.ts +2 -0
- package/src/pushNotifications/providers/pinpoint/apis/getPermissionStatus.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/identifyUser.native.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/identifyUser.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.ts +21 -12
- package/src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/onNotificationOpened.native.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/onNotificationOpened.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.native.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInBackground.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.native.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/onNotificationReceivedInForeground.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/onTokenReceived.native.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/onTokenReceived.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.native.ts +2 -0
- package/src/pushNotifications/providers/pinpoint/apis/requestPermissions.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/setBadgeCount.native.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/apis/setBadgeCount.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/types/analytics.ts +2 -2
- package/src/pushNotifications/providers/pinpoint/types/inputs.ts +4 -3
- package/src/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.ts +5 -1
- package/src/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.ts +3 -1
- package/src/pushNotifications/providers/pinpoint/utils/getChannelType.ts +1 -0
- package/src/pushNotifications/providers/pinpoint/utils/resolveConfig.ts +3 -1
- package/src/pushNotifications/types/inputs.ts +4 -3
- package/src/pushNotifications/utils/getPushNotificationUserAgentString.ts +1 -1
- package/src/pushNotifications/utils/resolveCredentials.ts +3 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initializePushNotifications.native.mjs","sources":["../../../../../../src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { PushNotificationAction } from '@aws-amplify/core/internals/utils';\nimport { updateEndpoint } from '@aws-amplify/core/internals/providers/pinpoint';\nimport { loadAmplifyPushNotification } from '@aws-amplify/react-native';\nimport { addEventListener, notifyEventListeners, notifyEventListenersAndAwaitHandlers, } from '../../../../eventListeners';\nimport { getPushNotificationUserAgentString, getToken, initialize, isInitialized, resolveCredentials, setToken, } from '../../../utils';\nimport { createMessageEventRecorder, getChannelType, resolveConfig, } from '../utils';\nconst { addMessageEventListener, addTokenEventListener, completeNotification, getConstants, registerHeadlessTask, } = loadAmplifyPushNotification();\nconst logger = new ConsoleLogger('Notifications.PushNotification');\nconst BACKGROUND_TASK_TIMEOUT = 25; // seconds\nexport const initializePushNotifications = () => {\n if (isInitialized()) {\n logger.info('Push notifications have already been enabled');\n return;\n }\n addNativeListeners();\n addAnalyticsListeners();\n initialize();\n};\nconst addNativeListeners = () => {\n let launchNotificationOpenedListener;\n const { NativeEvent, NativeHeadlessTaskKey } = getConstants();\n const { BACKGROUND_MESSAGE_RECEIVED, FOREGROUND_MESSAGE_RECEIVED, LAUNCH_NOTIFICATION_OPENED, NOTIFICATION_OPENED, TOKEN_RECEIVED, } = NativeEvent;\n // on platforms that can handle headless tasks, register one to broadcast background message received to\n // library listeners\n if (NativeHeadlessTaskKey) {\n registerHeadlessTask(async (message) => {\n // keep headless task running until handlers have completed their work\n await notifyEventListenersAndAwaitHandlers('backgroundMessageReceived', message);\n });\n }\n else if (BACKGROUND_MESSAGE_RECEIVED) {\n // on platforms that can't handle headless tasks, listen for native background message received event and\n // broadcast to library listeners\n addMessageEventListener(BACKGROUND_MESSAGE_RECEIVED, async (message, completionHandlerId) => {\n // keep background task running until handlers have completed their work\n try {\n await Promise.race([\n notifyEventListenersAndAwaitHandlers('backgroundMessageReceived', message),\n // background tasks will get suspended and all future tasks be deprioritized by the OS if they run for\n // more than 30 seconds so we reject with a error in a shorter amount of time to prevent this from\n // happening\n new Promise((_, reject) => {\n setTimeout(() => reject(`onNotificationReceivedInBackground handlers should complete their work within ${BACKGROUND_TASK_TIMEOUT} seconds, but they did not.`), BACKGROUND_TASK_TIMEOUT * 1000);\n }),\n ]);\n }\n catch (err) {\n logger.error(err);\n }\n finally {\n // notify native module that handlers have completed their work (or timed out)\n if (completionHandlerId) {\n completeNotification(completionHandlerId);\n }\n }\n });\n }\n addMessageEventListener(\n // listen for native foreground message received event and broadcast to library listeners\n FOREGROUND_MESSAGE_RECEIVED, message => {\n notifyEventListeners('foregroundMessageReceived', message);\n });\n launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED\n ? addMessageEventListener(\n // listen for native notification opened app (user tapped on notification, opening the app from quit -\n // not background - state) event. This is broadcasted to an internal listener only as it is not intended\n // for use otherwise as it produces inconsistent results when used within React Native app context\n LAUNCH_NOTIFICATION_OPENED, message => {\n notifyEventListeners('launchNotificationOpened', message);\n // once we are done with it we can remove the listener\n launchNotificationOpenedListener?.remove();\n })\n : null;\n addMessageEventListener(\n // listen for native notification opened (user tapped on notification, opening the app from background -\n // not quit - state) event and broadcast to library listeners\n NOTIFICATION_OPENED, message => {\n notifyEventListeners('notificationOpened', message);\n // if we are in this state, we no longer need the listener as the app was launched via some other means\n launchNotificationOpenedListener?.remove();\n });\n addTokenEventListener(\n // listen for native new token event, automatically re-register device with provider using new token and\n // broadcast to library listeners\n TOKEN_RECEIVED, async (token) => {\n // avoid a race condition where two endpoints are created with the same token on a fresh install\n if (getToken() === token) {\n return;\n }\n setToken(token);\n notifyEventListeners('tokenReceived', token);\n try {\n await registerDevice(token);\n }\n catch (err) {\n logger.error('Failed to register device for push notifications', err);\n throw err;\n }\n });\n};\nconst addAnalyticsListeners = () => {\n let launchNotificationOpenedListenerRemover;\n // wire up default Pinpoint message event handling\n addEventListener('backgroundMessageReceived', createMessageEventRecorder('received_background'));\n addEventListener('foregroundMessageReceived', createMessageEventRecorder('received_foreground'));\n launchNotificationOpenedListenerRemover = addEventListener('launchNotificationOpened', createMessageEventRecorder('opened_notification', \n // once we are done with it we can remove the listener\n launchNotificationOpenedListenerRemover?.remove));\n addEventListener('notificationOpened', createMessageEventRecorder('opened_notification', \n // if we are in this state, we no longer need the listener as the app was launched via some other means\n launchNotificationOpenedListenerRemover?.remove));\n};\nconst registerDevice = async (address) => {\n const { credentials, identityId } = await resolveCredentials();\n const { appId, region } = resolveConfig();\n await updateEndpoint({\n address,\n appId,\n category: 'PushNotification',\n credentials,\n region,\n channelType: getChannelType(),\n identityId,\n userAgentValue: getPushNotificationUserAgentString(PushNotificationAction.InitializePushNotifications),\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,YAAY,EAAE,oBAAoB,GAAG,GAAG,2BAA2B,EAAE,CAAC;AACpJ,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,gCAAgC,CAAC,CAAC;AACnE,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACvB,MAAC,2BAA2B,GAAG,MAAM;AACjD,IAAI,IAAI,aAAa,EAAE,EAAE;AACzB,QAAQ,MAAM,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;AACpE,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,kBAAkB,EAAE,CAAC;AACzB,IAAI,qBAAqB,EAAE,CAAC;AAC5B,IAAI,UAAU,EAAE,CAAC;AACjB,EAAE;AACF,MAAM,kBAAkB,GAAG,MAAM;AACjC,IAAI,IAAI,gCAAgC,CAAC;AACzC,IAAI,MAAM,EAAE,WAAW,EAAE,qBAAqB,EAAE,GAAG,YAAY,EAAE,CAAC;AAClE,IAAI,MAAM,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,cAAc,GAAG,GAAG,WAAW,CAAC;AACvJ;AACA;AACA,IAAI,IAAI,qBAAqB,EAAE;AAC/B,QAAQ,oBAAoB,CAAC,OAAO,OAAO,KAAK;AAChD;AACA,YAAY,MAAM,oCAAoC,CAAC,2BAA2B,EAAE,OAAO,CAAC,CAAC;AAC7F,SAAS,CAAC,CAAC;AACX,KAAK;AACL,SAAS,IAAI,2BAA2B,EAAE;AAC1C;AACA;AACA,QAAQ,uBAAuB,CAAC,2BAA2B,EAAE,OAAO,OAAO,EAAE,mBAAmB,KAAK;AACrG;AACA,YAAY,IAAI;AAChB,gBAAgB,MAAM,OAAO,CAAC,IA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AACzB,QAAQ,OAAO;AACf,QAAQ,KAAK;AACb,QAAQ,QAAQ,EAAE,kBAAkB;AACpC,QAAQ,WAAW;AACnB,QAAQ,MAAM;AACd,QAAQ,WAAW,EAAE,cAAc,EAAE;AACrC,QAAQ,UAAU;AAClB,QAAQ,cAAc,EAAE,kCAAkC,CAAC,sBAAsB,CAAC,2BAA2B,CAAC;AAC9G,KAAK,CAAC,CAAC;AACP,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"initializePushNotifications.native.mjs","sources":["../../../../../../src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { ConsoleLogger } from '@aws-amplify/core';\nimport { PushNotificationAction } from '@aws-amplify/core/internals/utils';\nimport { updateEndpoint } from '@aws-amplify/core/internals/providers/pinpoint';\nimport { loadAmplifyPushNotification } from '@aws-amplify/react-native';\nimport { addEventListener, notifyEventListeners, notifyEventListenersAndAwaitHandlers, } from '../../../../eventListeners';\nimport { getPushNotificationUserAgentString, getToken, initialize, isInitialized, resolveCredentials, setToken, } from '../../../utils';\nimport { createMessageEventRecorder, getChannelType, resolveConfig, } from '../utils';\nconst { addMessageEventListener, addTokenEventListener, completeNotification, getConstants, registerHeadlessTask, } = loadAmplifyPushNotification();\nconst logger = new ConsoleLogger('Notifications.PushNotification');\nconst BACKGROUND_TASK_TIMEOUT = 25; // seconds\nexport const initializePushNotifications = () => {\n if (isInitialized()) {\n logger.info('Push notifications have already been enabled');\n return;\n }\n addNativeListeners();\n addAnalyticsListeners();\n initialize();\n};\nconst addNativeListeners = () => {\n let launchNotificationOpenedListener;\n const { NativeEvent, NativeHeadlessTaskKey } = getConstants();\n const { BACKGROUND_MESSAGE_RECEIVED, FOREGROUND_MESSAGE_RECEIVED, LAUNCH_NOTIFICATION_OPENED, NOTIFICATION_OPENED, TOKEN_RECEIVED, } = NativeEvent;\n // on platforms that can handle headless tasks, register one to broadcast background message received to\n // library listeners\n if (NativeHeadlessTaskKey) {\n registerHeadlessTask(async (message) => {\n // keep headless task running until handlers have completed their work\n await notifyEventListenersAndAwaitHandlers('backgroundMessageReceived', message);\n });\n }\n else if (BACKGROUND_MESSAGE_RECEIVED) {\n // on platforms that can't handle headless tasks, listen for native background message received event and\n // broadcast to library listeners\n addMessageEventListener(BACKGROUND_MESSAGE_RECEIVED, async (message, completionHandlerId) => {\n // keep background task running until handlers have completed their work\n try {\n await Promise.race([\n notifyEventListenersAndAwaitHandlers('backgroundMessageReceived', message),\n // background tasks will get suspended and all future tasks be deprioritized by the OS if they run for\n // more than 30 seconds so we reject with a error in a shorter amount of time to prevent this from\n // happening\n new Promise((_resolve, reject) => {\n setTimeout(() => {\n reject(new Error(`onNotificationReceivedInBackground handlers should complete their work within ${BACKGROUND_TASK_TIMEOUT} seconds, but they did not.`));\n }, BACKGROUND_TASK_TIMEOUT * 1000);\n }),\n ]);\n }\n catch (err) {\n logger.error(err);\n }\n finally {\n // notify native module that handlers have completed their work (or timed out)\n if (completionHandlerId) {\n completeNotification(completionHandlerId);\n }\n }\n });\n }\n addMessageEventListener(\n // listen for native foreground message received event and broadcast to library listeners\n FOREGROUND_MESSAGE_RECEIVED, message => {\n notifyEventListeners('foregroundMessageReceived', message);\n });\n launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED\n ? addMessageEventListener(\n // listen for native notification opened app (user tapped on notification, opening the app from quit -\n // not background - state) event. This is broadcasted to an internal listener only as it is not intended\n // for use otherwise as it produces inconsistent results when used within React Native app context\n LAUNCH_NOTIFICATION_OPENED, message => {\n notifyEventListeners('launchNotificationOpened', message);\n // once we are done with it we can remove the listener\n launchNotificationOpenedListener?.remove();\n launchNotificationOpenedListener = undefined;\n })\n : undefined;\n addMessageEventListener(\n // listen for native notification opened (user tapped on notification, opening the app from background -\n // not quit - state) event and broadcast to library listeners\n NOTIFICATION_OPENED, message => {\n notifyEventListeners('notificationOpened', message);\n // if we are in this state, we no longer need the listener as the app was launched via some other means\n launchNotificationOpenedListener?.remove();\n });\n addTokenEventListener(\n // listen for native new token event, automatically re-register device with provider using new token and\n // broadcast to library listeners\n TOKEN_RECEIVED, async (token) => {\n // avoid a race condition where two endpoints are created with the same token on a fresh install\n if (getToken() === token) {\n return;\n }\n setToken(token);\n notifyEventListeners('tokenReceived', token);\n try {\n await registerDevice(token);\n }\n catch (err) {\n logger.error('Failed to register device for push notifications', err);\n throw err;\n }\n });\n};\nconst addAnalyticsListeners = () => {\n let launchNotificationOpenedListenerRemover;\n // wire up default Pinpoint message event handling\n addEventListener('backgroundMessageReceived', createMessageEventRecorder('received_background'));\n addEventListener('foregroundMessageReceived', createMessageEventRecorder('received_foreground'));\n launchNotificationOpenedListenerRemover = addEventListener('launchNotificationOpened', createMessageEventRecorder('opened_notification', \n // once we are done with it we can remove the listener\n () => {\n launchNotificationOpenedListenerRemover?.remove();\n launchNotificationOpenedListenerRemover = undefined;\n }));\n addEventListener('notificationOpened', createMessageEventRecorder('opened_notification', \n // if we are in this state, we no longer need the listener as the app was launched via some other means\n () => {\n launchNotificationOpenedListenerRemover?.remove();\n launchNotificationOpenedListenerRemover = undefined;\n }));\n};\nconst registerDevice = async (address) => {\n const { credentials, identityId } = await resolveCredentials();\n const { appId, region } = resolveConfig();\n await updateEndpoint({\n address,\n appId,\n category: 'PushNotification',\n credentials,\n region,\n channelType: getChannelType(),\n identityId,\n userAgentValue: getPushNotificationUserAgentString(PushNotificationAction.InitializePushNotifications),\n });\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AAAA;AACA;AAQA,MAAM,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,YAAY,EAAE,oBAAoB,GAAG,GAAG,2BAA2B,EAAE,CAAC;AACpJ,MAAM,MAAM,GAAG,IAAI,aAAa,CAAC,gCAAgC,CAAC,CAAC;AACnE,MAAM,uBAAuB,GAAG,EAAE,CAAC;AACvB,MAAC,2BAA2B,GAAG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M;AACd,QAAQ,WAAW,EAAE,cAAc,EAAE;AACrC,QAAQ,UAAU;AAClB,QAAQ,cAAc,EAAE,kCAAkC,CAAC,sBAAsB,CAAC,2BAA2B,CAAC;AAC9G,KAAK,CAAC,CAAC;AACP,CAAC;;;;"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export type PinpointMessageEvent = 'opened_notification' | 'received_background' | 'received_foreground';
|
|
2
2
|
export type PinpointMessageEventSource = '_campaign' | '_journey';
|
|
3
|
-
export
|
|
3
|
+
export interface AnalyticsEventAttributes {
|
|
4
4
|
source: PinpointMessageEventSource;
|
|
5
5
|
attributes: Record<string, string>;
|
|
6
|
-
}
|
|
6
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { PushNotificationIdentifyUserInput, PushNotificationOnNotificationOpenedInput, PushNotificationOnNotificationReceivedInBackgroundInput, PushNotificationOnNotificationReceivedInForegroundInput, PushNotificationOnTokenReceivedInput, PushNotificationRequestPermissionsInput, PushNotificationSetBadgeCountInput } from '../../../types';
|
|
1
2
|
import { IdentifyUserOptions } from './options';
|
|
2
|
-
import { PushNotificationIdentifyUserInput, PushNotificationRequestPermissionsInput, PushNotificationSetBadgeCountInput, PushNotificationOnNotificationOpenedInput, PushNotificationOnNotificationReceivedInBackgroundInput, PushNotificationOnNotificationReceivedInForegroundInput, PushNotificationOnTokenReceivedInput } from '../../../types';
|
|
3
3
|
export type IdentifyUserInput = PushNotificationIdentifyUserInput<IdentifyUserOptions>;
|
|
4
4
|
export type RequestPermissionsInput = PushNotificationRequestPermissionsInput;
|
|
5
5
|
export type SetBadgeCountInput = PushNotificationSetBadgeCountInput;
|
|
@@ -3,4 +3,4 @@ import { OnPushNotificationMessageHandler } from '../../../types';
|
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
6
|
-
export declare const createMessageEventRecorder: (event: PinpointMessageEvent, callback?:
|
|
6
|
+
export declare const createMessageEventRecorder: (event: PinpointMessageEvent, callback?: () => void) => OnPushNotificationMessageHandler;
|
|
@@ -24,7 +24,7 @@ const getAnalyticsEventAttributes = (data) => {
|
|
|
24
24
|
if (!data) {
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
if (
|
|
27
|
+
if (Object.prototype.hasOwnProperty.call(data, ANDROID_CAMPAIGN_ID_KEY)) {
|
|
28
28
|
return {
|
|
29
29
|
source: '_campaign',
|
|
30
30
|
attributes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getAnalyticsEvent.mjs","sources":["../../../../../../src/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst ANDROID_CAMPAIGN_ACTIVITY_ID_KEY = 'pinpoint.campaign.campaign_activity_id';\nconst ANDROID_CAMPAIGN_ID_KEY = 'pinpoint.campaign.campaign_id';\nconst ANDROID_CAMPAIGN_TREATMENT_ID_KEY = 'pinpoint.campaign.treatment_id';\n/**\n * @internal\n */\nexport const getAnalyticsEvent = ({ data }, event) => {\n if (!data) {\n return null;\n }\n const eventAttributes = getAnalyticsEventAttributes(data);\n if (!eventAttributes) {\n return null;\n }\n const { source, attributes } = eventAttributes;\n return {\n attributes,\n name: `${source}.${event}`,\n };\n};\nconst getAnalyticsEventAttributes = (data) => {\n if (!data) {\n return;\n }\n if (
|
|
1
|
+
{"version":3,"file":"getAnalyticsEvent.mjs","sources":["../../../../../../src/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nconst ANDROID_CAMPAIGN_ACTIVITY_ID_KEY = 'pinpoint.campaign.campaign_activity_id';\nconst ANDROID_CAMPAIGN_ID_KEY = 'pinpoint.campaign.campaign_id';\nconst ANDROID_CAMPAIGN_TREATMENT_ID_KEY = 'pinpoint.campaign.treatment_id';\n/**\n * @internal\n */\nexport const getAnalyticsEvent = ({ data }, event) => {\n if (!data) {\n return null;\n }\n const eventAttributes = getAnalyticsEventAttributes(data);\n if (!eventAttributes) {\n return null;\n }\n const { source, attributes } = eventAttributes;\n return {\n attributes,\n name: `${source}.${event}`,\n };\n};\nconst getAnalyticsEventAttributes = (data) => {\n if (!data) {\n return;\n }\n if (Object.prototype.hasOwnProperty.call(data, ANDROID_CAMPAIGN_ID_KEY)) {\n return {\n source: '_campaign',\n attributes: {\n campaign_activity_id: data[ANDROID_CAMPAIGN_ACTIVITY_ID_KEY],\n campaign_id: data[ANDROID_CAMPAIGN_ID_KEY],\n treatment_id: data[ANDROID_CAMPAIGN_TREATMENT_ID_KEY],\n },\n };\n }\n const pinpoint = typeof data.pinpoint === 'string'\n ? JSON.parse(data.pinpoint)\n : data.pinpoint;\n if (pinpoint?.campaign) {\n return {\n source: '_campaign',\n attributes: pinpoint.campaign,\n };\n }\n if (pinpoint?.journey) {\n return {\n source: '_journey',\n attributes: pinpoint.journey,\n };\n }\n};\n"],"names":[],"mappings":"AAAA;AACA;AACA,MAAM,gCAAgC,GAAG,wCAAwC,CAAC;AAClF,MAAM,uBAAuB,GAAG,+BAA+B,CAAC;AAChE,MAAM,iCAAiC,GAAG,gCAAgC,CAAC;AAC3E;AACA;AACA;AACY,MAAC,iBAAiB,GAAG,CAAC,EAAE,IAAI,EAAE,EAAE,KAAK,KAAK;AACtD,IAAI,IAAI,CAAC,IAAI,EAAE;AACf,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,MAAM,eAAe,GAAG,2BAA2B,CAAC,IAAI,CAAC,CAAC;AAC9D,IAAI,IAAI,CAAC,eAAe,EAAE;AAC1B,QAAQ,OAAO,IAAI,CAAC;AACpB,KAAK;AACL,IAAI,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,eAAe,CAAC;AACnD,IAAI,OAAO;AACX,QAAQ,UAAU;AAClB,QAAQ,IAAI,EAAE,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AAClC,KAAK,CAAC;AACN,EAAE;AACF,MAAM,2BAA2B,GAAG,CAAC,IAAI,KAAK;AAC9C,IAAI,IAAI,CAAC,IAAI,EAAE;AACf,QAAQ,OAAO;AACf,KAAK;AACL,IAAI,IAAI,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CAAC,IAAI,EAAE,uBAAuB,CAAC,EAAE;AAC7E,QAAQ,OAAO;AACf,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,UAAU,EAAE;AACxB,gBAAgB,oBAAoB,EAAE,IAAI,CAAC,gCAAgC,CAAC;AAC5E,gBAAgB,WAAW,EAAE,IAAI,CAAC,uBAAuB,CAAC;AAC1D,gBAAgB,YAAY,EAAE,IAAI,CAAC,iCAAiC,CAAC;AACrE,aAAa;AACb,SAAS,CAAC;AACV,KAAK;AACL,IAAI,MAAM,QAAQ,GAAG,OAAO,IAAI,CAAC,QAAQ,KAAK,QAAQ;AACtD,UAAU,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC;AACnC,UAAU,IAAI,CAAC,QAAQ,CAAC;AACxB,IAAI,IAAI,QAAQ,EAAE,QAAQ,EAAE;AAC5B,QAAQ,OAAO;AACf,YAAY,MAAM,EAAE,WAAW;AAC/B,YAAY,UAAU,EAAE,QAAQ,CAAC,QAAQ;AACzC,SAAS,CAAC;AACV,KAAK;AACL,IAAI,IAAI,QAAQ,EAAE,OAAO,EAAE;AAC3B,QAAQ,OAAO;AACf,YAAY,MAAM,EAAE,UAAU;AAC9B,YAAY,UAAU,EAAE,QAAQ,CAAC,OAAO;AACxC,SAAS,CAAC;AACV,KAAK;AACL,CAAC;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveConfig.mjs","sources":["../../../../../../src/pushNotifications/providers/pinpoint/utils/resolveConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport {
|
|
1
|
+
{"version":3,"file":"resolveConfig.mjs","sources":["../../../../../../src/pushNotifications/providers/pinpoint/utils/resolveConfig.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { Amplify } from '@aws-amplify/core';\nimport { PushNotificationValidationErrorCode, assert } from '../../../errors';\n/**\n * @internal\n */\nexport const resolveConfig = () => {\n const { appId, region } = Amplify.getConfig().Notifications?.PushNotification?.Pinpoint ?? {};\n assert(!!appId, PushNotificationValidationErrorCode.NoAppId);\n assert(!!region, PushNotificationValidationErrorCode.NoRegion);\n return { appId, region };\n};\n"],"names":[],"mappings":";;;;AAAA;AACA;AAGA;AACA;AACA;AACY,MAAC,aAAa,GAAG,MAAM;AACnC,IAAI,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,aAAa,EAAE,gBAAgB,EAAE,QAAQ,IAAI,EAAE,CAAC;AAClG,IAAI,MAAM,CAAC,CAAC,CAAC,KAAK,EAAE,mCAAmC,CAAC,OAAO,CAAC,CAAC;AACjE,IAAI,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,mCAAmC,CAAC,QAAQ,CAAC,CAAC;AACnE,IAAI,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAC7B;;;;"}
|
|
@@ -2,7 +2,7 @@ import { UserProfile } from '@aws-amplify/core';
|
|
|
2
2
|
import { PushNotificationServiceOptions } from './options';
|
|
3
3
|
import { PushNotificationPermissions } from './module';
|
|
4
4
|
import { OnPushNotificationMessageHandler, OnTokenReceivedHandler } from './pushNotifications';
|
|
5
|
-
export
|
|
5
|
+
export interface PushNotificationIdentifyUserInput<ServiceOptions extends PushNotificationServiceOptions = PushNotificationServiceOptions> {
|
|
6
6
|
/**
|
|
7
7
|
* A User ID associated to the current device.
|
|
8
8
|
*/
|
|
@@ -15,7 +15,7 @@ export type PushNotificationIdentifyUserInput<ServiceOptions extends PushNotific
|
|
|
15
15
|
* Options to be passed to the API.
|
|
16
16
|
*/
|
|
17
17
|
options?: ServiceOptions;
|
|
18
|
-
}
|
|
18
|
+
}
|
|
19
19
|
export type PushNotificationRequestPermissionsInput = PushNotificationPermissions;
|
|
20
20
|
export type PushNotificationSetBadgeCountInput = number;
|
|
21
21
|
export type PushNotificationOnNotificationOpenedInput = OnPushNotificationMessageHandler;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveCredentials.mjs","sources":["../../../../src/pushNotifications/utils/resolveCredentials.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { fetchAuthSession } from '@aws-amplify/core';\nimport {
|
|
1
|
+
{"version":3,"file":"resolveCredentials.mjs","sources":["../../../../src/pushNotifications/utils/resolveCredentials.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { fetchAuthSession } from '@aws-amplify/core';\nimport { PushNotificationValidationErrorCode, assert, } from '../errors/errorHelpers';\n/**\n * @internal\n */\nexport const resolveCredentials = async () => {\n const { credentials, identityId } = await fetchAuthSession();\n assert(!!credentials, PushNotificationValidationErrorCode.NoCredentials);\n return { credentials, identityId };\n};\n"],"names":[],"mappings":";;;AAAA;AACA;AAGA;AACA;AACA;AACY,MAAC,kBAAkB,GAAG,YAAY;AAC9C,IAAI,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,GAAG,MAAM,gBAAgB,EAAE,CAAC;AACjE,IAAI,MAAM,CAAC,CAAC,CAAC,WAAW,EAAE,mCAAmC,CAAC,aAAa,CAAC,CAAC;AAC7E,IAAI,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AACvC;;;;"}
|
package/package.json
CHANGED
|
@@ -1,105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
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
2
|
+
"name": "@aws-amplify/notifications",
|
|
3
|
+
"version": "2.0.18-experimental-lerna-test.d2b0b08.55+d2b0b087b",
|
|
4
|
+
"description": "Notifications category of aws-amplify",
|
|
5
|
+
"main": "./dist/cjs/index.js",
|
|
6
|
+
"module": "./dist/esm/index.mjs",
|
|
7
|
+
"react-native": "./src/index.ts",
|
|
8
|
+
"typings": "./dist/esm/index.d.ts",
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"publishConfig": {
|
|
11
|
+
"access": "public"
|
|
12
|
+
},
|
|
13
|
+
"scripts": {
|
|
14
|
+
"test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
|
|
15
|
+
"test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
|
|
16
|
+
"build-with-test": "npm run clean && npm run build",
|
|
17
|
+
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
|
|
18
|
+
"build:esm-cjs": "rollup -c rollup.config.mjs",
|
|
19
|
+
"build:watch": "npm run build:esm-cjs -- --watch",
|
|
20
|
+
"build": "npm run clean && npm run build:esm-cjs && npm run build:umd",
|
|
21
|
+
"clean": "npm run clean:size && rimraf dist lib lib-esm",
|
|
22
|
+
"clean:size": "rimraf dual-publish-tmp tmp*",
|
|
23
|
+
"format": "echo \"Not implemented\"",
|
|
24
|
+
"lint": "eslint '**/*.{ts,tsx}' && npm run ts-coverage",
|
|
25
|
+
"lint:fix": "eslint '**/*.{ts,tsx}' --fix",
|
|
26
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 88.21"
|
|
27
|
+
},
|
|
28
|
+
"typesVersions": {
|
|
29
|
+
">=4.2": {
|
|
30
|
+
"in-app-messaging": [
|
|
31
|
+
"./dist/esm/inAppMessaging/index.d.ts"
|
|
32
|
+
],
|
|
33
|
+
"push-notifications": [
|
|
34
|
+
"./dist/esm/pushNotifications/providers/index.d.ts"
|
|
35
|
+
],
|
|
36
|
+
"in-app-messaging/pinpoint": [
|
|
37
|
+
"./dist/esm/inAppMessaging/providers/pinpoint/index.d.ts"
|
|
38
|
+
],
|
|
39
|
+
"push-notifications/pinpoint": [
|
|
40
|
+
"./dist/esm/pushNotifications/providers/pinpoint/index.d.ts"
|
|
41
|
+
]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"exports": {
|
|
45
|
+
".": {
|
|
46
|
+
"import": "./dist/esm/index.mjs",
|
|
47
|
+
"require": "./dist/cjs/index.js",
|
|
48
|
+
"react-native": "./src/index.ts"
|
|
49
|
+
},
|
|
50
|
+
"./in-app-messaging": {
|
|
51
|
+
"types": "./dist/esm/inAppMessaging/index.d.ts",
|
|
52
|
+
"import": "./dist/esm/inAppMessaging/index.mjs",
|
|
53
|
+
"require": "./dist/cjs/inAppMessaging/index.js",
|
|
54
|
+
"react-native": "./src/inAppMessaging/index.ts"
|
|
55
|
+
},
|
|
56
|
+
"./push-notifications": {
|
|
57
|
+
"types": "./dist/esm/pushNotifications/index.d.ts",
|
|
58
|
+
"import": "./dist/esm/pushNotifications/index.mjs",
|
|
59
|
+
"require": "./dist/cjs/pushNotifications/index.js",
|
|
60
|
+
"react-native": "./src/pushNotifications/index.ts"
|
|
61
|
+
},
|
|
62
|
+
"./in-app-messaging/pinpoint": {
|
|
63
|
+
"types": "./dist/esm/inAppMessaging/providers/pinpoint/index.d.ts",
|
|
64
|
+
"import": "./dist/esm/inAppMessaging/providers/pinpoint/index.mjs",
|
|
65
|
+
"require": "./dist/cjs/inAppMessaging/providers/pinpoint/index.js",
|
|
66
|
+
"react-native": "./src/inAppMessaging/providers/pinpoint/index.ts"
|
|
67
|
+
},
|
|
68
|
+
"./push-notifications/pinpoint": {
|
|
69
|
+
"types": "./dist/esm/pushNotifications/providers/pinpoint/index.d.ts",
|
|
70
|
+
"import": "./dist/esm/pushNotifications/providers/pinpoint/index.mjs",
|
|
71
|
+
"require": "./dist/cjs/pushNotifications/providers/pinpoint/index.js",
|
|
72
|
+
"react-native": "./src/pushNotifications/providers/pinpoint/index.ts"
|
|
73
|
+
},
|
|
74
|
+
"./package.json": "./package.json"
|
|
75
|
+
},
|
|
76
|
+
"repository": {
|
|
77
|
+
"type": "git",
|
|
78
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
79
|
+
},
|
|
80
|
+
"author": "Amazon Web Services",
|
|
81
|
+
"license": "Apache-2.0",
|
|
82
|
+
"bugs": {
|
|
83
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
84
|
+
},
|
|
85
|
+
"homepage": "https://docs.amplify.aws/",
|
|
86
|
+
"files": [
|
|
87
|
+
"dist/cjs",
|
|
88
|
+
"dist/esm",
|
|
89
|
+
"src",
|
|
90
|
+
"in-app-messaging",
|
|
91
|
+
"push-notifications"
|
|
92
|
+
],
|
|
93
|
+
"dependencies": {
|
|
94
|
+
"lodash": "^4.17.21",
|
|
95
|
+
"tslib": "^2.5.0"
|
|
96
|
+
},
|
|
97
|
+
"peerDependencies": {
|
|
98
|
+
"@aws-amplify/core": "6.0.18-experimental-lerna-test.d2b0b08.55+d2b0b087b"
|
|
99
|
+
},
|
|
100
|
+
"devDependencies": {
|
|
101
|
+
"@aws-amplify/core": "6.0.18-experimental-lerna-test.d2b0b08.55+d2b0b087b",
|
|
102
|
+
"@aws-amplify/react-native": "1.0.18-experimental-lerna-test.d2b0b08.55+d2b0b087b",
|
|
103
|
+
"typescript": "5.0.2"
|
|
104
|
+
},
|
|
105
|
+
"gitHead": "d2b0b087bdaa4db452916b53afff3d664c29cca0"
|
|
105
106
|
}
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
EventListener,
|
|
6
|
+
EventListenerHandler,
|
|
7
|
+
EventListenerRemover,
|
|
8
|
+
EventType,
|
|
9
|
+
} from './types';
|
|
5
10
|
|
|
6
|
-
const eventListeners: Record<
|
|
11
|
+
const eventListeners: Record<
|
|
12
|
+
string,
|
|
13
|
+
Set<EventListener<EventListenerHandler>>
|
|
14
|
+
> = {};
|
|
7
15
|
|
|
8
16
|
export const notifyEventListeners = (type: EventType, ...args: any[]): void => {
|
|
9
17
|
eventListeners[type]?.forEach(listener => {
|
|
@@ -17,15 +25,11 @@ export const notifyEventListenersAndAwaitHandlers = (
|
|
|
17
25
|
): Promise<void[]> =>
|
|
18
26
|
Promise.all<void>(
|
|
19
27
|
Array.from(eventListeners[type] ?? []).map(async listener => {
|
|
20
|
-
|
|
21
|
-
await listener.handleEvent(...args);
|
|
22
|
-
} catch (err) {
|
|
23
|
-
throw err;
|
|
24
|
-
}
|
|
28
|
+
await listener.handleEvent(...args);
|
|
25
29
|
}),
|
|
26
30
|
);
|
|
27
31
|
|
|
28
|
-
export const addEventListener = <EventHandler extends
|
|
32
|
+
export const addEventListener = <EventHandler extends EventListenerHandler>(
|
|
29
33
|
type: EventType,
|
|
30
34
|
handler: EventHandler,
|
|
31
35
|
): EventListenerRemover => {
|
|
@@ -40,7 +44,10 @@ export const addEventListener = <EventHandler extends Function>(
|
|
|
40
44
|
},
|
|
41
45
|
};
|
|
42
46
|
eventListeners[type].add(listener);
|
|
47
|
+
|
|
43
48
|
return {
|
|
44
|
-
remove: () =>
|
|
49
|
+
remove: () => {
|
|
50
|
+
listener.remove();
|
|
51
|
+
},
|
|
45
52
|
};
|
|
46
53
|
};
|
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
import { InAppMessageInteractionEvent } from '../inAppMessaging/types';
|
|
5
5
|
import { PushNotificationEvent } from '../pushNotifications/types';
|
|
6
6
|
|
|
7
|
-
export
|
|
7
|
+
export type EventListenerHandler = (...args: any[]) => unknown;
|
|
8
|
+
|
|
9
|
+
export interface EventListener<EventHandler extends EventListenerHandler> {
|
|
8
10
|
handleEvent: EventHandler;
|
|
9
|
-
remove
|
|
11
|
+
remove(): void;
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export type EventType = InAppMessageInteractionEvent | PushNotificationEvent;
|
|
13
15
|
|
|
14
|
-
export
|
|
15
|
-
remove
|
|
16
|
-
}
|
|
16
|
+
export interface EventListenerRemover {
|
|
17
|
+
remove(): void;
|
|
18
|
+
}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { defaultStorage } from '@aws-amplify/core';
|
|
5
|
-
import { STORAGE_KEY_SUFFIX, PINPOINT_KEY_PREFIX } from '../utils';
|
|
6
5
|
|
|
6
|
+
import { PINPOINT_KEY_PREFIX, STORAGE_KEY_SUFFIX } from '../utils';
|
|
7
7
|
import { InAppMessagingValidationErrorCode } from '../../../errors';
|
|
8
8
|
import { assertIsInitialized } from '../../../utils';
|
|
9
9
|
|
|
@@ -22,5 +22,6 @@ import { assertIsInitialized } from '../../../utils';
|
|
|
22
22
|
export async function clearMessages(): Promise<void> {
|
|
23
23
|
assertIsInitialized();
|
|
24
24
|
const key = `${PINPOINT_KEY_PREFIX}${STORAGE_KEY_SUFFIX}`;
|
|
25
|
-
|
|
25
|
+
|
|
26
|
+
await defaultStorage.removeItem(key);
|
|
26
27
|
}
|
|
@@ -1,20 +1,26 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import flatten from 'lodash/flatten.js';
|
|
5
|
+
import { defaultStorage } from '@aws-amplify/core';
|
|
6
|
+
|
|
7
|
+
import { notifyEventListeners } from '../../../../eventListeners';
|
|
8
|
+
import {
|
|
9
|
+
InAppMessagingValidationErrorCode,
|
|
10
|
+
assertServiceError,
|
|
11
|
+
} from '../../../errors';
|
|
12
|
+
import { InAppMessage } from '../../../types';
|
|
13
|
+
import { assertIsInitialized } from '../../../utils';
|
|
14
|
+
import { DispatchEventInput } from '../types';
|
|
4
15
|
import {
|
|
5
16
|
PINPOINT_KEY_PREFIX,
|
|
6
17
|
STORAGE_KEY_SUFFIX,
|
|
18
|
+
getConflictHandler,
|
|
7
19
|
processInAppMessages,
|
|
8
20
|
} from '../utils';
|
|
9
|
-
|
|
10
|
-
import flatten from 'lodash/flatten.js';
|
|
11
|
-
import { defaultStorage } from '@aws-amplify/core';
|
|
12
|
-
import { notifyEventListeners } from '../../../../eventListeners';
|
|
13
|
-
import { assertServiceError } from '../../../errors';
|
|
14
|
-
import { DispatchEventInput } from '../types';
|
|
21
|
+
|
|
15
22
|
import { syncMessages } from './syncMessages';
|
|
16
|
-
import {
|
|
17
|
-
import { assertIsInitialized } from '../../../utils';
|
|
23
|
+
import { setConflictHandler } from './setConflictHandler';
|
|
18
24
|
|
|
19
25
|
/**
|
|
20
26
|
* Triggers an In-App message to be displayed. Use this after your campaigns have been synced to the device using
|
|
@@ -26,11 +32,14 @@ import { assertIsInitialized } from '../../../utils';
|
|
|
26
32
|
* To change this behavior, you can use the {@link setConflictHandler} API to provide
|
|
27
33
|
* your own logic for resolving message conflicts.
|
|
28
34
|
*
|
|
29
|
-
* @param
|
|
35
|
+
* @param input The input object that holds the event to be dispatched.
|
|
36
|
+
*
|
|
30
37
|
* @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
|
|
31
38
|
* configuration is incorrect, or if In App messaging hasn't been initialized.
|
|
32
39
|
* @throws service exceptions - Thrown when the underlying Pinpoint service returns an error.
|
|
40
|
+
*
|
|
33
41
|
* @returns A promise that will resolve when the operation is complete.
|
|
42
|
+
*
|
|
34
43
|
* @example
|
|
35
44
|
* ```ts
|
|
36
45
|
* // Sync message before disptaching an event
|
|
@@ -51,6 +60,7 @@ export async function dispatchEvent(input: DispatchEventInput): Promise<void> {
|
|
|
51
60
|
);
|
|
52
61
|
const flattenedMessages = flatten(messages);
|
|
53
62
|
if (flattenedMessages.length > 0) {
|
|
63
|
+
const conflictHandler = getConflictHandler();
|
|
54
64
|
notifyEventListeners(
|
|
55
65
|
'messageReceived',
|
|
56
66
|
conflictHandler(flattenedMessages),
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
import { InAppMessagingAction } from '@aws-amplify/core/internals/utils';
|
|
5
5
|
import {
|
|
6
|
-
updateEndpoint,
|
|
7
6
|
UpdateEndpointException,
|
|
7
|
+
updateEndpoint,
|
|
8
8
|
} from '@aws-amplify/core/internals/providers/pinpoint';
|
|
9
|
+
|
|
9
10
|
import { InAppMessagingValidationErrorCode } from '../../../errors';
|
|
10
11
|
import {
|
|
11
12
|
CATEGORY,
|
|
@@ -22,7 +23,7 @@ import { assertIsInitialized } from '../../../utils';
|
|
|
22
23
|
* profile and activities or actions in your application. Activity can be tracked across devices & platforms by using
|
|
23
24
|
* the same `userId`.
|
|
24
25
|
*
|
|
25
|
-
* @param
|
|
26
|
+
* @param input The input object that conforms to {@link IdentifyUserInput} used to construct requests sent to Pinpoint's UpdateEndpoint
|
|
26
27
|
* API.
|
|
27
28
|
* @throws service: {@link UpdateEndpointException} - Thrown when the underlying Pinpoint service returns an error.
|
|
28
29
|
* @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
|
|
@@ -66,11 +67,8 @@ import { assertIsInitialized } from '../../../utils';
|
|
|
66
67
|
* },
|
|
67
68
|
* });
|
|
68
69
|
*/
|
|
69
|
-
export const identifyUser = async ({
|
|
70
|
-
userId,
|
|
71
|
-
userProfile,
|
|
72
|
-
options,
|
|
73
|
-
}: IdentifyUserInput): Promise<void> => {
|
|
70
|
+
export const identifyUser = async (input: IdentifyUserInput): Promise<void> => {
|
|
71
|
+
const { userId, userProfile, options } = input;
|
|
74
72
|
assertIsInitialized();
|
|
75
73
|
const { credentials, identityId } = await resolveCredentials();
|
|
76
74
|
const { appId, region } = resolveConfig();
|
|
@@ -2,14 +2,16 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { sessionListener } from '@aws-amplify/core/internals/utils';
|
|
5
|
+
import { Hub, HubCapsule } from '@aws-amplify/core';
|
|
6
|
+
|
|
5
7
|
import { InAppMessage, InAppMessagingEvent } from '../../../types';
|
|
6
8
|
import { addEventListener } from '../../../../eventListeners';
|
|
7
9
|
import { recordAnalyticsEvent } from '../utils/helpers';
|
|
8
10
|
import { PinpointMessageEvent } from '../types';
|
|
9
|
-
import { Hub, HubCapsule } from '@aws-amplify/core';
|
|
10
|
-
import { dispatchEvent } from './dispatchEvent';
|
|
11
11
|
import { incrementMessageCounts, sessionStateChangeHandler } from '../utils';
|
|
12
|
-
import {
|
|
12
|
+
import { initialize, isInitialized } from '../../../utils';
|
|
13
|
+
|
|
14
|
+
import { dispatchEvent } from './dispatchEvent';
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Initialize and set up in-app messaging category. This API needs to be called to enable other InAppMessaging APIs.
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { notifyEventListeners } from '../../../../eventListeners';
|
|
5
|
+
import { InAppMessagingValidationErrorCode } from '../../../errors';
|
|
5
6
|
import { assertIsInitialized } from '../../../utils';
|
|
6
7
|
import { NotifyMessageInteractionInput } from '../types/inputs';
|
|
7
8
|
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { addEventListener } from '../../../../eventListeners';
|
|
5
|
+
import { InAppMessagingValidationErrorCode } from '../../../errors';
|
|
5
6
|
import { assertIsInitialized } from '../../../utils';
|
|
6
7
|
import { OnMessageActionTakenInput } from '../types/inputs';
|
|
7
8
|
import { OnMessageActionTakenOutput } from '../types/outputs';
|
|
@@ -25,5 +26,6 @@ export function onMessageActionTaken(
|
|
|
25
26
|
input: OnMessageActionTakenInput,
|
|
26
27
|
): OnMessageActionTakenOutput {
|
|
27
28
|
assertIsInitialized();
|
|
29
|
+
|
|
28
30
|
return addEventListener('messageActionTaken', input);
|
|
29
31
|
}
|
|
@@ -5,6 +5,7 @@ import { addEventListener } from '../../../../eventListeners';
|
|
|
5
5
|
import { OnMessageDismissedOutput } from '../types/outputs';
|
|
6
6
|
import { OnMessageDismissedInput } from '../types/inputs';
|
|
7
7
|
import { assertIsInitialized } from '../../../utils';
|
|
8
|
+
import { InAppMessagingValidationErrorCode } from '../../../errors';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* Registers a callback that will be invoked on `messageDismissed` events.
|
|
@@ -25,5 +26,6 @@ export function onMessageDismissed(
|
|
|
25
26
|
input: OnMessageDismissedInput,
|
|
26
27
|
): OnMessageDismissedOutput {
|
|
27
28
|
assertIsInitialized();
|
|
29
|
+
|
|
28
30
|
return addEventListener('messageDismissed', input);
|
|
29
31
|
}
|