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

Commit be5ec8d

Browse files
committed
feat(types): extract and export payload types for convenience
1 parent 7986a44 commit be5ec8d

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 = {
@@ -33,23 +35,27 @@ declare module 'vue-analytics' {
3335
}): void;
3436
}
3537

38+
interface SocialPayload {
39+
socialNetwork: string;
40+
socialAction: string;
41+
socialTarget: string;
42+
}
43+
3644
interface socialFn {
3745
(network: string, action: string, target: string): void;
38-
(options: {
39-
socialNetwork: string,
40-
socialAction: string,
41-
socialTarget: string
42-
}): void;
46+
(options: SocialPayload): void;
47+
}
48+
49+
interface TimePayload {
50+
timingCategory: string;
51+
timingVar: string;
52+
timingValue: number;
53+
timingLabel: string;
4354
}
4455

4556
interface timeFn {
4657
(category: string, variable: string, value: number, label: string): void;
47-
(options: {
48-
timingCategory: string,
49-
timingVar: string,
50-
timingValue: number,
51-
timingLabel: string
52-
}): void;
58+
(options: TimePayload): void;
5359
}
5460

5561
interface EcommerceItem {
@@ -156,12 +162,14 @@ declare module 'vue-analytics' {
156162
send(): void;
157163
}
158164

165+
interface ScreenViewPayload {
166+
screenName: string;
167+
[otherProperties: string]: any;
168+
}
169+
159170
interface screenviewFn {
160171
(screen: string) :void;
161-
(option: {
162-
screenName: string;
163-
[otherProperties: string]: any;
164-
}): void;
172+
(option: ScreenViewPayload): void;
165173
}
166174

167175
interface requireFn {

0 commit comments

Comments
 (0)