From 9f076daf85d5598872af27d0ed7ac2e16d55caff Mon Sep 17 00:00:00 2001 From: Denis Demchenko Date: Wed, 5 Jun 2019 21:08:14 +0300 Subject: [PATCH] Make Google Analytics support correct types for _gaq.push() (#35962) It seems that `_gaq.push` can accept not only strings, but boolean and numbers as well. This commit fixes the types declarations for it according to the documentation: https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking#_trackevent --- types/google.analytics/google.analytics-tests.ts | 3 +++ types/google.analytics/index.d.ts | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/types/google.analytics/google.analytics-tests.ts b/types/google.analytics/google.analytics-tests.ts index 63ca4e5ca4..6246ef923e 100644 --- a/types/google.analytics/google.analytics-tests.ts +++ b/types/google.analytics/google.analytics-tests.ts @@ -106,6 +106,9 @@ describe("tester Google Analytics Code _gaq object", () => { _gaq.push(['_gat._anonymizeIp']); _gaq.push(['_trackPageview']); + // more details: https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiEventTracking#_trackevent + _gaq.push(['_trackEvent', 'category', 'action_name', undefined, undefined, true]); + _gaq.push(() => { const tracker = _gat._getTrackerByName('UA-65432-1'); tracker._trackPageview(); diff --git a/types/google.analytics/index.d.ts b/types/google.analytics/index.d.ts index 9f522b3b9b..4f68ca4d84 100644 --- a/types/google.analytics/index.d.ts +++ b/types/google.analytics/index.d.ts @@ -19,7 +19,7 @@ declare class Tracker { } interface GoogleAnalyticsCode { - push(commandArray: string[]): void; + push(commandArray: Array): void; push(func: Function): void; }