mario-core 2.9.31-beta → 2.9.33-beta

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ var yup = require('yup');
10
10
  var reactRedux = require('react-redux');
11
11
  var toolkit = require('@reduxjs/toolkit');
12
12
  var axios = _interopDefault(require('axios'));
13
+ var amplitude = _interopDefault(require('amplitude-js'));
13
14
  var reactGoogleRecaptchaV3 = require('react-google-recaptcha-v3');
14
15
  var GoogleLogin = _interopDefault(require('react-google-login'));
15
16
  var Select = _interopDefault(require('react-select'));
@@ -29,7 +30,6 @@ var ReactNotification$1 = _interopDefault(require('react-notifications-component
29
30
  require('react-notifications-component/dist/theme.css');
30
31
  var ai = require('react-icons/ai');
31
32
  var moment = _interopDefault(require('moment'));
32
- var amplitude = _interopDefault(require('amplitude-js'));
33
33
 
34
34
  // A type of promise-like that resolves synchronously and supports only one observer
35
35
 
@@ -304,6 +304,16 @@ var apiUpload = axios.create({
304
304
  Object.keys(localStorage).forEach(function (key) {
305
305
  if (!key.includes('learning-plan')) delete localStorage[key];
306
306
  });
307
+ var userEmail = localStorage.getItem("USER_EMAIL");
308
+
309
+ if (userEmail) {
310
+ amplitude.getInstance().logEvent("general: session end", {
311
+ user_id: userEmail
312
+ });
313
+ amplitude.getInstance().resetSessionId();
314
+ }
315
+
316
+ localStorage.setItem("USER_EMAIL", "");
307
317
  window.location.href = "/login";
308
318
  }
309
319
 
@@ -417,7 +427,8 @@ var useLogin = function useLogin() {
417
427
  lastName = _res$data.lastName,
418
428
  roles = _res$data.roles,
419
429
  email = _res$data.email,
420
- profileImageFileName = _res$data.profileImageFileName;
430
+ profileImageFileName = _res$data.profileImageFileName,
431
+ isLoginFirst = _res$data.isLoginFirst;
421
432
  localStorage.setItem(ACCESS_TOKEN, token);
422
433
  dispatch(setUser({
423
434
  id: id,
@@ -428,6 +439,23 @@ var useLogin = function useLogin() {
428
439
  profileImageFileName: profileImageFileName
429
440
  }));
430
441
 
442
+ if (data !== null && data !== void 0 && data.email && !roles.includes("Admin")) {
443
+ amplitude.getInstance().init(INIT_AMPLITUDE_KEY, data.email, {
444
+ includeReferrer: true,
445
+ includeUtm: true
446
+ });
447
+ amplitude.getInstance().logEvent("general: session start", {
448
+ user_id: data.email
449
+ });
450
+ localStorage.setItem("USER_EMAIL", data.email);
451
+
452
+ if (isLoginFirst) {
453
+ amplitude.getInstance().logEvent("general: first login", {
454
+ user_id: data.email
455
+ });
456
+ }
457
+ }
458
+
431
459
  if (isDistrict) {
432
460
  history.push(HOMEPAGE_DISTRICT);
433
461
  } else if (roles.includes("Admin")) {