sdk.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. static _stopTrack = false;
  23. public eventer = new Eventer(this);
  24. public _history: IHistory;
  25. constructor(params: SDKConfigType) {
  26. super(params);
  27. console.log('params.appId', params.appId);
  28. this._history = new IHistory(this, params.appId);
  29. super._history = this._history;
  30. }
  31. public setConfig(config: SDKInitConfig): void {
  32. this._config = config;
  33. super._config = this._config;
  34. }
  35. public stop(): void {
  36. SDK._stopTrack = true;
  37. }
  38. public resume(): void {
  39. SDK._stopTrack = false;
  40. }
  41. }