Skip to content

Commit f3bce9e

Browse files
committed
cast option types
1 parent 69d7f6a commit f3bce9e

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

packages/tracing/src/hubextensions.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { getMainCarrier, Hub } from '@sentry/hub';
22
import {
3+
ClientOptions,
34
CustomSamplingContext,
45
Integration,
56
IntegrationClass,
6-
Options,
77
SamplingContext,
88
TransactionContext,
99
} from '@sentry/types';
@@ -41,7 +41,7 @@ function traceHeaders(this: Hub): { [key: string]: string } {
4141
*
4242
* @returns The given transaction with its `sampled` value set
4343
*/
44-
function sample<T extends Transaction>(transaction: T, options: Options, samplingContext: SamplingContext): T {
44+
function sample<T extends Transaction>(transaction: T, options: ClientOptions, samplingContext: SamplingContext): T {
4545
// nothing to do if tracing is not enabled
4646
if (!hasTracingEnabled(options)) {
4747
transaction.sampled = false;
@@ -171,10 +171,10 @@ function _startTransaction(
171171
customSamplingContext?: CustomSamplingContext,
172172
): Transaction {
173173
const client = this.getClient();
174-
const options = (client && client.getOptions()) || {};
174+
const options: Partial<ClientOptions> = (client && client.getOptions()) || {};
175175

176176
let transaction = new Transaction(transactionContext, this);
177-
transaction = sample(transaction, options, {
177+
transaction = sample(transaction, options as ClientOptions, {
178178
parentSampled: transactionContext.parentSampled,
179179
transactionContext,
180180
...customSamplingContext,
@@ -196,10 +196,10 @@ export function startIdleTransaction(
196196
customSamplingContext?: CustomSamplingContext,
197197
): IdleTransaction {
198198
const client = hub.getClient();
199-
const options = (client && client.getOptions()) || {};
199+
const options: Partial<ClientOptions> = (client && client.getOptions()) || {};
200200

201201
let transaction = new IdleTransaction(transactionContext, hub, idleTimeout, onScope);
202-
transaction = sample(transaction, options, {
202+
transaction = sample(transaction, options as ClientOptions, {
203203
parentSampled: transactionContext.parentSampled,
204204
transactionContext,
205205
...customSamplingContext,

packages/tracing/src/utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { getCurrentHub, Hub } from '@sentry/hub';
2-
import { Options, Transaction } from '@sentry/types';
2+
import { ClientOptions, Transaction } from '@sentry/types';
33

44
/**
55
* The `extractTraceparentData` function and `TRACEPARENT_REGEXP` constant used
@@ -20,7 +20,7 @@ export { TRACEPARENT_REGEXP, extractTraceparentData } from '@sentry/utils';
2020
*
2121
* Tracing is enabled when at least one of `tracesSampleRate` and `tracesSampler` is defined in the SDK config.
2222
*/
23-
export function hasTracingEnabled(maybeOptions?: Options | undefined): boolean {
23+
export function hasTracingEnabled(maybeOptions?: ClientOptions | undefined): boolean {
2424
const client = getCurrentHub().getClient();
2525
const options = maybeOptions || (client && client.getOptions());
2626
return !!options && ('tracesSampleRate' in options || 'tracesSampler' in options);

0 commit comments

Comments
 (0)