--- title: pos.cash-tracking-session-complete.event.observe description: >- Observes when cash tracking sessions complete, triggering when merchants finish cash handling operations. Use this target for monitoring cash handling completion for audit trails, compliance reporting, or operational analytics. Extensions at this target receive session data including the session ID, opening time, and closing time when a cash tracking session is completed. api_version: 2025-07 api_name: pos-ui-extensions source_url: html: >- https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/cash-tracking/pos-cash-tracking-session-complete-event-observe md: >- https://shopify.dev/docs/api/pos-ui-extensions/2025-07/targets/cash-tracking/pos-cash-tracking-session-complete-event-observe.md --- # pos.​cash-tracking-session-complete.​event.​observe Observes when cash tracking sessions complete, triggering when merchants finish cash handling operations. Use this target for monitoring cash handling completion for audit trails, compliance reporting, or operational analytics. Extensions at this target receive session data including the session ID, opening time, and closing time when a cash tracking session is completed. ## CashTrackingSessionCompleteData The data object provided to this extension target. * cashTrackingSessionComplete { id: number; openingTime: string; closingTime: string; } required The cash tracking session complete data containing the session identifier, opening time, and closing time. This represents the full lifecycle of a cash drawer session from opening to closing. * connectivity ConnectivityState required The current Internet connectivity state of the POS device. Indicates whether the device is connected to or disconnected from the Internet. This state updates in real-time as connectivity changes, allowing extensions to adapt behavior for offline scenarios, show connectivity warnings, or queue operations for when connectivity is restored. * device Device required Comprehensive information about the physical POS device where the extension is currently running. Includes the device name, unique device ID, and form factor information (tablet vs other). This data is static for the session and helps extensions adapt to different device types, log device-specific information, or implement device-based configurations. * locale string required The [IETF BCP 47](https://en.wikipedia.org/wiki/IETF_language_tag) locale string for the current POS session (for example, `"en-US"`, `"fr-CA"`, `"de-DE"`). This indicates the merchant's language and regional preferences. Commonly used for internationalization (i18n), locale-specific date/time/number formatting, translating UI text, and providing localized content. The locale remains constant for the session and reflects the language selected in POS settings. * session Session required Comprehensive information about the current POS session including shop ID and domain, authenticated user, pinned staff member, active location, currency settings, and POS version. This session data remains constant for the session duration and provides critical context for business logic, permissions, API authentication, and transaction processing. Session data updates when users switch locations or change pinned staff members. * storage Storage required Provides access to the persistent local storage methods for storing and retrieving extension data. ### ConnectivityState Represents the current Internet connectivity status of the device. Indicates whether the device is connected or disconnected from the Internet. * internetConnected Whether the device is connected to the Internet. Returns either \`Connected\` or \`Disconnected\` to indicate the current Internet connectivity status. Use for implementing connectivity-aware functionality, displaying connectivity indicators, or controlling network-dependent features. ```ts ConnectivityStateSeverity ``` ```ts export interface ConnectivityState { /** * Whether the device is connected to the Internet. Returns either `Connected` or `Disconnected` to indicate the current Internet connectivity status. Use for implementing connectivity-aware functionality, displaying connectivity indicators, or controlling network-dependent features. */ internetConnected: ConnectivityStateSeverity; } ``` ### ConnectivityStateSeverity ```ts 'Connected' | 'Disconnected' ``` ### Device Defines information about the POS device where the extension is running. * deviceId The unique identifier for the POS device. ```ts number ``` * isTablet Whether the device is a tablet form factor. ```ts boolean ``` * name The name of the POS device. ```ts string ``` ```ts export interface Device { /** * The name of the POS device. */ name: string; /** * The unique identifier for the POS device. */ deviceId: number; /** * Whether the device is a tablet form factor. */ isTablet: boolean; } ``` ### Session Defines information about the current POS session. * currency The \[ISO 4217]\(https://en.wikipedia.org/wiki/ISO\_4217) currency code associated with the location currently active on POS. ```ts CurrencyCode ``` * locationId The location ID associated with the POS device's current location. ```ts number ``` * posVersion The version of \[the POS app]\(https://apps.shopify.com/shopify-pos) currently running. ```ts string ``` * shopDomain The shop domain associated with the shop currently logged into POS. ```ts string ``` * shopId The shop ID associated with the shop currently logged into POS. ```ts number ``` * staffMemberId The staff ID of the staff member currently pinned into the POS. This may differ from the user ID if the pinned staff member is different from the logged-in user. ```ts number ``` * userId The user ID associated with the Shopify account currently authenticated on POS. ```ts number ``` ```ts export interface Session { /** * The shop ID associated with the shop currently logged into POS. */ shopId: number; /** * The user ID associated with the Shopify account currently authenticated on POS. */ userId: number; /** * The shop domain associated with the shop currently logged into POS. */ shopDomain: string; /** * The location ID associated with the POS device's current location. */ locationId: number; /** * The staff ID of the staff member currently pinned into the POS. This may differ from the user ID if the pinned staff member is different from the logged-in user. */ staffMemberId?: number; /** * The [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code associated with the location currently active on POS. */ currency: CurrencyCode; /** * The version of [the POS app](https://apps.shopify.com/shopify-pos) currently running. */ posVersion: string; } ``` ### CurrencyCode ```ts 'AED' | 'AFN' | 'ALL' | 'AMD' | 'ANG' | 'AOA' | 'ARS' | 'AUD' | 'AWG' | 'AZN' | 'BAM' | 'BBD' | 'BDT' | 'BGN' | 'BHD' | 'BIF' | 'BMD' | 'BND' | 'BOB' | 'BOV' | 'BRL' | 'BSD' | 'BTN' | 'BWP' | 'BYN' | 'BZD' | 'CAD' | 'CDF' | 'CHE' | 'CHF' | 'CHW' | 'CLF' | 'CLP' | 'CNY' | 'COP' | 'COU' | 'CRC' | 'CUC' | 'CUP' | 'CVE' | 'CZK' | 'DJF' | 'DKK' | 'DOP' | 'DZD' | 'EGP' | 'ERN' | 'ETB' | 'EUR' | 'FJD' | 'FKP' | 'GBP' | 'GEL' | 'GHS' | 'GIP' | 'GMD' | 'GNF' | 'GTQ' | 'GYD' | 'HKD' | 'HNL' | 'HRK' | 'HTG' | 'HUF' | 'IDR' | 'ILS' | 'INR' | 'IQD' | 'IRR' | 'ISK' | 'JMD' | 'JOD' | 'JPY' | 'KES' | 'KGS' | 'KHR' | 'KMF' | 'KPW' | 'KRW' | 'KWD' | 'KYD' | 'KZT' | 'LAK' | 'LBP' | 'LKR' | 'LRD' | 'LSL' | 'LYD' | 'MAD' | 'MDL' | 'MGA' | 'MKD' | 'MMK' | 'MNT' | 'MOP' | 'MRU' | 'MUR' | 'MVR' | 'MWK' | 'MXN' | 'MXV' | 'MYR' | 'MZN' | 'NAD' | 'NGN' | 'NIO' | 'NOK' | 'NPR' | 'NZD' | 'OMR' | 'PAB' | 'PEN' | 'PGK' | 'PHP' | 'PKR' | 'PLN' | 'PYG' | 'QAR' | 'RON' | 'RSD' | 'RUB' | 'RWF' | 'SAR' | 'SBD' | 'SCR' | 'SDG' | 'SEK' | 'SGD' | 'SHP' | 'SLL' | 'SOS' | 'SRD' | 'SSP' | 'STN' | 'SVC' | 'SYP' | 'SZL' | 'THB' | 'TJS' | 'TMT' | 'TND' | 'TOP' | 'TRY' | 'TTD' | 'TWD' | 'TZS' | 'UAH' | 'UGX' | 'USD' | 'USN' | 'UYI' | 'UYU' | 'UYW' | 'UZS' | 'VES' | 'VND' | 'VUV' | 'WST' | 'XAF' | 'XAG' | 'XAU' | 'XBA' | 'XBB' | 'XBC' | 'XBD' | 'XCD' | 'XDR' | 'XOF' | 'XPD' | 'XPF' | 'XPT' | 'XSU' | 'XTS' | 'XUA' | 'XXX' | 'YER' | 'ZAR' | 'ZMW' | 'ZWL' ``` ### Storage Defines the storage interface for persisting extension data across sessions. * clear Clears all data from storage, removing all key-value pairs. ```ts () => Promise ``` * delete Deletes a specific key from storage and returns \`true\` if the key existed, \`false\` if it didn't exist. Returns \`false\` for non-existent keys rather than throwing an error. Commonly used for cleaning up temporary workflow data, removing expired cache entries, or handling user preference changes. ```ts (key: Keys) => Promise ``` * entries Retrieves all stored key-value pairs as an array of tuples, preserving original data types. Returns all data at once which may impact memory usage with large datasets. Commonly used for debugging storage contents, implementing data export features, or performing bulk operations across stored data. ```ts () => Promise<[Keys, StorageTypes[Keys]][]> ``` * get Retrieves the value associated with a key, returning \`undefined\` if the key doesn't exist. Always handle the \`undefined\` case by providing fallback values or conditional logic. Commonly used for loading user preferences, retrieving cached data, or accessing contextual information passed between extension targets. ```ts (key: Keys) => Promise ``` * set Stores a value under the specified key, overwriting any existing value. Values must be JSON-serializable and return \`StorageError\` when storage limits are exceeded. Commonly used for storing user preferences, caching API responses, or passing contextual data from tiles to modals. ```ts (key: Keys, value: StorageTypes[Keys]) => Promise ``` ```ts export interface Storage< BaseStorageTypes extends Record = Record, > { /** * Stores a value under the specified key, overwriting any existing value. Values must be JSON-serializable and return `StorageError` when storage limits are exceeded. Commonly used for storing user preferences, caching API responses, or passing contextual data from tiles to modals. * * @param key - The key to set the value for. * @param value - The value to set for the key. * @throws StorageError when: * - Maximum number of records is exceeded (`code: 'RecordsCount'`) * - Individual record size exceeds the limit (`code: 'RecordSize'`) * - Key is not a string (`code: 'KeyType'`) * - Key size exceeds the limit (`code: 'KeySize'`) */ set< StorageTypes extends BaseStorageTypes = BaseStorageTypes, Keys extends keyof StorageTypes = keyof StorageTypes, >( key: Keys, value: StorageTypes[Keys], ): Promise; /** * Retrieves the value associated with a key, returning `undefined` if the key doesn't exist. Always handle the `undefined` case by providing fallback values or conditional logic. Commonly used for loading user preferences, retrieving cached data, or accessing contextual information passed between extension targets. * * @param key - The key to get the value for. * @returns The value of the key. * @throws StorageError when the key isn't a string or exceeds its allotted size. */ get< StorageTypes extends BaseStorageTypes = BaseStorageTypes, Keys extends keyof StorageTypes = keyof StorageTypes, >( key: Keys, ): Promise; /** * Clears all data from storage, removing all key-value pairs. */ clear: () => Promise; /** * Deletes a specific key from storage and returns `true` if the key existed, `false` if it didn't exist. Returns `false` for non-existent keys rather than throwing an error. Commonly used for cleaning up temporary workflow data, removing expired cache entries, or handling user preference changes. * * @param key - The key to delete. */ delete< StorageTypes extends BaseStorageTypes = BaseStorageTypes, Keys extends keyof StorageTypes = keyof StorageTypes, >( key: Keys, ): Promise; /** * Retrieves all stored key-value pairs as an array of tuples, preserving original data types. Returns all data at once which may impact memory usage with large datasets. Commonly used for debugging storage contents, implementing data export features, or performing bulk operations across stored data. * * @returns An array containing all the keys and values in the storage. */ entries< StorageTypes extends BaseStorageTypes = BaseStorageTypes, Keys extends keyof StorageTypes = keyof StorageTypes, >(): Promise<[Keys, StorageTypes[Keys]][]>; } ``` ### Examples * #### Track cash session closures ##### Description Subscribe to cash tracking session completion events to generate end-of-shift reports and reconcile cash handling. This example demonstrates logging session closures with session ID, opening time, and closing time, enabling audit trails, compliance notifications, and comprehensive cash management tracking. ##### React ```tsx import {reactEventExtension} from '@shopify/ui-extensions-react/point-of-sale'; export default reactEventExtension( 'pos.cash-tracking-session-complete.event.observe', (eventData) => { // Access session data from the event const {cashTrackingSessionComplete} = eventData; // Log session completion for audit trails console.log('Cash tracking session completed:', { sessionId: cashTrackingSessionComplete.id, openingTime: new Date(cashTrackingSessionComplete.openingTime).toISOString(), closingTime: new Date(cashTrackingSessionComplete.closingTime).toISOString(), }); // Example: Generate end-of-shift report // fetch('/api/cash-sessions/complete', { // method: 'POST', // body: JSON.stringify({ // sessionId: cashTrackingSessionComplete.id, // openingTime: cashTrackingSessionComplete.openingTime, // closingTime: cashTrackingSessionComplete.closingTime, // }), // }); // Return success (no errors) return {}; }, ); ``` ##### TS ```ts import {eventExtension} from '@shopify/ui-extensions/point-of-sale'; export default eventExtension( 'pos.cash-tracking-session-complete.event.observe', (eventData) => { // Access session data from the event const {cashTrackingSessionComplete} = eventData; // Log session completion for audit trails console.log('Cash tracking session completed:', { sessionId: cashTrackingSessionComplete.id, openingTime: new Date(cashTrackingSessionComplete.openingTime).toISOString(), closingTime: new Date(cashTrackingSessionComplete.closingTime).toISOString(), }); // Example: Generate end-of-shift report // fetch('/api/cash-sessions/complete', { // method: 'POST', // body: JSON.stringify({ // sessionId: cashTrackingSessionComplete.id, // openingTime: cashTrackingSessionComplete.openingTime, // closingTime: cashTrackingSessionComplete.closingTime, // }), // }); // Return success (no errors) return {}; }, ); ```