@aws-amplify/notifications 2.0.17-unstable.5c56101.0 → 2.0.17
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/esm/inAppMessaging/types/options.d.ts +1 -1
- package/dist/esm/pushNotifications/types/options.d.ts +1 -1
- package/package.json +103 -103
- package/src/eventListeners/eventListeners.ts +2 -2
- package/src/inAppMessaging/errors/assertServiceError.ts +1 -1
- package/src/inAppMessaging/errors/assertValidationError.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/apis/dispatchEvent.ts +2 -2
- package/src/inAppMessaging/providers/pinpoint/apis/identifyUser.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/apis/onMessageActionTaken.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/apis/onMessageDismissed.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/apis/onMessageDisplayed.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/apis/onMessageReceived.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/apis/syncMessages.ts +2 -2
- package/src/inAppMessaging/providers/pinpoint/types/types.ts +2 -2
- package/src/inAppMessaging/providers/pinpoint/utils/helpers.ts +11 -11
- package/src/inAppMessaging/providers/pinpoint/utils/messageProcessingHelpers.ts +2 -2
- package/src/inAppMessaging/providers/pinpoint/utils/resolveCredentials.ts +1 -1
- package/src/inAppMessaging/providers/pinpoint/utils/userAgent.ts +1 -1
- package/src/inAppMessaging/types/options.ts +1 -1
- package/src/inAppMessaging/utils/statusHelpers.ts +1 -1
- package/src/pushNotifications/errors/errorHelpers.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/identifyUser.native.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/apis/initializePushNotifications.native.ts +17 -17
- package/src/pushNotifications/providers/pinpoint/types/apis.ts +5 -5
- package/src/pushNotifications/providers/pinpoint/utils/createMessageEventRecorder.ts +1 -1
- package/src/pushNotifications/providers/pinpoint/utils/getAnalyticsEvent.ts +2 -2
- package/src/pushNotifications/types/options.ts +1 -1
- package/src/pushNotifications/types/pushNotifications.ts +1 -1
- package/src/pushNotifications/utils/getPushNotificationUserAgentString.ts +1 -1
package/package.json
CHANGED
|
@@ -1,105 +1,105 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
2
|
+
"name": "@aws-amplify/notifications",
|
|
3
|
+
"version": "2.0.17",
|
|
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": "tslint 'src/**/*.ts' && npm run ts-coverage",
|
|
25
|
+
"ts-coverage": "typescript-coverage-report -p ./tsconfig.build.json -t 88.21"
|
|
26
|
+
},
|
|
27
|
+
"typesVersions": {
|
|
28
|
+
">=4.2": {
|
|
29
|
+
"in-app-messaging": [
|
|
30
|
+
"./dist/esm/inAppMessaging/index.d.ts"
|
|
31
|
+
],
|
|
32
|
+
"push-notifications": [
|
|
33
|
+
"./dist/esm/pushNotifications/providers/index.d.ts"
|
|
34
|
+
],
|
|
35
|
+
"in-app-messaging/pinpoint": [
|
|
36
|
+
"./dist/esm/inAppMessaging/providers/pinpoint/index.d.ts"
|
|
37
|
+
],
|
|
38
|
+
"push-notifications/pinpoint": [
|
|
39
|
+
"./dist/esm/pushNotifications/providers/pinpoint/index.d.ts"
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"exports": {
|
|
44
|
+
".": {
|
|
45
|
+
"import": "./dist/esm/index.mjs",
|
|
46
|
+
"require": "./dist/cjs/index.js",
|
|
47
|
+
"react-native": "./src/index.ts"
|
|
48
|
+
},
|
|
49
|
+
"./in-app-messaging": {
|
|
50
|
+
"types": "./dist/esm/inAppMessaging/index.d.ts",
|
|
51
|
+
"import": "./dist/esm/inAppMessaging/index.mjs",
|
|
52
|
+
"require": "./dist/cjs/inAppMessaging/index.js",
|
|
53
|
+
"react-native": "./src/inAppMessaging/index.ts"
|
|
54
|
+
},
|
|
55
|
+
"./push-notifications": {
|
|
56
|
+
"types": "./dist/esm/pushNotifications/index.d.ts",
|
|
57
|
+
"import": "./dist/esm/pushNotifications/index.mjs",
|
|
58
|
+
"require": "./dist/cjs/pushNotifications/index.js",
|
|
59
|
+
"react-native": "./src/pushNotifications/index.ts"
|
|
60
|
+
},
|
|
61
|
+
"./in-app-messaging/pinpoint": {
|
|
62
|
+
"types": "./dist/esm/inAppMessaging/providers/pinpoint/index.d.ts",
|
|
63
|
+
"import": "./dist/esm/inAppMessaging/providers/pinpoint/index.mjs",
|
|
64
|
+
"require": "./dist/cjs/inAppMessaging/providers/pinpoint/index.js",
|
|
65
|
+
"react-native": "./src/inAppMessaging/providers/pinpoint/index.ts"
|
|
66
|
+
},
|
|
67
|
+
"./push-notifications/pinpoint": {
|
|
68
|
+
"types": "./dist/esm/pushNotifications/providers/pinpoint/index.d.ts",
|
|
69
|
+
"import": "./dist/esm/pushNotifications/providers/pinpoint/index.mjs",
|
|
70
|
+
"require": "./dist/cjs/pushNotifications/providers/pinpoint/index.js",
|
|
71
|
+
"react-native": "./src/pushNotifications/providers/pinpoint/index.ts"
|
|
72
|
+
},
|
|
73
|
+
"./package.json": "./package.json"
|
|
74
|
+
},
|
|
75
|
+
"repository": {
|
|
76
|
+
"type": "git",
|
|
77
|
+
"url": "https://github.com/aws-amplify/amplify-js.git"
|
|
78
|
+
},
|
|
79
|
+
"author": "Amazon Web Services",
|
|
80
|
+
"license": "Apache-2.0",
|
|
81
|
+
"bugs": {
|
|
82
|
+
"url": "https://github.com/aws/aws-amplify/issues"
|
|
83
|
+
},
|
|
84
|
+
"homepage": "https://docs.amplify.aws/",
|
|
85
|
+
"files": [
|
|
86
|
+
"dist/cjs",
|
|
87
|
+
"dist/esm",
|
|
88
|
+
"src",
|
|
89
|
+
"in-app-messaging",
|
|
90
|
+
"push-notifications"
|
|
91
|
+
],
|
|
92
|
+
"dependencies": {
|
|
93
|
+
"lodash": "^4.17.21",
|
|
94
|
+
"tslib": "^2.5.0"
|
|
95
|
+
},
|
|
96
|
+
"peerDependencies": {
|
|
97
|
+
"@aws-amplify/core": "^6.0.0"
|
|
98
|
+
},
|
|
99
|
+
"devDependencies": {
|
|
100
|
+
"@aws-amplify/core": "6.0.17",
|
|
101
|
+
"@aws-amplify/react-native": "1.0.17",
|
|
102
|
+
"typescript": "5.0.2"
|
|
103
|
+
},
|
|
104
|
+
"gitHead": "c54a19c8a654a47d559cb0fd41c74bd2c3eb79ca"
|
|
105
105
|
}
|
|
@@ -22,12 +22,12 @@ export const notifyEventListenersAndAwaitHandlers = (
|
|
|
22
22
|
} catch (err) {
|
|
23
23
|
throw err;
|
|
24
24
|
}
|
|
25
|
-
})
|
|
25
|
+
}),
|
|
26
26
|
);
|
|
27
27
|
|
|
28
28
|
export const addEventListener = <EventHandler extends Function>(
|
|
29
29
|
type: EventType,
|
|
30
|
-
handler: EventHandler
|
|
30
|
+
handler: EventHandler,
|
|
31
31
|
): EventListenerRemover => {
|
|
32
32
|
// If there is no listener set for the event type, just create it
|
|
33
33
|
if (!eventListeners[type]) {
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
*/
|
|
13
13
|
export function assertValidationError(
|
|
14
14
|
assertion: boolean,
|
|
15
|
-
name: InAppMessagingValidationErrorCode
|
|
15
|
+
name: InAppMessagingValidationErrorCode,
|
|
16
16
|
): asserts assertion {
|
|
17
17
|
const { message, recoverySuggestion } = validationErrorMap[name];
|
|
18
18
|
|
|
@@ -47,13 +47,13 @@ export async function dispatchEvent(input: DispatchEventInput): Promise<void> {
|
|
|
47
47
|
const cachedMessages = await defaultStorage.getItem(key);
|
|
48
48
|
const messages: InAppMessage[] = await processInAppMessages(
|
|
49
49
|
cachedMessages ? JSON.parse(cachedMessages) : [],
|
|
50
|
-
input
|
|
50
|
+
input,
|
|
51
51
|
);
|
|
52
52
|
const flattenedMessages = flatten(messages);
|
|
53
53
|
if (flattenedMessages.length > 0) {
|
|
54
54
|
notifyEventListeners(
|
|
55
55
|
'messageReceived',
|
|
56
|
-
conflictHandler(flattenedMessages)
|
|
56
|
+
conflictHandler(flattenedMessages),
|
|
57
57
|
);
|
|
58
58
|
}
|
|
59
59
|
} catch (error) {
|
|
@@ -22,7 +22,7 @@ import { OnMessageActionTakenOutput } from '../types/outputs';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
export function onMessageActionTaken(
|
|
25
|
-
input: OnMessageActionTakenInput
|
|
25
|
+
input: OnMessageActionTakenInput,
|
|
26
26
|
): OnMessageActionTakenOutput {
|
|
27
27
|
assertIsInitialized();
|
|
28
28
|
return addEventListener('messageActionTaken', input);
|
|
@@ -22,7 +22,7 @@ import { assertIsInitialized } from '../../../utils';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
export function onMessageDismissed(
|
|
25
|
-
input: OnMessageDismissedInput
|
|
25
|
+
input: OnMessageDismissedInput,
|
|
26
26
|
): OnMessageDismissedOutput {
|
|
27
27
|
assertIsInitialized();
|
|
28
28
|
return addEventListener('messageDismissed', input);
|
|
@@ -22,7 +22,7 @@ import { assertIsInitialized } from '../../../utils';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
export function onMessageDisplayed(
|
|
25
|
-
input: OnMessageDisplayedInput
|
|
25
|
+
input: OnMessageDisplayedInput,
|
|
26
26
|
): OnMessageDisplayedOutput {
|
|
27
27
|
assertIsInitialized();
|
|
28
28
|
return addEventListener('messageDisplayed', input);
|
|
@@ -22,7 +22,7 @@ import { OnMessageReceivedOutput } from '../types/outputs';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
export function onMessageReceived(
|
|
25
|
-
input: OnMessageReceivedInput
|
|
25
|
+
input: OnMessageReceivedInput,
|
|
26
26
|
): OnMessageReceivedOutput {
|
|
27
27
|
assertIsInitialized();
|
|
28
28
|
return addEventListener('messageReceived', input);
|
|
@@ -66,7 +66,7 @@ async function fetchInAppMessages() {
|
|
|
66
66
|
identityId,
|
|
67
67
|
region,
|
|
68
68
|
userAgentValue: getInAppMessagingUserAgentString(
|
|
69
|
-
InAppMessagingAction.SyncMessages
|
|
69
|
+
InAppMessagingAction.SyncMessages,
|
|
70
70
|
),
|
|
71
71
|
});
|
|
72
72
|
|
|
@@ -76,7 +76,7 @@ async function fetchInAppMessages() {
|
|
|
76
76
|
};
|
|
77
77
|
const response: GetInAppMessagesOutput = await getInAppMessages(
|
|
78
78
|
{ credentials, region },
|
|
79
|
-
input
|
|
79
|
+
input,
|
|
80
80
|
);
|
|
81
81
|
const { InAppMessageCampaigns: messages } =
|
|
82
82
|
response.InAppMessagesResponse ?? {};
|
|
@@ -18,7 +18,7 @@ export type InAppMessageCounts = {
|
|
|
18
18
|
|
|
19
19
|
export type MetricsComparator = (
|
|
20
20
|
metricsVal: number,
|
|
21
|
-
eventVal: number
|
|
21
|
+
eventVal: number,
|
|
22
22
|
) => boolean;
|
|
23
23
|
|
|
24
24
|
export enum PinpointMessageEvent {
|
|
@@ -28,7 +28,7 @@ export enum PinpointMessageEvent {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
export type InAppMessageConflictHandler = (
|
|
31
|
-
messages: InAppMessage[]
|
|
31
|
+
messages: InAppMessage[],
|
|
32
32
|
) => InAppMessage;
|
|
33
33
|
|
|
34
34
|
export type OnMessageInteractionEventHandler = (message: InAppMessage) => void;
|
|
@@ -30,7 +30,7 @@ export const logger = new ConsoleLogger('InAppMessaging.Pinpoint.Utils');
|
|
|
30
30
|
|
|
31
31
|
export const recordAnalyticsEvent = (
|
|
32
32
|
event: PinpointMessageEvent,
|
|
33
|
-
message: InAppMessage
|
|
33
|
+
message: InAppMessage,
|
|
34
34
|
) => {
|
|
35
35
|
const { appId, region } = resolveConfig();
|
|
36
36
|
|
|
@@ -53,7 +53,7 @@ export const recordAnalyticsEvent = (
|
|
|
53
53
|
identityId,
|
|
54
54
|
region,
|
|
55
55
|
userAgentValue: getInAppMessagingUserAgentString(
|
|
56
|
-
InAppMessagingAction.NotifyMessageInteraction
|
|
56
|
+
InAppMessagingAction.NotifyMessageInteraction,
|
|
57
57
|
),
|
|
58
58
|
});
|
|
59
59
|
})
|
|
@@ -71,7 +71,7 @@ export const getStartOfDay = (): string => {
|
|
|
71
71
|
|
|
72
72
|
export const matchesEventType = (
|
|
73
73
|
{ CampaignId, Schedule }: PinpointInAppMessage,
|
|
74
|
-
{ name: eventType }: InAppMessagingEvent
|
|
74
|
+
{ name: eventType }: InAppMessagingEvent,
|
|
75
75
|
) => {
|
|
76
76
|
const { EventType } = Schedule?.EventFilter?.Dimensions ?? {};
|
|
77
77
|
const memoKey = `${CampaignId}:${eventType}`;
|
|
@@ -83,7 +83,7 @@ export const matchesEventType = (
|
|
|
83
83
|
|
|
84
84
|
export const matchesAttributes = (
|
|
85
85
|
{ CampaignId, Schedule }: PinpointInAppMessage,
|
|
86
|
-
{ attributes = {} }: InAppMessagingEvent
|
|
86
|
+
{ attributes = {} }: InAppMessagingEvent,
|
|
87
87
|
): boolean => {
|
|
88
88
|
const { Attributes } = Schedule?.EventFilter?.Dimensions ?? {};
|
|
89
89
|
if (isEmpty(Attributes)) {
|
|
@@ -98,8 +98,8 @@ export const matchesAttributes = (
|
|
|
98
98
|
if (!eventAttributesMemo.hasOwnProperty(memoKey)) {
|
|
99
99
|
eventAttributesMemo[memoKey] =
|
|
100
100
|
!Attributes ||
|
|
101
|
-
Object.entries(Attributes).every(
|
|
102
|
-
|
|
101
|
+
Object.entries(Attributes).every(([key, { Values }]) =>
|
|
102
|
+
Values?.includes(attributes[key]),
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
return eventAttributesMemo[memoKey];
|
|
@@ -107,7 +107,7 @@ export const matchesAttributes = (
|
|
|
107
107
|
|
|
108
108
|
export const matchesMetrics = (
|
|
109
109
|
{ CampaignId, Schedule }: PinpointInAppMessage,
|
|
110
|
-
{ metrics = {} }: InAppMessagingEvent
|
|
110
|
+
{ metrics = {} }: InAppMessagingEvent,
|
|
111
111
|
): boolean => {
|
|
112
112
|
const { Metrics } = Schedule?.EventFilter?.Dimensions ?? {};
|
|
113
113
|
if (isEmpty(Metrics)) {
|
|
@@ -132,7 +132,7 @@ export const matchesMetrics = (
|
|
|
132
132
|
};
|
|
133
133
|
|
|
134
134
|
export const getComparator = (
|
|
135
|
-
operator?: string
|
|
135
|
+
operator?: string,
|
|
136
136
|
): MetricsComparator | undefined => {
|
|
137
137
|
switch (operator) {
|
|
138
138
|
case 'EQUAL':
|
|
@@ -187,13 +187,13 @@ export const isQuietTime = (message: PinpointInAppMessage): boolean => {
|
|
|
187
187
|
Number.parseInt(startHours, 10),
|
|
188
188
|
Number.parseInt(startMinutes, 10),
|
|
189
189
|
0,
|
|
190
|
-
0
|
|
190
|
+
0,
|
|
191
191
|
);
|
|
192
192
|
end.setHours(
|
|
193
193
|
Number.parseInt(endHours, 10),
|
|
194
194
|
Number.parseInt(endMinutes, 10),
|
|
195
195
|
0,
|
|
196
|
-
0
|
|
196
|
+
0,
|
|
197
197
|
);
|
|
198
198
|
|
|
199
199
|
// if quiet time includes midnight, bump the end time to the next day
|
|
@@ -225,7 +225,7 @@ export const clearMemo = () => {
|
|
|
225
225
|
// - 2. Amplify correctly handles the legacy layout values from Pinpoint after they are updated
|
|
226
226
|
|
|
227
227
|
export const interpretLayout = (
|
|
228
|
-
layout: NonNullable<PinpointInAppMessage['InAppMessage']>['Layout']
|
|
228
|
+
layout: NonNullable<PinpointInAppMessage['InAppMessage']>['Layout'],
|
|
229
229
|
): InAppMessageLayout => {
|
|
230
230
|
if (layout === 'MOBILE_FEED') {
|
|
231
231
|
return 'MODAL';
|
|
@@ -28,7 +28,7 @@ let sessionMessageCountMap: InAppMessageCountMap = {};
|
|
|
28
28
|
|
|
29
29
|
export async function processInAppMessages(
|
|
30
30
|
messages: PinpointInAppMessage[],
|
|
31
|
-
event: InAppMessagingEvent
|
|
31
|
+
event: InAppMessagingEvent,
|
|
32
32
|
): Promise<InAppMessage[]> {
|
|
33
33
|
let highestPrioritySeen: number | undefined;
|
|
34
34
|
let acc: PinpointInAppMessage[] = [];
|
|
@@ -116,7 +116,7 @@ async function isBelowCap({
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
async function getMessageCounts(
|
|
119
|
-
messageId?: string
|
|
119
|
+
messageId?: string,
|
|
120
120
|
): Promise<InAppMessageCounts> {
|
|
121
121
|
let messageCounts = {
|
|
122
122
|
sessionCount: 0,
|
|
@@ -14,7 +14,7 @@ export const resolveCredentials = async () => {
|
|
|
14
14
|
const { credentials, identityId } = await fetchAuthSession();
|
|
15
15
|
assertValidationError(
|
|
16
16
|
!!credentials,
|
|
17
|
-
InAppMessagingValidationErrorCode.NoCredentials
|
|
17
|
+
InAppMessagingValidationErrorCode.NoCredentials,
|
|
18
18
|
);
|
|
19
19
|
return { credentials, identityId };
|
|
20
20
|
};
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { UserAgent } from '@aws-sdk/types';
|
|
10
10
|
|
|
11
11
|
export function getInAppMessagingUserAgent(
|
|
12
|
-
action: InAppMessagingAction
|
|
12
|
+
action: InAppMessagingAction,
|
|
13
13
|
): UserAgent {
|
|
14
14
|
return getAmplifyUserAgentObject({
|
|
15
15
|
category: Category.InAppMessaging,
|
|
@@ -37,7 +37,7 @@ const pushNotificationValidationErrorMap: AmplifyErrorMap<PushNotificationValida
|
|
|
37
37
|
export const assert: AssertionFunction<PushNotificationValidationErrorCode> =
|
|
38
38
|
createAssertionFunction(
|
|
39
39
|
pushNotificationValidationErrorMap,
|
|
40
|
-
PushNotificationError
|
|
40
|
+
PushNotificationError,
|
|
41
41
|
);
|
|
42
42
|
|
|
43
43
|
export const assertIsInitialized = () => {
|
|
@@ -66,7 +66,7 @@ const addNativeListeners = (): void => {
|
|
|
66
66
|
// keep headless task running until handlers have completed their work
|
|
67
67
|
await notifyEventListenersAndAwaitHandlers(
|
|
68
68
|
'backgroundMessageReceived',
|
|
69
|
-
message
|
|
69
|
+
message,
|
|
70
70
|
);
|
|
71
71
|
});
|
|
72
72
|
} else if (BACKGROUND_MESSAGE_RECEIVED) {
|
|
@@ -80,7 +80,7 @@ const addNativeListeners = (): void => {
|
|
|
80
80
|
await Promise.race([
|
|
81
81
|
notifyEventListenersAndAwaitHandlers(
|
|
82
82
|
'backgroundMessageReceived',
|
|
83
|
-
message
|
|
83
|
+
message,
|
|
84
84
|
),
|
|
85
85
|
// background tasks will get suspended and all future tasks be deprioritized by the OS if they run for
|
|
86
86
|
// more than 30 seconds so we reject with a error in a shorter amount of time to prevent this from
|
|
@@ -89,9 +89,9 @@ const addNativeListeners = (): void => {
|
|
|
89
89
|
setTimeout(
|
|
90
90
|
() =>
|
|
91
91
|
reject(
|
|
92
|
-
`onNotificationReceivedInBackground handlers should complete their work within ${BACKGROUND_TASK_TIMEOUT} seconds, but they did not
|
|
92
|
+
`onNotificationReceivedInBackground handlers should complete their work within ${BACKGROUND_TASK_TIMEOUT} seconds, but they did not.`,
|
|
93
93
|
),
|
|
94
|
-
BACKGROUND_TASK_TIMEOUT * 1000
|
|
94
|
+
BACKGROUND_TASK_TIMEOUT * 1000,
|
|
95
95
|
);
|
|
96
96
|
}),
|
|
97
97
|
]);
|
|
@@ -103,7 +103,7 @@ const addNativeListeners = (): void => {
|
|
|
103
103
|
completeNotification(completionHandlerId);
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
-
}
|
|
106
|
+
},
|
|
107
107
|
);
|
|
108
108
|
}
|
|
109
109
|
|
|
@@ -112,7 +112,7 @@ const addNativeListeners = (): void => {
|
|
|
112
112
|
FOREGROUND_MESSAGE_RECEIVED,
|
|
113
113
|
message => {
|
|
114
114
|
notifyEventListeners('foregroundMessageReceived', message);
|
|
115
|
-
}
|
|
115
|
+
},
|
|
116
116
|
);
|
|
117
117
|
|
|
118
118
|
launchNotificationOpenedListener = LAUNCH_NOTIFICATION_OPENED
|
|
@@ -125,8 +125,8 @@ const addNativeListeners = (): void => {
|
|
|
125
125
|
notifyEventListeners('launchNotificationOpened', message);
|
|
126
126
|
// once we are done with it we can remove the listener
|
|
127
127
|
launchNotificationOpenedListener?.remove();
|
|
128
|
-
}
|
|
129
|
-
|
|
128
|
+
},
|
|
129
|
+
)
|
|
130
130
|
: null;
|
|
131
131
|
|
|
132
132
|
addMessageEventListener(
|
|
@@ -137,7 +137,7 @@ const addNativeListeners = (): void => {
|
|
|
137
137
|
notifyEventListeners('notificationOpened', message);
|
|
138
138
|
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
139
139
|
launchNotificationOpenedListener?.remove();
|
|
140
|
-
}
|
|
140
|
+
},
|
|
141
141
|
);
|
|
142
142
|
|
|
143
143
|
addTokenEventListener(
|
|
@@ -157,7 +157,7 @@ const addNativeListeners = (): void => {
|
|
|
157
157
|
logger.error('Failed to register device for push notifications', err);
|
|
158
158
|
throw err;
|
|
159
159
|
}
|
|
160
|
-
}
|
|
160
|
+
},
|
|
161
161
|
);
|
|
162
162
|
};
|
|
163
163
|
|
|
@@ -167,27 +167,27 @@ const addAnalyticsListeners = (): void => {
|
|
|
167
167
|
// wire up default Pinpoint message event handling
|
|
168
168
|
addEventListener(
|
|
169
169
|
'backgroundMessageReceived',
|
|
170
|
-
createMessageEventRecorder('received_background')
|
|
170
|
+
createMessageEventRecorder('received_background'),
|
|
171
171
|
);
|
|
172
172
|
addEventListener(
|
|
173
173
|
'foregroundMessageReceived',
|
|
174
|
-
createMessageEventRecorder('received_foreground')
|
|
174
|
+
createMessageEventRecorder('received_foreground'),
|
|
175
175
|
);
|
|
176
176
|
launchNotificationOpenedListenerRemover = addEventListener(
|
|
177
177
|
'launchNotificationOpened',
|
|
178
178
|
createMessageEventRecorder(
|
|
179
179
|
'opened_notification',
|
|
180
180
|
// once we are done with it we can remove the listener
|
|
181
|
-
launchNotificationOpenedListenerRemover?.remove
|
|
182
|
-
)
|
|
181
|
+
launchNotificationOpenedListenerRemover?.remove,
|
|
182
|
+
),
|
|
183
183
|
);
|
|
184
184
|
addEventListener(
|
|
185
185
|
'notificationOpened',
|
|
186
186
|
createMessageEventRecorder(
|
|
187
187
|
'opened_notification',
|
|
188
188
|
// if we are in this state, we no longer need the listener as the app was launched via some other means
|
|
189
|
-
launchNotificationOpenedListenerRemover?.remove
|
|
190
|
-
)
|
|
189
|
+
launchNotificationOpenedListenerRemover?.remove,
|
|
190
|
+
),
|
|
191
191
|
);
|
|
192
192
|
};
|
|
193
193
|
|
|
@@ -203,7 +203,7 @@ const registerDevice = async (address: string): Promise<void> => {
|
|
|
203
203
|
channelType: getChannelType(),
|
|
204
204
|
identityId,
|
|
205
205
|
userAgentValue: getPushNotificationUserAgentString(
|
|
206
|
-
PushNotificationAction.InitializePushNotifications
|
|
206
|
+
PushNotificationAction.InitializePushNotifications,
|
|
207
207
|
),
|
|
208
208
|
});
|
|
209
209
|
};
|
|
@@ -32,23 +32,23 @@ export type IdentifyUser = (input: IdentifyUserInput) => Promise<void>;
|
|
|
32
32
|
export type InitializePushNotifications = () => void;
|
|
33
33
|
|
|
34
34
|
export type RequestPermissions = (
|
|
35
|
-
input?: RequestPermissionsInput
|
|
35
|
+
input?: RequestPermissionsInput,
|
|
36
36
|
) => Promise<RequestPermissionsOutput>;
|
|
37
37
|
|
|
38
38
|
export type SetBadgeCount = (input: SetBadgeCountInput) => void;
|
|
39
39
|
|
|
40
40
|
export type OnNotificationOpened = (
|
|
41
|
-
input: OnNotificationOpenedInput
|
|
41
|
+
input: OnNotificationOpenedInput,
|
|
42
42
|
) => OnNotificationOpenedOutput;
|
|
43
43
|
|
|
44
44
|
export type OnNotificationReceivedInBackground = (
|
|
45
|
-
input: OnNotificationReceivedInBackgroundInput
|
|
45
|
+
input: OnNotificationReceivedInBackgroundInput,
|
|
46
46
|
) => OnNotificationReceivedInBackgroundOutput;
|
|
47
47
|
|
|
48
48
|
export type OnNotificationReceivedInForeground = (
|
|
49
|
-
input: OnNotificationReceivedInForegroundInput
|
|
49
|
+
input: OnNotificationReceivedInForegroundInput,
|
|
50
50
|
) => OnNotificationReceivedInForegroundOutput;
|
|
51
51
|
|
|
52
52
|
export type OnTokenReceived = (
|
|
53
|
-
input: OnTokenReceivedInput
|
|
53
|
+
input: OnTokenReceivedInput,
|
|
54
54
|
) => OnTokenReceivedOutput;
|
|
@@ -22,7 +22,7 @@ const logger = new ConsoleLogger('PushNotification.recordMessageEvent');
|
|
|
22
22
|
export const createMessageEventRecorder =
|
|
23
23
|
(
|
|
24
24
|
event: PinpointMessageEvent,
|
|
25
|
-
callback?: Function
|
|
25
|
+
callback?: Function,
|
|
26
26
|
): OnPushNotificationMessageHandler =>
|
|
27
27
|
async message => {
|
|
28
28
|
const { credentials } = await resolveCredentials();
|
|
@@ -15,7 +15,7 @@ const ANDROID_CAMPAIGN_TREATMENT_ID_KEY = 'pinpoint.campaign.treatment_id';
|
|
|
15
15
|
*/
|
|
16
16
|
export const getAnalyticsEvent = (
|
|
17
17
|
{ data }: PushNotificationMessage,
|
|
18
|
-
event: PinpointMessageEvent
|
|
18
|
+
event: PinpointMessageEvent,
|
|
19
19
|
): PinpointAnalyticsEvent | null => {
|
|
20
20
|
if (!data) {
|
|
21
21
|
return null;
|
|
@@ -32,7 +32,7 @@ export const getAnalyticsEvent = (
|
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
const getAnalyticsEventAttributes = (
|
|
35
|
-
data: PushNotificationMessage['data']
|
|
35
|
+
data: PushNotificationMessage['data'],
|
|
36
36
|
): AnalyticsEventAttributes | undefined => {
|
|
37
37
|
if (!data) {
|
|
38
38
|
return;
|
|
@@ -6,7 +6,7 @@ import { PushNotificationMessage } from './module';
|
|
|
6
6
|
export type OnTokenReceivedHandler = (token: string) => void;
|
|
7
7
|
|
|
8
8
|
export type OnPushNotificationMessageHandler = (
|
|
9
|
-
message: PushNotificationMessage
|
|
9
|
+
message: PushNotificationMessage,
|
|
10
10
|
) => void;
|
|
11
11
|
|
|
12
12
|
export type PushNotificationEvent =
|