@aws-amplify/core 6.2.0 → 6.2.1-unstable.6ae339a.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/Platform/version.js +1 -1
- package/dist/cjs/Platform/version.js.map +1 -1
- package/dist/cjs/providers/pinpoint/apis/updateEndpoint.js +46 -31
- package/dist/cjs/providers/pinpoint/apis/updateEndpoint.js.map +1 -1
- package/dist/esm/Platform/version.d.ts +1 -1
- package/dist/esm/Platform/version.mjs +1 -1
- package/dist/esm/Platform/version.mjs.map +1 -1
- package/dist/esm/ServiceWorker/ServiceWorker.mjs +1 -1
- package/dist/esm/providers/pinpoint/apis/updateEndpoint.mjs +46 -31
- package/dist/esm/providers/pinpoint/apis/updateEndpoint.mjs.map +1 -1
- package/package.json +3 -3
- package/src/Platform/version.ts +1 -1
- package/src/providers/pinpoint/apis/updateEndpoint.ts +51 -32
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.3.0';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,
|
|
1
|
+
{"version":3,"file":"version.js","sources":["../../../src/Platform/version.ts"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.version = void 0;\n// generated by genversion\nexports.version = '6.3.1-unstable.6ae339a.0+6ae339a';\n"],"names":[],"mappings":";;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,CAAC;AACzB;AACA,OAAO,CAAC,OAAO,GAAG,kCAAkC;;"}
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
// SPDX-License-Identifier: Apache-2.0
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.updateEndpoint = void 0;
|
|
7
|
+
const pinpoint_1 = require("../../../awsClients/pinpoint");
|
|
7
8
|
const amplifyUuid_1 = require("../../../utils/amplifyUuid");
|
|
8
9
|
const getClientInfo_1 = require("../../../utils/getClientInfo");
|
|
9
|
-
const pinpoint_1 = require("../../../awsClients/pinpoint");
|
|
10
10
|
const cacheEndpointId_1 = require("../utils/cacheEndpointId");
|
|
11
11
|
const createEndpointId_1 = require("../utils/createEndpointId");
|
|
12
12
|
const getEndpointId_1 = require("../utils/getEndpointId");
|
|
@@ -20,22 +20,31 @@ const updateEndpoint = async ({ address, appId, category, channelType, credentia
|
|
|
20
20
|
? (0, createEndpointId_1.createEndpointId)(appId, category)
|
|
21
21
|
: undefined;
|
|
22
22
|
const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};
|
|
23
|
-
|
|
23
|
+
// only automatically populate the endpoint with client info and identity id upon endpoint creation to
|
|
24
|
+
// avoid overwriting the endpoint with these values every time the endpoint is updated
|
|
25
|
+
const demographicsFromClientInfo = {};
|
|
26
|
+
const resolvedUserId = createdEndpointId ? userId ?? identityId : userId;
|
|
27
|
+
if (createdEndpointId) {
|
|
28
|
+
const clientInfo = (0, getClientInfo_1.getClientInfo)();
|
|
29
|
+
demographicsFromClientInfo.appVersion = clientInfo.appVersion;
|
|
30
|
+
demographicsFromClientInfo.make = clientInfo.make;
|
|
31
|
+
demographicsFromClientInfo.model = clientInfo.model;
|
|
32
|
+
demographicsFromClientInfo.modelVersion = clientInfo.version;
|
|
33
|
+
demographicsFromClientInfo.platform = clientInfo.platform;
|
|
34
|
+
}
|
|
24
35
|
const mergedDemographic = {
|
|
25
|
-
|
|
26
|
-
make: clientInfo.make,
|
|
27
|
-
model: clientInfo.model,
|
|
28
|
-
modelVersion: clientInfo.version,
|
|
29
|
-
platform: clientInfo.platform,
|
|
36
|
+
...demographicsFromClientInfo,
|
|
30
37
|
...demographic,
|
|
31
38
|
};
|
|
32
|
-
const shouldAddAttributes = email || customProperties || name || plan;
|
|
33
39
|
const attributes = {
|
|
34
40
|
...(email && { email: [email] }),
|
|
35
41
|
...(name && { name: [name] }),
|
|
36
42
|
...(plan && { plan: [plan] }),
|
|
37
43
|
...customProperties,
|
|
38
44
|
};
|
|
45
|
+
const shouldAddDemographics = createdEndpointId || demographic;
|
|
46
|
+
const shouldAddAttributes = email || customProperties || name || plan;
|
|
47
|
+
const shouldAddUser = resolvedUserId || userAttributes;
|
|
39
48
|
const input = {
|
|
40
49
|
ApplicationId: appId,
|
|
41
50
|
EndpointId: endpointId ?? createdEndpointId,
|
|
@@ -44,31 +53,37 @@ const updateEndpoint = async ({ address, appId, category, channelType, credentia
|
|
|
44
53
|
EffectiveDate: new Date().toISOString(),
|
|
45
54
|
ChannelType: channelType,
|
|
46
55
|
Address: address,
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
56
|
+
...(shouldAddAttributes && { Attributes: attributes }),
|
|
57
|
+
...(shouldAddDemographics && {
|
|
58
|
+
Demographic: {
|
|
59
|
+
AppVersion: mergedDemographic.appVersion,
|
|
60
|
+
Locale: mergedDemographic.locale,
|
|
61
|
+
Make: mergedDemographic.make,
|
|
62
|
+
Model: mergedDemographic.model,
|
|
63
|
+
ModelVersion: mergedDemographic.modelVersion,
|
|
64
|
+
Platform: mergedDemographic.platform,
|
|
65
|
+
PlatformVersion: mergedDemographic.platformVersion,
|
|
66
|
+
Timezone: mergedDemographic.timezone,
|
|
67
|
+
},
|
|
68
|
+
}),
|
|
69
|
+
...(location && {
|
|
70
|
+
Location: {
|
|
71
|
+
City: location.city,
|
|
72
|
+
Country: location.country,
|
|
73
|
+
Latitude: location.latitude,
|
|
74
|
+
Longitude: location.longitude,
|
|
75
|
+
PostalCode: location.postalCode,
|
|
76
|
+
Region: location.region,
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
66
79
|
Metrics: metrics,
|
|
67
80
|
OptOut: optOut,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
81
|
+
...(shouldAddUser && {
|
|
82
|
+
User: {
|
|
83
|
+
UserId: resolvedUserId,
|
|
84
|
+
UserAttributes: userAttributes,
|
|
85
|
+
},
|
|
86
|
+
}),
|
|
72
87
|
},
|
|
73
88
|
};
|
|
74
89
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateEndpoint.js","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.updateEndpoint = void 0;\nconst
|
|
1
|
+
{"version":3,"file":"updateEndpoint.js","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["\"use strict\";\n// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.updateEndpoint = void 0;\nconst pinpoint_1 = require(\"../../../awsClients/pinpoint\");\nconst amplifyUuid_1 = require(\"../../../utils/amplifyUuid\");\nconst getClientInfo_1 = require(\"../../../utils/getClientInfo\");\nconst cacheEndpointId_1 = require(\"../utils/cacheEndpointId\");\nconst createEndpointId_1 = require(\"../utils/createEndpointId\");\nconst getEndpointId_1 = require(\"../utils/getEndpointId\");\n/**\n * @internal\n */\nconst updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {\n const endpointId = await (0, getEndpointId_1.getEndpointId)(appId, category);\n // only generate a new endpoint id if one was not found in cache\n const createdEndpointId = !endpointId\n ? (0, createEndpointId_1.createEndpointId)(appId, category)\n : undefined;\n const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};\n // only automatically populate the endpoint with client info and identity id upon endpoint creation to\n // avoid overwriting the endpoint with these values every time the endpoint is updated\n const demographicsFromClientInfo = {};\n const resolvedUserId = createdEndpointId ? userId ?? identityId : userId;\n if (createdEndpointId) {\n const clientInfo = (0, getClientInfo_1.getClientInfo)();\n demographicsFromClientInfo.appVersion = clientInfo.appVersion;\n demographicsFromClientInfo.make = clientInfo.make;\n demographicsFromClientInfo.model = clientInfo.model;\n demographicsFromClientInfo.modelVersion = clientInfo.version;\n demographicsFromClientInfo.platform = clientInfo.platform;\n }\n const mergedDemographic = {\n ...demographicsFromClientInfo,\n ...demographic,\n };\n const attributes = {\n ...(email && { email: [email] }),\n ...(name && { name: [name] }),\n ...(plan && { plan: [plan] }),\n ...customProperties,\n };\n const shouldAddDemographics = createdEndpointId || demographic;\n const shouldAddAttributes = email || customProperties || name || plan;\n const shouldAddUser = resolvedUserId || userAttributes;\n const input = {\n ApplicationId: appId,\n EndpointId: endpointId ?? createdEndpointId,\n EndpointRequest: {\n RequestId: (0, amplifyUuid_1.amplifyUuid)(),\n EffectiveDate: new Date().toISOString(),\n ChannelType: channelType,\n Address: address,\n ...(shouldAddAttributes && { Attributes: attributes }),\n ...(shouldAddDemographics && {\n Demographic: {\n AppVersion: mergedDemographic.appVersion,\n Locale: mergedDemographic.locale,\n Make: mergedDemographic.make,\n Model: mergedDemographic.model,\n ModelVersion: mergedDemographic.modelVersion,\n Platform: mergedDemographic.platform,\n PlatformVersion: mergedDemographic.platformVersion,\n Timezone: mergedDemographic.timezone,\n },\n }),\n ...(location && {\n Location: {\n City: location.city,\n Country: location.country,\n Latitude: location.latitude,\n Longitude: location.longitude,\n PostalCode: location.postalCode,\n Region: location.region,\n },\n }),\n Metrics: metrics,\n OptOut: optOut,\n ...(shouldAddUser && {\n User: {\n UserId: resolvedUserId,\n UserAttributes: userAttributes,\n },\n }),\n },\n };\n try {\n await (0, pinpoint_1.updateEndpoint)({ credentials, region, userAgentValue }, input);\n // if we had to create an endpoint id, we need to now cache it\n if (createdEndpointId) {\n await (0, cacheEndpointId_1.cacheEndpointId)(appId, category, createdEndpointId);\n }\n }\n finally {\n // at this point, we completely reset the behavior so even if the update was unsuccessful\n // we can just start over with a newly created endpoint id\n if (createdEndpointId) {\n (0, createEndpointId_1.clearCreatedEndpointId)(appId, category);\n }\n }\n};\nexports.updateEndpoint = updateEndpoint;\n"],"names":[],"mappings":";;AACA;AACA;AACA,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,YAAY,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;AAC9D,OAAO,CAAC,cAAc,GAAG,KAAK,CAAC,CAAC;AAChC,MAAM,UAAU,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC3D,MAAM,aAAa,GAAG,OAAO,CAAC,4BAA4B,CAAC,CAAC;AAC5D,MAAM,eAAe,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAChE,MAAM,iBAAiB,GAAG,OAAO,CAAC,0BAA0B,CAAC,CAAC;AAC9D,MAAM,kBAAkB,GAAG,OAAO,CAAC,2BAA2B,CAAC,CAAC;AAChE,MAAM,eAAe,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;AAC1D;AACA;AACA;AACA,MAAM,cAAc,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,WAAW,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3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.3.0';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
|
|
1
|
+
{"version":3,"file":"version.mjs","sources":["../../../src/Platform/version.ts"],"sourcesContent":["// generated by genversion\nexport const version = '6.3.1-unstable.6ae339a.0+6ae339a';\n"],"names":[],"mappings":"AAAA;AACY,MAAC,OAAO,GAAG;;;;"}
|
|
@@ -5,11 +5,11 @@ import '../utils/retry/retry.mjs';
|
|
|
5
5
|
import { AmplifyError } from '../errors/AmplifyError.mjs';
|
|
6
6
|
import '../types/errors.mjs';
|
|
7
7
|
import '../errors/errorHelpers.mjs';
|
|
8
|
-
import 'uuid';
|
|
9
8
|
import '@aws-crypto/sha256-js';
|
|
10
9
|
import '@smithy/util-hex-encoding';
|
|
11
10
|
import '../awsClients/pinpoint/base.mjs';
|
|
12
11
|
import '../awsClients/pinpoint/errorHelpers.mjs';
|
|
12
|
+
import 'uuid';
|
|
13
13
|
import '../Cache/index.mjs';
|
|
14
14
|
import { record } from '../providers/pinpoint/apis/record.mjs';
|
|
15
15
|
import '../providers/pinpoint/utils/PinpointEventBuffer.mjs';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { amplifyUuid } from '../../../utils/amplifyUuid/index.mjs';
|
|
2
1
|
import { getClientInfo } from '../../../utils/getClientInfo/getClientInfo.mjs';
|
|
3
2
|
import '../../../utils/retry/retry.mjs';
|
|
4
3
|
import '@aws-crypto/sha256-js';
|
|
@@ -6,6 +5,7 @@ import '@smithy/util-hex-encoding';
|
|
|
6
5
|
import '../../../awsClients/pinpoint/base.mjs';
|
|
7
6
|
import '../../../awsClients/pinpoint/errorHelpers.mjs';
|
|
8
7
|
import { updateEndpoint as updateEndpoint$1 } from '../../../awsClients/pinpoint/updateEndpoint.mjs';
|
|
8
|
+
import { amplifyUuid } from '../../../utils/amplifyUuid/index.mjs';
|
|
9
9
|
import { cacheEndpointId } from '../utils/cacheEndpointId.mjs';
|
|
10
10
|
import { createEndpointId, clearCreatedEndpointId } from '../utils/createEndpointId.mjs';
|
|
11
11
|
import { getEndpointId } from '../utils/getEndpointId.mjs';
|
|
@@ -22,22 +22,31 @@ const updateEndpoint = async ({ address, appId, category, channelType, credentia
|
|
|
22
22
|
? createEndpointId(appId, category)
|
|
23
23
|
: undefined;
|
|
24
24
|
const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};
|
|
25
|
-
|
|
25
|
+
// only automatically populate the endpoint with client info and identity id upon endpoint creation to
|
|
26
|
+
// avoid overwriting the endpoint with these values every time the endpoint is updated
|
|
27
|
+
const demographicsFromClientInfo = {};
|
|
28
|
+
const resolvedUserId = createdEndpointId ? userId ?? identityId : userId;
|
|
29
|
+
if (createdEndpointId) {
|
|
30
|
+
const clientInfo = getClientInfo();
|
|
31
|
+
demographicsFromClientInfo.appVersion = clientInfo.appVersion;
|
|
32
|
+
demographicsFromClientInfo.make = clientInfo.make;
|
|
33
|
+
demographicsFromClientInfo.model = clientInfo.model;
|
|
34
|
+
demographicsFromClientInfo.modelVersion = clientInfo.version;
|
|
35
|
+
demographicsFromClientInfo.platform = clientInfo.platform;
|
|
36
|
+
}
|
|
26
37
|
const mergedDemographic = {
|
|
27
|
-
|
|
28
|
-
make: clientInfo.make,
|
|
29
|
-
model: clientInfo.model,
|
|
30
|
-
modelVersion: clientInfo.version,
|
|
31
|
-
platform: clientInfo.platform,
|
|
38
|
+
...demographicsFromClientInfo,
|
|
32
39
|
...demographic,
|
|
33
40
|
};
|
|
34
|
-
const shouldAddAttributes = email || customProperties || name || plan;
|
|
35
41
|
const attributes = {
|
|
36
42
|
...(email && { email: [email] }),
|
|
37
43
|
...(name && { name: [name] }),
|
|
38
44
|
...(plan && { plan: [plan] }),
|
|
39
45
|
...customProperties,
|
|
40
46
|
};
|
|
47
|
+
const shouldAddDemographics = createdEndpointId || demographic;
|
|
48
|
+
const shouldAddAttributes = email || customProperties || name || plan;
|
|
49
|
+
const shouldAddUser = resolvedUserId || userAttributes;
|
|
41
50
|
const input = {
|
|
42
51
|
ApplicationId: appId,
|
|
43
52
|
EndpointId: endpointId ?? createdEndpointId,
|
|
@@ -46,31 +55,37 @@ const updateEndpoint = async ({ address, appId, category, channelType, credentia
|
|
|
46
55
|
EffectiveDate: new Date().toISOString(),
|
|
47
56
|
ChannelType: channelType,
|
|
48
57
|
Address: address,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
58
|
+
...(shouldAddAttributes && { Attributes: attributes }),
|
|
59
|
+
...(shouldAddDemographics && {
|
|
60
|
+
Demographic: {
|
|
61
|
+
AppVersion: mergedDemographic.appVersion,
|
|
62
|
+
Locale: mergedDemographic.locale,
|
|
63
|
+
Make: mergedDemographic.make,
|
|
64
|
+
Model: mergedDemographic.model,
|
|
65
|
+
ModelVersion: mergedDemographic.modelVersion,
|
|
66
|
+
Platform: mergedDemographic.platform,
|
|
67
|
+
PlatformVersion: mergedDemographic.platformVersion,
|
|
68
|
+
Timezone: mergedDemographic.timezone,
|
|
69
|
+
},
|
|
70
|
+
}),
|
|
71
|
+
...(location && {
|
|
72
|
+
Location: {
|
|
73
|
+
City: location.city,
|
|
74
|
+
Country: location.country,
|
|
75
|
+
Latitude: location.latitude,
|
|
76
|
+
Longitude: location.longitude,
|
|
77
|
+
PostalCode: location.postalCode,
|
|
78
|
+
Region: location.region,
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
68
81
|
Metrics: metrics,
|
|
69
82
|
OptOut: optOut,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
83
|
+
...(shouldAddUser && {
|
|
84
|
+
User: {
|
|
85
|
+
UserId: resolvedUserId,
|
|
86
|
+
UserAttributes: userAttributes,
|
|
87
|
+
},
|
|
88
|
+
}),
|
|
74
89
|
},
|
|
75
90
|
};
|
|
76
91
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateEndpoint.mjs","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport {
|
|
1
|
+
{"version":3,"file":"updateEndpoint.mjs","sources":["../../../../../src/providers/pinpoint/apis/updateEndpoint.ts"],"sourcesContent":["// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.\n// SPDX-License-Identifier: Apache-2.0\nimport { updateEndpoint as clientUpdateEndpoint, } from '../../../awsClients/pinpoint';\nimport { amplifyUuid } from '../../../utils/amplifyUuid';\nimport { getClientInfo } from '../../../utils/getClientInfo';\nimport { cacheEndpointId } from '../utils/cacheEndpointId';\nimport { clearCreatedEndpointId, createEndpointId, } from '../utils/createEndpointId';\nimport { getEndpointId } from '../utils/getEndpointId';\n/**\n * @internal\n */\nexport const updateEndpoint = async ({ address, appId, category, channelType, credentials, identityId, optOut, region, userAttributes, userId, userProfile, userAgentValue, }) => {\n const endpointId = await getEndpointId(appId, category);\n // only generate a new endpoint id if one was not found in cache\n const createdEndpointId = !endpointId\n ? createEndpointId(appId, category)\n : undefined;\n const { customProperties, demographic, email, location, metrics, name, plan, } = userProfile ?? {};\n // only automatically populate the endpoint with client info and identity id upon endpoint creation to\n // avoid overwriting the endpoint with these values every time the endpoint is updated\n const demographicsFromClientInfo = {};\n const resolvedUserId = createdEndpointId ? userId ?? identityId : userId;\n if (createdEndpointId) {\n const clientInfo = getClientInfo();\n demographicsFromClientInfo.appVersion = clientInfo.appVersion;\n demographicsFromClientInfo.make = clientInfo.make;\n demographicsFromClientInfo.model = clientInfo.model;\n demographicsFromClientInfo.modelVersion = clientInfo.version;\n demographicsFromClientInfo.platform = clientInfo.platform;\n }\n const mergedDemographic = {\n ...demographicsFromClientInfo,\n ...demographic,\n };\n const attributes = {\n ...(email && { email: [email] }),\n ...(name && { name: [name] }),\n ...(plan && { plan: [plan] }),\n ...customProperties,\n };\n const shouldAddDemographics = createdEndpointId || demographic;\n const shouldAddAttributes = email || customProperties || name || plan;\n const shouldAddUser = resolvedUserId || userAttributes;\n const input = {\n ApplicationId: appId,\n EndpointId: endpointId ?? createdEndpointId,\n EndpointRequest: {\n RequestId: amplifyUuid(),\n EffectiveDate: new Date().toISOString(),\n ChannelType: channelType,\n Address: address,\n ...(shouldAddAttributes && { Attributes: attributes }),\n ...(shouldAddDemographics && {\n Demographic: {\n AppVersion: mergedDemographic.appVersion,\n Locale: mergedDemographic.locale,\n Make: mergedDemographic.make,\n Model: mergedDemographic.model,\n ModelVersion: mergedDemographic.modelVersion,\n Platform: mergedDemographic.platform,\n PlatformVersion: mergedDemographic.platformVersion,\n Timezone: mergedDemographic.timezone,\n },\n }),\n ...(location && {\n Location: {\n City: location.city,\n Country: location.country,\n Latitude: location.latitude,\n Longitude: location.longitude,\n PostalCode: location.postalCode,\n Region: location.region,\n },\n }),\n Metrics: metrics,\n OptOut: optOut,\n ...(shouldAddUser && {\n User: {\n UserId: resolvedUserId,\n UserAttributes: userAttributes,\n },\n }),\n },\n };\n try {\n await clientUpdateEndpoint({ credentials, region, userAgentValue }, input);\n // if we had to create an endpoint id, we need to now cache it\n if (createdEndpointId) {\n await cacheEndpointId(appId, category, createdEndpointId);\n }\n }\n finally {\n // at this point, we completely reset the behavior so even if the update was unsuccessful\n // we can just start over with a newly created endpoint id\n if (createdEndpointId) {\n clearCreatedEndpointId(appId, category);\n }\n }\n};\n"],"names":["clientUpdateEndpoint"],"mappings":";;;;;;;;;;;;AAAA;AACA;AAOA;AACA;AACA;AACY,MAAC,cAAc,GAAG,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAA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B,gBAAgB,QAAQ,EAAE;AAC1B,oBAAoB,IAAI,EAAE,QAAQ,CAAC,IAAI;AACvC,oBAAoB,OAAO,EAAE,QAAQ,CAAC,OAAO;AAC7C,oBAAoB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;AAC/C,oBAAoB,SAAS,EAAE,QAAQ,CAAC,SAAS;AACjD,oBAAoB,UAAU,EAAE,QAAQ,CAAC,UAAU;AACnD,oBAAoB,MAAM,EAAE,QAAQ,CAAC,MAAM;AAC3C,iBAAiB;AACjB,aAAa;AACb,YAAY,OAAO,EAAE,OAAO;AAC5B,YAAY,MAAM,EAAE,MAAM;AAC1B,YAAY,IAAI,aAAa,IAAI;AACjC,gBAAgB,IAAI,EAAE;AACtB,oBAAoB,MAAM,EAAE,cAAc;AAC1C,oBAAoB,cAAc,EAAE,cAAc;AAClD,iBAAiB;AACjB,aAAa;AACb,SAAS;AACT,KAAK,CAAC;AACN,IAAI,IAAI;AACR,QAAQ,MAAMA,gBAAoB,CAAC,EAAE,WAAW,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,KAAK,CAAC,CAAC;AACnF;AACA,QAAQ,IAAI,iBAAiB,EAAE;AAC/B,YAAY,MAAM,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,iBAAiB,CAAC,CAAC;AACtE,SAAS;AACT,KAAK;AACL,YAAY;AACZ;AACA;AACA,QAAQ,IAAI,iBAAiB,EAAE;AAC/B,YAAY,sBAAsB,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;AACpD,SAAS;AACT,KAAK;AACL;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aws-amplify/core",
|
|
3
|
-
"version": "6.2.0",
|
|
3
|
+
"version": "6.2.1-unstable.6ae339a.0+6ae339a",
|
|
4
4
|
"description": "Core category of aws-amplify",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.mjs",
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"uuid": "^9.0.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@aws-amplify/react-native": "1.1.0",
|
|
63
|
+
"@aws-amplify/react-native": "1.1.1-unstable.6ae339a.0+6ae339a",
|
|
64
64
|
"@types/js-cookie": "3.0.2",
|
|
65
65
|
"genversion": "^2.2.0",
|
|
66
66
|
"typescript": "5.0.2"
|
|
@@ -192,5 +192,5 @@
|
|
|
192
192
|
]
|
|
193
193
|
}
|
|
194
194
|
},
|
|
195
|
-
"gitHead": "
|
|
195
|
+
"gitHead": "6ae339a468b0f58d0ca7b3bc3d9240e80e99e232"
|
|
196
196
|
}
|
package/src/Platform/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// generated by genversion
|
|
2
|
-
export const version = '6.3.0';
|
|
2
|
+
export const version = '6.3.1-unstable.6ae339a.0+6ae339a';
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import { amplifyUuid } from '../../../utils/amplifyUuid';
|
|
5
|
-
import { getClientInfo } from '../../../utils/getClientInfo';
|
|
6
4
|
import {
|
|
7
5
|
UpdateEndpointInput,
|
|
8
6
|
updateEndpoint as clientUpdateEndpoint,
|
|
9
7
|
} from '../../../awsClients/pinpoint';
|
|
8
|
+
import { UserProfile } from '../../../types';
|
|
9
|
+
import { amplifyUuid } from '../../../utils/amplifyUuid';
|
|
10
|
+
import { getClientInfo } from '../../../utils/getClientInfo';
|
|
10
11
|
import { PinpointUpdateEndpointInput } from '../types';
|
|
11
12
|
import { cacheEndpointId } from '../utils/cacheEndpointId';
|
|
12
13
|
import {
|
|
@@ -46,22 +47,34 @@ export const updateEndpoint = async ({
|
|
|
46
47
|
name,
|
|
47
48
|
plan,
|
|
48
49
|
} = userProfile ?? {};
|
|
49
|
-
|
|
50
|
+
|
|
51
|
+
// only automatically populate the endpoint with client info and identity id upon endpoint creation to
|
|
52
|
+
// avoid overwriting the endpoint with these values every time the endpoint is updated
|
|
53
|
+
const demographicsFromClientInfo: UserProfile['demographic'] = {};
|
|
54
|
+
const resolvedUserId = createdEndpointId ? userId ?? identityId : userId;
|
|
55
|
+
if (createdEndpointId) {
|
|
56
|
+
const clientInfo = getClientInfo();
|
|
57
|
+
demographicsFromClientInfo.appVersion = clientInfo.appVersion;
|
|
58
|
+
demographicsFromClientInfo.make = clientInfo.make;
|
|
59
|
+
demographicsFromClientInfo.model = clientInfo.model;
|
|
60
|
+
demographicsFromClientInfo.modelVersion = clientInfo.version;
|
|
61
|
+
demographicsFromClientInfo.platform = clientInfo.platform;
|
|
62
|
+
}
|
|
50
63
|
const mergedDemographic = {
|
|
51
|
-
|
|
52
|
-
make: clientInfo.make,
|
|
53
|
-
model: clientInfo.model,
|
|
54
|
-
modelVersion: clientInfo.version,
|
|
55
|
-
platform: clientInfo.platform,
|
|
64
|
+
...demographicsFromClientInfo,
|
|
56
65
|
...demographic,
|
|
57
66
|
};
|
|
58
|
-
const shouldAddAttributes = email || customProperties || name || plan;
|
|
59
67
|
const attributes = {
|
|
60
68
|
...(email && { email: [email] }),
|
|
61
69
|
...(name && { name: [name] }),
|
|
62
70
|
...(plan && { plan: [plan] }),
|
|
63
71
|
...customProperties,
|
|
64
72
|
};
|
|
73
|
+
|
|
74
|
+
const shouldAddDemographics = createdEndpointId || demographic;
|
|
75
|
+
const shouldAddAttributes = email || customProperties || name || plan;
|
|
76
|
+
const shouldAddUser = resolvedUserId || userAttributes;
|
|
77
|
+
|
|
65
78
|
const input: UpdateEndpointInput = {
|
|
66
79
|
ApplicationId: appId,
|
|
67
80
|
EndpointId: endpointId ?? createdEndpointId,
|
|
@@ -70,31 +83,37 @@ export const updateEndpoint = async ({
|
|
|
70
83
|
EffectiveDate: new Date().toISOString(),
|
|
71
84
|
ChannelType: channelType,
|
|
72
85
|
Address: address,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
...(shouldAddAttributes && { Attributes: attributes }),
|
|
87
|
+
...(shouldAddDemographics && {
|
|
88
|
+
Demographic: {
|
|
89
|
+
AppVersion: mergedDemographic.appVersion,
|
|
90
|
+
Locale: mergedDemographic.locale,
|
|
91
|
+
Make: mergedDemographic.make,
|
|
92
|
+
Model: mergedDemographic.model,
|
|
93
|
+
ModelVersion: mergedDemographic.modelVersion,
|
|
94
|
+
Platform: mergedDemographic.platform,
|
|
95
|
+
PlatformVersion: mergedDemographic.platformVersion,
|
|
96
|
+
Timezone: mergedDemographic.timezone,
|
|
97
|
+
},
|
|
98
|
+
}),
|
|
99
|
+
...(location && {
|
|
100
|
+
Location: {
|
|
101
|
+
City: location.city,
|
|
102
|
+
Country: location.country,
|
|
103
|
+
Latitude: location.latitude,
|
|
104
|
+
Longitude: location.longitude,
|
|
105
|
+
PostalCode: location.postalCode,
|
|
106
|
+
Region: location.region,
|
|
107
|
+
},
|
|
108
|
+
}),
|
|
92
109
|
Metrics: metrics,
|
|
93
110
|
OptOut: optOut,
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
111
|
+
...(shouldAddUser && {
|
|
112
|
+
User: {
|
|
113
|
+
UserId: resolvedUserId,
|
|
114
|
+
UserAttributes: userAttributes,
|
|
115
|
+
},
|
|
116
|
+
}),
|
|
98
117
|
},
|
|
99
118
|
};
|
|
100
119
|
try {
|