@aws-amplify/notifications 2.0.1-console-preview.11cf989.0 → 2.0.1-console-preview.4ae78ed.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/lib/common/AWSPinpointProviderCommon/index.d.ts +2 -2
  2. package/lib/common/AWSPinpointProviderCommon/index.js +1 -1
  3. package/lib/common/AWSPinpointProviderCommon/index.js.map +1 -1
  4. package/lib/common/AWSPinpointProviderCommon/types.d.ts +2 -2
  5. package/lib/inAppMessaging/index.d.ts +0 -1
  6. package/lib/inAppMessaging/index.js +0 -2
  7. package/lib/inAppMessaging/index.js.map +1 -1
  8. package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +55 -2
  9. package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.js +89 -4
  10. package/lib/inAppMessaging/providers/pinpoint/apis/identifyUser.js.map +1 -1
  11. package/lib/inAppMessaging/providers/pinpoint/apis/syncMessages.js +1 -2
  12. package/lib/inAppMessaging/providers/pinpoint/apis/syncMessages.js.map +1 -1
  13. package/lib/inAppMessaging/providers/pinpoint/types/errors.d.ts +9 -0
  14. package/lib/inAppMessaging/providers/pinpoint/types/errors.js +15 -0
  15. package/lib/inAppMessaging/providers/pinpoint/types/errors.js.map +1 -0
  16. package/lib/inAppMessaging/providers/pinpoint/types/index.d.ts +3 -0
  17. package/lib/inAppMessaging/providers/pinpoint/types/index.js +7 -0
  18. package/lib/inAppMessaging/providers/pinpoint/types/index.js.map +1 -0
  19. package/lib/inAppMessaging/providers/pinpoint/types/inputs.d.ts +6 -0
  20. package/lib/inAppMessaging/providers/pinpoint/types/inputs.js +5 -0
  21. package/lib/inAppMessaging/providers/pinpoint/types/inputs.js.map +1 -0
  22. package/lib/inAppMessaging/providers/pinpoint/types/options.d.ts +5 -0
  23. package/lib/inAppMessaging/providers/pinpoint/types/options.js +5 -0
  24. package/lib/inAppMessaging/providers/pinpoint/types/options.js.map +1 -0
  25. package/lib/inAppMessaging/types/config.d.ts +5 -0
  26. package/lib/inAppMessaging/types/config.js +3 -0
  27. package/lib/inAppMessaging/types/config.js.map +1 -0
  28. package/lib/inAppMessaging/types/event.d.ts +6 -0
  29. package/lib/inAppMessaging/types/event.js +5 -0
  30. package/lib/inAppMessaging/types/event.js.map +1 -0
  31. package/lib/inAppMessaging/types/index.d.ts +5 -0
  32. package/lib/inAppMessaging/types/index.js +5 -0
  33. package/lib/inAppMessaging/types/index.js.map +1 -0
  34. package/lib/inAppMessaging/types/inputs.d.ts +21 -0
  35. package/lib/inAppMessaging/types/inputs.js +5 -0
  36. package/lib/inAppMessaging/types/inputs.js.map +1 -0
  37. package/lib/inAppMessaging/types/message.d.ts +44 -0
  38. package/lib/inAppMessaging/types/message.js +5 -0
  39. package/lib/inAppMessaging/types/message.js.map +1 -0
  40. package/lib/inAppMessaging/types/options.d.ts +4 -0
  41. package/lib/inAppMessaging/types/options.js +5 -0
  42. package/lib/inAppMessaging/types/options.js.map +1 -0
  43. package/lib/index.d.ts +1 -2
  44. package/lib/index.js +0 -2
  45. package/lib/index.js.map +1 -1
  46. package/lib/pushNotifications/providers/AWSPinpointProvider/index.js +4 -4
  47. package/lib/pushNotifications/providers/AWSPinpointProvider/index.js.map +1 -1
  48. package/lib/pushNotifications/types.d.ts +3 -9
  49. package/lib-esm/common/AWSPinpointProviderCommon/index.d.ts +2 -2
  50. package/lib-esm/common/AWSPinpointProviderCommon/index.js +1 -1
  51. package/lib-esm/common/AWSPinpointProviderCommon/index.js.map +1 -1
  52. package/lib-esm/common/AWSPinpointProviderCommon/types.d.ts +2 -2
  53. package/lib-esm/inAppMessaging/index.d.ts +0 -1
  54. package/lib-esm/inAppMessaging/index.js +0 -1
  55. package/lib-esm/inAppMessaging/index.js.map +1 -1
  56. package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.d.ts +55 -2
  57. package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.js +89 -3
  58. package/lib-esm/inAppMessaging/providers/pinpoint/apis/identifyUser.js.map +1 -1
  59. package/lib-esm/inAppMessaging/providers/pinpoint/apis/syncMessages.js +2 -3
  60. package/lib-esm/inAppMessaging/providers/pinpoint/apis/syncMessages.js.map +1 -1
  61. package/lib-esm/inAppMessaging/providers/pinpoint/types/errors.d.ts +9 -0
  62. package/lib-esm/inAppMessaging/providers/pinpoint/types/errors.js +13 -0
  63. package/lib-esm/inAppMessaging/providers/pinpoint/types/errors.js.map +1 -0
  64. package/lib-esm/inAppMessaging/providers/pinpoint/types/index.d.ts +3 -0
  65. package/lib-esm/inAppMessaging/providers/pinpoint/types/index.js +4 -0
  66. package/lib-esm/inAppMessaging/providers/pinpoint/types/index.js.map +1 -0
  67. package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.d.ts +6 -0
  68. package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.js +3 -0
  69. package/lib-esm/inAppMessaging/providers/pinpoint/types/inputs.js.map +1 -0
  70. package/lib-esm/inAppMessaging/providers/pinpoint/types/options.d.ts +5 -0
  71. package/lib-esm/inAppMessaging/providers/pinpoint/types/options.js +3 -0
  72. package/lib-esm/inAppMessaging/providers/pinpoint/types/options.js.map +1 -0
  73. package/lib-esm/inAppMessaging/types/config.d.ts +5 -0
  74. package/lib-esm/inAppMessaging/types/config.js +1 -0
  75. package/lib-esm/inAppMessaging/types/config.js.map +1 -0
  76. package/lib-esm/inAppMessaging/types/event.d.ts +6 -0
  77. package/lib-esm/inAppMessaging/types/event.js +3 -0
  78. package/lib-esm/inAppMessaging/types/event.js.map +1 -0
  79. package/lib-esm/inAppMessaging/types/index.d.ts +5 -0
  80. package/lib-esm/inAppMessaging/types/index.js +3 -0
  81. package/lib-esm/inAppMessaging/types/index.js.map +1 -0
  82. package/lib-esm/inAppMessaging/types/inputs.d.ts +21 -0
  83. package/lib-esm/inAppMessaging/types/inputs.js +3 -0
  84. package/lib-esm/inAppMessaging/types/inputs.js.map +1 -0
  85. package/lib-esm/inAppMessaging/types/message.d.ts +44 -0
  86. package/lib-esm/inAppMessaging/types/message.js +3 -0
  87. package/lib-esm/inAppMessaging/types/message.js.map +1 -0
  88. package/lib-esm/inAppMessaging/types/options.d.ts +4 -0
  89. package/lib-esm/inAppMessaging/types/options.js +3 -0
  90. package/lib-esm/inAppMessaging/types/options.js.map +1 -0
  91. package/lib-esm/index.d.ts +1 -2
  92. package/lib-esm/index.js +0 -1
  93. package/lib-esm/index.js.map +1 -1
  94. package/lib-esm/pushNotifications/providers/AWSPinpointProvider/index.js +4 -4
  95. package/lib-esm/pushNotifications/providers/AWSPinpointProvider/index.js.map +1 -1
  96. package/lib-esm/pushNotifications/types.d.ts +3 -9
  97. package/package.json +4 -4
  98. package/src/common/AWSPinpointProviderCommon/index.ts +3 -3
  99. package/src/common/AWSPinpointProviderCommon/types.ts +2 -2
  100. package/src/inAppMessaging/index.ts +0 -13
  101. package/src/inAppMessaging/providers/pinpoint/apis/identifyUser.ts +90 -7
  102. package/src/inAppMessaging/providers/pinpoint/apis/syncMessages.ts +2 -6
  103. package/src/inAppMessaging/providers/pinpoint/types/errors.ts +12 -0
  104. package/src/inAppMessaging/providers/pinpoint/types/index.ts +6 -0
  105. package/src/inAppMessaging/providers/pinpoint/types/inputs.ts +11 -0
  106. package/src/inAppMessaging/providers/pinpoint/types/options.ts +9 -0
  107. package/src/inAppMessaging/types/config.ts +8 -0
  108. package/src/inAppMessaging/types/event.ts +14 -0
  109. package/src/inAppMessaging/types/index.ts +8 -0
  110. package/src/inAppMessaging/types/inputs.ts +29 -0
  111. package/src/inAppMessaging/types/message.ts +62 -0
  112. package/src/inAppMessaging/types/options.ts +7 -0
  113. package/src/index.ts +1 -14
  114. package/src/pushNotifications/providers/AWSPinpointProvider/index.ts +13 -20
  115. package/src/pushNotifications/types.ts +8 -9
  116. package/lib/inAppMessaging/providers/pinpoint/utils/utils.d.ts +0 -17
  117. package/lib/inAppMessaging/providers/pinpoint/utils/utils.js +0 -243
  118. package/lib/inAppMessaging/providers/pinpoint/utils/utils.js.map +0 -1
  119. package/lib/inAppMessaging/types.d.ts +0 -87
  120. package/lib/inAppMessaging/types.js +0 -12
  121. package/lib/inAppMessaging/types.js.map +0 -1
  122. package/lib-esm/inAppMessaging/providers/pinpoint/utils/utils.d.ts +0 -17
  123. package/lib-esm/inAppMessaging/providers/pinpoint/utils/utils.js +0 -241
  124. package/lib-esm/inAppMessaging/providers/pinpoint/utils/utils.js.map +0 -1
  125. package/lib-esm/inAppMessaging/types.d.ts +0 -87
  126. package/lib-esm/inAppMessaging/types.js +0 -10
  127. package/lib-esm/inAppMessaging/types.js.map +0 -1
  128. package/src/inAppMessaging/providers/pinpoint/utils/utils.ts +0 -304
  129. package/src/inAppMessaging/types.ts +0 -142
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aws-amplify/notifications",
3
- "version": "2.0.1-console-preview.11cf989.0+11cf989",
3
+ "version": "2.0.1-console-preview.4ae78ed.0+4ae78ed",
4
4
  "description": "Notifications category of aws-amplify",
