sdk(astro,nextjs): add astro sdk and ensure window.op always first on nextjs
This commit is contained in:
46
packages/sdks/astro/index.ts
Normal file
46
packages/sdks/astro/index.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type {
|
||||
DecrementPayload,
|
||||
IdentifyPayload,
|
||||
IncrementPayload,
|
||||
TrackProperties,
|
||||
} from '@openpanel/web';
|
||||
import IdentifyComponent from './src/IdentifyComponent.astro';
|
||||
import OpenPanelComponent from './src/OpenPanelComponent.astro';
|
||||
import SetGlobalPropertiesComponent from './src/SetGlobalPropertiesComponent.astro';
|
||||
|
||||
export * from '@openpanel/web';
|
||||
|
||||
export { OpenPanelComponent, IdentifyComponent, SetGlobalPropertiesComponent };
|
||||
|
||||
export function setGlobalProperties(properties: Record<string, unknown>) {
|
||||
window.op?.('setGlobalProperties', properties);
|
||||
}
|
||||
|
||||
export function track(name: string, properties?: TrackProperties) {
|
||||
window.op?.('track', name, properties);
|
||||
}
|
||||
|
||||
export function screenView(properties?: TrackProperties): void;
|
||||
export function screenView(path: string, properties?: TrackProperties): void;
|
||||
export function screenView(
|
||||
pathOrProperties?: string | TrackProperties,
|
||||
propertiesOrUndefined?: TrackProperties,
|
||||
) {
|
||||
window.op?.('screenView', pathOrProperties, propertiesOrUndefined);
|
||||
}
|
||||
|
||||
export function identify(payload: IdentifyPayload) {
|
||||
window.op?.('identify', payload);
|
||||
}
|
||||
|
||||
export function increment(payload: IncrementPayload) {
|
||||
window.op?.('increment', payload);
|
||||
}
|
||||
|
||||
export function decrement(payload: DecrementPayload) {
|
||||
window.op('decrement', payload);
|
||||
}
|
||||
|
||||
export function clear() {
|
||||
window.op?.('clear');
|
||||
}
|
||||
Reference in New Issue
Block a user