fix sdk version

This commit is contained in:
goenning 2023-09-01 15:24:42 +01:00
parent 47042f043b
commit ce24e8f4fb
12 changed files with 31 additions and 7 deletions

View file

@ -4,3 +4,4 @@ type AptabaseState = {
};
declare var __APTABASE__: AptabaseState;
declare var __APTABASE_SDK_VERSION__: string;

View file

@ -14,7 +14,8 @@ export async function trackEvent(
eventName: string,
props?: Record<string, string | number | boolean>,
): Promise<void> {
const appKey = globalThis.__APTABASE__?.appKey;
const { appKey } = globalThis.__APTABASE__ || {};
if (!appKey) return Promise.resolve();
const userAgent = req.headers.get('user-agent') ?? '';
@ -27,7 +28,7 @@ export async function trackEvent(
isDebug: true,
locale: 'en',
appVersion: '',
sdkVersion: 'aptabase-node@0.1.0',
sdkVersion: globalThis.__APTABASE_SDK_VERSION__ ?? `aptabase-node@${process.env.PKG_VERSION}`,
},
props: props,
});

View file

@ -1,4 +1,5 @@
import { defineConfig } from 'tsup';
const { version } = require('./package.json');
export default defineConfig({
entry: ['src/index.ts'],
@ -8,4 +9,7 @@ export default defineConfig({
minify: true,
sourcemap: true,
clean: true,
env: {
PKG_VERSION: version,
},
});