feat: Implement telemetry for step creation and updates
This commit is contained in:
@@ -2,6 +2,7 @@ import Analytics, { apiObject } from '@rudderstack/rudder-sdk-node';
|
|||||||
import organizationId from './organization-id';
|
import organizationId from './organization-id';
|
||||||
import instanceId from './instance-id';
|
import instanceId from './instance-id';
|
||||||
import appConfig from '../../config/app';
|
import appConfig from '../../config/app';
|
||||||
|
import Step from '../../models/step';
|
||||||
|
|
||||||
const WRITE_KEY = '284Py4VgK2MsNYV7xlKzyrALx0v';
|
const WRITE_KEY = '284Py4VgK2MsNYV7xlKzyrALx0v';
|
||||||
const DATA_PLANE_URL = 'https://telemetry.automatisch.io/v1/batch';
|
const DATA_PLANE_URL = 'https://telemetry.automatisch.io/v1/batch';
|
||||||
@@ -31,11 +32,28 @@ class Telemetry {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Example implementation of telemetry methods.
|
stepCreated(step: Step) {
|
||||||
// TODO: Revise properties for the step.
|
this.track('stepCreated', {
|
||||||
// stepUpdated(key: string, appKey: string) {
|
stepId: step.id,
|
||||||
// this.track('Step updated', { key, appKey });
|
flowId: step.flowId,
|
||||||
// }
|
createdAt: step.createdAt,
|
||||||
|
updatedAt: step.updatedAt,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
stepUpdated(step: Step) {
|
||||||
|
this.track('stepUpdated', {
|
||||||
|
stepId: step.id,
|
||||||
|
flowId: step.flowId,
|
||||||
|
key: step.key,
|
||||||
|
appKey: step.appKey,
|
||||||
|
type: step.type,
|
||||||
|
position: step.position,
|
||||||
|
status: step.status,
|
||||||
|
createdAt: step.createdAt,
|
||||||
|
updatedAt: step.updatedAt,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const telemetry = new Telemetry();
|
const telemetry = new Telemetry();
|
||||||
|
@@ -1,15 +1,17 @@
|
|||||||
|
import { QueryContext, ModelOptions } from 'objection';
|
||||||
import Base from './base';
|
import Base from './base';
|
||||||
import Flow from './flow';
|
import Flow from './flow';
|
||||||
import Connection from './connection';
|
import Connection from './connection';
|
||||||
import ExecutionStep from './execution-step';
|
import ExecutionStep from './execution-step';
|
||||||
import type { IStep } from '@automatisch/types';
|
import type { IStep } from '@automatisch/types';
|
||||||
|
import Telemetry from '../helpers/telemetry';
|
||||||
|
|
||||||
class Step extends Base {
|
class Step extends Base {
|
||||||
id!: string;
|
id!: string;
|
||||||
flowId!: string;
|
flowId!: string;
|
||||||
key?: string;
|
key?: string;
|
||||||
appKey?: string;
|
appKey?: string;
|
||||||
type!: IStep["type"];
|
type!: IStep['type'];
|
||||||
connectionId?: string;
|
connectionId?: string;
|
||||||
status = 'incomplete';
|
status = 'incomplete';
|
||||||
position!: number;
|
position!: number;
|
||||||
@@ -63,6 +65,16 @@ class Step extends Base {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
async $afterInsert(queryContext: QueryContext) {
|
||||||
|
await super.$afterInsert(queryContext);
|
||||||
|
Telemetry.stepCreated(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
async $afterUpdate(opt: ModelOptions, queryContext: QueryContext) {
|
||||||
|
await super.$afterUpdate(opt, queryContext);
|
||||||
|
Telemetry.stepUpdated(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Step;
|
export default Step;
|
||||||
|
Reference in New Issue
Block a user