* Standard initialization method to be used to initialize the tracker. Ensures that the * initialize process is only called once and returns the initializationComplete promise. * * Calls internal initialize method
()
| 92 | * Calls internal initialize method |
| 93 | */ |
| 94 | async initialize () { |
| 95 | if (this.isInitializing) { |
| 96 | return this.initializationComplete |
| 97 | } |
| 98 | |
| 99 | this.isInitializing = true |
| 100 | |
| 101 | const initTimeout = new Promise((resolve, reject) => { |
| 102 | setTimeout(() => reject(new Error(`${this.constructor.name || 'Tracker'} init timeout`)), this.trackerInitTimeout) |
| 103 | }) |
| 104 | |
| 105 | try { |
| 106 | await Promise.race([initTimeout, this._initializeTracker()]) |
| 107 | } catch (e) { |
| 108 | this.onInitializeFail(e) |
| 109 | } |
| 110 | |
| 111 | return this.initializationComplete |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Internal tracker initialization method to be implemented by sub trackers. This is |
no test coverage detected