當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript react-ga.initialize函數代碼示例

本文整理匯總了TypeScript中react-ga.initialize函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript initialize函數的具體用法?TypeScript initialize怎麽用?TypeScript initialize使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了initialize函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

    it("Able to initailize react-ga object", () => {
        const options: ga.InitializeOptions = {
            debug: true,
        };

        ga.initialize("UA-65432-1", options);
    });
開發者ID:Crevil,項目名稱:DefinitelyTyped,代碼行數:7,代碼來源:react-ga-tests.ts

示例2:

addons.register('storybook/google-analytics', api => {
  ReactGA.initialize(window.STORYBOOK_GA_ID);

  api.on(STORY_CHANGED, () => {
    const { url } = api.getUrlState();
    ReactGA.pageview(url);
  });
  api.on(STORY_ERRORED, ({ description }: { description: string }) => {
    ReactGA.exception({
      description,
      fatal: true,
    });
  });
  api.on(STORY_MISSING, ({ id }: { id: string }) => {
    ReactGA.exception({
      description: `attempted to render ${id}, but it is missing`,
      fatal: false,
    });
  });
});
開發者ID:chinmaymoharir,項目名稱:storybook,代碼行數:20,代碼來源:register.ts

示例3:

import * as ReactGA from 'react-ga';

import {SETTINGS} from 'core/config/settings';

if (SETTINGS.analytics.ga) {
  ReactGA.initialize(SETTINGS.analytics.ga, {});
}
開發者ID:jcwest,項目名稱:deck,代碼行數:7,代碼來源:react.ga.ts

示例4: init

import * as _ from 'lodash';
import * as ReactGA from 'react-ga';
import { configs } from 'ts/utils/configs';
import { utils } from 'ts/utils/utils';
import * as Web3 from 'web3';

export const analytics = {
    init() {
        ReactGA.initialize(configs.GOOGLE_ANALYTICS_ID);
    },
    logEvent(category: string, action: string, label: string, value?: any) {
        ReactGA.event({
            category,
            action,
            label,
            value,
        });
    },
    async logProviderAsync(web3IfExists: Web3) {
        await utils.onPageLoadAsync();
        const providerType = !_.isUndefined(web3IfExists)
            ? utils.getProviderType(web3IfExists.currentProvider)
            : 'NONE';
        ReactGA.ga('set', 'dimension1', providerType);
    },
};
開發者ID:ewingrj,項目名稱:0x-monorepo,代碼行數:26,代碼來源:analytics.ts

示例5: pageView

import { useContext, useEffect, useState } from 'react';
import * as GA from 'react-ga';

import {
  dataContext,
  langContext,
  preferenceContext,
  uiContext
} from '../contexts';
import { getNewPath, isDateInRange } from '../contexts/uiContext';
import * as api from '../utils/api';
import { isProduction, version } from './consts';
import { useSelectedArea } from './hooks';

GA.initialize('UA-85003235-1', {
  debug: !isProduction
});

function pageView(location: Location) {
  const pathname = location.pathname + location.search;
  GA.set({ page: pathname, 'App Version': version });
  GA.pageview(pathname);
}

export default (location: any, history: any) => {
  const { lang } = useContext(langContext);
  const preferences = useContext(preferenceContext);
  const ui = useContext(uiContext);
  const data = useContext(dataContext);
  const selectedArea = useSelectedArea();
開發者ID:Kanttiinit,項目名稱:kanttiinit-web,代碼行數:30,代碼來源:useSideEffects.ts


注:本文中的react-ga.initialize函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。