Merge pull request #11643 from ianks/react-ga-set

react-ga: add set method definition
This commit is contained in:
Yui 2016-11-07 16:07:54 -08:00 committed by GitHub
commit 191bc9e02d
2 changed files with 25 additions and 7 deletions

View File

@ -8,11 +8,11 @@ describe("Testing react-ga initialize object", () => {
});
it("Able to initailize react-ga object", () => {
let ga = __reactGA;
let options: __reactGA.InitializeOptions = {
debug: true,
}
ga.initialize("UA-65432-1", options);
});
});
@ -21,7 +21,7 @@ describe("Testing react-ga pageview calls", () => {
it("Able to make pageview calls", () => {
let ga = __reactGA;
ga.initialize("UA-65432-1");
ga.pageview("http://telshin.com");
});
});
@ -30,7 +30,7 @@ describe("Testing react-ga modal calls", () => {
it("Able to make modal calls", () => {
let ga = __reactGA;
ga.initialize("UA-65432-1");
ga.modalview("Test modal");
});
});
@ -39,7 +39,7 @@ describe("Testing react-ga event calls", () => {
it("Able to make event calls", () => {
let ga = __reactGA;
ga.initialize("UA-65432-1");
let options: __reactGA.EventArgs = {
category: "Test",
action: "CI",
@ -47,7 +47,20 @@ describe("Testing react-ga event calls", () => {
value: 4,
nonInteraction: true,
}
ga.event(options);
});
});
});
describe("Testing react-ga set calls", () => {
it("Able to make set calls", () => {
let ga = __reactGA;
ga.initialize("UA-65432-1");
let fieldObject: __reactGA.FieldsObject = {
page: '/users'
};
ga.set(fieldObject);
});
});

View File

@ -16,10 +16,15 @@ declare namespace __reactGA {
debug?: boolean;
}
export interface FieldsObject {
[i: string]: any;
}
export function initialize(trackingCode: string, options?: InitializeOptions): void;
export function pageview(path: string): void;
export function modalview(name: string): void;
export function event(args: EventArgs): void;
export function set(fieldsObject: FieldsObject): void;
}
declare module 'react-ga' {