feat(docs-infra): support sending Google Analytics events (#25042)
PR Close #25042
This commit is contained in:
parent
d46a961509
commit
a224df43af
|
@ -74,6 +74,13 @@ describe('GaService', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('sendEvent', () => {
|
||||
it('should send "event" with associated data', () => {
|
||||
gaService.sendEvent('some source', 'some campaign', 'a label', 45);
|
||||
expect(gaSpy).toHaveBeenCalledWith('send', 'event', 'some source', 'some campaign', 'a label', 45);
|
||||
});
|
||||
});
|
||||
|
||||
it('should support replacing the `window.ga` function', () => {
|
||||
const gaSpy2 = jasmine.createSpy('new ga');
|
||||
mockWindow.ga = gaSpy2;
|
||||
|
|
|
@ -29,6 +29,10 @@ export class GaService {
|
|||
this.ga('send', 'pageview');
|
||||
}
|
||||
|
||||
sendEvent(source: string, action: string, label?: string, value?: number) {
|
||||
this.ga('send', 'event', source, action, label, value);
|
||||
}
|
||||
|
||||
ga(...args: any[]) {
|
||||
const gaFn = (this.window as any)['ga'];
|
||||
if (gaFn) {
|
||||
|
|
Loading…
Reference in New Issue