@webority/analytics 0.33.1 → 0.34.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.
package/dist/errors.js ADDED
@@ -0,0 +1 @@
1
+ import"./chunk-O2XFH626.js";var e={started:!1,posthog:null,pending:[],loadPosthog:()=>import("posthog-js")};function l({host:t}){return{api_host:t,capture_exceptions:!0,capture_pageview:!1,capture_pageleave:!1,autocapture:!1,persistence:"memory",disable_session_recording:!0,disable_surveys:!0,advanced_disable_feature_flags:!0,person_profiles:"never",save_referrer:!1}}function _({host:t,clientKey:r,product:n,surface:p,environment:s,release:c,enabled:u=!0}={}){if(!(!u||s==="Local"||e.started)){if(!t||!r||!n||!s)throw new Error("@webority/analytics: initErrorTracking needs host, clientKey, product and environment.");e.started=!0,Promise.resolve().then(e.loadPosthog).then(i=>{let o=i.default??i;o.init(r,l({host:t})),o.register(h({product:n,surface:p,environment:s,release:c})),e.posthog=o;let d=e.pending;e.pending=[];for(let[f,g]of d)a(o,f,g)}).catch(()=>{e.pending=[]})}}function E(t,r){e.started&&(e.posthog?a(e.posthog,t,r):e.pending.length<20&&e.pending.push([t,r]))}function a(t,r,n){try{t.captureException(r,n)}catch{}}function h(t){return Object.fromEntries(Object.entries(t).filter(([,r])=>r!==void 0))}function P(t=()=>import("posthog-js")){e.started=!1,e.posthog=null,e.pending=[],e.loadPosthog=t}export{l as buildErrorTrackingInitOptions,E as captureBrowserException,_ as initErrorTracking,P as resetErrorTrackingForTests};
package/dist/node.js ADDED
@@ -0,0 +1 @@
1
+ import{PostHog as s}from"posthog-node";var t={client:null,base:{},createClient:(e,r)=>new s(e,r)};function p({host:e,clientKey:r,product:n,surface:i,environment:o,release:c,enabled:u=!0,captureUncaught:f=!0}={}){if(!(!u||o==="Local"||t.client!==null)){if(!e||!r||!n||!o)throw new Error("@webority/analytics: initServerErrorTracking needs host, clientKey, product and environment.");t.client=t.createClient(r,{host:e,flushAt:1,flushInterval:0,enableExceptionAutocapture:f}),t.base=l({product:n,surface:i,environment:o,release:c})}}function a(e,{distinctId:r,path:n,method:i,statusCode:o,properties:c}={}){if(t.client)try{t.client.captureException(e,r??"server",l({...t.base,...c,path:n,$current_url:n,method:i,statusCode:o}))}catch{}}function E(){return(e,r,n,i)=>{a(e,{path:r.originalUrl,method:r.method,statusCode:e?.status??e?.statusCode??500}),i(e)}}async function x(e=2e3){if(!t.client)return;let r;await Promise.race([t.client.flush(),new Promise(n=>{r=setTimeout(n,e)})]),clearTimeout(r),t.client=null}function T(e=(r,n)=>new s(r,n)){t.client=null,t.base={},t.createClient=e}function l(e){return Object.fromEntries(Object.entries(e).filter(([,r])=>r!==void 0))}export{a as captureServerException,E as expressErrorHandler,x as flushServerErrorTracking,p as initServerErrorTracking,T as resetServerErrorTrackingForTests};
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "@webority/analytics",
3
- "version": "0.33.1",
3
+ "version": "0.34.0",
4
4
  "license": "SEE LICENSE IN LICENSE",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
8
8
  ".": "./dist/index.js",
9
9
  "./site": "./dist/site.js",
10
+ "./errors": "./dist/errors.js",
11
+ "./node": "./dist/node.js",
10
12
  "./react-native": "./dist/react-native.js",
11
13
  "./dist/webority-analytics-site.global.js": "./dist/webority-analytics-site.global.js",
12
14
  "./dist/webority-analytics-web-vitals.global.js": "./dist/webority-analytics-web-vitals.global.js"
@@ -29,12 +31,16 @@
29
31
  },
30
32
  "peerDependencies": {
31
33
  "posthog-js": "^1.417.1",
34
+ "posthog-node": "^5.61.2",
32
35
  "posthog-react-native": "^4.80.0"
33
36
  },
34
37
  "peerDependenciesMeta": {
35
38
  "posthog-js": {
36
39
  "optional": true
37
40
  },
41
+ "posthog-node": {
42
+ "optional": true
43
+ },
38
44
  "posthog-react-native": {
39
45
  "optional": true
40
46
  }
@@ -43,6 +49,7 @@
43
49
  "@biomejs/biome": "2.5.8",
44
50
  "esbuild": "0.28.2",
45
51
  "posthog-js": "1.417.1",
52
+ "posthog-node": "5.61.2",
46
53
  "web-vitals": "6.2.3"
47
54
  },
