Skip to content

Commit

Permalink
inline telemetryEndpoint constant
Browse files Browse the repository at this point in the history
  • Loading branch information
dcousens committed Feb 8, 2024
1 parent 336a9af commit 4bc4670
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
1 change: 0 additions & 1 deletion packages/core/src/lib/defaults.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export const healthCheckPath = '/_healthcheck'
export const telemetryEndpoint = 'https://telemetry.keystonejs.com'
19 changes: 13 additions & 6 deletions packages/core/src/lib/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import os from 'os'
import { platform } from 'node:os'
import ci from 'ci-info'
import Conf from 'conf'
import fetch from 'node-fetch'
import chalk from 'chalk'
import { type Configuration, type Telemetry, type Project, type Device, type PackageName } from '../types/telemetry'
import {
type Configuration,
type Device,
type PackageName,
type Project,
type Telemetry,
} from '../types/telemetry'
import { type DatabaseProvider } from '../types'
import { telemetryEndpoint as defaultTelemetryEndpoint } from './defaults'
import type { InitialisedList } from './core/initialise-lists'

const defaultTelemetryEndpoint = 'https://telemetry.keystonejs.com'

const packageNames: PackageName[] = [
'@keystone-6/core',
'@keystone-6/auth',
Expand Down Expand Up @@ -60,7 +67,7 @@ function getTelemetryConfig () {
// dont copy garbage
if (typeof project !== 'object') continue
if (typeof project.lastSentDate !== 'string') continue
if (new Date(project.lastSentDate).toString() === 'Invalid Date') continue
if (new Date(project.lastSentDate).toString () === 'Invalid Date') continue

// only lastSentDate is retained
replacement.projects[projectPath] = {
Expand Down Expand Up @@ -100,7 +107,7 @@ function getDefaultedTelemetryConfig () {

const todaysDate = new Date().toISOString().slice(0, 10)

function collectFieldCount (lists: Record<string, InitialisedList>) {
function collectFieldCount(lists: Record<string, InitialisedList>) {
const fields: Project['fields'] = { unknown: 0 }

for (const list of Object.values(lists)) {
Expand Down Expand Up @@ -273,7 +280,7 @@ async function sendDeviceTelemetryEvent () {

await sendEvent('device', {
previous: lastSentDate,
os: os.platform(),
os: platform(),
node: process.versions.node.split('.')[0],
})

Expand Down

0 comments on commit 4bc4670

Please sign in to comment.