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

feat: Custom user agent enhancements merge to main #11476

Merged
merged 52 commits into from
Jun 19, 2023

Conversation

stocaaro
Copy link
Member

@stocaaro stocaaro commented Jun 8, 2023

Description of changes

This is a merge back to main of changes that have been reviewed as they where merged into feat/user-agent-enhancements/main. Changes are available for testing on the v5-custom-user-agent tag in NPM.

Feature work:

Administrative/Unblocking

Merges from main

Description of how you validated changes

  • Unit tests added/modified
  • Integration steps running and working before preid releases
  • We are working through manually testing of the preid release candidate to verify the user agent enhancements are working and not introducing issues

Checklist

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

erinleigh90 and others added 30 commits April 18, 2023 10:18
* feat: update userAgentSuffix to capture new information and format

* feat: update customUserAgent to agreed-upon format, change userAgentSuffix to customUserAgent

* chore: simplify override of customUserAgent props

* chore: update import to be more concise

Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>

* chore: define expected user agents at the top

* chore: move platform-specific types and enums to platform folder

* chore: update category and framework import to come from Platform instead of top-level

* chore: add return type for detectFramework

* chore: remove unnecessary toString

* feat: update getAmplifyUserAgent to return format expected by aws-sdk

* fix: change customuseragent format to work with aws-sdk cleaning

* feat: refine detectFramework to detect react more reliably and prevent undefined error

* chore: remove unnecessary logs

* fix: typescript - change let to const

* fix: typescript - change == to ===

* test: updates test to strict equal to avoid serializes to the same string failure

* feat: use category/action (auth/1) format and updates tests for that format

* chore: change reactWindow to more generic enhancedWindow

* chore: remove part3 code for this iteration

* chore: remove part3 code for this iteration

* fix: remove accidental pi string

* chore: remove part 4 code from this iteration

* chore: remove part 4 code from this iteration

* chore: cleanup naming and building of user agent string

* chore: move framework detection to platform constant to prevent unnecessary repetition of detection

* chore: destructure customUserAgent param in buildUserAgent

* chore: move aws-sdk/types from dependencies to devDependencies

* chore: simplify if-else to ternary

* chore: remove unnecessary function

* chore: alphabetize type/enum exports, fix getAmplifyUserAgent export

* chore: rerun framework detection once if none, in case DOM not yet loaded on Platform declaration

* chore: update to type definitions to require action and name change

* chore: revert cross-category communication pending agreement

* test: revert test changes related to cross-category communication pending consensus

* chore: remove unused imports

* test: update test name

* chore: remove unnecessary trim

* chore: add copyright header to detectFramework file

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>

* chore: change comments on framework detection to doc-string format

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>

* chore: mark frameworkHasBeenRerun after rerun

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>

* chore: address feedback

---------

Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
* feat: implement new custom user agent details in amazon-cognito-identity-js

* chore: update variable name for clearer semantics

Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>

* chore: incorporate PR feedback, fix inconsistent renaming of frameworkHasBeenRerun

---------

Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
* chore(release): Publish [ci skip]

 - aws-amplify@5.2.3
 - @aws-amplify/datastore-storage-adapter@2.0.33
 - @aws-amplify/datastore@4.4.0
 - @aws-amplify/predictions@5.2.0
 - @aws-amplify/storage@5.3.0

* chore(release): update API docs [ci skip]

