@temps-sdk/react-analytics 0.0.1-beta.2 → 0.0.1-beta.3
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/dist/Provider.d.ts.map +1 -1
- package/dist/Provider.js +2 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +8 -1
- package/package.json +1 -1
package/dist/Provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../src/Provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAIlF,wBAAgB,sBAAsB,CAAC,EACrC,QAAwB,EACxB,QAAgB,EAChB,eAAsB,EACtB,kBAAyB,EACzB,QAAQ,GACT,EAAE,2BAA2B,
|
|
1
|
+
{"version":3,"file":"Provider.d.ts","sourceRoot":"","sources":["../src/Provider.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AAIlF,wBAAgB,sBAAsB,CAAC,EACrC,QAAwB,EACxB,QAAgB,EAChB,eAAsB,EACtB,kBAAyB,EACzB,QAAQ,GACT,EAAE,2BAA2B,2CAsI7B;AAED,wBAAgB,iBAAiB,IAAI,qBAAqB,CAMzD"}
|
package/dist/Provider.js
CHANGED
|
@@ -7,6 +7,8 @@ export function TempsAnalyticsProvider({ basePath = "/api/_temps", disabled = fa
|
|
|
7
7
|
const enabled = useMemo(() => {
|
|
8
8
|
if (disabled)
|
|
9
9
|
return false;
|
|
10
|
+
if (typeof window === "undefined")
|
|
11
|
+
return false;
|
|
10
12
|
if (ignoreLocalhost && (isLocalhostLike() || isTestEnvironment()))
|
|
11
13
|
return false;
|
|
12
14
|
try {
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAcjD;AAED,wBAAgB,eAAe,IAAI,OAAO,CASzC;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAY3C;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/B,MAAM,GAAE,MAAM,GAAG,KAAK,GAAG,OAAgB,EACzC,QAAQ,SAAgB,GACvB,OAAO,CAAC,IAAI,CAAC,CAoBf"}
|
package/dist/utils.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
export function getRequestId() {
|
|
3
|
+
if (typeof document === "undefined")
|
|
4
|
+
return undefined;
|
|
2
5
|
const metaElement = document.querySelector('meta[name="temps-metadata"]');
|
|
3
6
|
if (metaElement) {
|
|
4
7
|
try {
|
|
@@ -25,6 +28,8 @@ export function isLocalhostLike() {
|
|
|
25
28
|
}
|
|
26
29
|
}
|
|
27
30
|
export function isTestEnvironment() {
|
|
31
|
+
if (typeof window === "undefined")
|
|
32
|
+
return false;
|
|
28
33
|
// @ts-expect-error - non-standard globals from test frameworks
|
|
29
34
|
const isPhantom = Boolean(window._phantom);
|
|
30
35
|
// @ts-expect-error - non-standard globals from test frameworks
|
|
@@ -41,7 +46,9 @@ export async function sendAnalytics(endpoint, data, method = "POST", basePath =
|
|
|
41
46
|
const enrichedData = {
|
|
42
47
|
...data,
|
|
43
48
|
request_id: getRequestId(),
|
|
44
|
-
session_id:
|
|
49
|
+
session_id: typeof localStorage !== "undefined"
|
|
50
|
+
? localStorage.getItem("session_id") || undefined
|
|
51
|
+
: undefined,
|
|
45
52
|
};
|
|
46
53
|
await fetch(`${basePath}/${endpoint}`, {
|
|
47
54
|
method,
|