* Initializes this client instance. * * @param options Options for the client.
(options: O)
| 226 | * @param options Options for the client. |
| 227 | */ |
| 228 | protected constructor(options: O) { |
| 229 | this._options = options; |
| 230 | this._integrations = {}; |
| 231 | this._numProcessing = 0; |
| 232 | this._outcomes = {}; |
| 233 | this._hooks = {}; |
| 234 | this._eventProcessors = []; |
| 235 | this._promiseBuffer = makePromiseBuffer(options.transportOptions?.bufferSize ?? DEFAULT_TRANSPORT_BUFFER_SIZE); |
| 236 | this._dataCollection = resolveDataCollectionOptions(options); |
| 237 | |
| 238 | if (options.dsn) { |
| 239 | this._dsn = makeDsn(options.dsn); |
| 240 | } else { |
| 241 | DEBUG_BUILD && debug.warn('No DSN provided, client will not send events.'); |
| 242 | } |
| 243 | |
| 244 | if (this._dsn) { |
| 245 | const url = getEnvelopeEndpointWithUrlEncodedAuth( |
| 246 | this._dsn, |
| 247 | options.tunnel, |
| 248 | options._metadata ? options._metadata.sdk : undefined, |
| 249 | ); |
| 250 | this._transport = options.transport({ |
| 251 | tunnel: this._options.tunnel, |
| 252 | recordDroppedEvent: this.recordDroppedEvent.bind(this), |
| 253 | ...options.transportOptions, |
| 254 | url, |
| 255 | }); |
| 256 | } |
| 257 | |
| 258 | // Backfill enableLogs option from _experiments.enableLogs |
| 259 | // TODO(v11): Remove or change default value |
| 260 | // eslint-disable-next-line typescript/no-deprecated |
| 261 | this._options.enableLogs = this._options.enableLogs ?? this._options._experiments?.enableLogs; |
| 262 | |
| 263 | // Setup log flushing with weight and timeout tracking |
| 264 | if (this._options.enableLogs) { |
| 265 | setupWeightBasedFlushing(this, 'afterCaptureLog', 'flushLogs', estimateLogSizeInBytes, _INTERNAL_flushLogsBuffer); |
| 266 | } |
| 267 | |
| 268 | // todo(v11): Remove the experimental flag |
| 269 | // eslint-disable-next-line typescript/no-deprecated |
| 270 | const enableMetrics = this._options.enableMetrics ?? this._options._experiments?.enableMetrics ?? true; |
| 271 | |
| 272 | // Setup metric flushing with weight and timeout tracking |
| 273 | if (enableMetrics) { |
| 274 | setupWeightBasedFlushing( |
| 275 | this, |
| 276 | 'afterCaptureMetric', |
| 277 | 'flushMetrics', |
| 278 | estimateMetricSizeInBytes, |
| 279 | _INTERNAL_flushMetricsBuffer, |
| 280 | ); |
| 281 | } |
| 282 | } |
| 283 | |
| 284 | /** |
| 285 | * Captures an exception event and sends it to Sentry. |
nothing calls this directly
no test coverage detected