(options: CloudflareOptions)
| 51 | * Initializes the cloudflare SDK. |
| 52 | */ |
| 53 | export function init(options: CloudflareOptions): CloudflareClient | undefined { |
| 54 | if (options.defaultIntegrations === undefined) { |
| 55 | options.defaultIntegrations = getDefaultIntegrations(options); |
| 56 | } |
| 57 | |
| 58 | const flushLock = options.ctx ? makeFlushLock(options.ctx) : undefined; |
| 59 | delete options.ctx; |
| 60 | |
| 61 | const clientOptions: CloudflareClientOptions = { |
| 62 | ...options, |
| 63 | stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser), |
| 64 | integrations: getIntegrationsToSetup(options), |
| 65 | transport: options.transport || makeCloudflareTransport, |
| 66 | flushLock, |
| 67 | }; |
| 68 | |
| 69 | /** |
| 70 | * The Cloudflare SDK is not OpenTelemetry native, however, we set up some OpenTelemetry compatibility |
| 71 | * via a custom trace provider. |
| 72 | * This ensures that any spans emitted via `@opentelemetry/api` will be captured by Sentry. |
| 73 | * HOWEVER, big caveat: This does not handle custom context handling, it will always work off the current scope. |
| 74 | * This should be good enough for many, but not all integrations. |
| 75 | */ |
| 76 | if (!options.skipOpenTelemetrySetup) { |
| 77 | setupOpenTelemetryTracer(); |
| 78 | } |
| 79 | |
| 80 | return initAndBind(CloudflareClient, clientOptions) as CloudflareClient; |
| 81 | } |
no test coverage detected