5
5
  "main": "./lib/index.js",
6
6
  "module": "./lib-esm/index.js",
@@ -101,10 +101,10 @@
101
101
  "uuid": "^9.0.0"
102
102
  },
103
103
  "peerDependencies": {
104
- "@aws-amplify/core": "6.0.1-console-preview.11cf989.0+11cf989"
104
+ "@aws-amplify/core": "6.0.1-console-preview.4ae78ed.0+4ae78ed"
105
105
  },
106
106
  "devDependencies": {
107
- "@aws-amplify/core": "6.0.1-console-preview.11cf989.0+11cf989",
107
+ "@aws-amplify/core": "6.0.1-console-preview.4ae78ed.0+4ae78ed",
108
108
  "@babel/core": "7.15.5",
109
109
  "@babel/plugin-proposal-class-properties": "^7.0.0",
110
110
  "@babel/plugin-proposal-private-methods": "^7.0.0",
@@ -125,5 +125,5 @@
125
125
  "limit": "29.95 kB"
126
126
  }
127
127
  ],
128
- "gitHead": "11cf9890e0229d7f36a7b2375e57bc0decf9935a"
128
+ "gitHead": "4ae78ed23fc03ae718488c98fc48782d2bd6f5f3"
129
129
  }
@@ -27,7 +27,7 @@ import {
27
27
  NotificationsProvider,
28
28
  UserInfo,
29
29
  } from '../../types';
