@temps-sdk/react-analytics 0.0.1-beta.2 → 0.0.1-beta.4

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.
@@ -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,2CAqI7B;AAED,wBAAgB,iBAAiB,IAAI,qBAAqB,CAMzD"}
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,2CAwI7B;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 {
@@ -23,6 +25,7 @@ export function TempsAnalyticsProvider({ basePath = "/api/_temps", disabled = fa
23
25
  event_name: eventName,
24
26
  request_query: window.location.search,
25
27
  request_path: window.location.pathname,
28
+ domain: window.location.hostname,
26
29
  event_data: data,
27
30
  }, "POST", basePath);
28
31
  }, [enabled, basePath]);
@@ -33,6 +36,7 @@ export function TempsAnalyticsProvider({ basePath = "/api/_temps", disabled = fa
33
36
  event_name: "pageview",
34
37
  request_query: window.location.search,
35
38
  request_path: window.location.pathname,
39
+ domain: window.location.hostname,
36
40
  event_data: {
37
41
  referrer: document.referrer,
38
42
  userAgent: navigator.userAgent,
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,wBAAgB,YAAY,IAAI,MAAM,GAAG,SAAS,CAajD;AAED,wBAAgB,eAAe,IAAI,OAAO,CASzC;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAW3C;AAED,wBAAsB,aAAa,CAClC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,EAC/B,MAAM,GAAE,MAAM,GAAG,KAAK,GAAG,OAAgB,EACzC,QAAQ,SAAgB,GACtB,OAAO,CAAC,IAAI,CAAC,CAiBf"}
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: (typeof localStorage !== "undefined" && localStorage.getItem("session_id")) || undefined,
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@temps-sdk/react-analytics",
3
- "version": "0.0.1-beta.2",
3
+ "version": "0.0.1-beta.4",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",