## Record Event The Amplify Analytics plugin provides a simple interface to record custom events within your app: import ios0 from "/src/fragments/lib/analytics/ios/record-event-code.mdx"; ## Flush Events By default, events are automatically flushed out to the network every 60 seconds. If you would like to change this, update `amplifyconfiguration.json` and set the value you would prefer under `autoFlushEventsInterval`, expressed in seconds: ```json { "UserAgent": "aws-amplify-cli/2.0", "Version": "1.0", "analytics": { "plugins": { "awsPinpointAnalyticsPlugin": { "pinpointAnalytics": { "appId": "AppID", "region": "Region" }, "autoFlushEventsInterval": 60 } } } } ``` > **Note** > > Setting `autoFlushEventsInterval` to 0 will **disable** the automatic flush of events and you will be responsible for submitting them. To manually submit the recoded events to the backend, call: ```swift Amplify.Analytics.flushEvents() ``` The plugin automatically batches requests in order to reduce network bandwidth and handles the retry logic if the device loses connectivity. ## Authentication events import native_common from "/src/fragments/lib-v1/analytics/native_common/getting-started/auth-events.mdx"; ```swift func sendUserSignInEvent() { let event = BasicAnalyticsEvent( name: "_userauth.sign_in" ) Amplify.Analytics.record(event: event) } ``` ## Global Properties You can register properties which will be included across all `Amplify.Analytics.record(event:)` calls. ```swift let globalProperties: AnalyticsProperties = [ "globalPropertyKey": "value" ] Amplify.Analytics.registerGlobalProperties(globalProperties) ``` To unregister global properties, call `Amplify.Analytics.unregisterGlobalProperties()`: ```swift // When called with no arguments, it unregisters all global properties Amplify.Analytics.unregisterGlobalProperties() // Or you can specify which properties to unregister let globalProperties = ["globalPropertyKey1", "globalPropertyKey2"] Amplify.Analytics.unregisterGlobalProperties(globalProperties) ```