30
- import { AWSPinpointUserInfo } from './types';
30
+ import { PinpointUserInfo } from './types';
31
31
 
32
32
  export default abstract class AWSPinpointProviderCommon
33
33
  implements NotificationsProvider
@@ -115,7 +115,7 @@ export default abstract class AWSPinpointProviderCommon
115
115
  } else {
116
116
  customUserAgentDetails = {
117
117
  category: Category.InAppMessaging,
118
- action: InAppMessagingAction.None,
118
+ action: InAppMessagingAction.IdentifyUser,
119
119
  };
120
120
  }
121
121
 
@@ -159,7 +159,7 @@ export default abstract class AWSPinpointProviderCommon
159
159
 
160
160
  protected updateEndpoint = async (
161
161
  userId: string = null,
162
- userInfo: AWSPinpointUserInfo = null
162
+ userInfo: PinpointUserInfo = null
163
163
  ): Promise<void> => {
164
164
  const credentials = await this.getCredentials();
165
165
  // Shallow compare to determine if credentials stored here are outdated
@@ -3,12 +3,12 @@
3
3
 
4
4
  import { UserInfo } from '../../types';
5
5
 
6
- export interface AWSPinpointProviderConfig {
6
+ export interface PinpointProviderConfig {
7
7
  appId: string;
8
8
  region: string;
9
9
  }
10
10
 
11
- export interface AWSPinpointUserInfo extends UserInfo {
11
+ export interface PinpointUserInfo extends UserInfo {
12
12
  address?: string;
13
13
  optOut?: 'ALL' | 'NONE';
14
14
  }
@@ -2,16 +2,3 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export { identifyUser, syncMessages } from './providers/pinpoint';
5
- export {
6
- InAppMessage,
7
- InAppMessageAction,
8
- InAppMessageButton,
9
- InAppMessageContent,
10
- InAppMessageImage,
11
- InAppMessageInteractionEvent,
12
- InAppMessageLayout,
13
- InAppMessageStyle,
14
- InAppMessageTextAlign,
15
- InAppMessagingConfig,
16
- InAppMessagingEvent,
17
- } from './types';
@@ -1,11 +1,94 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import { UserInfo } from '../../../../types';
4
+ import { InAppMessagingAction } from '@aws-amplify/core/internals/utils';
5
+ import { updateEndpoint } from '@aws-amplify/core/internals/providers/pinpoint';
6
+ import { InAppMessagingValidationErrorCode } from '../../../errors';
7
+ import {
8
+ CATEGORY,
9
+ CHANNEL_TYPE,
10
+ getInAppMessagingUserAgentString,
11
+ resolveConfig,
12
+ resolveCredentials,
13
+ } from '../utils';
14
+ import { IdentifyUserInput } from '../types';
5
15
 
6
- export function identifyUser(
7
- userId: string,
8
- userInfo: UserInfo
9
- ): Promise<void> {
10
- throw new Error('WIP');
11
- }
16
+ /**
17
+ * Sends information about a user to Pinpoint. Sending user information allows you to associate a user to their user
18
+ * profile and activities or actions in your application. Activity can be tracked across devices & platforms by using
19
+ * the same `userId`.
20
+ *
21
+ * @param {IdentifyUserParameters} params The input object used to construct requests sent to Pinpoint's UpdateEndpoint
22
+ * API.
23
+ *
24
+ * @throws service: {@link UpdateEndpointException} - Thrown when the underlying Pinpoint service returns an error.
25
+ * @throws validation: {@link InAppMessagingValidationErrorCode} - Thrown when the provided parameters or library
26
+ * configuration is incorrect.
27
+ *
28
+ * @returns A promise that will resolve when the operation is complete.
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * // Identify a user with Pinpoint
33
+ * await identifyUser({
34
+ * userId,
35
+ * userProfile: {
36
+ * email: 'userEmail@example.com'
37
+ * customProperties: {
38
+ * phoneNumber: ['555-555-5555'],
39
+ * },
40
+ * }
41
+ * });
42
+ * ```
43
+ *
44
+ * @example
45
+ * ```ts
46
+ * // Identify a user with Pinpoint specific options
47
+ * await identifyUser({
48
+ * userId,
49
+ * userProfile: {
50
+ * email: 'userEmail@example.com'
51
+ * customProperties: {
52
+ * phoneNumber: ['555-555-5555'],
53
+ * },
54
+ * demographic: {
55
+ * platform: 'ios',
56
+ * timezone: 'America/Los_Angeles'
57
+ * }
58
+ * },
59
+ * options: {
60
+ * serviceOptions: {
61
+ * address: 'device-address',
62
+ * optOut: 'NONE',
63
+ * userAttributes: {
64
+ * interests: ['food']
65
+ * },
66
+ * },
67
+ * },
68
+ * });
69
+ */
70
+ export const identifyUser = async ({
71
+ userId,
72
+ userProfile,
73
+ options,
74
+ }: IdentifyUserInput): Promise<void> => {
75
+ const { credentials, identityId } = await resolveCredentials();
76
+ const { appId, region } = resolveConfig();
77
+ const { address, optOut, userAttributes } = options?.serviceOptions ?? {};
78
+ updateEndpoint({
79
+ address,
80
+ channelType: CHANNEL_TYPE,
81
+ optOut,
82
+ appId,
83
+ category: CATEGORY,
84
+ credentials,
85
+ identityId,
86
+ region,
87
+ userAttributes,
88
+ userId,
89
+ userProfile,
90
+ userAgentValue: getInAppMessagingUserAgentString(
91
+ InAppMessagingAction.IdentifyUser
92
+ ),
93
+ });
94
+ };
@@ -1,10 +1,7 @@
1
1
  // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
- import {
5
- InAppMessagingAction,
6
- ConsoleLogger as Logger,
7
- } from '@aws-amplify/core/internals/utils';
4
+ import { InAppMessagingAction } from '@aws-amplify/core/internals/utils';
8
5
  import {
9
6
  updateEndpoint,
10
7
  getEndpointId,
@@ -77,9 +74,8 @@ async function fetchInAppMessages() {
77
74
  credentials,
78
75
  identityId,
79
76
  region,
80
- // TODO(V6): Update InAppMessagingAction.None
81
77
  userAgentValue: getInAppMessagingUserAgentString(
82
- InAppMessagingAction.None
78
+ InAppMessagingAction.SyncMessages
83
79
  ),
84
80
  });
85
81
 
@@ -0,0 +1,12 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum UpdateEndpointException {
5
+ BadRequestException = 'BadRequestException',
6
+ ForbiddenException = 'ForbiddenException',
7
+ InternalServerErrorException = 'InternalServerErrorException',
8
+ MethodNotAllowedException = 'MethodNotAllowedException',
9
+ NotFoundException = 'NotFoundException',
10
+ PayloadTooLargeException = 'PayloadTooLargeException',
11
+ TooManyRequestsException = 'TooManyRequestsException',
12
+ }
@@ -0,0 +1,6 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { UpdateEndpointException } from './errors';
5
+ export { IdentifyUserInput } from './inputs';
6
+ export { IdentifyUserOptions } from './options';
@@ -0,0 +1,11 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { IdentifyUserOptions } from '.';
5
+ import { InAppMessagingIdentifyUserInput } from '../../../types';
6
+
7
+ /**
8
+ * Input type for Pinpoint identifyUser API.
9
+ */
10
+ export type IdentifyUserInput =
11
+ InAppMessagingIdentifyUserInput<IdentifyUserOptions>;
@@ -0,0 +1,9 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { PinpointServiceOptions } from '@aws-amplify/core/internals/providers/pinpoint';
5
+
6
+ /**
7
+ * Options specific to Pinpoint identityUser.
8
+ */
9
+ export type IdentifyUserOptions = PinpointServiceOptions;
@@ -0,0 +1,8 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { PinpointProviderConfig } from '../../common/AWSPinpointProviderCommon/types';
4
+
5
+ export interface InAppMessagingConfig {
6
+ listenForAnalyticsEvents?: boolean;
7
+ AWSPinpoint?: PinpointProviderConfig;
8
+ }
@@ -0,0 +1,14 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export type InAppMessageInteractionEvent =
5
+ | 'messageReceived'
6
+ | 'messageDisplayed'
7
+ | 'messageDismissed'
8
+ | 'messageActionTaken';
9
+
10
+ export type InAppMessagingEvent = {
11
+ name: string;
12
+ attributes?: Record<string, string>;
13
+ metrics?: Record<string, number>;
14
+ };
@@ -0,0 +1,8 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { InAppMessagingServiceOptions } from './options';
5
+ export { InAppMessagingIdentifyUserInput } from './inputs';
6
+ export { InAppMessagingConfig } from './config';
7
+ export { InAppMessageInteractionEvent, InAppMessagingEvent } from './event';
8
+ export { InAppMessage } from './message';
@@ -0,0 +1,29 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { UserProfile } from '@aws-amplify/core';
5
+ import { InAppMessagingServiceOptions } from '.';
6
+
7
+ /**
8
+ * Input type for `identifyUser`.
9
+ */
10
+ export type InAppMessagingIdentifyUserInput<
11
+ ServiceOptions extends InAppMessagingServiceOptions = InAppMessagingServiceOptions
12
+ > = {
13
+ /**
14
+ * A User ID associated to the current device.
15
+ */
16
+ userId: string;
17
+
18
+ /**
19
+ * Additional information about the user and their device.
20
+ */
21
+ userProfile: UserProfile;
22
+
23
+ /**
24
+ * Options to be passed to the API.
25
+ */
26
+ options?: {
27
+ serviceOptions?: ServiceOptions;
28
+ };
29
+ };
@@ -0,0 +1,62 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export type InAppMessageLayout =
5
+ | 'BOTTOM_BANNER'
6
+ | 'CAROUSEL'
7
+ | 'FULL_SCREEN'
8
+ | 'MIDDLE_BANNER'
9
+ | 'MODAL'
10
+ | 'TOP_BANNER';
11
+
12
+ export type InAppMessageAction = 'CLOSE' | 'DEEP_LINK' | 'LINK';
13
+
14
+ export type InAppMessageTextAlign = 'center' | 'left' | 'right';
15
+
16
+ interface InAppMessageContainer {
17
+ style?: InAppMessageStyle;
18
+ }
19
+
20
+ interface InAppMessageHeader {
21
+ content: string;
22
+ style?: InAppMessageStyle;
23
+ }
24
+
25
+ interface InAppMessageBody {
26
+ content: string;
27
+ style?: InAppMessageStyle;
28
+ }
29
+
30
+ export interface InAppMessageImage {
31
+ src: string;
32
+ }
33
+
34
+ export interface InAppMessageButton {
35
+ title: string;
36
+ action: InAppMessageAction;
37
+ url?: string;
38
+ style?: InAppMessageStyle;
39
+ }
40
+
41
+ export interface InAppMessageStyle {
42
+ backgroundColor?: string;
43
+ borderRadius?: number;
44
+ color?: string;
45
+ textAlign?: InAppMessageTextAlign;
46
+ }
47
+
48
+ export interface InAppMessageContent {
49
+ container?: InAppMessageContainer;
50
+ header?: InAppMessageHeader;
51
+ body?: InAppMessageBody;
52
+ image?: InAppMessageImage;
53
+ primaryButton?: InAppMessageButton;
54
+ secondaryButton?: InAppMessageButton;
55
+ }
56
+
57
+ export interface InAppMessage {
58
+ id: string;
59
+ layout: InAppMessageLayout;
60
+ content: InAppMessageContent[];
61
+ metadata?: any;
62
+ }
@@ -0,0 +1,7 @@
1
+ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ /**
5
+ * Base type for service options.
6
+ */
7
+ export type InAppMessagingServiceOptions = any;
package/src/index.ts CHANGED
@@ -2,20 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  export { AWSPinpointProviderCommon } from './common';
5
- export { AWSPinpointUserInfo } from './common/AWSPinpointProviderCommon/types';
6
- export {
7
- InAppMessage,
8
- InAppMessageAction,
9
- InAppMessageButton,
10
- InAppMessageContent,
11
- InAppMessageImage,
12
- InAppMessageInteractionEvent,
13
- InAppMessageLayout,
14
- InAppMessageStyle,
15
- InAppMessageTextAlign,
16
- InAppMessagingConfig,
17
- InAppMessagingEvent,
18
- } from './inAppMessaging';
5
+ export { PinpointUserInfo } from './common/AWSPinpointProviderCommon/types';
19
6
  export {
20
7
  PushNotificationMessage,
21
8
  PushNotificationPermissions,
@@ -3,16 +3,13 @@
3
3
 
4
4
  import { addEventListener, AWSPinpointProviderCommon } from '../../../common';
5
5
  import { ChannelType } from '../../../common/AWSPinpointProviderCommon/types';
6
- import PlatformNotSupportedError from '../../PlatformNotSupportedError';
7
- import { Platform } from '../../Platform';
8
6
  import {
9
- PushNotificationEvent,
10
7
  PushNotificationMessage,
11
8
  PushNotificationProvider,
12
9
  NotificationsSubCategory,
13
10
  } from '../../types';
14
11
  import { AWSPinpointMessageEvent } from './types';
15
- import { getAnalyticsEvent, logger } from './utils';
12
+ import { logger } from './utils';
16
13
 
17
14
  export default class AWSPinpointProvider
18
15
  extends AWSPinpointProviderCommon
@@ -42,24 +39,20 @@ export default class AWSPinpointProvider
42
39
  // some configuration steps should not be re-run even if provider is re-configured for some reason
43
40
  if (!this.configured) {
44
41
  // wire up default Pinpoint message event handling
45
- addEventListener(
46
- PushNotificationEvent.BACKGROUND_MESSAGE_RECEIVED,
47
- message =>
48
- this.recordMessageEvent(
49
- message,
50
- AWSPinpointMessageEvent.BACKGROUND_MESSAGE_RECEIVED
51
- )
42
+ addEventListener('backgroundMessageReceived', message =>
43
+ this.recordMessageEvent(
44
+ message,
45
+ AWSPinpointMessageEvent.BACKGROUND_MESSAGE_RECEIVED
46
+ )
52
47
  );
53
- addEventListener(
54
- PushNotificationEvent.FOREGROUND_MESSAGE_RECEIVED,
55
- message =>
56
- this.recordMessageEvent(
57
- message,
58
- AWSPinpointMessageEvent.FOREGROUND_MESSAGE_RECEIVED
59
- )
48
+ addEventListener('foregroundMessageReceived', message =>
49
+ this.recordMessageEvent(
50
+ message,
51
+ AWSPinpointMessageEvent.FOREGROUND_MESSAGE_RECEIVED
52
+ )
60
53
  );
61
54
  const launchNotificationOpenedListener = addEventListener(
62
- PushNotificationEvent.LAUNCH_NOTIFICATION_OPENED,
55
+ 'launchNotificationsOpened',
63
56
  message => {
64
57
  this.recordMessageEvent(
65
58
  message,
@@ -69,7 +62,7 @@ export default class AWSPinpointProvider
69
62
  launchNotificationOpenedListener?.remove();
70
63
  }
71
64
  );
72
- addEventListener(PushNotificationEvent.NOTIFICATION_OPENED, message => {
65
+ addEventListener('notificationOpened', message => {
73
66
  this.recordMessageEvent(
74
67
  message,
75
68
  AWSPinpointMessageEvent.NOTIFICATION_OPENED
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
 
4
4
  import { EventListener } from '../common';
5
- import { AWSPinpointProviderConfig } from '../common/AWSPinpointProviderCommon/types';
5
+ import { PinpointProviderConfig } from '../common/AWSPinpointProviderCommon/types';
6
6
  import {
7
7
  NotificationsProvider,
8
8
  NotificationsSubCategory as NotificationsSubCategories,
@@ -52,7 +52,7 @@ export interface PushNotificationProvider extends NotificationsProvider {
52
52
  }
53
53
 
54
54
  export interface PushNotificationConfig {
55
- AWSPinpoint?: AWSPinpointProviderConfig;
55
+ Pinpoint?: PinpointProviderConfig;
56
56
  }
57
57
 
58
58
  export interface PushNotificationMessage {
@@ -97,13 +97,12 @@ export type OnPushNotificationMessageHandler = (
97
97
  message: PushNotificationMessage
98
98
  ) => any;
99
99
 
100
- export const enum PushNotificationEvent {
101
- BACKGROUND_MESSAGE_RECEIVED,
102
- FOREGROUND_MESSAGE_RECEIVED,
103
- LAUNCH_NOTIFICATION_OPENED,
104
- NOTIFICATION_OPENED,
105
- TOKEN_RECEIVED,
106
- }
100
+ export type PushNotificationEvent =
101
+ | 'backgroundMessageReceived'
102
+ | 'foregroundMessageReceived'
103
+ | 'launchNotificationsOpened'
104
+ | 'notificationOpened'
105
+ | 'tokenReceived';
107
106
 
108
107
  export interface NormalizedValues {
109
108
  body?: string;
@@ -1,17 +0,0 @@
1
- import { ConsoleLogger } from '@aws-amplify/core/internals/utils';
2
- import type { InAppMessageCampaign as PinpointInAppMessage } from '@aws-amplify/core/internals/aws-clients/pinpoint';
3
- import { InAppMessage, InAppMessageContent, InAppMessageLayout, InAppMessagingEvent } from '../../../types';
4
- import { AWSPinpointMessageEvent, MetricsComparator } from '../types/types';
5
- export declare const logger: ConsoleLogger;
6
- export declare const recordAnalyticsEvent: (event: AWSPinpointMessageEvent, message: InAppMessage) => void;
7
- export declare const getStartOfDay: () => string;
8
- export declare const matchesEventType: ({ CampaignId, Schedule }: PinpointInAppMessage, { name: eventType }: InAppMessagingEvent) => any;
9
- export declare const matchesAttributes: ({ CampaignId, Schedule }: PinpointInAppMessage, { attributes }: InAppMessagingEvent) => boolean;
10
- export declare const matchesMetrics: ({ CampaignId, Schedule }: PinpointInAppMessage, { metrics }: InAppMessagingEvent) => boolean;
11
- export declare const getComparator: (operator: string) => MetricsComparator;
12
- export declare const isBeforeEndDate: ({ Schedule, }: PinpointInAppMessage) => boolean;
13
- export declare const isQuietTime: (message: PinpointInAppMessage) => boolean;
14
- export declare const clearMemo: () => void;
15
- export declare const interpretLayout: (layout: string) => InAppMessageLayout;
16
- export declare const extractContent: ({ InAppMessage: message, }: PinpointInAppMessage) => InAppMessageContent[];
17
- export declare const extractMetadata: ({ InAppMessage, Priority, Schedule, TreatmentId, }: PinpointInAppMessage) => any;