feat: Convert helpers to use JS files

This commit is contained in:
Faruk AYDIN
2024-01-04 19:55:41 +01:00
parent 8819ddefa7
commit 85141812d9
48 changed files with 259 additions and 384 deletions

View File

@@ -1,12 +1,7 @@
import Analytics, { apiObject } from '@rudderstack/rudder-sdk-node';
import Analytics from '@rudderstack/rudder-sdk-node';
import organizationId from './organization-id';
import instanceId from './instance-id';
import appConfig from '../../config/app';
import Step from '../../models/step';
import Flow from '../../models/flow';
import Execution from '../../models/execution';
import ExecutionStep from '../../models/execution-step';
import Connection from '../../models/connection';
import os from 'os';
const WRITE_KEY = '284Py4VgK2MsNYV7xlKzyrALx0v';
@@ -15,22 +10,17 @@ const CPUS = os.cpus();
const SIX_HOURS_IN_MILLISECONDS = 21600000;
class Telemetry {
organizationId: string;
instanceId: string;
client: Analytics;
serviceType: string;
constructor() {
this.client = new Analytics(WRITE_KEY, DATA_PLANE_URL);
this.organizationId = organizationId();
this.instanceId = instanceId();
}
setServiceType(type: string) {
setServiceType(type) {
this.serviceType = type;
}
track(name: string, properties: apiObject) {
track(name, properties) {
if (!appConfig.telemetryEnabled) {
return;
}
@@ -48,7 +38,7 @@ class Telemetry {
});
}
stepCreated(step: Step) {
stepCreated(step) {
this.track('stepCreated', {
stepId: step.id,
flowId: step.flowId,
@@ -57,7 +47,7 @@ class Telemetry {
});
}
stepUpdated(step: Step) {
stepUpdated(step) {
this.track('stepUpdated', {
stepId: step.id,
flowId: step.flowId,
@@ -71,7 +61,7 @@ class Telemetry {
});
}
flowCreated(flow: Flow) {
flowCreated(flow) {
this.track('flowCreated', {
flowId: flow.id,
name: flow.name,
@@ -81,7 +71,7 @@ class Telemetry {
});
}
flowUpdated(flow: Flow) {
flowUpdated(flow) {
this.track('flowUpdated', {
flowId: flow.id,
name: flow.name,
@@ -91,7 +81,7 @@ class Telemetry {
});
}
executionCreated(execution: Execution) {
executionCreated(execution) {
this.track('executionCreated', {
executionId: execution.id,
flowId: execution.flowId,
@@ -101,7 +91,7 @@ class Telemetry {
});
}
executionStepCreated(executionStep: ExecutionStep) {
executionStepCreated(executionStep) {
this.track('executionStepCreated', {
executionStepId: executionStep.id,
executionId: executionStep.executionId,
@@ -112,7 +102,7 @@ class Telemetry {
});
}
connectionCreated(connection: Connection) {
connectionCreated(connection) {
this.track('connectionCreated', {
connectionId: connection.id,
key: connection.key,
@@ -122,7 +112,7 @@ class Telemetry {
});
}
connectionUpdated(connection: Connection) {
connectionUpdated(connection) {
this.track('connectionUpdated', {
connectionId: connection.id,
key: connection.key,