From de619c01788b4bb39a1e985230128e5bf89c873a Mon Sep 17 00:00:00 2001 From: Nick Amoscato Date: Wed, 5 Feb 2020 03:13:46 -0500 Subject: [PATCH] fix(typescript): event type definitions (#60) --- vue-gtag.d.ts | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/vue-gtag.d.ts b/vue-gtag.d.ts index 5c5f930..708011e 100644 --- a/vue-gtag.d.ts +++ b/vue-gtag.d.ts @@ -8,10 +8,14 @@ declare module 'vue-gtag' { page_path: string; } - export interface Event { - event_category: string; - event_label: string; - value: string; + export interface EventParams { + /** string that will appear as the event category */ + event_category?: string; + /** string that will appear as the event label */ + event_label?: string; + /** non-negative integer that will appear as the event value */ + value?: number; + [key: string]: any; } export interface ScreenView { @@ -38,7 +42,16 @@ declare module 'vue-gtag' { export interface VueGtag { pageview(pageView: PageView): void; - event(action: string, event: Event): void; + + /** + * Send a Google Analytics Event. + * + * @see https://developers.google.com/analytics/devguides/collection/gtagjs/events + * + * @param action string that will appear as the event action in Google Analytics Event reports + * @param eventParams + */ + event(action: string, eventParams?: EventParams): void; screenview(screenView: ScreenView): void; customMap(map: Dictionary): void; purchase(purchase: Purchase): void;