* fix(notifications): Add babel plugins to devDependencies (#11414)

* fix(storage): make getProperties param optional (#11413)

* Revert "fix(storage): make getProperties param optional (#11413)"

This reverts commit 5d00b1f.

* Revert "feat(storage): getProperties API (#11378)"

This reverts commit 3bed12b.

---------

Co-authored-by: israx <70438514+israx@users.noreply.github.com>
Co-authored-by: aws-amplify-bot <aws@amazon.com>
Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
Co-authored-by: Jim Blanchard <jablanch@amazon.com>
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
* chore(release): Publish [ci skip]

 - aws-amplify@5.2.3
 - @aws-amplify/datastore-storage-adapter@2.0.33
 - @aws-amplify/datastore@4.4.0
 - @aws-amplify/predictions@5.2.0
 - @aws-amplify/storage@5.3.0

* chore(release): update API docs [ci skip]

* fix(notifications): Add babel plugins to devDependencies (#11414)

* fix(storage): make getProperties param optional (#11413)

* Revert "fix(storage): make getProperties param optional (#11413)"

This reverts commit 5d00b1f.

* Revert "feat(storage): getProperties API (#11378)"

This reverts commit 3bed12b.

* fix(core): bundle react-native-url-polyfill to unblock jest test failure (#11422)

* fix(core): bundle react-native-url-polyfill to unblock jest test failure

* Revert "test(notification): unblock unit test failure of rn url polyfill"

This reverts commit dbacebc.

* chore: remove unused code

* chore: remove unused polyfills/URL/package.json

* chore(release): Publish [ci skip]

 - @aws-amplify/analytics@6.1.1
 - @aws-amplify/api-graphql@3.2.1
 - @aws-amplify/api-rest@3.1.1
 - @aws-amplify/api@5.1.1
 - @aws-amplify/auth@5.3.7
 - aws-amplify@5.2.4
 - @aws-amplify/cache@5.0.33
 - @aws-amplify/core@5.3.1
 - @aws-amplify/datastore-storage-adapter@2.0.34
 - @aws-amplify/datastore@4.4.1
 - @aws-amplify/geo@2.0.33
 - @aws-amplify/interactions@5.0.33
 - @aws-amplify/notifications@1.1.7
 - @aws-amplify/predictions@5.2.1
 - @aws-amplify/pubsub@5.1.16
 - @aws-amplify/pushnotification@5.0.33
 - @aws-amplify/storage@5.3.1

* chore(release): update API docs [ci skip]

---------

Co-authored-by: israx <70438514+israx@users.noreply.github.com>
Co-authored-by: aws-amplify-bot <aws@amazon.com>
Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
Co-authored-by: Jim Blanchard <jablanch@amazon.com>
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
Co-authored-by: AllanZhengYP <zheallan@amazon.com>
…#11368)

* feat: update userAgentSuffix to capture new information and format

* feat: update customUserAgent to agreed-upon format, change userAgentSuffix to customUserAgent

* chore: simplify override of customUserAgent props

* chore: update import to be more concise

Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>

* chore: define expected user agents at the top

* chore: move platform-specific types and enums to platform folder

* chore: update category and framework import to come from Platform instead of top-level

* chore: add return type for detectFramework

* chore: remove unnecessary toString

* feat: update getAmplifyUserAgent to return format expected by aws-sdk

* fix: change customuseragent format to work with aws-sdk cleaning

* feat: refine detectFramework to detect react more reliably and prevent undefined error

* chore: remove unnecessary logs

* fix: typescript - change let to const

* fix: typescript - change == to ===

* test: updates test to strict equal to avoid serializes to the same string failure

* feat: use category/action (auth/1) format and updates tests for that format

* chore: change reactWindow to more generic enhancedWindow

* chore: remove part3 code for this iteration

* chore: remove part3 code for this iteration

* fix: remove accidental pi string

* chore: remove part 4 code from this iteration

* chore: remove part 4 code from this iteration

* chore: cleanup naming and building of user agent string

* chore: move framework detection to platform constant to prevent unnecessary repetition of detection

* chore: destructure customUserAgent param in buildUserAgent

* chore: move aws-sdk/types from dependencies to devDependencies

* chore: simplify if-else to ternary

* chore: remove unnecessary function

* chore: alphabetize type/enum exports, fix getAmplifyUserAgent export

* chore: rerun framework detection once if none, in case DOM not yet loaded on Platform declaration

* chore: update to type definitions to require action and name change

* chore: revert cross-category communication pending agreement

* test: revert test changes related to cross-category communication pending consensus

* chore: remove unused imports

* test: update test name

* chore: remove unnecessary trim

* chore: add copyright header to detectFramework file

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>

* chore: change comments on framework detection to doc-string format

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>

* chore: mark frameworkHasBeenRerun after rerun

Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>

* chore: address feedback

* feat: internal GraphQLAPIClass to expose customUserAgentDetails

* chore: clean up unnecessary interface

* chore: clean up unnecessary interface

* feat: user customUserAgentDetails sent from APIClass

* feat: internal vs external APIClass with extra customUserAgentDetails parameter

* chore: sort imports

* feat: export API internal module

* chore: sort imports/exports

* feat: point API in amplifyContext to InternalAPI instance

* chore: add copyright to top of internal index

* test: fix jest issue with scoped import in API

* test: fix jest issue with scoped import in PushNotification

* feat: add InternalPubSub for customUserAgentDetails

* test: update api-graphql test for internal class

* chore: export api/api-graphql internal from subpath

* chore: register InternalGraphQLAPI with Amplify

* feat: add Subscribe PubSubAction

* chore: register internal api with Amplify

* chore: override moduleName in graphqlapi

* chore: export scoped internal in pubsub

* test: point datastore processor tests to internal api and api-graphql

* feat: send ds user agent details through api

* fix: changes prop name for InternalAPI to fix graphql calls going through API

* feat: send api action through to internal pubsub

* fix: send user agent details through subscribe function instead of after

* chore: remove redundant InternalAPI

* test: fix tests failing due to transition to InternalAPI

* chore: code cleanup

* chore: incorperate minor PR feedback

* chore: change internal to internals

* chore: add react-native to internals packages

* chore: change values of Datastore Actions

---------

Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
Co-authored-by: Jim Blanchard <jim.l.blanchard@gmail.com>
* feat: add action and category to cognito calls based on Client request operation

* fix: add exports to index.d.ts

* fix: fix silly mistakes in user agent work

* test: fix spacing issue in index.test.js

* test: fix failing tests and update getAmplifyUserAgentString signature based on changes

* test: adds user agent test to CognitoUserPool

* fix: update name missmatch

* fix: update name missmatch

* chore: add revokeToken for non global sign outs

* test: fix name mismatch

* test: fix test side effects:

* test: add tests for InitiateAuth user agent headers

* test: fix plain username password test

* chore: set category/framework on UserAgent instead of UserAgent.prototype

* test: user agent test for authaction confirmdevice

* test: remove unnecessary spies

* test: fix test name

* test: add getDeviceResponse test for user agent header

* chore: move new function exports to internals
* feat: add action and category to cognito calls based on Client request operation

* fix: add exports to index.d.ts

* fix: fix silly mistakes in user agent work

* test: fix spacing issue in index.test.js

* test: fix failing tests and update getAmplifyUserAgentString signature based on changes

* test: adds user agent test to CognitoUserPool

* fix: update name missmatch

* fix: update name missmatch

* chore: add revokeToken for non global sign outs

* test: fix name mismatch

* test: fix test side effects:

* test: add tests for InitiateAuth user agent headers

* test: fix plain username password test

* chore: set category/framework on UserAgent instead of UserAgent.prototype

* test: user agent test for authaction confirmdevice

* test: remove unnecessary spies

* test: fix test name

* test: add getDeviceResponse test for user agent header

* feat: add oauth action to token exchange

* fix: get user agent and action from core in oauth

* Change the action number for OAuthToken so as not to conflict with cognito actions

* test: add missing props to core mock

* chore: adds comment pointing to standard auth actions

* chore: increase auth bundle size limit
* chore(core): bump to ts 5.0 (#11077)

* feat(clients): basic types and fetch handler (#11120)

* feat(clients): compose transfer handler with middleware & retry middleware (#11188)

* feat(clients): middleware interface and retry middleware

* test(clients): retry middleare unit test

* fix(clients): middleware type to include options

* feat(clients): add retry middleware unit test and update interface

* chore(clients): update bundle size limit for fetch and retry

* chore(clients): add retry docs; fix format

* fix(clients): address feedbacks

* fix(retry): add metadata to returns from retry middldeware (#11212)

* fix(retry): add metadata to returns from retry middldeware; fix minor bugs

* feat(clients): address retry middleware feedbacks

Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>

* chore(core): update size limit

* feat(clients): cognito identity client (#11213)

* feat(clients): implement service API composer

* chore(clients): rename middleware interface

* feat(clients): middleware handler interface can be non request/response interface

* chore(clients): move fetch handler to handlers folder

* feat(clients): implement user agent middleware

* feat(clients): implement unauth aws transfer handler

* feat(clients): implement api handler composer

* feat(clients): implement cognito-identity client

* chore(clients): update bundle size limit

* feat(clients): add serde utils; remove retry in api handler composer

* feat(clients): integrate cognito-identity client to Credentials class

* fix(clients): make retryDecider interface async

* chore: move cognito client to dev dep

* chore(clients): use Pascale path name

* fix(clients): handle fetch response.body undefined in RN

* chore: publish under v5-custom-clients dist-tag

* fix(clients): read body once for errors

* chore(clients): enable tagged release of custom clients (#11267)

* test(clients): add functional test to cognito identity client (#11266)

* test(clients): add cognito-identity functional test

* chore(clients): prefer destructuring parameters at top

* feat(clients): add useragent to cognito identity (#11269)

* chore(clients): add license header to files (#11292)

* feat(clients): Add custom signature v4 signer (#11273)

* feat(clients): Add custom signature v4 signer

* Updated docstrings

* Extracted common code

* Use == null instead of isNil

* Add unit tests

* Add missing licensing headers

* Use test case options in presign tests

* Fixed comment

* Add test for data hashing with SourceData keys

* Remove buffer dependency

* Remove internal sdk dependency

* chore(clients): Make signing functions synchronous (#11307)

* chore(clients): Replace existing Signer implementation (#11310)

* chore(clients): Add @internal annotation (#11320)

* feat(clients): Add signing middleware (#11323)

* feat(clients): Add signing middleware

* Use closure for clock offset

* Add bundle size test entry

* Address comments

* feat(clients): support CN partition by adding DNS suffix resolver (#11311)

* feat(clients): support CN partition by adding DNS suffix resolver

* chore(clients): update bundle size test limit

* fix(clients): address feedbacks

* chore: update bundle size limit

* chore(clients): Add context to some regex (#11334)

* feat(clients) Add updateEndpoint API (#11330)

* feat(clients) Add updateEndpoint API

* Rename handler

* chore(clients): Use DNS suffix util in Pinpoint client (#11340)

* chore(clients): Annotate custom client APIs with @internal (#11347)

* feat(clients) Add putEvents API (#11342)

* feat(clients) Add putEvents API

* Add additional verification for expected date format

* Mark API as internal

* feat(clients) Add getInAppMessages API (#11348)

* feat(clients) Add getInAppMessages API

* Update unit test

* chore(clients): Replace SDK Pinpoint Client (#11359)

Co-authored-by: Allan Zheng <zheallan@amazon.com>

* chore: update size limit

* chore(clients): export pinpoint client from internal subpath (#11369)

* feat(clients): allow fetch handler to read body multiple times

* chore: update size limit

* fix(clients): add react-native entrypoint for internal modules

* chore: address feedbacks

* feat(clients): vendor TS types from pinpoint and cognito-identity clients (#11393)

* chore: dts bundler script for AWS SDK types

* feat(clients): vendor AWS SDK client types

* chore: workaround the tslint errors for generated rollup types

* docs: add readme to build clients script

* feat: update SDK types

* chore(storage): update size limit (#11406)

* fix(clients): middleware chain revert after every invocation (#11432)

* chore: prepare for release; split out data packages diffs

* fix: address feedbacks

* fix(analytics): apply useragent enhancement to pinpoint client

* chore: update size limit

* fix: Auth bundle size test

* fix: Update bundle size for pubsub

* fix: api-graphql bundle size update

* fix: Update api bundle sizes

* fix: DataStore bundle size test

---------

Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com>
Co-authored-by: Aaron S <94858815+stocaaro@users.noreply.github.com>
* feat: Custom user agent enhancement for api-rest

* fix: Tests in rest-api and add client test

* chore: Update bundle size to resolve issues

* fix: Predictions bundle size threshold

* fix:api-rest bundle size test

* fix: Interactions bundle size test
AllanZhengYP
AllanZhengYP previously approved these changes Jun 15, 2023
Copy link
Member

@AllanZhengYP AllanZhengYP left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I skimmed through it since most of the changes were reviewed already, and left some questions. None of them are blocking. It looks good!

.circleci/config.yml Show resolved Hide resolved
.circleci/config.yml Outdated Show resolved Hide resolved
package.json Outdated Show resolved Hide resolved
packages/api-graphql/package.json Outdated Show resolved Hide resolved
AllanZhengYP
AllanZhengYP previously approved these changes Jun 19, 2023
elorzafe
elorzafe previously approved these changes Jun 19, 2023
Copy link
Contributor

@elorzafe elorzafe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with minor non blocking comments

.circleci/config.yml Show resolved Hide resolved
docs/api/assets/js/search.json Outdated Show resolved Hide resolved
jimblanc
jimblanc previously approved these changes Jun 19, 2023
Copy link
Contributor

@jimblanc jimblanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gave it a pass paying special attention to configuration & package interfaces, LGTM! Great work to you and Erin on this 🥳

matrix:
parameters:
browser: [chrome]
#- integ_javascript_geo:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will take a loot at turning this test on again in main. Theres a usage of static assets here that I wasn't able to figure out how to fix to make this test value add. Hopefully I'm missing something. Will validate with Francisco before releasing anything.

Copy link
Member

@iartemiev iartemiev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked over the api*/* and datastore/* changes - no surprises vs. already-approved PRs. LGTM 👍🏻

@stocaaro stocaaro merged commit 66974b5 into main Jun 19, 2023
@erinleigh90 erinleigh90 deleted the feat/user-agent-enhancements/main branch August 8, 2023 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants