Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release: Amplify JS release #13366

Merged
merged 9 commits into from
May 13, 2024
22 changes: 1 addition & 21 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,27 +53,7 @@ module.exports = {
'packages/react-native/__tests__',
'packages/rtn-push-notification/__tests__',
'packages/rtn-web-browser/__tests__',
'packages/storage/__tests__',
// will enable lint by packages
// 'adapter-nextjs',
// 'packages/analytics',
// 'packages/api',
// 'packages/api-graphql',
// 'packages/api-rest',
// 'packages/auth',
// 'packages/aws-amplify',
// 'packages/core',
'packages/datastore',
'packages/datastore-storage-adapter',
// 'packages/geo',
// 'packages/interactions',
// 'packages/notifications',
// 'packages/predictions',
// 'packages/pubsub',
// 'packages/react-native',
// 'packages/rtn-push-notification',
// 'packages/rtn-web-browser',
// 'packages/storage',
// 'packages/storage/__tests__',
],
rules: {
camelcase: [
Expand Down
2 changes: 2 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Run `eslint --fix` against staged files
yarn lint-staged
3 changes: 3 additions & 0 deletions .lintstagedrc.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default {
"*.{ts,tsx}": "eslint --fix"
}
3 changes: 2 additions & 1 deletion license_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
"**/Gemfile",
"**/.rollup.cache",
"**/rollup.config.mjs",
"rollup"
"rollup",
".husky"
],
"ignoreFile": ".gitignore",
"license": "license_header.txt",
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"publish:v5-stable": "lerna publish --conventional-commits --yes --dist-tag=stable-5 --message 'chore(release): Publish [ci skip]' --no-verify-access",
"publish:verdaccio": "lerna publish --canary --force-publish --no-push --dist-tag=unstable --preid=unstable --yes",
"ts-coverage": "lerna run ts-coverage",
"prepare": "./scripts/set-preid-versions.sh"
"prepare": "husky && ./scripts/set-preid-versions.sh"
},
"workspaces": {
"packages": [
Expand Down Expand Up @@ -103,11 +103,13 @@
"eslint-plugin-promise": "^6.1.1",
"eslint-plugin-unused-imports": "^3.0.0",
"glob": "^10.3.10",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"json-loader": "^0.5.7",
"lerna": "^7.4.2",
"license-check-and-add": "^4.0.5",
"lint-staged": "^15.2.2",
"mkdirp": "^3.0.1",
"prettier": "^3.2.5",
"rimraf": "^2.6.2",
Expand All @@ -116,8 +118,6 @@
"terser-webpack-plugin": "^5.3.6",
"ts-jest": "^29.1.1",
"ts-loader": "^9.4.3",
"tslint": "^5.7.0",
"tslint-config-airbnb": "^5.8.0",
"typedoc": "0.25.8",
"typedoc-plugin-extras": "^3.0.0",
"typedoc-plugin-missing-exports": "^2.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */
// this is an auto generated file. This will be overwritten

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */
// this is an auto generated file. This will be overwritten

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */
// this is an auto generated file. This will be overwritten

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */
// This file was automatically generated and should not be edited.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */
// this is an auto generated file. This will be overwritten

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */
// this is an auto generated file. This will be overwritten

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable */
/* eslint-disable */
// this is an auto generated file. This will be overwritten

Expand Down
2 changes: 1 addition & 1 deletion packages/api-graphql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
},
"scripts": {
"test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
"test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
"test:watch": "jest -w 1 --watch",
"build-with-test": "npm test && npm build",
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
"build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
Expand Down
2 changes: 1 addition & 1 deletion packages/api-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
},
"scripts": {
"test": "npm run lint && jest -w 1 --coverage --logHeapUsage",
"test:watch": "tslint 'src/**/*.ts' && jest -w 1 --watch",
"test:watch": "jest -w 1 --watch",
"build-with-test": "npm test && npm build",
"build:umd": "webpack && webpack --config ./webpack.config.dev.js",
"build:esm-cjs": "rollup --forceExit -c rollup.config.mjs",
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-amplify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
"name": "[Analytics] record (Pinpoint)",
"path": "./dist/esm/analytics/index.mjs",
"import": "{ record }",
"limit": "17.05 kB"
"limit": "17.08 kB"
},
{
"name": "[Analytics] record (Kinesis)",
Expand All @@ -317,7 +317,7 @@
"name": "[Analytics] identifyUser (Pinpoint)",
"path": "./dist/esm/analytics/index.mjs",
"import": "{ identifyUser }",
"limit": "15.53 kB"
"limit": "15.57 kB"
},
{
"name": "[Analytics] enable",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import {
appId,
clientDemographic,
endpointId as defaultEndpointId,
uuid,
} from '../../testUtils/data';
Expand All @@ -12,7 +11,7 @@ export const getExpectedInput = ({
address,
attributes,
channelType,
demographic = clientDemographic as any,
demographic,
endpointId = defaultEndpointId,
location,
metrics,
Expand All @@ -28,30 +27,36 @@ export const getExpectedInput = ({
EffectiveDate: expect.any(String),
ChannelType: channelType,
Address: address,
Attributes: attributes,
Demographic: {
AppVersion: demographic.appVersion,
Locale: demographic.locale,
Make: demographic.make,
Model: demographic.model,
ModelVersion: demographic.modelVersion ?? demographic.version,
Platform: demographic.platform,
PlatformVersion: demographic.platformVersion,
Timezone: demographic.timezone,
},
Location: {
City: location?.city,
Country: location?.country,
Latitude: location?.latitude,
Longitude: location?.longitude,
PostalCode: location?.postalCode,
Region: location?.region,
},
...(attributes && { Attributes: attributes }),
...(demographic && {
Demographic: {
AppVersion: demographic.appVersion,
Locale: demographic.locale,
Make: demographic.make,
Model: demographic.model,
ModelVersion: demographic.modelVersion ?? demographic.version,
Platform: demographic.platform,
PlatformVersion: demographic.platformVersion,
Timezone: demographic.timezone,
},
}),
...(location && {
Location: {
City: location?.city,
Country: location?.country,
Latitude: location?.latitude,
Longitude: location?.longitude,
PostalCode: location?.postalCode,
Region: location?.region,
},
}),
Metrics: metrics,
OptOut: optOut,
User: {
UserId: userId,
UserAttributes: userAttributes,
},
...((userId || userAttributes) && {
User: {
UserId: userId,
UserAttributes: userAttributes,
},
}),
}),
});
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {
clientDemographic,
credentials,
endpointId,
identityId,
region,
userAttributes,
userId,
userProfile,
uuid,
Expand Down Expand Up @@ -130,7 +132,8 @@ describe('Pinpoint Provider API: updateEndpoint', () => {
);
});

it('merges demographics', async () => {
it('merges demographics with client info on endpoint creation', async () => {
mockGetEndpointId.mockReturnValue(undefined);
const partialDemographic = { ...demographic } as any;
delete partialDemographic.make;
delete partialDemographic.model;
Expand All @@ -146,6 +149,7 @@ describe('Pinpoint Provider API: updateEndpoint', () => {
expect(mockClientUpdateEndpoint).toHaveBeenCalledWith(
{ credentials, region },
getExpectedInput({
endpointId: createdEndpointId,
demographic: {
...demographic,
make: clientDemographic.make,
Expand All @@ -155,6 +159,58 @@ describe('Pinpoint Provider API: updateEndpoint', () => {
);
});

it('does not merge demographics with client info on endpoint update', async () => {
const partialDemographic = { ...demographic } as any;
delete partialDemographic.make;
delete partialDemographic.model;
await updateEndpoint({
appId,
category,
credentials,
region,
userProfile: {
demographic: partialDemographic,
},
});
expect(mockClientUpdateEndpoint).toHaveBeenCalledWith(
{ credentials, region },
getExpectedInput({ demographic: partialDemographic }),
);
});

it('falls back to idenity id on endpoint creation', async () => {
mockGetEndpointId.mockReturnValue(undefined);
await updateEndpoint({
appId,
category,
credentials,
identityId,
region,
});
expect(mockClientUpdateEndpoint).toHaveBeenCalledWith(
{ credentials, region },
getExpectedInput({
endpointId: createdEndpointId,
userId: identityId,
}),
);
});

it('does not fall back to idenity id on endpoint update', async () => {
await updateEndpoint({
appId,
category,
credentials,
identityId,
region,
userAttributes,
});
expect(mockClientUpdateEndpoint).toHaveBeenCalledWith(
{ credentials, region },
getExpectedInput({ userAttributes }),
);
});

it('creates an endpoint if one is not already cached', async () => {
mockGetEndpointId.mockReturnValue(undefined);
await updateEndpoint({ appId, category, credentials, region });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ export const event = {
};
export const identityId = 'identity-id';
export const region = 'region';
export const userAttributes = {
attr: ['attr-value-one', 'attr-value-two'],
};
export const userId = 'user-id';
export const userProfile = {
customProperties: {
Expand Down