Merge pull request #314 from automatisch/feature/telemetry-flow
feat: Implement telemetry for created and updated flows
This commit is contained in:
@@ -3,6 +3,7 @@ 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';
|
||||
|
||||
const WRITE_KEY = '284Py4VgK2MsNYV7xlKzyrALx0v';
|
||||
const DATA_PLANE_URL = 'https://telemetry.automatisch.io/v1/batch';
|
||||
@@ -54,6 +55,26 @@ class Telemetry {
|
||||
updatedAt: step.updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
flowCreated(flow: Flow) {
|
||||
this.track('flowCreated', {
|
||||
flowId: flow.id,
|
||||
name: flow.name,
|
||||
active: flow.active,
|
||||
createdAt: flow.createdAt,
|
||||
updatedAt: flow.updatedAt,
|
||||
});
|
||||
}
|
||||
|
||||
flowUpdated(flow: Flow) {
|
||||
this.track('flowUpdated', {
|
||||
flowId: flow.id,
|
||||
name: flow.name,
|
||||
active: flow.active,
|
||||
createdAt: flow.createdAt,
|
||||
updatedAt: flow.updatedAt,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const telemetry = new Telemetry();
|
||||
|
@@ -1,8 +1,9 @@
|
||||
import { ValidationError } from 'objection';
|
||||
import type { ModelOptions } from 'objection';
|
||||
import type { ModelOptions, QueryContext } from 'objection';
|
||||
import Base from './base';
|
||||
import Step from './step';
|
||||
import Execution from './execution';
|
||||
import Telemetry from '../helpers/telemetry';
|
||||
|
||||
class Flow extends Base {
|
||||
id!: string;
|
||||
@@ -71,6 +72,16 @@ class Flow extends Base {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
async $afterInsert(queryContext: QueryContext) {
|
||||
await super.$afterInsert(queryContext);
|
||||
Telemetry.flowCreated(this);
|
||||
}
|
||||
|
||||
async $afterUpdate(opt: ModelOptions, queryContext: QueryContext) {
|
||||
await super.$afterUpdate(opt, queryContext);
|
||||
Telemetry.flowUpdated(this);
|
||||
}
|
||||
}
|
||||
|
||||
export default Flow;
|
||||
|
Reference in New Issue
Block a user