sdk.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // import { getGlobalObject } from '@medici/utils';
  2. // import { BehaviorSubject } from 'rxjs';
  3. import { BaseTrack } from './basicTrack';
  4. import { IHistory } from './history';
  5. import { Eventer } from './event';
  6. export type PlatformType = 'web' | 'miniApp';
  7. export interface SDKInitConfig {
  8. user?: string;
  9. version?: string; //client version
  10. }
  11. export interface SDKConfigType {
  12. endPoint: string;
  13. appId: string;
  14. platform?: PlatformType;
  15. autoTrack?: boolean;
  16. config?: SDKInitConfig;
  17. trackEndPoint?: string;
  18. }
  19. export class SDK extends BaseTrack {
  20. protected _platform: PlatformType;
  21. protected _config: SDKInitConfig;
  22. public eventer = new Eventer(this);
  23. public _history: IHistory;
  24. constructor(params: SDKConfigType) {
  25. super(params);
  26. console.log('params.appId', params.appId);
  27. this._history = new IHistory(this, params.appId);
  28. super._history = this._history;
  29. }
  30. public setConfig(config: SDKInitConfig): void {
  31. this._config = config;
  32. }
  33. }