-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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(in-app-messaging): Add web support for session cap #9308
feat(in-app-messaging): Add web support for session cap #9308
Conversation
Codecov Report
@@ Coverage Diff @@
## in-app-messaging/staging #9308 +/- ##
============================================================
- Coverage 74.37% 74.32% -0.06%
============================================================
Files 312 312
Lines 20148 20177 +29
Branches 4385 4394 +9
============================================================
+ Hits 14986 14997 +11
- Misses 5023 5041 +18
Partials 139 139
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Looks good. Just two questions.
if (typeof document.hidden !== 'undefined') { | ||
hidden = 'hidden'; | ||
visibilityChange = 'visibilitychange'; | ||
} else if (typeof document['msHidden'] !== 'undefined') { | ||
hidden = 'msHidden'; | ||
visibilityChange = 'msvisibilitychange'; | ||
} else if (typeof document['webkitHidden'] !== 'undefined') { | ||
hidden = 'webkitHidden'; | ||
visibilityChange = 'webkitvisibilitychange'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small nit: document.hidden
and document['msHidden']
. The way the value is accessed is different.
And a tiny question, this needs to run only once?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should only need to run once as it's setting up vendor differences for browsers only.
document
seems to be typed so that the vendor prefixed versions are not readily available, hence the different accessors as dot notation would error.
return this.getSessionState(); | ||
}; | ||
|
||
private getSessionState = (): SessionState => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Observation: return type is SessionState
but this function returns a string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah the typing for SessionState is as follows:
export type SessionState = 'started' | 'ended';
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! right 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some concerns if document is undefined, can it be a Native implementation on one for the browser?
let hidden: string; | ||
let visibilityChange: string; | ||
|
||
if (typeof document.hidden !== 'undefined') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can document
be undefined
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this code should not run on React Native, there should be no reason it's undefined. However, there's no harm in adding a check in case it does run in some unsupported environment for some reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🌮
LGTM 🚀 |
…saging/main (#9365) * chore(in-app-message): In app messaging/add unit tests (#9253) * chore: Add unit tests * Add licensing to top of analytics test * Fixed typo * Addressed PR feedback * Remove quiet time test Co-authored-by: Chris Fang <chrfang@amazon.com> * fix(@aws-amplify/datastore): consecutive saves with timestamps (#9298) * chore: preparing release * chore(release): Publish [ci skip] - @aws-amplify/ui-angular@1.0.36 - @aws-amplify/ui-components@1.9.7 - @aws-amplify/ui-react@1.2.27 - @aws-amplify/ui-storybook@2.0.27 - @aws-amplify/ui-vue@1.1.21 - @aws-amplify/ui@2.0.4 - @aws-amplify/analytics@5.1.7 - @aws-amplify/api-graphql@2.2.16 - @aws-amplify/api-rest@2.0.27 - @aws-amplify/api@4.0.27 - @aws-amplify/auth@4.3.17 - aws-amplify-angular@6.0.27 - aws-amplify-react@5.1.10 - aws-amplify-vue@2.1.6 - aws-amplify@4.3.9 - @aws-amplify/cache@4.0.29 - @aws-amplify/core@4.3.9 - @aws-amplify/datastore-storage-adapter@1.2.1 - @aws-amplify/datastore@3.7.1 - @aws-amplify/geo@1.1.9 - @aws-amplify/interactions@4.0.27 - @aws-amplify/predictions@4.0.27 - @aws-amplify/pubsub@4.2.3 - @aws-amplify/pushnotification@4.3.6 - @aws-amplify/storage@4.4.10 - @aws-amplify/xr@3.0.27 * chore(release): update version.ts [ci skip] * fix(@aws-amplify/amplify-ui): change private property to false in package.json (#9303) Resolving an issue with installing the library * chore: preparing release * fix(@aws-amplify/amplify-ui): remove private prop from package.json (#9304) * fix(@aws-amplify/amplify-ui): change private property to false in package.json * fix(@aws-amplify/amplify-ui): remove private property from package.json Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com> * fix(@aws-amplify/amplify-ui): remove private prop from package.json (#9304) * fix(@aws-amplify/amplify-ui): change private property to false in package.json * fix(@aws-amplify/amplify-ui): remove private property from package.json Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com> * chore(release): Publish [ci skip] - @aws-amplify/ui-angular@1.0.37 - @aws-amplify/ui-components@1.9.8 - @aws-amplify/ui-react@1.2.28 - @aws-amplify/ui-storybook@2.0.28 - @aws-amplify/ui-vue@1.1.22 - @aws-amplify/ui@2.0.5 - @aws-amplify/analytics@5.1.8 - @aws-amplify/api-graphql@2.2.17 - @aws-amplify/api-rest@2.0.28 - @aws-amplify/api@4.0.28 - @aws-amplify/auth@4.3.18 - aws-amplify-angular@6.0.28 - aws-amplify-react@5.1.11 - aws-amplify@4.3.10 - @aws-amplify/cache@4.0.30 - @aws-amplify/core@4.3.10 - @aws-amplify/datastore-storage-adapter@1.2.2 - @aws-amplify/datastore@3.7.2 - @aws-amplify/geo@1.1.10 - @aws-amplify/interactions@4.0.28 - @aws-amplify/predictions@4.0.28 - @aws-amplify/pubsub@4.2.4 - @aws-amplify/pushnotification@4.3.7 - @aws-amplify/storage@4.4.11 - @aws-amplify/xr@3.0.28 * chore(release): update version.ts [ci skip] * fix(@aws-amplify/datastore): fixes observeQuery in local-only mode (#9300) * feat(in-app-messaging): Add web support for session cap (#9308) * feat(in-app-messaging): Add web support for session cap * Add undefined check for document Co-authored-by: Chris Fang <chrfang@amazon.com> * fix(@aws-amplify/pushnotification): make eligible variables final (#9301) Co-authored-by: Manoj NB <manojnb@amazon.com> Co-authored-by: Caleb Pollman <cpollman1@gmail.com> * fix(@aws-amplify/aws-amplify-react-native): fix dev build for Windows (#9341) * fix(@aws-amplify/api-graphql): Fix webpack build (#9358) * chore: preparing release * chore(release): Publish [ci skip] - @aws-amplify/ui-angular@1.0.38 - @aws-amplify/ui-components@1.9.9 - @aws-amplify/ui-react@1.2.29 - @aws-amplify/ui-storybook@2.0.29 - @aws-amplify/ui-vue@1.1.23 - @aws-amplify/analytics@5.1.9 - @aws-amplify/api-graphql@2.2.18 - @aws-amplify/api-rest@2.0.29 - @aws-amplify/api@4.0.29 - @aws-amplify/auth@4.3.19 - aws-amplify-angular@6.0.29 - aws-amplify-react-native@6.0.2 - aws-amplify-react@5.1.12 - aws-amplify@4.3.11 - @aws-amplify/cache@4.0.31 - @aws-amplify/core@4.3.11 - @aws-amplify/datastore-storage-adapter@1.2.3 - @aws-amplify/datastore@3.7.3 - @aws-amplify/geo@1.1.11 - @aws-amplify/interactions@4.0.29 - @aws-amplify/predictions@4.0.29 - @aws-amplify/pubsub@4.2.5 - @aws-amplify/pushnotification@4.3.8 - @aws-amplify/storage@4.4.12 - @aws-amplify/xr@3.0.29 * chore(release): update version.ts [ci skip] * chore(in-app-messaging): upgrade internal dependency versions and notifications version (#9364) Co-authored-by: Chris F <5827964+cshfang@users.noreply.github.com> Co-authored-by: Chris Fang <chrfang@amazon.com> Co-authored-by: Ivan Artemiev <29709626+iartemiev@users.noreply.github.com> Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: Nick Arocho <16296496+nickarocho@users.noreply.github.com> Co-authored-by: Nick Arocho <nicaroch@amazon.com> Co-authored-by: Francisco Rodriguez <frodriguez.cs@gmail.com> Co-authored-by: ManojNB <manojnb95@gmail.com> Co-authored-by: Manoj NB <manojnb@amazon.com> Co-authored-by: David McAfee <mcafd@amazon.com> Co-authored-by: Katie Goines <katiegoi@amazon.com>
This pull request has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs. Looking for a help forum? We recommend joining the Amplify Community Discord server |
Description of changes
Previously, session tracking for the purposes of Pinpoint in-app messaging campaign session caps only worked with React Native. This PR implements the session tracker for web to extend that feature to the web.
Issue #, if available
N/A
Description of how you validated changes
Created a web app and tested session cap mechanism to see that:
Tested with Chrome, Firefox, Safari and Edge
Checklist
yarn test
passesBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.