本文整理匯總了TypeScript中react-ga.event函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript event函數的具體用法?TypeScript event怎麽用?TypeScript event使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了event函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: evalExpression
export function evalExpression(gist: string, scriptId: string, expr: string) {
if (!expr)
return;
const request = new EvaluateExpression();
request.scriptId = scriptId;
request.expression = expr;
request.includeJson = true;
ReactGA.event({ category: 'preview', action: 'Evaluate Expression', label: gist + ": " + expr.substring(0, 50) });
client.post(request)
.then(r => {
if (r.result.errors && r.result.errors.length > 0) {
r.result.errors.forEach(x => {
store.dispatch({ type: 'CONSOLE_LOG', logs: [{ msg: x.info, cls: "error" }] });
});
} else {
store.dispatch({ type: 'EXPRESSION_LOAD', expressionResult: r.result });
}
})
.catch(e => {
var status = e.responseStatus || e; //both have schema `{ message }`
store.dispatch({ type: 'CONSOLE_LOG', logs: [statusToError(status)] });
});
};
示例2: useEffect
useEffect(() => {
if (selectedArea) {
GA.event({
action: 'selected area',
category: 'User',
label: selectedArea.name,
value: selectedArea.id
});
}
}, [selectedArea]);
示例3: it
it("Able to make event calls", () => {
ga.initialize("UA-65432-1");
const options: ga.EventArgs = {
category: "Test",
action: "CI",
label: "Running Jasmine tests for react-ga typscript library",
value: 4,
nonInteraction: true,
};
ga.event(options);
});
示例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);
},
};
示例5: event
export const sendEvent = (eventPayload: AnalyticsEvent) => {
event(eventPayload);
}