Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: Update collected telemetry #562

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading