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

1
packages/react/src/global.d.ts vendored Normal file
View file

@ -0,0 +1 @@
declare var __APTABASE_SDK_VERSION__: string;

View file

@ -3,9 +3,12 @@
import { init, trackEvent, type AptabaseOptions } from '@aptabase/web';
import { createContext, useContext, useEffect } from 'react';
globalThis.__APTABASE_SDK_VERSION__ = `aptabase-react@${process.env.PKG_VERSION}`;
type ContextProps = {
appKey?: string;
} & AptabaseOptions;
options?: AptabaseOptions;
};
export type AptabaseClient = {
trackEvent: typeof trackEvent;
@ -24,7 +27,7 @@ export function AptabaseProvider({ appKey, options, children }: Props) {
init(appKey, options);
}, [appKey, options]);
return <AptabaseContext.Provider value={{ appKey, ...options }}>{children}</AptabaseContext.Provider>;
return <AptabaseContext.Provider value={{ appKey, options }}>{children}</AptabaseContext.Provider>;
}
export function useAptabase(): AptabaseClient {

View file

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