Skip to content
This repository was archived by the owner on Mar 21, 2025. It is now read-only.

Commit a5e4778

Browse files
Merge pull request #266 from romansp/typescript-extract-payload-types
Extract and export payload types
2 parents cc858f7 + 9e8a770 commit a5e4778

File tree

1 file changed

+29
-21
lines changed

1 file changed

+29
-21
lines changed

vue-analytics.d.ts

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@ declare module 'vue-analytics' {
44
import VueRouter, { Route } from 'vue-router';
55
import { Store } from 'vuex';
66

7+
interface EventPayload {
8+
eventCategory: string;
9+
eventAction?: string;
10+
eventLabel?: string;
11+
eventValue?: number;
12+
}
13+
714
interface eventFn {
815
(category: string, action?: string, label?: string, value?: number): void;
9-
(options: {
10-
eventCategory: string,
11-
eventAction?: string,
12-
eventLabel?: string,
13-
eventValue?: number
14-
}): void;
16+
(options: EventPayload): void;
1517
}
1618

1719
type pageDetails = {
@@ -36,23 +38,27 @@ declare module 'vue-analytics' {
3638
(options: Record<string, any>): void;
3739
}
3840

41+
interface SocialPayload {
42+
socialNetwork: string;
43+
socialAction: string;
44+
socialTarget: string;
45+
}
46+
3947
interface socialFn {
4048
(network: string, action: string, target: string): void;
41-
(options: {
42-
socialNetwork: string,
43-
socialAction: string,
44-
socialTarget: string
45-
}): void;
49+
(options: SocialPayload): void;
50+
}
51+
52+
interface TimePayload {
53+
timingCategory: string;
54+
timingVar: string;
55+
timingValue: number;
56+
timingLabel: string;
4657
}
4758

4859
interface timeFn {
4960
(category: string, variable: string, value: number, label: string): void;
50-
(options: {
51-
timingCategory: string,
52-
timingVar: string,
53-
timingValue: number,
54-
timingLabel: string
55-
}): void;
61+
(options: TimePayload): void;
5662
}
5763

5864
interface EcommerceItem {
@@ -159,12 +165,14 @@ declare module 'vue-analytics' {
159165
send(): void;
160166
}
161167

168+
interface ScreenViewPayload {
169+
screenName: string;
170+
[otherProperties: string]: any;
171+
}
172+
162173
interface screenviewFn {
163174
(screen: string) :void;
164-
(option: {
165-
screenName: string;
166-
[otherProperties: string]: any;
167-
}): void;
175+
(option: ScreenViewPayload): void;
168176
}
169177

170178
interface requireFn {

0 commit comments

Comments
 (0)