{"version":3,"file":"sdk.mjs","sources":["../../src/sdk.ts"],"sourcesContent":["import type { Client, Integration, Options } from '@sentry/core';\nimport {\n  dedupeIntegration,\n  functionToStringIntegration,\n  getIntegrationsToSetup,\n  GLOBAL_OBJ,\n  inboundFiltersIntegration,\n  initAndBind,\n  logger,\n  stackParserFromStackParserOptions,\n  supportsFetch,\n} from '@sentry/core';\nimport type { LynxClientOptions, LynxOptions } from './client';\nimport { LynxClient } from './client';\nimport { breadcrumbsIntegration, browserApiErrorsIntegration, browserSessionIntegration, globalHandlersIntegration } from '@sentry/browser';\nimport { httpContextIntegration } from '@sentry/browser';\nimport { linkedErrorsIntegration } from '@sentry/browser';\nimport { defaultStackParser } from '@sentry/browser';\nimport { makeFetchTransport } from '@sentry/browser';\nimport { dropTopLevelUndefinedKeys } from './utils/dropTopLevelUndefinedKeys';\nimport { getLynx, isBrowserMainThread, isLynxBackgroundThread, isMobile, notMobile } from './environment';\nimport { getFetch } from './utils/fetch';\nimport { developmentSymbolicatorIntegration } from './integrations/developmentSymbolicator';\nimport { lynxGlobalHandlersIntegration } from './integrations/globalHandlers';\n\n/** Get the default integrations for the Lynx SDK. */\nexport function getDefaultIntegrations(_options: Options): Integration[] {\n  const integrations = [\n    // TODO(v10): Replace with `eventFiltersIntegration` once we remove the deprecated `inboundFiltersIntegration`\n    // eslint-disable-next-line deprecation/deprecation\n    inboundFiltersIntegration(),\n    functionToStringIntegration(),\n    breadcrumbsIntegration({\n      history: false,\n      dom: false,\n    }),\n    linkedErrorsIntegration(),\n    dedupeIntegration(),\n    httpContextIntegration(),\n    developmentSymbolicatorIntegration(),\n    lynxGlobalHandlersIntegration(),\n  ];\n\n  if (isBrowserMainThread()) {\n    integrations.push(\n      browserApiErrorsIntegration(),\n      globalHandlersIntegration(),\n      browserSessionIntegration(),\n    );\n  }\n\n  return integrations;\n}\n\n/** Exported only for tests. */\nexport function applyDefaultOptions(optionsArg: LynxOptions = {}): LynxOptions {\n  const defaultOptions: LynxOptions = {\n    defaultIntegrations: getDefaultIntegrations(optionsArg),\n    release: GLOBAL_OBJ.SENTRY_RELEASE?.id, // This supports the variable that sentry-webpack-plugin injects\n    sendClientReports: true,\n  };\n\n  return {\n    ...defaultOptions,\n    ...dropTopLevelUndefinedKeys(optionsArg),\n  };\n}\n\n/**\n * The Sentry Lynx SDK Client.\n *\n * To use this SDK, call the {@link init} function as early as possible when\n * loading the application. To set context information or send manual events, use\n * the provided methods.\n *\n * @example\n *\n * ```\n *\n * import { init } from '@sentry/lynx-react';\n *\n * init({\n *   dsn: '__DSN__',\n *   // ...\n * });\n * ```\n *\n * @example\n * ```\n *\n * import { addBreadcrumb } from '@sentry/lynx-react';\n * addBreadcrumb({\n *   message: 'My Breadcrumb',\n *   // ...\n * });\n * ```\n *\n * @example\n *\n * ```\n *\n * import * as Sentry from '@sentry/lynx-react';\n * Sentry.captureMessage('Hello, world!');\n * Sentry.captureException(new Error('Good bye'));\n * Sentry.captureEvent({\n *   message: 'Manual',\n *   stacktrace: [\n *     // ...\n *   ],\n * });\n * ```\n *\n * @see {@link LynxOptions} for documentation on configuration options.\n */\nexport function init(lynxOptions: LynxOptions = {}): Client | undefined {\n  if (!isLynxBackgroundThread() && !isBrowserMainThread()) {\n    logger.info('Sentry initialization skipped: Sentry is only enabled on the mobile background thread or browser main thread.')\n    return\n  }\n\n  const options = applyDefaultOptions(lynxOptions);\n\n  if (!supportsFetch() && notMobile()) {\n    logger.warn(\n      'No Fetch API detected. The Sentry SDK requires a Fetch API compatible environment to send events. Please add a Fetch API polyfill.',\n    );\n  }\n  const clientOptions: LynxClientOptions = {\n    ...options,\n    stackParser: stackParserFromStackParserOptions(options.stackParser || defaultStackParser),\n    integrations: getIntegrationsToSetup(options),\n    transport: options.transport || ((transportOptions) => makeFetchTransport(transportOptions, getFetch())),\n  };\n\n  return initAndBind(LynxClient, clientOptions);\n}\n"],"names":[],"mappings":";;;;;;;;;AAyBA;AACM,SAAU,sBAAsB,CAAC,QAAiB,EAAA;AACt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