@lukajekic/metrica-sdk 1.0.0

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.
Files changed (2) hide show
  1. package/index.js +35 -0
  2. package/package.json +12 -0
package/index.js ADDED
@@ -0,0 +1,35 @@
1
+ METRICA_BACKEND_URL = 'https://metrica-suce.onrender.com' //Do not modify
2
+
3
+ export function CreateMetricaView(APIKey) {
4
+ const path = window.location.pathname
5
+ const sessionID = window.sessionStorage.getItem()
6
+ let unique = 'false'
7
+ if (!sessionID) {
8
+ unique = 'true'
9
+ }
10
+ fetch(`${METRICA_BACKEND_URL}/metrica/pageview/track?unique=${unique}`, {
11
+ method: 'POST',
12
+ headers: {
13
+ "Content-Type": "application/json",
14
+ "x-metrica-key": APIKey,
15
+ "x-metrica-path": path
16
+ }
17
+ })
18
+ }
19
+
20
+
21
+ export function CreateMetricaEvent(APIKey, EventID) {
22
+ const sessionID = window.sessionStorage.getItem()
23
+ let unique = 'false'
24
+ if (!sessionID) {
25
+ unique = 'true'
26
+ }
27
+ fetch(`${METRICA_BACKEND_URL}/metrica/eventtrigger/track?unique=${unique}`, {
28
+ method: 'POST',
29
+ headers: {
30
+ "Content-Type": "application/json",
31
+ "x-metrica-key": APIKey,
32
+ "x-metrica-event": EventID
33
+ }
34
+ })
35
+ }
package/package.json ADDED
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "@lukajekic/metrica-sdk",
3
+ "version": "1.0.0",
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
+ "license": "ISC",
6
+ "author": "Luka Jekic",
7
+ "type": "module",
8
+ "main": "index.js",
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1"
11
+ }
12
+ }