diff --git a/src/extensions/replay/sessionrecording.ts b/src/extensions/replay/sessionrecording.ts index 63d420f80..ae681a6ad 100644 --- a/src/extensions/replay/sessionrecording.ts +++ b/src/extensions/replay/sessionrecording.ts @@ -18,7 +18,6 @@ import { import { PostHog } from '../../posthog-core' import { DecideResponse, FlagVariant, NetworkRecordOptions, NetworkRequest, Properties } from '../../types' import { EventType, type eventWithTime, IncrementalSource, type listenerHandler, RecordPlugin } from '@rrweb/types' -import { timestamp } from '../../utils' import { isBoolean, isFunction, isNullish, isNumber, isObject, isString, isUndefined } from '../../utils/type-utils' import { logger } from '../../utils/logger' @@ -492,7 +491,7 @@ export class SessionRecording { payload: [JSON.stringify(message)], }, }, - timestamp: timestamp(), + timestamp: Date.now(), }) } diff --git a/src/utils/event-utils.ts b/src/utils/event-utils.ts index cbca97de5..4544a9755 100644 --- a/src/utils/event-utils.ts +++ b/src/utils/event-utils.ts @@ -2,7 +2,7 @@ import { getQueryParam, convertToURL } from './request-utils' import { isNull } from './type-utils' import { Properties } from '../types' import Config from '../config' -import { each, extend, stripEmptyProperties, stripLeadingDollar, timestamp } from './index' +import { each, extend, stripEmptyProperties, stripLeadingDollar } from './index' import { document, location, userAgent, window } from './globals' import { detectBrowser, detectBrowserVersion, detectDevice, detectDeviceType, detectOS } from './user-agent-utils' @@ -211,7 +211,7 @@ export const Info = { $lib: 'web', $lib_version: Config.LIB_VERSION, $insert_id: Math.random().toString(36).substring(2, 10) + Math.random().toString(36).substring(2, 10), - $time: timestamp() / 1000, // epoch time in seconds + $time: Date.now() / 1000, // epoch time in seconds } ) }, diff --git a/src/utils/index.ts b/src/utils/index.ts index 61261fae2..435a107d8 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -117,15 +117,6 @@ export const isValidRegex = function (str: string): boolean { return true } -export const timestamp = function (): number { - Date.now = - Date.now || - function () { - return +new Date() - } - return Date.now() -} - export const trySafe = function (fn: () => T): T | undefined { try { return fn()