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

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

@ -5,6 +5,7 @@ import axios from 'axios';
import isDocker from 'is-docker';
import { packageVersion } from '~/utils/packageVersion';
import TeleBatchProcessor from '~/utils/TeleBatchProcessor';
import { isEE } from '~/utils';
const isDisabled = !!process.env.NC_DISABLE_TELE;
const cache = !!process.env.NC_REDIS_URL;
@ -249,7 +250,14 @@ class Tele {
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> = {
package_id: packageVersion,
node_version: process.version,
@ -268,6 +276,7 @@ class Tele {
payload.docker = isDocker();
payload.machine_id = `${this.id},,`;
payload.upTime = Math.round(process.uptime() / 3600);
payload.payload = (await Tele.getInstanceMeta()) || {};
} catch {
// ignore
}

Loading…
Cancel
Save