Skip to content

Commit e2999c7

Browse files
committed
create telem plugin
1 parent a1c6ccf commit e2999c7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import { type Hub, type NodeClient } from "@sentry/node";
2+
import { type UnpluginOptions } from "unplugin";
3+
import { dim } from "../utils/logging";
4+
import { safeFlushTelemetry } from "../sentry";
5+
6+
interface TelemetryPluginOptions {
7+
sentryHub?: Hub;
8+
sentryClient?: NodeClient;
9+
shouldSendTelemetry: boolean;
10+
}
11+
12+
export function telemetryPlugin({
13+
sentryHub,
14+
sentryClient,
15+
shouldSendTelemetry,
16+
}: TelemetryPluginOptions): UnpluginOptions {
17+
return {
18+
name: "codecov-telemetry-plugin",
19+
async buildStart() {
20+
if (shouldSendTelemetry && sentryHub && sentryClient) {
21+
dim(
22+
"Sending error and performance telemetry data to Sentry. To disable telemetry, set `options.telemetry` to `false`.",
23+
);
24+
sentryHub
25+
.startTransaction({ name: "Codecov Bundler Plugin execution" })
26+
.finish();
27+
await safeFlushTelemetry(sentryClient);
28+
}
29+
},
30+
};
31+
}

0 commit comments

Comments
 (0)