Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: it's just rude to assign to date now #1435

Merged
merged 3 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/extensions/replay/sessionrecording.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -492,7 +491,7 @@ export class SessionRecording {
payload: [JSON.stringify(message)],
},
},
timestamp: timestamp(),
timestamp: Date.now(),
})
}

Expand Down
4 changes: 2 additions & 2 deletions src/utils/event-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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
}
)
},
Expand Down
9 changes: 0 additions & 9 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 <T>(fn: () => T): T | undefined {
try {
return fn()
Expand Down
Loading