This repository has been archived by the owner on Sep 7, 2024. It is now read-only.
generated from NuroDev/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
analytics.module.ts
106 lines (101 loc) · 2.75 KB
/
analytics.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { fetch } from "~/fetch";
import type {
ActivityByCountryParams,
ActivityByCountryResponse,
ActivityByDateParams,
ActivityByDateResponse,
ActivityByReadingEnvironmentParams,
ActivityByReadingEnvironmentResponse,
ActivityByUserAgentParams,
ActivityByUserAgentResponse,
} from ".";
/**
* Get Activity By Date
*
* @description Retrieve data grouped by date, based on activity
*
* @see https://developers.mailersend.com/api/v1/analytics.html#activity-data-by-date
*
* @param {String} apiKey - Unique API access token
* @param {Object} options - Activity by date options
*/
export async function activityByDate<TResponse = ActivityByDateResponse>(
apiKey: string,
options: ActivityByDateParams
): Promise<TResponse> {
const { domainId, ...params } = options;
return fetch({
apiKey,
endpoint: "/analytics/date",
json: true,
method: "GET",
params,
});
}
/**
* Get Activity By Country
*
* @description Retrieve data grouped by country, based on activity
*
* @see https://developers.mailersend.com/api/v1/analytics.html#opens-by-country
*
* @param {String} apiKey - Unique API access token
* @param {Object} options - Activity by country options
*/
export async function activityByCountry<TResponse = ActivityByCountryResponse>(
apiKey: string,
params: ActivityByCountryParams
): Promise<TResponse> {
return fetch({
apiKey,
endpoint: "/analytics/country",
json: true,
method: "GET",
params,
});
}
/**
* Get Activity By User Agent
*
* @description Retrieve data grouped by user-agent name (browser and operating system), based on activity
*
* @see https://developers.mailersend.com/api/v1/analytics.html#opens-by-user-agent-name
*
* @param {String} apiKey - Unique API access token
* @param {Object} options - Activity by user agent options
*/
export async function activityByUserAgent<
TResponse = ActivityByUserAgentResponse
>(apiKey: string, params: ActivityByUserAgentParams): Promise<TResponse> {
return fetch({
apiKey,
endpoint: "/analytics/ua-name",
json: true,
method: "GET",
params,
});
}
/**
* Get Activity By Reading Environment
*
* @description Retrieve data grouped by the reading environment (webmail, mobile, desktop), based on activity
*
* @see https://developers.mailersend.com/api/v1/analytics.html#opens-by-reading-environment
*
* @param {String} apiKey - Unique API access token
* @param {Object} options - Activity by reading environment options
*/
export async function activityByReadingEnvironment<
TResponse = ActivityByReadingEnvironmentResponse
>(
apiKey: string,
params: ActivityByReadingEnvironmentParams
): Promise<TResponse> {
return fetch({
apiKey,
endpoint: "/analytics/ua-type",
json: true,
method: "GET",
params,
});
}