diff --git a/cspell.json b/cspell.json index ae1e2cff180..71467a6a579 100644 --- a/cspell.json +++ b/cspell.json @@ -775,6 +775,7 @@ "keystore", "kibana", "kill", + "kinesisfirehose", "Kinesis", "KinesisFirehoseRecorder", "KinesisRecorder", diff --git a/public/images/storing-db-creds-in-secrets-manager.png b/public/images/storing-db-creds-in-secrets-manager.png new file mode 100644 index 00000000000..ba852f45105 Binary files /dev/null and b/public/images/storing-db-creds-in-secrets-manager.png differ diff --git a/src/directory/directory.mjs b/src/directory/directory.mjs index af43247e2b8..8b51ded7cd2 100644 --- a/src/directory/directory.mjs +++ b/src/directory/directory.mjs @@ -284,10 +284,77 @@ export const directory = { path: 'src/pages/[platform]/build-a-backend/add-aws-services/in-app-messaging/index.mdx' }, { - path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/index.mdx' + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/index.mdx', + children: [ + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/set-up-analytics/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/record-events/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/identify-user/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/auto-track-sessions/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/enable-disable/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/streaming-data/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/storing-data/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/personalize-recommendations/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/existing-resources/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/sdk/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/data-usage-policy/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/analytics/app-uninstall/index.mdx' + } + ] }, { path: 'src/pages/[platform]/build-a-backend/add-aws-services/geo/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/index.mdx', + children: [ + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/set-up-predictions/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/text-to-speech/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/transcribe-audio/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/translate/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/identify-text/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/identify-entity/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/label-image/index.mdx' + }, + { + path: 'src/pages/[platform]/build-a-backend/add-aws-services/predictions/interpret-sentiment/index.mdx' + } + ] } ] } diff --git a/src/fragments/lib/predictions/js/getting-started.mdx b/src/fragments/lib/predictions/js/getting-started.mdx index 77631421024..c7e4dbf62a9 100644 --- a/src/fragments/lib/predictions/js/getting-started.mdx +++ b/src/fragments/lib/predictions/js/getting-started.mdx @@ -92,7 +92,7 @@ Amplify.configure({ identityPoolId: 'us-east-1:xxx-xxx-xxx-xxx-xxx', region: 'us-east-1' }, - predictions: { + Predictions: { convert: { translateText: { region: 'us-east-1', diff --git a/src/pages/[platform]/build-a-backend/add-aws-services/analytics/app-uninstall/index.mdx b/src/pages/[platform]/build-a-backend/add-aws-services/analytics/app-uninstall/index.mdx new file mode 100644 index 00000000000..237cb7aaa49 --- /dev/null +++ b/src/pages/[platform]/build-a-backend/add-aws-services/analytics/app-uninstall/index.mdx @@ -0,0 +1,39 @@ +import { getCustomStaticPath } from '@/utils/getCustomStaticPath'; + +export const meta = { + title: 'Uninstalling the app', + description: + 'Understand how to handle persistent data on a device when a user uninstalls the app.', + platforms: ['swift', 'android'], +}; + +export const getStaticPaths = async () => { + return getCustomStaticPath(meta.platforms); +}; + +export function getStaticProps(context) { + return { + props: { + platform: context.params.platform, + meta + } + }; +} + + +Some Amplify categories such as Analytics and Auth persist data to the local device. This application data is removed when a user uninstalls the application from the device. + +If the [Android Auto Backup for Apps](https://developer.android.com/guide/topics/data/autobackup) service was enabled, this service will attempt to restore application data. + +Amplify Auth uses [EncryptedSharedPreferences](https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences) when persisting auth data. When an application is uninstalled, the [Android Keystore](https://developer.android.com/training/articles/keystore) keys used to create our EncryptedSharedPreferences files are deleted. Upon an application re-install, these restored files are no longer readable due to the key removal from the Android Keystore. + +Due to this limitation with EncryptedSharedPreferences, Auth information can’t be restored on an application re-install. The user will have to re-authenticate. + + + +Some Amplify categories such as Analytics, Auth, and DataStore persist data to the local device. Some of that data is automatically removed when a user uninstalls the app from the device. + +Amplify stores Auth information in the local [system keychain](https://developer.apple.com/documentation/security/keychain_services), which does not guarantee any particular behavior around whether data is removed when an app is uninstalled. + +Deciding on when to clear this auth information is not something that the SDK can do in a generic way, so App developers should decide when to clear the data by signing out. One strategy for accomplishing this would be to use [UserDefaults](https://developer.apple.com/documentation/foundation/userdefaults) to detect whether or not the app is launching for the first time, and invoking [`Auth.signOut()`](/[platform]/build-a-backend/auth/enable-sign-up/#sign-out) if the app has not been launched before. + diff --git a/src/pages/[platform]/build-a-backend/add-aws-services/analytics/auto-track-sessions/index.mdx b/src/pages/[platform]/build-a-backend/add-aws-services/analytics/auto-track-sessions/index.mdx new file mode 100644 index 00000000000..32e745d0a6a --- /dev/null +++ b/src/pages/[platform]/build-a-backend/add-aws-services/analytics/auto-track-sessions/index.mdx @@ -0,0 +1,210 @@ +import { getCustomStaticPath } from '@/utils/getCustomStaticPath'; + +export const meta = { + title: 'Automatically track sessions', + description: 'The Amplify analytics plugin records when an application opens and closes. This session information can be viewed either from your local computer’s terminal or the AWS Console for Pinpoint.', + platforms: [ + 'javascript', + 'react-native', + 'swift', + 'android', + 'flutter', + 'angular', + 'nextjs', + 'react', + 'vue' + ], +}; + +export const getStaticPaths = async () => { + return getCustomStaticPath(meta.platforms); +}; + +export function getStaticProps(context) { + return { + props: { + platform: context.params.platform, + meta + } + }; +} + + + +Analytics Auto Tracking helps you to automatically track user behaviors like sessions start/stop, page view change and web events like clicking or mouseover. + +## Session Tracking + +You can track the session both in a web app or a React Native app by using Analytics. A web session can be defined in different ways. To keep it simple we define a web session as being active when the page is not hidden and inactive when the page is hidden. A session in a React Native app is active when the app is in the foreground and inactive when the app is in the background. + +For example: + +```javascript +import { configureAutoTrack } from 'aws-amplify/analytics'; + +configureAutoTrack({ + // REQUIRED, turn on/off the auto tracking + enable: true, + // REQUIRED, the event type, it's one of 'event', 'pageView' or 'session' + type: 'session', + // OPTIONAL, additional options for the tracked event. + options: { + // OPTIONAL, the attributes of the event + attributes: { + customizableField: 'attr' + } + } +}); +``` + +By default, when the page/app transitions to the foreground, the Analytics module will send an event to the Amazon Pinpoint Service. + +```json +{ + "eventType": "_session_start", + "attributes": { + "customizableField": "attr" + } +} +``` + +This behavior can be disabled by calling `configureAutoTrack`: + +```javascript +import { configureAutoTrack } from 'aws-amplify/analytics'; + +configureAutoTrack({ + enable: false, + type: 'session' +}); +``` + +## Page View Tracking + +Use this feature to track the most frequently viewed page/url in your webapp. It automatically sends events containing url information when a page is visited. + +This behavior can be enabled by calling `configureAutoTrack`: +```javascript +import { configureAutoTrack } from 'aws-amplify/analytics'; + +configureAutoTrack({ + // REQUIRED, turn on/off the auto tracking + enable: true, + // REQUIRED, the event type, it's one of 'event', 'pageView' or 'session' + type: 'pageView', + // OPTIONAL, additional options for the tracked event. + options: { + // OPTIONAL, the attributes of the event + attributes: { + customizableField: 'attr' + }, + + // OPTIONAL, the event name. By default, this is 'pageView' + eventName: 'pageView', + + // OPTIONAL, the type of app under tracking. By default, this is 'multiPageApp'. + // You will need to change it to 'singlePage' if your app is a single-page app like React + appType: 'multiPageApp', + + // OPTIONAL, provide the URL for the event. + urlProvider: () => { + // the default function + return window.location.origin + window.location.pathname; + } + } +}); +``` + +This behavior can be disabled by calling `configureAutoTrack`: +```javascript +import { configureAutoTrack } from 'aws-amplify/analytics'; + +configureAutoTrack({ + enable: false, + type: 'pageView' +}); +``` + +## Page Event Tracking + +Use this type of tracking to track user interactions with specific elements on a page. Just attach the specified selectors to your DOM element and turn on the auto tracking. + +This behavior can be enabled by calling `configureAutoTrack`: +```javascript +import { configureAutoTrack } from 'aws-amplify/analytics'; + +configureAutoTrack({ + // REQUIRED, turn on/off the auto tracking + enable: true, + // REQUIRED, the event type, it's one of 'event', 'pageView' or 'session' + type: 'event', + // OPTIONAL, additional options for the tracked event. + options: { + // OPTIONAL, the attributes of the event + attributes: { + customizableField: 'attr' + }, + // OPTIONAL, events you want to track. By default, this is 'click' + events: ['click'], + + // OPTIONAL, the prefix of the selectors. By default, this is 'data-amplify-analytics-' + // Per https://www.w3schools.com/tags/att_global_data.asp, always start + // the prefix with 'data' to avoid collisions with the user agent + selectorPrefix: 'data-amplify-analytics-' + } +}); +``` + +For example: + +```html + +