48
55
  "module": "dist/index.js",
@@ -54,11 +61,11 @@
54
61
  }
55
62
  },
56
63
  "scripts": {
57
- "build": "node -e \"require(\\\"node:fs\\\").rmSync(\\\"dist\\\",{recursive:true,force:true})\" && esbuild src/index.js src/site.js --bundle --splitting --format=esm --external:posthog-js --target=es2020 --minify --outdir=dist && esbuild src/site.js --bundle --format=iife --global-name=WeborityAnalytics --alias:posthog-js=./src/site-posthog-snippet.js --conditions=webority-site-global --target=es2020 --minify --outfile=dist/webority-analytics-site.global.js && esbuild src/web-vitals-global.js --bundle --format=iife --global-name=WeborityAnalyticsWebVitals --target=es2020 --minify --outfile=dist/webority-analytics-web-vitals.global.js && esbuild src/react-native/index.js --bundle --format=esm --external:posthog-react-native --target=es2020 --minify --outfile=dist/react-native.js && esbuild src/catalogue/check-events.js src/catalogue/generate-events.js --bundle --platform=node --format=esm --target=node20 --minify --outdir=dist && node -e \"for (const f of [\\\"fleet-tracking-plan.json\\\", \\\"tracking-plan.schema.json\\\"]) require(\\\"node:fs\\\").copyFileSync(\\\"src/catalogue/\\\" + f, \\\"dist/\\\" + f)\"",
64
+ "build": "node -e \"require(\\\"node:fs\\\").rmSync(\\\"dist\\\",{recursive:true,force:true})\" && esbuild src/index.js src/site.js src/errors.js --bundle --splitting --format=esm --external:posthog-js --target=es2020 --minify --outdir=dist && esbuild src/site.js --bundle --format=iife --global-name=WeborityAnalytics --alias:posthog-js=./src/site-posthog-snippet.js --conditions=webority-site-global --target=es2020 --minify --outfile=dist/webority-analytics-site.global.js && esbuild src/web-vitals-global.js --bundle --format=iife --global-name=WeborityAnalyticsWebVitals --target=es2020 --minify --outfile=dist/webority-analytics-web-vitals.global.js && esbuild src/react-native/index.js --bundle --format=esm --external:posthog-react-native --target=es2020 --minify --outfile=dist/react-native.js && esbuild src/node/index.js --bundle --platform=node --format=esm --external:posthog-node --target=node20 --minify --outfile=dist/node.js && esbuild src/catalogue/check-events.js src/catalogue/generate-events.js --bundle --platform=node --format=esm --target=node20 --minify --outdir=dist && node -e \"for (const f of [\\\"fleet-tracking-plan.json\\\", \\\"tracking-plan.schema.json\\\"]) require(\\\"node:fs\\\").copyFileSync(\\\"src/catalogue/\\\" + f, \\\"dist/\\\" + f)\"",
58
65
  "lint": "biome lint ./src ./test",
59
66
  "format": "biome format --write ./src ./test",
60
67
  "check": "biome check ./src ./test",
61
- "test": "node test/smoke.mjs && node test/site.mjs && node test/react-native.mjs && node test/url-scrub.mjs && node test/web-vitals.mjs && node test/tours.mjs && node test/catalogue.mjs && node src/catalogue/generate-events.js --plan src/catalogue/fleet-tracking-plan.json --cs ../Webority.Analytics/FleetEventCatalogue.g.cs --cs-namespace Webority.Analytics --cs-class FleetEventCatalogue --cs-internal --check && pnpm run --silent build && node test/bundle.mjs",
68
+ "test": "node test/smoke.mjs && node test/site.mjs && node test/errors.mjs && node test/react-native.mjs && node test/url-scrub.mjs && node test/web-vitals.mjs && node test/tours.mjs && node test/catalogue.mjs && node src/catalogue/generate-events.js --plan src/catalogue/fleet-tracking-plan.json --cs ../Webority.Analytics/FleetEventCatalogue.g.cs --cs-namespace Webority.Analytics --cs-class FleetEventCatalogue --cs-internal --check && pnpm run --silent build && node test/bundle.mjs",
62
69
  "catalogue:generate": "node src/catalogue/generate-events.js --plan src/catalogue/fleet-tracking-plan.json --cs ../Webority.Analytics/FleetEventCatalogue.g.cs --cs-namespace Webority.Analytics --cs-class FleetEventCatalogue --cs-internal"
63
70
  }
64
71
  }