mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-14 22:10:30 +00:00
Vendored
+42
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for react-ga 1.4
|
||||
// Type definitions for react-ga 2.1.2
|
||||
// Project: https://github.com/react-ga/react-ga
|
||||
// Definitions by: Tim Aldridge <https://github.com/telshin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -11,16 +11,56 @@ export interface EventArgs {
|
||||
nonInteraction?: boolean;
|
||||
}
|
||||
|
||||
export interface GaOptions {
|
||||
name?: string;
|
||||
clientId?: string;
|
||||
sampleRate?: number;
|
||||
siteSpeedSampleRate?: number;
|
||||
alwaysSendReferrer?: boolean;
|
||||
allowAnchor?: boolean;
|
||||
cookieName?: string;
|
||||
cookieDomain?: string;
|
||||
cookieExpires?: number;
|
||||
legacyCookieDomain?: string;
|
||||
legacyHistoryImport?: boolean;
|
||||
allowLinker?: boolean;
|
||||
userId?: string;
|
||||
}
|
||||
|
||||
export interface InitializeOptions {
|
||||
debug?: boolean;
|
||||
titleCase?: boolean;
|
||||
gaOptions?: GaOptions;
|
||||
}
|
||||
|
||||
export interface FieldsObject {
|
||||
[i: string]: any;
|
||||
}
|
||||
|
||||
export interface TimingArgs {
|
||||
category: string;
|
||||
variable: string;
|
||||
value: number;
|
||||
label?: string;
|
||||
}
|
||||
|
||||
export interface Plugin {
|
||||
require(name: string, options: any): void;
|
||||
execute(pluginName: string, action: string, actionTypeOrPayload: string|any, payload?: any): void;
|
||||
}
|
||||
|
||||
export interface OutboundLinkArgs {
|
||||
label: string;
|
||||
}
|
||||
|
||||
export function initialize(trackingCode: string, options?: InitializeOptions): void;
|
||||
export function ga(): any;
|
||||
export function set(fieldsObject: FieldsObject): void;
|
||||
export function send(fieldsObject: FieldsObject): void;
|
||||
export function pageview(path: string): void;
|
||||
export function modalview(name: string): void;
|
||||
export function timing(args: TimingArgs): void;
|
||||
export function event(args: EventArgs): void;
|
||||
export function set(fieldsObject: FieldsObject): void;
|
||||
export function exception(fieldsObject: FieldsObject): void;
|
||||
export const plugin: Plugin;
|
||||
export function outboundLink(args: OutboundLinkArgs, hitCallback: () => void): void;
|
||||
|
||||
@@ -19,7 +19,6 @@ describe("Testing react-ga initialize object", () => {
|
||||
describe("Testing react-ga pageview calls", () => {
|
||||
it("Able to make pageview calls", () => {
|
||||
ga.initialize("UA-65432-1");
|
||||
|
||||
ga.pageview("http://telshin.com");
|
||||
});
|
||||
});
|
||||
@@ -59,3 +58,42 @@ describe("Testing react-ga set calls", () => {
|
||||
ga.set(fieldObject);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Testing react-ga v2.1.2", () => {
|
||||
it("Able to make ga calls", () => {
|
||||
ga.ga();
|
||||
});
|
||||
it("Able to make send calls", () => {
|
||||
let fieldObject: ga.FieldsObject = {
|
||||
page: '/users'
|
||||
};
|
||||
|
||||
ga.send(fieldObject);
|
||||
});
|
||||
it("Able to make timing calls", () => {
|
||||
ga.timing({
|
||||
category: 'string',
|
||||
variable: 'string',
|
||||
value: 1,
|
||||
label: 'string'
|
||||
});
|
||||
});
|
||||
it("Able to make exception calls", () => {
|
||||
let fieldObject: ga.FieldsObject = {
|
||||
page: '/users'
|
||||
};
|
||||
ga.exception(fieldObject);
|
||||
});
|
||||
it("Able to make plugin object calls", () => {
|
||||
const execute = ga.plugin.execute;
|
||||
const require = ga.plugin.require;
|
||||
const payload = {};
|
||||
|
||||
execute('name', 'action', payload);
|
||||
execute('name', 'action', 'type', payload);
|
||||
require('name', {});
|
||||
});
|
||||
it("Able to make outboundLink calls", () => {
|
||||
ga.outboundLink({label: 'string'}, () => {});
|
||||
});
|
||||
});
|
||||
@@ -13,11 +13,10 @@
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"jsx": "react"
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-ga-tests.tsx"
|
||||
"react-ga-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user