airbyte-faros-destination 0.18.5 → 0.18.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/converters/asana/tasks.d.ts +6 -1
- package/lib/converters/asana/tasks.js +51 -1
- package/lib/converters/asana/tasks.js.map +1 -1
- package/lib/converters/cursor/common.d.ts +2 -1
- package/lib/converters/cursor/common.js +61 -0
- package/lib/converters/cursor/common.js.map +1 -1
- package/lib/converters/cursor/daily_usage.d.ts +0 -1
- package/lib/converters/cursor/daily_usage.js +7 -80
- package/lib/converters/cursor/daily_usage.js.map +1 -1
- package/lib/converters/cursor/members.d.ts +2 -5
- package/lib/converters/cursor/members.js +27 -53
- package/lib/converters/cursor/members.js.map +1 -1
- package/lib/converters/cursor/usage_events.d.ts +8 -0
- package/lib/converters/cursor/usage_events.js +49 -0
- package/lib/converters/cursor/usage_events.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -3,7 +3,10 @@ import { DestinationModel, DestinationRecord, StreamContext, StreamName } from '
|
|
|
3
3
|
import { AsanaConverter } from './common';
|
|
4
4
|
export declare class Tasks extends AsanaConverter {
|
|
5
5
|
private config;
|
|
6
|
-
private seenProjects;
|
|
6
|
+
private readonly seenProjects;
|
|
7
|
+
private readonly seenTasks;
|
|
8
|
+
private readonly taskComments;
|
|
9
|
+
private fetchTaskComments;
|
|
7
10
|
private initialize;
|
|
8
11
|
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
9
12
|
static readonly tagsStream: StreamName;
|
|
@@ -13,4 +16,6 @@ export declare class Tasks extends AsanaConverter {
|
|
|
13
16
|
private findFieldByName;
|
|
14
17
|
private toTaskField;
|
|
15
18
|
protected shouldProcessProjectMembership(): boolean;
|
|
19
|
+
onProcessingComplete(_ctx?: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
20
|
+
private convertComments;
|
|
16
21
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Tasks = void 0;
|
|
4
4
|
const faros_js_client_1 = require("faros-js-client");
|
|
5
|
+
const types_1 = require("../../common/types");
|
|
5
6
|
const converter_1 = require("../converter");
|
|
6
7
|
const common_1 = require("./common");
|
|
7
8
|
const project_tasks_1 = require("./project_tasks");
|
|
@@ -18,11 +19,15 @@ class Tasks extends common_1.AsanaConverter {
|
|
|
18
19
|
super(...arguments);
|
|
19
20
|
this.config = undefined;
|
|
20
21
|
this.seenProjects = new Set();
|
|
22
|
+
this.seenTasks = new Set();
|
|
23
|
+
this.taskComments = [];
|
|
24
|
+
this.fetchTaskComments = false;
|
|
21
25
|
this.destinationModels = [
|
|
22
26
|
'tms_Task',
|
|
23
27
|
'tms_TaskDependency',
|
|
24
28
|
'tms_TaskAssignment',
|
|
25
29
|
'tms_TaskTag',
|
|
30
|
+
'tms_TaskComment',
|
|
26
31
|
];
|
|
27
32
|
}
|
|
28
33
|
initialize(ctx) {
|
|
@@ -34,13 +39,15 @@ class Tasks extends common_1.AsanaConverter {
|
|
|
34
39
|
return [Tasks.tagsStream];
|
|
35
40
|
}
|
|
36
41
|
async convert(record, ctx) {
|
|
37
|
-
var _a, _b, _c, _d, _e;
|
|
42
|
+
var _a, _b, _c, _d, _e, _f;
|
|
38
43
|
this.initialize(ctx);
|
|
39
44
|
const res = [];
|
|
40
45
|
const source = this.streamName.source;
|
|
41
46
|
const task = record.record.data;
|
|
42
47
|
const taskKey = { uid: task.gid, source };
|
|
43
48
|
const parent = task.parent ? { uid: task.parent.gid, source } : null;
|
|
49
|
+
// Track this task for comment deletion
|
|
50
|
+
this.seenTasks.add(task.gid);
|
|
44
51
|
const taskCustomFields = ((_a = task.custom_fields) !== null && _a !== void 0 ? _a : []).filter((f) => { var _a; return (_a = this.config.task_custom_fields) === null || _a === void 0 ? void 0 : _a.includes(f.gid); });
|
|
45
52
|
const statusChangelog = [];
|
|
46
53
|
for (const story of (_b = task.stories) !== null && _b !== void 0 ? _b : []) {
|
|
@@ -132,6 +139,26 @@ class Tasks extends common_1.AsanaConverter {
|
|
|
132
139
|
});
|
|
133
140
|
}
|
|
134
141
|
}
|
|
142
|
+
// Process comments following Jira pattern
|
|
143
|
+
if (task.comments) {
|
|
144
|
+
this.fetchTaskComments = true;
|
|
145
|
+
for (const comment of task.comments) {
|
|
146
|
+
this.taskComments.push({
|
|
147
|
+
model: 'tms_TaskComment',
|
|
148
|
+
record: {
|
|
149
|
+
task: taskKey,
|
|
150
|
+
uid: comment.gid,
|
|
151
|
+
comment: faros_js_client_1.Utils.cleanAndTruncate(comment.text, common_1.AsanaCommon.MAX_DESCRIPTION_LENGTH),
|
|
152
|
+
createdAt: faros_js_client_1.Utils.toDate(comment.created_at),
|
|
153
|
+
updatedAt: faros_js_client_1.Utils.toDate(comment.created_at), // Asana stories don't have updated_at
|
|
154
|
+
author: ((_f = comment.created_by) === null || _f === void 0 ? void 0 : _f.gid)
|
|
155
|
+
? { uid: comment.created_by.gid, source }
|
|
156
|
+
: undefined,
|
|
157
|
+
// Note: Asana comments don't have reply structure like Jira
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
}
|
|
135
162
|
return res;
|
|
136
163
|
}
|
|
137
164
|
getStatus(task) {
|
|
@@ -162,6 +189,29 @@ class Tasks extends common_1.AsanaConverter {
|
|
|
162
189
|
shouldProcessProjectMembership() {
|
|
163
190
|
return false;
|
|
164
191
|
}
|
|
192
|
+
async onProcessingComplete(_ctx) {
|
|
193
|
+
return [...this.convertComments()];
|
|
194
|
+
}
|
|
195
|
+
convertComments() {
|
|
196
|
+
if (!this.fetchTaskComments) {
|
|
197
|
+
return [];
|
|
198
|
+
}
|
|
199
|
+
return [
|
|
200
|
+
// Delete existing comments for all processed tasks
|
|
201
|
+
...Array.from(this.seenTasks.keys()).map((taskGid) => ({
|
|
202
|
+
model: 'tms_TaskComment__Deletion',
|
|
203
|
+
record: {
|
|
204
|
+
flushRequired: false,
|
|
205
|
+
where: {
|
|
206
|
+
task: { uid: taskGid, source: this.source },
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
})),
|
|
210
|
+
types_1.FLUSH,
|
|
211
|
+
// Insert all new comments
|
|
212
|
+
...this.taskComments,
|
|
213
|
+
];
|
|
214
|
+
}
|
|
165
215
|
}
|
|
166
216
|
exports.Tasks = Tasks;
|
|
167
217
|
Tasks.tagsStream = new converter_1.StreamName('asana', 'tags');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/converters/asana/tasks.ts"],"names":[],"mappings":";;;AACA,qDAAsC;AAGtC,4CAKsB;AACtB,qCAAqD;AACrD,mDAA6C;AAC7C,yCAAoC;AA0BpC,IAAK,sBAKJ;AALD,WAAK,sBAAsB;IACzB,2CAAiB,CAAA;IACjB,uCAAa,CAAA;IACb,mDAAyB,CAAA;IACzB,uCAAa,CAAA;AACf,CAAC,EALI,sBAAsB,KAAtB,sBAAsB,QAK1B;AAMD,MAAa,KAAM,SAAQ,uBAAc;IAAzC;;QACU,WAAM,GAAW,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"tasks.js","sourceRoot":"","sources":["../../../src/converters/asana/tasks.ts"],"names":[],"mappings":";;;AACA,qDAAsC;AAGtC,8CAAyC;AACzC,4CAKsB;AACtB,qCAAqD;AACrD,mDAA6C;AAC7C,yCAAoC;AA0BpC,IAAK,sBAKJ;AALD,WAAK,sBAAsB;IACzB,2CAAiB,CAAA;IACjB,uCAAa,CAAA;IACb,mDAAyB,CAAA;IACzB,uCAAa,CAAA;AACf,CAAC,EALI,sBAAsB,KAAtB,sBAAsB,QAK1B;AAMD,MAAa,KAAM,SAAQ,uBAAc;IAAzC;;QACU,WAAM,GAAW,SAAS,CAAC;QAClB,iBAAY,GAAgB,IAAI,GAAG,EAAE,CAAC;QACtC,cAAS,GAAgB,IAAI,GAAG,EAAE,CAAC;QACnC,iBAA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
|
1
1
|
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
2
|
import { DailyUsageItem } from 'faros-airbyte-common/cursor';
|
|
3
|
-
import { Converter, StreamContext } from '../converter';
|
|
3
|
+
import { Converter, DestinationRecord, StreamContext } from '../converter';
|
|
4
4
|
export interface CursorConfig {
|
|
5
5
|
custom_metrics?: ReadonlyArray<keyof DailyUsageItem>;
|
|
6
6
|
}
|
|
@@ -8,4 +8,5 @@ export declare abstract class CursorConverter extends Converter {
|
|
|
8
8
|
source: string;
|
|
9
9
|
id(record: AirbyteRecord): any;
|
|
10
10
|
protected cursorConfig(ctx: StreamContext): CursorConfig;
|
|
11
|
+
protected getAssistantMetric(startedAt: Date, endedAt: Date, assistantMetricType: string, value: number | string | boolean, org: string, userEmail: string, customMetricName?: keyof DailyUsageItem, model?: string, feature?: string): DestinationRecord[];
|
|
11
12
|
}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CursorConverter = void 0;
|
|
4
|
+
const common_1 = require("faros-airbyte-common/common");
|
|
5
|
+
const lodash_1 = require("lodash");
|
|
6
|
+
const vcs_1 = require("../common/vcs");
|
|
4
7
|
const converter_1 = require("../converter");
|
|
5
8
|
class CursorConverter extends converter_1.Converter {
|
|
6
9
|
constructor() {
|
|
@@ -15,6 +18,64 @@ class CursorConverter extends converter_1.Converter {
|
|
|
15
18
|
var _a, _b, _c;
|
|
16
19
|
return (_c = (_b = (_a = ctx === null || ctx === void 0 ? void 0 : ctx.config) === null || _a === void 0 ? void 0 : _a.source_specific_configs) === null || _b === void 0 ? void 0 : _b.cursor) !== null && _c !== void 0 ? _c : {};
|
|
17
20
|
}
|
|
21
|
+
getAssistantMetric(startedAt, endedAt, assistantMetricType, value, org, userEmail, customMetricName, model, feature) {
|
|
22
|
+
return [
|
|
23
|
+
{
|
|
24
|
+
model: 'vcs_AssistantMetric',
|
|
25
|
+
record: {
|
|
26
|
+
uid: (0, common_1.digest)([]
|
|
27
|
+
.concat(
|
|
28
|
+
// original fields (required) to be included in the digest
|
|
29
|
+
...[
|
|
30
|
+
vcs_1.VCSToolDetail.Cursor,
|
|
31
|
+
assistantMetricType,
|
|
32
|
+
startedAt.toISOString(),
|
|
33
|
+
org,
|
|
34
|
+
userEmail,
|
|
35
|
+
customMetricName,
|
|
36
|
+
],
|
|
37
|
+
// newer fields (optional) to be included in the digest
|
|
38
|
+
...[
|
|
39
|
+
{ key: 'model', value: model },
|
|
40
|
+
{ key: 'feature', value: feature },
|
|
41
|
+
]
|
|
42
|
+
.filter((v) => !(0, lodash_1.isNil)(v.value))
|
|
43
|
+
.map((v) => `${v.key}:${v.value}`))
|
|
44
|
+
.join('__')),
|
|
45
|
+
source: this.source,
|
|
46
|
+
startedAt,
|
|
47
|
+
endedAt,
|
|
48
|
+
type: {
|
|
49
|
+
category: assistantMetricType,
|
|
50
|
+
...(customMetricName && { detail: customMetricName }),
|
|
51
|
+
},
|
|
52
|
+
valueType: getValueType(value),
|
|
53
|
+
value: String(value),
|
|
54
|
+
organization: {
|
|
55
|
+
uid: org,
|
|
56
|
+
source: this.streamName.source,
|
|
57
|
+
},
|
|
58
|
+
user: { uid: userEmail, source: this.streamName.source },
|
|
59
|
+
tool: {
|
|
60
|
+
category: vcs_1.VCSToolCategory.CodingAssistant,
|
|
61
|
+
detail: vcs_1.VCSToolDetail.Cursor,
|
|
62
|
+
},
|
|
63
|
+
...(model && { model }),
|
|
64
|
+
...(feature && { feature }),
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
}
|
|
18
69
|
}
|
|
19
70
|
exports.CursorConverter = CursorConverter;
|
|
71
|
+
function getValueType(value) {
|
|
72
|
+
switch (typeof value) {
|
|
73
|
+
case 'number':
|
|
74
|
+
return 'Int';
|
|
75
|
+
case 'boolean':
|
|
76
|
+
return 'Bool';
|
|
77
|
+
default:
|
|
78
|
+
return 'String';
|
|
79
|
+
}
|
|
80
|
+
}
|
|
20
81
|
//# sourceMappingURL=common.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/cursor/common.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../../src/converters/cursor/common.ts"],"names":[],"mappings":";;;AACA,wDAAmD;AAEnD,mCAA6B;AAE7B,uCAA6D;AAC7D,4CAAyE;AAMzE,MAAsB,eAAgB,SAAQ,qBAAS;IAAvD;;QACE,WAAM,GAAG,QAAQ,CAAC;IAuEpB,CAAC;IArEC,EAAE,CAAC,MAAqB;;QACtB,OAAO,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,MAAM,0CAAE,IAAI,0CAAE,EAAE,CAAC;IAClC,CAAC;IAES,YAAY,CAAC,GAAkB;;QACvC,OAAO,MAAA,MAAA,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,MAAM,0CAAE,uBAAuB,0CAAE,MAAM,mCAAI,EAAE,CAAC;IAC5D,CAAC;IAES,kBAAkB,CAC1B,SAAe,EACf,OAAa,EACb,mBAA2B,EAC3B,KAAgC,EAChC,GAAW,EACX,SAAiB,EACjB,gBAAuC,EACvC,KAAc,EACd,OAAgB;QAEhB,OAAO;YACL;gBACE,KAAK,EAAE,qBAAqB;gBAC5B,MAAM,EAAE;oBACN,GAAG,EAAE,IAAA,eAAM,EACT,EAAE;yBACC,MAAM;oBACL,0DAA0D;oBAC1D,GAAG;wBACD,mBAAa,CAAC,MAAM;wBACpB,mBAAmB;wBACnB,SAAS,CAAC,WAAW,EAAE;wBACvB,GAAG;wBACH,SAAS;wBACT,gBAAgB;qBACjB;oBACD,uDAAuD;oBACvD,GAAG;wBACD,EAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC;wBAC5B,EAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAA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 @@ export declare class DailyUsage extends CursorConverter {
|
|
|
5
5
|
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
6
|
id(record: AirbyteRecord): string;
|
|
7
7
|
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
8
|
-
private getAssistantMetric;
|
|
9
8
|
}
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DailyUsage = void 0;
|
|
4
|
-
const common_1 = require("faros-airbyte-common/common");
|
|
5
4
|
const faros_js_client_1 = require("faros-js-client");
|
|
6
5
|
const lodash_1 = require("lodash");
|
|
7
6
|
const vcs_1 = require("../common/vcs");
|
|
8
|
-
const
|
|
7
|
+
const common_1 = require("./common");
|
|
9
8
|
const DailyUsageItemToAssistantMetricType = {
|
|
10
9
|
acceptedLinesAdded: vcs_1.AssistantMetric.LinesAccepted,
|
|
11
10
|
totalAccepts: vcs_1.AssistantMetric.SuggestionsAccepted,
|
|
@@ -30,16 +29,16 @@ const DailyUsageItemToFeature = {
|
|
|
30
29
|
};
|
|
31
30
|
const DEFAULT_CUSTOM_METRICS = [];
|
|
32
31
|
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
33
|
-
class DailyUsage extends
|
|
32
|
+
class DailyUsage extends common_1.CursorConverter {
|
|
34
33
|
constructor() {
|
|
35
34
|
super(...arguments);
|
|
36
35
|
this.destinationModels = [
|
|
37
36
|
'vcs_AssistantMetric',
|
|
38
|
-
'vcs_UserToolUsage',
|
|
39
37
|
];
|
|
40
38
|
}
|
|
41
39
|
id(record) {
|
|
42
|
-
|
|
40
|
+
const dailyUsageItem = record.record.data;
|
|
41
|
+
return `${dailyUsageItem.date}__${dailyUsageItem.email}`;
|
|
43
42
|
}
|
|
44
43
|
async convert(record, ctx) {
|
|
45
44
|
var _a;
|
|
@@ -49,30 +48,12 @@ class DailyUsage extends common_2.CursorConverter {
|
|
|
49
48
|
}
|
|
50
49
|
const day = faros_js_client_1.Utils.toDate(dailyUsageItem.date);
|
|
51
50
|
const res = [];
|
|
52
|
-
res.push({
|
|
53
|
-
model: 'vcs_UserToolUsage',
|
|
54
|
-
record: {
|
|
55
|
-
userTool: {
|
|
56
|
-
user: { uid: dailyUsageItem.email, source: this.streamName.source },
|
|
57
|
-
organization: {
|
|
58
|
-
uid: vcs_1.VCSToolDetail.Cursor,
|
|
59
|
-
source: this.streamName.source,
|
|
60
|
-
},
|
|
61
|
-
tool: {
|
|
62
|
-
category: vcs_1.VCSToolCategory.CodingAssistant,
|
|
63
|
-
detail: vcs_1.VCSToolDetail.Cursor,
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
usedAt: day.toISOString(),
|
|
67
|
-
recordedAt: day.toISOString(),
|
|
68
|
-
},
|
|
69
|
-
});
|
|
70
51
|
for (const [field, assistantMetricType] of Object.entries(DailyUsageItemToAssistantMetricType)) {
|
|
71
52
|
const value = dailyUsageItem[field];
|
|
72
53
|
if ((0, lodash_1.isNil)(value)) {
|
|
73
54
|
continue;
|
|
74
55
|
}
|
|
75
|
-
res.push(...this.getAssistantMetric(day, assistantMetricType, value, vcs_1.VCSToolDetail.Cursor, dailyUsageItem.email));
|
|
56
|
+
res.push(...this.getAssistantMetric(day, faros_js_client_1.Utils.toDate(day.getTime() + DAY_MS), assistantMetricType, value, vcs_1.VCSToolDetail.Cursor, dailyUsageItem.email));
|
|
76
57
|
}
|
|
77
58
|
// Get custom metrics from config, fallback to default if not configured
|
|
78
59
|
const config = this.cursorConfig(ctx);
|
|
@@ -82,71 +63,17 @@ class DailyUsage extends common_2.CursorConverter {
|
|
|
82
63
|
if ((0, lodash_1.isNil)(value)) {
|
|
83
64
|
continue;
|
|
84
65
|
}
|
|
85
|
-
res.push(...this.getAssistantMetric(day, vcs_1.AssistantMetric.Custom, value, vcs_1.VCSToolDetail.Cursor, dailyUsageItem.email, field));
|
|
66
|
+
res.push(...this.getAssistantMetric(day, faros_js_client_1.Utils.toDate(day.getTime() + DAY_MS), vcs_1.AssistantMetric.Custom, value, vcs_1.VCSToolDetail.Cursor, dailyUsageItem.email, field));
|
|
86
67
|
}
|
|
87
68
|
for (const [field, feature] of Object.entries(DailyUsageItemToFeature)) {
|
|
88
69
|
const value = dailyUsageItem[field];
|
|
89
70
|
if ((0, lodash_1.isNil)(value)) {
|
|
90
71
|
continue;
|
|
91
72
|
}
|
|
92
|
-
res.push(...this.getAssistantMetric(day, vcs_1.AssistantMetric.Usages, value, vcs_1.VCSToolDetail.Cursor, dailyUsageItem.email, undefined, feature));
|
|
73
|
+
res.push(...this.getAssistantMetric(day, faros_js_client_1.Utils.toDate(day.getTime() + DAY_MS), vcs_1.AssistantMetric.Usages, value, vcs_1.VCSToolDetail.Cursor, dailyUsageItem.email, undefined, undefined, feature));
|
|
93
74
|
}
|
|
94
75
|
return res;
|
|
95
76
|
}
|
|
96
|
-
getAssistantMetric(day, assistantMetricType, value, org, userEmail, customMetricName, feature) {
|
|
97
|
-
return [
|
|
98
|
-
{
|
|
99
|
-
model: 'vcs_AssistantMetric',
|
|
100
|
-
record: {
|
|
101
|
-
uid: (0, common_1.digest)([]
|
|
102
|
-
.concat(
|
|
103
|
-
// original fields (required) to be included in the digest
|
|
104
|
-
...[
|
|
105
|
-
vcs_1.VCSToolDetail.Cursor,
|
|
106
|
-
assistantMetricType,
|
|
107
|
-
day.toISOString(),
|
|
108
|
-
org,
|
|
109
|
-
userEmail,
|
|
110
|
-
customMetricName,
|
|
111
|
-
],
|
|
112
|
-
// newer fields (optional) to be included in the digest
|
|
113
|
-
...[{ key: 'feature', value: feature }]
|
|
114
|
-
.filter((v) => !(0, lodash_1.isNil)(v.value))
|
|
115
|
-
.map((v) => `${v.key}:${v.value}`))
|
|
116
|
-
.join('__')),
|
|
117
|
-
source: this.source,
|
|
118
|
-
startedAt: day,
|
|
119
|
-
endedAt: faros_js_client_1.Utils.toDate(day.getTime() + DAY_MS),
|
|
120
|
-
type: {
|
|
121
|
-
category: assistantMetricType,
|
|
122
|
-
...(customMetricName && { detail: customMetricName }),
|
|
123
|
-
},
|
|
124
|
-
valueType: getValueType(value),
|
|
125
|
-
value: String(value),
|
|
126
|
-
organization: {
|
|
127
|
-
uid: org,
|
|
128
|
-
source: this.streamName.source,
|
|
129
|
-
},
|
|
130
|
-
user: { uid: userEmail, source: this.streamName.source },
|
|
131
|
-
tool: {
|
|
132
|
-
category: vcs_1.VCSToolCategory.CodingAssistant,
|
|
133
|
-
detail: vcs_1.VCSToolDetail.Cursor,
|
|
134
|
-
},
|
|
135
|
-
...(feature && { feature }),
|
|
136
|
-
},
|
|
137
|
-
},
|
|
138
|
-
];
|
|
139
|
-
}
|
|
140
77
|
}
|
|
141
78
|
exports.DailyUsage = DailyUsage;
|
|
142
|
-
function getValueType(value) {
|
|
143
|
-
switch (typeof value) {
|
|
144
|
-
case 'number':
|
|
145
|
-
return 'Int';
|
|
146
|
-
case 'boolean':
|
|
147
|
-
return 'Bool';
|
|
148
|
-
default:
|
|
149
|
-
return 'String';
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
79
|
//# sourceMappingURL=daily_usage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daily_usage.js","sourceRoot":"","sources":["../../../src/converters/cursor/daily_usage.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"daily_usage.js","sourceRoot":"","sources":["../../../src/converters/cursor/daily_usage.ts"],"names":[],"mappings":";;;AAEA,qDAAsC;AACtC,mCAA6B;AAE7B,uCAA6D;AAE7D,qCAAyC;AAEzC,MAAM,mCAAmC,GAErC;IACF,kBAAkB,EAAE,qBAAe,CAAC,aAAa;IACjD,YAAY,EAAE,qBAAe,CAAC,mBAAmB;IACjD,YAAY,EAAE,qBAAe,CAAC,oBAAoB;CACnD,CAAC;AAEF,IAAK,OAOJ;AAPD,WAAK,OAAO;IACV,sBAAW,CAAA;IACX,gCAAqB,CAAA;IACrB,wB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AC,kBAAkB,CACxB,GAAG,EACH,uBAAK,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,EACpC,qBAAe,CAAC,MAAM,EACtB,KAAK,EACL,mBAAa,CAAC,MAAM,EACpB,cAAc,CAAC,KAAK,EACpB,SAAS,EACT,SAAS,EACT,OAAO,CACR,CACF,CAAC;QACJ,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AArFD,gCAqFC"}
|
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
-
import { DestinationModel, DestinationRecord
|
|
2
|
+
import { DestinationModel, DestinationRecord } from '../converter';
|
|
3
3
|
import { CursorConverter } from './common';
|
|
4
4
|
export declare class Members extends CursorConverter {
|
|
5
5
|
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
-
private static readonly dailyUsageStream;
|
|
7
|
-
get dependencies(): ReadonlyArray<StreamName>;
|
|
8
|
-
private readonly seenUsers;
|
|
9
6
|
convert(record: AirbyteRecord): Promise<ReadonlyArray<DestinationRecord>>;
|
|
10
|
-
onProcessingComplete(
|
|
7
|
+
onProcessingComplete(): Promise<ReadonlyArray<DestinationRecord>>;
|
|
11
8
|
}
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Members = void 0;
|
|
4
4
|
const faros_js_client_1 = require("faros-js-client");
|
|
5
5
|
const vcs_1 = require("../common/vcs");
|
|
6
|
-
const converter_1 = require("../converter");
|
|
7
6
|
const common_1 = require("./common");
|
|
8
7
|
class Members extends common_1.CursorConverter {
|
|
9
8
|
constructor() {
|
|
@@ -14,58 +13,31 @@ class Members extends common_1.CursorConverter {
|
|
|
14
13
|
'vcs_UserEmail',
|
|
15
14
|
'vcs_UserTool',
|
|
16
15
|
];
|
|
17
|
-
this.seenUsers = {};
|
|
18
|
-
}
|
|
19
|
-
get dependencies() {
|
|
20
|
-
return [Members.dailyUsageStream];
|
|
21
16
|
}
|
|
22
17
|
async convert(record) {
|
|
23
18
|
const member = record.record.data;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
this.seenUsers[member.email] = {
|
|
27
|
-
name: member.name,
|
|
28
|
-
active: true,
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return res;
|
|
32
|
-
}
|
|
33
|
-
async onProcessingComplete(ctx) {
|
|
34
|
-
var _a;
|
|
35
|
-
const res = [];
|
|
36
|
-
for (const record of Object.values(ctx.getAll(Members.dailyUsageStream.asString))) {
|
|
37
|
-
const dailyUsage = record.record.data;
|
|
38
|
-
if (!dailyUsage.email) {
|
|
39
|
-
continue;
|
|
40
|
-
}
|
|
41
|
-
if (!this.seenUsers[dailyUsage.email]) {
|
|
42
|
-
this.seenUsers[dailyUsage.email] = { active: false };
|
|
43
|
-
}
|
|
44
|
-
if (!this.seenUsers[dailyUsage.email].minUsageDate ||
|
|
45
|
-
dailyUsage.minUsageDate < this.seenUsers[dailyUsage.email].minUsageDate) {
|
|
46
|
-
this.seenUsers[dailyUsage.email].minUsageDate = dailyUsage.minUsageDate;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
for (const [email, user] of Object.entries(this.seenUsers)) {
|
|
50
|
-
res.push({
|
|
19
|
+
return [
|
|
20
|
+
{
|
|
51
21
|
model: 'vcs_User',
|
|
52
22
|
record: {
|
|
53
|
-
uid: email,
|
|
23
|
+
uid: member.email,
|
|
54
24
|
source: this.streamName.source,
|
|
55
|
-
|
|
56
|
-
email: email,
|
|
25
|
+
...(member.name && { name: member.name }),
|
|
26
|
+
email: member.email,
|
|
57
27
|
type: vcs_1.UserTypeCategory.User,
|
|
58
28
|
},
|
|
59
|
-
},
|
|
29
|
+
},
|
|
30
|
+
{
|
|
60
31
|
model: 'vcs_UserEmail',
|
|
61
32
|
record: {
|
|
62
|
-
user: { uid: email, source: this.streamName.source },
|
|
63
|
-
email,
|
|
33
|
+
user: { uid: member.email, source: this.streamName.source },
|
|
34
|
+
email: member.email,
|
|
64
35
|
},
|
|
65
|
-
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
66
38
|
model: 'vcs_UserTool',
|
|
67
39
|
record: {
|
|
68
|
-
user: { uid: email, source: this.streamName.source },
|
|
40
|
+
user: { uid: member.email, source: this.streamName.source },
|
|
69
41
|
organization: {
|
|
70
42
|
uid: vcs_1.VCSToolDetail.Cursor,
|
|
71
43
|
source: this.streamName.source,
|
|
@@ -74,23 +46,25 @@ class Members extends common_1.CursorConverter {
|
|
|
74
46
|
category: vcs_1.VCSToolCategory.CodingAssistant,
|
|
75
47
|
detail: vcs_1.VCSToolDetail.Cursor,
|
|
76
48
|
},
|
|
77
|
-
inactive: !
|
|
78
|
-
...(
|
|
79
|
-
startedAt: faros_js_client_1.Utils.toDate(
|
|
49
|
+
inactive: !member.active,
|
|
50
|
+
...(member.minUsageTimestamp && {
|
|
51
|
+
startedAt: faros_js_client_1.Utils.toDate(member.minUsageTimestamp).toISOString(),
|
|
80
52
|
}),
|
|
81
53
|
},
|
|
82
|
-
});
|
|
83
|
-
}
|
|
84
|
-
res.push({
|
|
85
|
-
model: 'vcs_Organization',
|
|
86
|
-
record: {
|
|
87
|
-
uid: vcs_1.VCSToolDetail.Cursor,
|
|
88
|
-
source: this.streamName.source,
|
|
89
54
|
},
|
|
90
|
-
|
|
91
|
-
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
async onProcessingComplete() {
|
|
58
|
+
return [
|
|
59
|
+
{
|
|
60
|
+
model: 'vcs_Organization',
|
|
61
|
+
record: {
|
|
62
|
+
uid: vcs_1.VCSToolDetail.Cursor,
|
|
63
|
+
source: this.streamName.source,
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
];
|
|
92
67
|
}
|
|
93
68
|
}
|
|
94
69
|
exports.Members = Members;
|
|
95
|
-
Members.dailyUsageStream = new converter_1.StreamName('cursor', 'daily_usage');
|
|
96
70
|
//# sourceMappingURL=members.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"members.js","sourceRoot":"","sources":["../../../src/converters/cursor/members.ts"],"names":[],"mappings":";;;AAEA,qDAAsC;AAEtC,uCAA+E;
|
|
1
|
+
{"version":3,"file":"members.js","sourceRoot":"","sources":["../../../src/converters/cursor/members.ts"],"names":[],"mappings":";;;AAEA,qDAAsC;AAEtC,uCAA+E;AAE/E,qCAAyC;AAEzC,MAAa,OAAQ,SAAQ,wBAAe;IAA5C;;QACW,sBAAiB,GAAoC;YAC5D,kBAAkB;YAClB,UAAU;YACV,eAAe;YACf,cAAc;SACf,CAAC;IAwDJ,CAAC;IAtDC,KAAK,CAAC,OAAO,CACX,MAAqB;QAErB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAkB,CAAC;QAChD,OAAO;YACL;gBACE,KAAK,EAAE,UAAU;gBACjB,MAAM,EAAE;oBACN,GAAG,EAAE,MAAM,CAAC,KAAK;oBACjB,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;oBAC9B,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,EAAC,IAAI,EAAE,MAAM,CAAC,IAAI,EAAC,CAAC;oBACvC,KAAK,EAAE,MAAM,CAAC,KAAK;oBACnB,IAAI,EAAE,sBAAgB,CAAC,IAAI;iBAC5B;aACF;YACD;gBACE,KAAK,EAAE,eAAe;gBACtB,MAAM,EAAE;oBACN,IAAI,EAAE,EAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAC;oBACzD,KAAK,EAAE,MAAM,CAAC,KAAK;iBACpB;aACF;YACD;gBACE,KAAK,EAAE,cAAc;gBACrB,MAAM,EAAE;oBACN,IAAI,EAAE,EAAC,GAAG,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM,EAAC;oBACzD,YAAY,EAAE;wBACZ,GAAG,EAAE,mBAAa,CAAC,MAAM;wBACzB,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;qBAC/B;oBACD,IAAI,EAAE;wBACJ,QAAQ,EAAE,qBAAe,CAAC,eAAe;wBACzC,MAAM,EAAE,mBAAa,CAAC,MAAM;qBAC7B;oBACD,QAAQ,EAAE,CAAC,MAAM,CAAC,MAAM;oBACxB,GAAG,CAAC,MAAM,CAAC,iBAAiB,IAAI;wBAC9B,SAAS,EAAE,uBAAK,CAAC,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,WAAW,EAAE;qBAChE,CAAC;iBACH;aACF;SACF,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,oBAAoB;QACxB,OAAO;YACL;gBACE,KAAK,EAAE,kBAAkB;gBACzB,MAAM,EAAE;oBACN,GAAG,EAAE,mBAAa,CAAC,MAAM;oBACzB,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,MAAM;iBAC/B;aACF;SACF,CAAC;IACJ,CAAC;CACF;AA9DD,0BA8DC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AirbyteRecord } from 'faros-airbyte-cdk';
|
|
2
|
+
import { DestinationModel, DestinationRecord, StreamContext } from '../converter';
|
|
3
|
+
import { CursorConverter } from './common';
|
|
4
|
+
export declare class UsageEvents extends CursorConverter {
|
|
5
|
+
readonly destinationModels: ReadonlyArray<DestinationModel>;
|
|
6
|
+
id(record: AirbyteRecord): string;
|
|
7
|
+
convert(record: AirbyteRecord, ctx: StreamContext): Promise<ReadonlyArray<DestinationRecord>>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsageEvents = void 0;
|
|
4
|
+
const faros_js_client_1 = require("faros-js-client");
|
|
5
|
+
const vcs_1 = require("../common/vcs");
|
|
6
|
+
const common_1 = require("./common");
|
|
7
|
+
class UsageEvents extends common_1.CursorConverter {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
this.destinationModels = [
|
|
11
|
+
'vcs_AssistantMetric',
|
|
12
|
+
'vcs_UserToolUsage',
|
|
13
|
+
];
|
|
14
|
+
}
|
|
15
|
+
id(record) {
|
|
16
|
+
const usageEventItem = record.record.data;
|
|
17
|
+
return `${usageEventItem.timestamp}__${usageEventItem.userEmail}`;
|
|
18
|
+
}
|
|
19
|
+
async convert(record, ctx) {
|
|
20
|
+
const usageEventItem = record.record.data;
|
|
21
|
+
if (!usageEventItem.userEmail) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
const timestamp = faros_js_client_1.Utils.toDate(Number(usageEventItem.timestamp));
|
|
25
|
+
const res = [];
|
|
26
|
+
res.push({
|
|
27
|
+
model: 'vcs_UserToolUsage',
|
|
28
|
+
record: {
|
|
29
|
+
userTool: {
|
|
30
|
+
user: { uid: usageEventItem.userEmail, source: this.streamName.source },
|
|
31
|
+
organization: {
|
|
32
|
+
uid: vcs_1.VCSToolDetail.Cursor,
|
|
33
|
+
source: this.streamName.source,
|
|
34
|
+
},
|
|
35
|
+
tool: {
|
|
36
|
+
category: vcs_1.VCSToolCategory.CodingAssistant,
|
|
37
|
+
detail: vcs_1.VCSToolDetail.Cursor,
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
usedAt: timestamp.toISOString(),
|
|
41
|
+
recordedAt: timestamp.toISOString(),
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
res.push(...this.getAssistantMetric(timestamp, timestamp, vcs_1.AssistantMetric.Usages, 1, vcs_1.VCSToolDetail.Cursor, usageEventItem.userEmail, undefined, usageEventItem.model));
|
|
45
|
+
return res;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.UsageEvents = UsageEvents;
|
|
49
|
+
//# sourceMappingURL=usage_events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage_events.js","source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