Commit 74ff32f37c7 for woocommerce

commit 74ff32f37c79c83c62a15672eaa60987772bb6fa
Author: Chi-Hsuan Huang <chihsuan.tw@gmail.com>
Date:   Fri Dec 4 15:59:22 2026 +0800

    Keep analytics sessions going across midnight UTC (#71637)

    * End analytics sessions after 30 minutes of inactivity

    * Add changelog entry for analytics session inactivity timeout

    * Keep session tests valid past their dates and update the README

    * Avoid Array.prototype.at in session tests for the package's TS lib

    * Guard the session fields the expiry refresh must keep and trim overlapping tests

    * Say what merchants will see in the session inactivity changelog entry

    * Keep analytics sessions going across UTC midnight

    * Add changelog entry for keeping analytics sessions across UTC midnight

    * Test only the session expiry, which fake timers can observe

    * Say the session cookie expires after the last page view in the fallback id docblock

diff --git a/packages/php/woocommerce-analytics/README.md b/packages/php/woocommerce-analytics/README.md
index 13d38569d7c..57185570e46 100644
--- a/packages/php/woocommerce-analytics/README.md
+++ b/packages/php/woocommerce-analytics/README.md
@@ -261,7 +261,7 @@ The package uses a hierarchical approach to identify users for analytics:

 **Session Management:**

--   Session cookies (`woocommerceanalytics_session`) expire after 30 minutes without a page view, or at midnight UTC (whichever comes first)
+-   Session cookies (`woocommerceanalytics_session`) expire after 30 minutes without a page view
 -   Used for tracking user journey within a session (separate from user identification)
 -   Contains session ID, landing page, and engagement status

diff --git a/packages/php/woocommerce-analytics/changelog/uni-1135-session-midnight b/packages/php/woocommerce-analytics/changelog/uni-1135-session-midnight
new file mode 100644
index 00000000000..67a65c9d4f0
--- /dev/null
+++ b/packages/php/woocommerce-analytics/changelog/uni-1135-session-midnight
@@ -0,0 +1,4 @@
+Significance: patch
+Type: changed
+
+Keep a shopper in one analytics session across midnight UTC, so session counts may drop slightly and conversion rates rise.
diff --git a/packages/php/woocommerce-analytics/src/class-wc-analytics-tracking.php b/packages/php/woocommerce-analytics/src/class-wc-analytics-tracking.php
index d2b5aebc23b..eae4551d160 100644
--- a/packages/php/woocommerce-analytics/src/class-wc-analytics-tracking.php
+++ b/packages/php/woocommerce-analytics/src/class-wc-analytics-tracking.php
@@ -632,7 +632,7 @@ class WC_Analytics_Tracking {

 	/**
 	 * Session id for a server-side event whose request lost the session cookie, which expires
-	 * 30 minutes after the session starts. Same for a visitor all UTC day, so a visitor's late
+	 * 30 minutes after the last page view. Same for a visitor all UTC day, so a visitor's late
 	 * events count as one session. Same shape as Woo Ads' `ServerPixel::fallback_session_id()`.
 	 *
 	 * @since 0.19.2
diff --git a/packages/php/woocommerce-analytics/src/client/session-manager.ts b/packages/php/woocommerce-analytics/src/client/session-manager.ts
index 97946d61611..dfa4ce3f207 100644
--- a/packages/php/woocommerce-analytics/src/client/session-manager.ts
+++ b/packages/php/woocommerce-analytics/src/client/session-manager.ts
@@ -103,19 +103,12 @@ export default class SessionManager {
 	}

 	/**
-	 * Generate session expiration time
-	 * 30 minutes from now or at midnight UTC, whichever comes first
+	 * Generate session expiration time, 30 minutes from now
 	 *
 	 * @return string
 	 */
 	getSessionExpirationTime(): string {
-		const thirtyMinutesFromNow = Date.now() + 30 * 60 * 1000;
-		const midnightUTC = new Date();
-		midnightUTC.setUTCDate( midnightUTC.getUTCDate() + 1 );
-		midnightUTC.setUTCHours( 0, 0, 0, 0 );
-
-		const expirationTime = Math.min( thirtyMinutesFromNow, midnightUTC.getTime() );
-		return new Date( expirationTime ).toUTCString();
+		return new Date( Date.now() + 30 * 60 * 1000 ).toUTCString();
 	}

 	/**
diff --git a/packages/php/woocommerce-analytics/src/client/test/session-manager.test.ts b/packages/php/woocommerce-analytics/src/client/test/session-manager.test.ts
index fb43a74a15a..4b9118de2f1 100644
--- a/packages/php/woocommerce-analytics/src/client/test/session-manager.test.ts
+++ b/packages/php/woocommerce-analytics/src/client/test/session-manager.test.ts
@@ -84,13 +84,13 @@ describe( 'SessionManager', () => {
 		}
 	} );

-	it( 'never extends the session past the next UTC midnight', () => {
+	it( 'does not cap the expiry at the next UTC midnight', () => {
 		jest.setSystemTime( tomorrowAt( '23:20:00' ) );
 		startPageView();

 		jest.setSystemTime( tomorrowAt( '23:45:00' ) );
 		startPageView();

-		expect( readCookie()?.expires ).toBe( new Date( tomorrowAt( '00:00:00' ).getTime() + DAY ).toUTCString() );
+		expect( readCookie()?.expires ).toBe( new Date( tomorrowAt( '00:15:00' ).getTime() + DAY ).toUTCString() );
 	} );
 } );