Browse Source

refactor: setup NODE_ENV

pull/9323/head
Pranav C 2 months ago
parent
commit
9db6b0243f
  1. 6
      packages/nocodb/src/services/utils.service.ts
  2. 11
      packages/nocodb/src/utils/tele.ts

6
packages/nocodb/src/services/utils.service.ts

@ -6,8 +6,8 @@ import { ViewTypes } from 'nocodb-sdk';
import { ConfigService } from '@nestjs/config'; import { ConfigService } from '@nestjs/config';
import { useAgent } from 'request-filtering-agent'; import { useAgent } from 'request-filtering-agent';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
import { T } from '~/utils';
import type { AppConfig, NcRequest } from '~/interface/config'; import type { AppConfig, NcRequest } from '~/interface/config';
import { T } from '~/utils';
import { NC_APP_SETTINGS, NC_ATTACHMENT_FIELD_SIZE } from '~/constants'; import { NC_APP_SETTINGS, NC_ATTACHMENT_FIELD_SIZE } from '~/constants';
import SqlMgrv2 from '~/db/sql-mgr/v2/SqlMgrv2'; import SqlMgrv2 from '~/db/sql-mgr/v2/SqlMgrv2';
import { NcError } from '~/helpers/catchError'; import { NcError } from '~/helpers/catchError';
@ -503,8 +503,10 @@ export class UtilsService {
} }
} }
let payload = null;
if (dayjs().isAfter(this.lastSyncTime.add(3, 'hours'))) { if (dayjs().isAfter(this.lastSyncTime.add(3, 'hours'))) {
this.lastSyncTime = dayjs(); this.lastSyncTime = dayjs();
payload = await T.payload();
} }
let response; let response;
@ -512,7 +514,7 @@ export class UtilsService {
try { try {
response = await axios.post( response = await axios.post(
'https://product-feed.nocodb.com/api/v1/social/feed', 'https://product-feed.nocodb.com/api/v1/social/feed',
T.payload, payload,
{ {
params: { params: {
per_page, per_page,

11
packages/nocodb/src/utils/tele.ts

@ -5,6 +5,7 @@ import axios from 'axios';
import isDocker from 'is-docker'; import isDocker from 'is-docker';
import { packageVersion } from '~/utils/packageVersion'; import { packageVersion } from '~/utils/packageVersion';
import TeleBatchProcessor from '~/utils/TeleBatchProcessor'; import TeleBatchProcessor from '~/utils/TeleBatchProcessor';
import { isEE } from '~/utils';
const isDisabled = !!process.env.NC_DISABLE_TELE; const isDisabled = !!process.env.NC_DISABLE_TELE;
const cache = !!process.env.NC_REDIS_URL; const cache = !!process.env.NC_REDIS_URL;
@ -249,7 +250,14 @@ class Tele {
return this.machineId || machineIdSync(); return this.machineId || machineIdSync();
} }
static get payload() { static async payload() {
if (
process.env.NODE_ENV === 'test' ||
process.env.NODE_ENV === 'development' ||
isEE
)
return null;
const payload: Record<string, any> = { const payload: Record<string, any> = {
package_id: packageVersion, package_id: packageVersion,
node_version: process.version, node_version: process.version,
@ -268,6 +276,7 @@ class Tele {
payload.docker = isDocker(); payload.docker = isDocker();
payload.machine_id = `${this.id},,`; payload.machine_id = `${this.id},,`;
payload.upTime = Math.round(process.uptime() / 3600); payload.upTime = Math.round(process.uptime() / 3600);
payload.payload = (await Tele.getInstanceMeta()) || {};
} catch { } catch {
// ignore // ignore
} }

Loading…
Cancel
Save