How to use the universal-analytics.Visitor function in universal-analytics

To help you get started, we’ve selected a few universal-analytics examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FantasticFiasco / searchlight / src / main / analytics / analytics.ts View on Github external
expect.toBeTrue(Analytics.IdFormat.test(userId));

        const trackingId: string = (config as any).analytics.trackingId;

        log.info('Analytics', 'tracking id', trackingId.slice(0, 7) + '*******');
        log.info('Analytics', 'client id', clientId);
        log.info('Analytics', 'user id', userId);

        const options: ua.VisitorOptions = {
            tid: trackingId,
            cid: clientId,
            uid: userId,
            https: true,
        };

        this.visitor = new ua.Visitor(options);

        // Register for messages sent from the renderer
        ipcMain.on(
            AnalyticsChannelName.ReportEventWithValue,
            (event: any, arg: ValueEvent) => this.reportEventWithValue(arg.category, arg.action, arg.label, arg.value));
        ipcMain.on(
            AnalyticsChannelName.ReportPageView,
            (event: any, arg: PageViewEvent) => this.reportPageView(arg.path));
        ipcMain.on(
            AnalyticsChannelName.ReportException,
            (event: any, arg: ExceptionEvent) => this.reportException(arg.description));
    }
github celador / ForceCode / src / services / fcAnalytics.ts View on Github external
return new Promise(resolve => {
    // check if the user has opted in to tracking
    if (optIn()) {
      const params = {
        ec: fcVersion + ' - ' + category,
        ea: getOS(),
        el: message,
      };
      const analytics: Visitor = new Visitor(GA_TRACKING_ID, vscode.window.forceCode.uuid);
      analytics
        .event(params, response => {
          if (!response) {
            // according to universal-analytics, no response from the callback is a success
            resolve(true);
          }
          resolve(false);
        })
        .send();
    } else {
      resolve(false);
    }
  });
}

universal-analytics

A node module for Google's Universal Analytics tracking

MIT
Latest version published 2 years ago

Package Health Score

68 / 100
Full package analysis