-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
71 lines (66 loc) · 1.6 KB
/
index.js
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
// The following APIs and libraries are available at runtime:
// * [email protected] as AWS
// * [email protected] as atob
// * [email protected] as btoa
// * crypto as crypto
// * [email protected] as FormData
// * [email protected] as OAuth
// * [email protected] as xml
// * [email protected] as _
// * [email protected] as fetch
const trackEndpoint = "https://api.june.so/api/track";
const pageEndpoint = "https://api.june.so/api/page";
const identifyEndpoint = "https://api.june.so/api/identify";
const groupEndpoint = "https://api.june.so/api/group";
/**
* Handle track event
*/
async function onTrack(event, settings) {
await fetch(trackEndpoint, {
method: "POST",
headers: {
Authorization: `Basic ${settings.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(event),
});
}
/**
* Handle identify event
*/
async function onIdentify(event, settings) {
await fetch(identifyEndpoint, {
method: "POST",
headers: {
Authorization: `Basic ${settings.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(event),
});
}
/**
* Handle group event
*/
async function onGroup(event, settings) {
await fetch(groupEndpoint, {
method: "POST",
headers: {
Authorization: `Basic ${settings.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(event),
});
}
/**
* Handle page event
*/
async function onPage(event, settings) {
await fetch(pageEndpoint, {
method: "POST",
headers: {
Authorization: `Basic ${settings.apiKey}`,
"Content-Type": "application/json",
},
body: JSON.stringify(event),
});
}