Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

fix: backward comp cache web script

Carl-Gerhard Lindesvärd71270b3493f3
diff --git a/apps/public/content/articles/cookieless-analytics.mdx b/apps/public/content/articles/cookieless-analytics.mdx
index 2aac0bbf9..9d1cf4d88 100644
--- a/apps/public/content/articles/cookieless-analytics.mdx
+++ b/apps/public/content/articles/cookieless-analytics.mdx
@@ -88,7 +88,7 @@ We built OpenPanel from the ground up with privacy at its heart—and with featu
```html
<script>
- window.op=window.op||function(){var n=[],o=new Proxy((function(){arguments.length>0&&n.push(Array.prototype.slice.call(arguments))}),{get:function(o,t){return"q"===t?n:function(){n.push([t].concat(Array.prototype.slice.call(arguments)))}}});return o}();
+ window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();
window.op('init', {
clientId: 'YOUR_CLIENT_ID',
trackScreenViews: true,
diff --git a/apps/public/content/docs/(tracking)/adblockers.mdx b/apps/public/content/docs/(tracking)/adblockers.mdx
index f2dc18448..862b78fd5 100644
--- a/apps/public/content/docs/(tracking)/adblockers.mdx
+++ b/apps/public/content/docs/(tracking)/adblockers.mdx
@@ -89,7 +89,7 @@ Once your proxy is running, you need to configure the OpenPanel script on your f
```html
<script>
- window.op=window.op||function(){var n=[],o=new Proxy((function(){arguments.length>0&&n.push(Array.prototype.slice.call(arguments))}),{get:function(o,t){return"q"===t?n:function(){n.push([t].concat(Array.prototype.slice.call(arguments)))}}});return o}();
+ window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();
window.op('init', {
apiUrl: 'https://api.domain.com'
clientId: 'YOUR_CLIENT_ID',
diff --git a/apps/public/content/docs/(tracking)/sdks/script.mdx b/apps/public/content/docs/(tracking)/sdks/script.mdx
index 3eda8a5d0..c039e4766 100644
--- a/apps/public/content/docs/(tracking)/sdks/script.mdx
+++ b/apps/public/content/docs/(tracking)/sdks/script.mdx
@@ -15,7 +15,7 @@ Just insert this snippet and replace `YOUR_CLIENT_ID` with your client id.
```html title="index.html" /clientId: 'YOUR_CLIENT_ID'/
<script>
- window.op=window.op||function(){var n=[],o=new Proxy((function(){arguments.length>0&&n.push(Array.prototype.slice.call(arguments))}),{get:function(o,t){return"q"===t?n:function(){n.push([t].concat(Array.prototype.slice.call(arguments)))}}});return o}();
+ window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();
window.op('init', {
clientId: 'YOUR_CLIENT_ID',
trackScreenViews: true,
diff --git a/apps/public/content/docs/get-started/install-openpanel.mdx b/apps/public/content/docs/get-started/install-openpanel.mdx
index a73922ec3..57a59b0a6 100644
--- a/apps/public/content/docs/get-started/install-openpanel.mdx
+++ b/apps/public/content/docs/get-started/install-openpanel.mdx
@@ -14,7 +14,7 @@ Simply add this script tag to your website's `<head>` section.
```html title="index.html"
<script>
- window.op=window.op||function(){var n=[],o=new Proxy((function(){arguments.length>0&&n.push(Array.prototype.slice.call(arguments))}),{get:function(o,t){return"q"===t?n:function(){n.push([t].concat(Array.prototype.slice.call(arguments)))}}});return o}();
+ window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();
window.op('init', {
clientId: 'YOUR_CLIENT_ID',
trackScreenViews: true,
diff --git a/apps/public/content/docs/self-hosting/self-hosting.mdx b/apps/public/content/docs/self-hosting/self-hosting.mdx
index 1b4ec1ffb..376bed5ff 100644
--- a/apps/public/content/docs/self-hosting/self-hosting.mdx
+++ b/apps/public/content/docs/self-hosting/self-hosting.mdx
@@ -76,7 +76,7 @@ The path should be `/api` and the domain should be your domain.
```html title="index.html"
<script>
- window.op=window.op||function(){var n=[],o=new Proxy((function(){arguments.length>0&&n.push(Array.prototype.slice.call(arguments))}),{get:function(o,t){return"q"===t?n:function(){n.push([t].concat(Array.prototype.slice.call(arguments)))}}});return o}();
+ window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();
window.op('init', {
apiUrl: 'https://your-domain.com/api', // [!code highlight]
clientId: 'YOUR_CLIENT_ID',
diff --git a/apps/start/src/components/onboarding/connect-web.tsx b/apps/start/src/components/onboarding/connect-web.tsx
index efedc1a92..440e155f1 100644
--- a/apps/start/src/components/onboarding/connect-web.tsx
+++ b/apps/start/src/components/onboarding/connect-web.tsx
@@ -24,7 +24,7 @@ const ConnectWeb = ({ client }: Props) => {
<Syntax
className="border"
code={`<script>
- window.op=window.op||function(){var n=[],o=new Proxy((function(){arguments.length>0&&n.push(Array.prototype.slice.call(arguments))}),{get:function(o,t){return"q"===t?n:function(){n.push([t].concat(Array.prototype.slice.call(arguments)))}}});return o}();
+ window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();
window.op('init', {
clientId: '${client?.id ?? 'YOUR_CLIENT_ID'}',
trackScreenViews: true,
diff --git a/packages/sdks/web/src/init-snippet.ts b/packages/sdks/web/src/init-snippet.ts
index d668cbb58..81388180d 100644
--- a/packages/sdks/web/src/init-snippet.ts
+++ b/packages/sdks/web/src/init-snippet.ts
@@ -19,5 +19,5 @@
// })();
export function getInitSnippet(): string {
- return `window.op=window.op||function(){var n=[],o=new Proxy((function(){arguments.length>0&&n.push(Array.prototype.slice.call(arguments))}),{get:function(o,t){return"q"===t?n:function(){n.push([t].concat(Array.prototype.slice.call(arguments)))}}});return o}();`;
+ return `window.op=window.op||function(){var n=[];return new Proxy(function(){arguments.length&&n.push([].slice.call(arguments))},{get:function(t,r){return"q"===r?n:function(){n.push([r].concat([].slice.call(arguments)))}} ,has:function(t,r){return"q"===r}}) }();`;
}