@lukajekic/metrica-sdk 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +12 -5
- package/lukajekic-metrica-sdk-1.0.1.tgz +0 -0
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
METRICA_BACKEND_URL = 'https://metrica-suce.onrender.com'
|
|
1
|
+
const METRICA_BACKEND_URL = 'https://metrica-suce.onrender.com'
|
|
2
2
|
|
|
3
3
|
export function CreateMetricaView(APIKey) {
|
|
4
4
|
const path = window.location.pathname
|
|
5
|
-
const sessionID = window.sessionStorage.getItem()
|
|
5
|
+
const sessionID = window.sessionStorage.getItem('metrica_session')
|
|
6
6
|
let unique = 'false'
|
|
7
|
+
|
|
7
8
|
if (!sessionID) {
|
|
8
9
|
unique = 'true'
|
|
10
|
+
const uuid = crypto.randomUUID()
|
|
11
|
+
window.sessionStorage.setItem('metrica_session', uuid)
|
|
9
12
|
}
|
|
13
|
+
|
|
10
14
|
fetch(`${METRICA_BACKEND_URL}/metrica/pageview/track?unique=${unique}`, {
|
|
11
15
|
method: 'POST',
|
|
12
16
|
headers: {
|
|
@@ -17,13 +21,16 @@ export function CreateMetricaView(APIKey) {
|
|
|
17
21
|
})
|
|
18
22
|
}
|
|
19
23
|
|
|
20
|
-
|
|
21
24
|
export function CreateMetricaEvent(APIKey, EventID) {
|
|
22
|
-
const sessionID = window.sessionStorage.getItem()
|
|
25
|
+
const sessionID = window.sessionStorage.getItem('metrica_session')
|
|
23
26
|
let unique = 'false'
|
|
27
|
+
|
|
24
28
|
if (!sessionID) {
|
|
25
29
|
unique = 'true'
|
|
30
|
+
const uuid = crypto.randomUUID()
|
|
31
|
+
window.sessionStorage.setItem('metrica_session', uuid)
|
|
26
32
|
}
|
|
33
|
+
|
|
27
34
|
fetch(`${METRICA_BACKEND_URL}/metrica/eventtrigger/track?unique=${unique}`, {
|
|
28
35
|
method: 'POST',
|
|
29
36
|
headers: {
|
|
@@ -32,4 +39,4 @@ export function CreateMetricaEvent(APIKey, EventID) {
|
|
|
32
39
|
"x-metrica-event": EventID
|
|
33
40
|
}
|
|
34
41
|
})
|
|
35
|
-
}
|
|
42
|
+
}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lukajekic/metrica-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Metrica SDK connects your App with Metrica Cloud's server for monitoring traffic and Events on your website. Make sure you are using Vercel for deploying your frontend.",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "Luka Jekic",
|