OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix: nextjs 16 support and web logging
Carl-Gerhard Lindesvärd7e381764223a
diff --git a/packages/sdks/nextjs/package.json b/packages/sdks/nextjs/package.jsonindex 48e4c3bd4..3f399098c 100644--- a/packages/sdks/nextjs/package.json+++ b/packages/sdks/nextjs/package.json@@ -10,7 +10,7 @@"@openpanel/web": "workspace:1.0.1-local"},"peerDependencies": {- "next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",+ "next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0 || ^16.0.0","react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0","react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"},diff --git a/packages/sdks/web/src/index.ts b/packages/sdks/web/src/index.tsindex 759398af6..911b38338 100644--- a/packages/sdks/web/src/index.ts+++ b/packages/sdks/web/src/index.ts@@ -32,6 +32,8 @@ export class OpenPanel extends OpenPanelBase {});if (!this.isServer()) {+ console.log('OpenPanel.dev - Initialized', this.options);+this.setGlobalProperties({__referrer: document.referrer,});@@ -71,14 +73,22 @@ export class OpenPanel extends OpenPanelBase {if (link && target) {const href = link.getAttribute('href');if (href?.startsWith('http')) {- super.track('link_out', {- href,- text:- link.innerText ||- link.getAttribute('title') ||- target.getAttribute('alt') ||- target.getAttribute('title'),- });+ try {+ const linkUrl = new URL(href);+ const currentHostname = window.location.hostname;+ if (linkUrl.hostname !== currentHostname) {+ super.track('link_out', {+ href,+ text:+ link.innerText ||+ link.getAttribute('title') ||+ target.getAttribute('alt') ||+ target.getAttribute('title'),+ });+ }+ } catch {+ // Invalid URL, skip tracking+ }}}});@@ -174,6 +184,7 @@ export class OpenPanel extends OpenPanelBase {}this.lastPath = path;+ console.log('OpenPanel.dev - Track page view');super.track('screen_view', {...(properties ?? {}),__path: path,