mirror of
https://github.com/LukeHagar/better-auth.git
synced 2025-12-06 04:19:20 +00:00
fix(telemetry): avoid async import if telemetry disabled, fix for esbuild (#5086)
This commit is contained in:
@@ -100,13 +100,17 @@ export const init = async (options: BetterAuthOptions) => {
|
||||
return generateId(size);
|
||||
};
|
||||
|
||||
const { publish } = await createTelemetry(options, {
|
||||
const { publish } = options.telemetry?.enabled
|
||||
? await createTelemetry(options, {
|
||||
adapter: adapter.id,
|
||||
database:
|
||||
typeof options.database === "function"
|
||||
? "adapter"
|
||||
: getKyselyDatabaseType(options.database) || "unknown",
|
||||
});
|
||||
})
|
||||
: {
|
||||
publish: async () => {},
|
||||
};
|
||||
|
||||
let ctx: AuthContext = {
|
||||
appName: options.appName || "Better Auth",
|
||||
|
||||
@@ -5,7 +5,9 @@ let lazyImportCreateTelemetry: Promise<
|
||||
export const createTelemetry: typeof import("./create-telemetry").createTelemetry =
|
||||
async (...args) => {
|
||||
if (!lazyImportCreateTelemetry) {
|
||||
lazyImportCreateTelemetry = import("./create-telemetry").then(
|
||||
// keep esbuild from following dynamic import during bundling
|
||||
const importPath = "./create-telemetry";
|
||||
lazyImportCreateTelemetry = import(importPath).then(
|
||||
(mod) => mod.createTelemetry,
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user