We can query LoginHistory entity using AuthenticationServiceId to find the users who logged in using Social Logins. AuthenticationServiceId refers to Auth. Provider Id which is used in the Social Login.
SOQL for Today:
SELECT COUNT( Id ), UserId
FROM LoginHistory
WHERE LoginTime = TODAY
AND AuthenticationServiceId IN(
SELECT Id
FROM AuthProvider
)
GROUP BY UserId
SOQL for the last two days:
SELECT COUNT( Id ), UserId
FROM LoginHistory
WHERE LoginTime = LAST_N_DAYS:2
AND AuthenticationServiceId IN(
SELECT Id
FROM AuthProvider
)
GROUP BY UserId
SOQL for specific datetime:
SELECT COUNT( Id ), UserId
FROM LoginHistory
WHERE LoginTime >= 2022-09-19T14:00:00Z AND LoginTime <= 2022-09-19T21:00:00Z
AND AuthenticationServiceId IN(
SELECT Id
FROM AuthProvider
)
GROUP BY UserId
SOQL with specific hour count:
SELECT COUNT( Id ), HOUR_IN_DAY( LoginTime )
FROM LoginHistory
WHERE LoginTime >= 2022-09-19T14:00:00Z AND LoginTime <= 2022-09-19T21:00:00Z
AND AuthenticationServiceId IN(
SELECT Id
FROM AuthProvider
)
GROUP BY HOUR_IN_DAY( LoginTime )
Note:
Timing in GMT/UTC.