sessiontiming.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { defineIntegration, convertIntegrationFnToClass } from '@sentry/core';
  2. const INTEGRATION_NAME = 'SessionTiming';
  3. const _sessionTimingIntegration = (() => {
  4. const startTime = Date.now();
  5. return {
  6. name: INTEGRATION_NAME,
  7. // TODO v8: Remove this
  8. setupOnce() {}, // eslint-disable-line @typescript-eslint/no-empty-function
  9. processEvent(event) {
  10. const now = Date.now();
  11. return {
  12. ...event,
  13. extra: {
  14. ...event.extra,
  15. ['session:start']: startTime,
  16. ['session:duration']: now - startTime,
  17. ['session:end']: now,
  18. },
  19. };
  20. },
  21. };
  22. }) ;
  23. const sessionTimingIntegration = defineIntegration(_sessionTimingIntegration);
  24. /**
  25. * This function adds duration since Sentry was initialized till the time event was sent.
  26. * @deprecated Use `sessionTimingIntegration()` instead.
  27. */
  28. // eslint-disable-next-line deprecation/deprecation
  29. const SessionTiming = convertIntegrationFnToClass(
  30. INTEGRATION_NAME,
  31. sessionTimingIntegration,
  32. ) ;
  33. export { SessionTiming, sessionTimingIntegration };
  34. //# sourceMappingURL=sessiontiming.js.map