Skip to content

Commit

Permalink
ref: Update collected telemetry
Browse files Browse the repository at this point in the history
  • Loading branch information
lforst committed Jun 27, 2024
1 parent 9bb19f3 commit 21a1c9a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
10 changes: 1 addition & 9 deletions packages/bundler-plugin-core/src/debug-id-upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { Logger } from "./sentry/logger";
import { promisify } from "util";
import { Hub, NodeClient } from "@sentry/node";
import SentryCli from "@sentry/cli";
import { dynamicSamplingContextToSentryBaggageHeader } from "@sentry/utils";
import { safeFlushTelemetry } from "./sentry/telemetry";

interface RewriteSourcesHook {
Expand Down Expand Up @@ -152,14 +151,7 @@ export function createDebugIdUploadFunction({

const cliInstance = new SentryCli(null, {
...sentryCliOptions,
headers: {
"sentry-trace": uploadSpan.toTraceparent(),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
baggage: dynamicSamplingContextToSentryBaggageHeader(
artifactBundleUploadTransaction.getDynamicSamplingContext()
)!,
...sentryCliOptions.headers,
},
headers: sentryCliOptions.headers,
});

await cliInstance.releases.uploadSourceMaps(
Expand Down
15 changes: 9 additions & 6 deletions packages/bundler-plugin-core/src/sentry/telemetry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import SentryCli from "@sentry/cli";
import { defaultStackParser, Hub, makeNodeTransport, NodeClient } from "@sentry/node";
import { NormalizedOptions, SENTRY_SAAS_URL } from "../options-mapping";
import crypto from "crypto";

const SENTRY_SAAS_HOSTNAME = "sentry.io";

Expand Down Expand Up @@ -99,13 +100,15 @@ export function setTelemetryDataOnHub(options: NormalizedOptions, hub: Hub, bund

hub.setTag("application-key-set", options.applicationKey !== undefined);

hub.setTags({
organization: org,
project,
bundler,
});
hub.setTag("bundler", bundler);

hub.setUser({ id: org });
if (org) {
hub.setTag("org-hash", crypto.createHash("md5").update(org).digest("hex"));
}

if (project) {
hub.setTag("project-hash", crypto.createHash("md5").update(project).digest("hex"));
}
}

export async function allowedToSendTelemetry(options: NormalizedOptions): Promise<boolean> {
Expand Down

0 comments on commit 21a1c9a

Please sign in to comment.