From 0bd25bf46a4daa8971b75a42c6f2dd61a9ef82fc Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Wed, 18 Mar 2009 07:44:23 +0000
Subject: [PATCH] statistics: Log first SSO to a service during a session.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@1420 44740490-163a-0410-bde0-09ae8108e29a
---
 modules/core/lib/Auth/Process/StatisticsWithAttribute.php | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/modules/core/lib/Auth/Process/StatisticsWithAttribute.php b/modules/core/lib/Auth/Process/StatisticsWithAttribute.php
index 49cc61b87..604b208ae 100644
--- a/modules/core/lib/Auth/Process/StatisticsWithAttribute.php
+++ b/modules/core/lib/Auth/Process/StatisticsWithAttribute.php
@@ -62,9 +62,12 @@ class sspmod_core_Auth_Process_StatisticsWithAttribute extends SimpleSAML_Auth_P
 		if (array_key_exists('Source', $state)) $source = $state['Source']['entityid'];
 		if (array_key_exists('Destination', $state)) $dest = $state['Destination']['entityid'];
 
-		
+		if (!array_key_exists('PreviousSSOTimestamp', $state)) {
+			/* The user hasn't authenticated with this SP earlier in this session. */
+			SimpleSAML_Logger::stats($this->typeTag . '-first ' . $dest . ' ' . $source . ' ' . $logAttribute);
+		}
+
 		SimpleSAML_Logger::stats($this->typeTag . ' ' . $dest . ' ' . $source . ' ' . $logAttribute);
-		
 	}
 
 }
-- 
GitLab