-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1850 from rosahbruno/1862955-sessions
Bug 1862955 - Gleanjs session implementation
- Loading branch information
Showing
11 changed files
with
226 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
/** | ||
* Check if the current session is inactive - the default timeout is 30 minutes. | ||
* | ||
* @param sessionLengthInMinutes Length of the session in minutes - defaults to 30. | ||
* @returns {boolean} If the current session is inactive. | ||
*/ | ||
export function isSessionInactive(sessionLengthInMinutes = 30): boolean { | ||
const lastActive = localStorage.getItem("glean_session_last_active"); | ||
const lastActiveDate = new Date(Number(lastActive)); | ||
|
||
// Subtract the session length from the current date. | ||
const inactiveThreshold = new Date(); | ||
inactiveThreshold.setMinutes(inactiveThreshold.getMinutes() - sessionLengthInMinutes); | ||
|
||
// If the inactiveThreshold is more recent than the lastActiveDate, then the | ||
// current session is expired. | ||
return inactiveThreshold > lastActiveDate; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -122,6 +122,51 @@ glean.internal.metrics: | |
- [email protected] | ||
expires: never | ||
|
||
session_id: | ||
type: uuid | ||
description: | | ||
A UUID uniquely identifying the client's current session. A session is | ||
the period of time in which a user interacts with the application. After | ||
a period of inactivity (default being 30 minutes) a new session will be | ||
created the next time the user interacts with the application. On each | ||
new session, the session_id will be updated. | ||
This metric WILL NOT be included for pings where `include_client_id` is `false`. | ||
send_in_pings: | ||
- glean_client_info | ||
lifetime: user | ||
bugs: | ||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1862955 | ||
data_reviews: | ||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1862955#c2 | ||
data_sensitivity: | ||
- technical | ||
notification_emails: | ||
- [email protected] | ||
expires: never | ||
|
||
session_count: | ||
type: counter | ||
description: | | ||
A running counter of the number of sessions for this client. A session is | ||
the period of time in which a user interacts with the application. After | ||
a period of inactivity (default being 30 minutes) a new session will be | ||
created the next time the user interacts with the application. On each | ||
new session, the session_count will be incremented. | ||
This count will ONLY be reset on opt-out or whenever storage is deleted. | ||
send_in_pings: | ||
- glean_client_info | ||
lifetime: user | ||
bugs: | ||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1862955 | ||
data_reviews: | ||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1862955#c2 | ||
data_sensitivity: | ||
- technical | ||
notification_emails: | ||
- [email protected] | ||
expires: never | ||
|
||
app_build: | ||
type: string | ||
lifetime: application | ||
|
Oops, something went wrong.