All files / src Index.ts

64.71% Statements 11/17
33.33% Branches 2/6
100% Functions 1/1
66.67% Lines 10/15

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32            1x   1x 1x   4x       1x 1x 1x 1x 1x                   1x    
/**
 * Index.ts
 * @author Abhilash Panwar (abpanwar)
 * @copyright Microsoft 2020
 */
 
import { isWindowObjectAvailable, getWindow, Utils } from '@ms/1ds-core-js';
import { IEvent, IView, IReferrer, IAnalyticsConfiguration, IAutoCapture, IAction, IUser } from './analytics/DataModels';
import { ActionType } from './analytics/Enums';
import Analytics from './Analytics';
 
export { IEvent, IView, IReferrer, IUser, IAnalyticsConfiguration, IAutoCapture, IAction, ActionType, Analytics };
 
// Run through queue if window object available
 
Eif (isWindowObjectAvailable) {
    let win = getWindow();
    let queueName = 'MSEIqueue';
    let queue = win[queueName];
    Iif (Utils.isArray(queue)) {
       for (let index = 0; index < queue.length; index++) {
            const args = queue[index];
            if (args[0] === 'new') {
                win[args[1] as string] = new Analytics();
            } else {
                (win[args[1] as string] as Analytics)[args[0] as string].apply(win[args[1]], args[2]);
            }
        }
    }
    delete win[queueName];
}