Rocky_Mountain_Vending/.pnpm-store/v10/files/f4/87304149105b021e37a5939af0089922c01ecca3da5747a1626569b87efdc9fb26d25b4752e165a80720de39eeffbcd9f0991d032b2449e42ed5514769deca
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

54 lines
1.6 KiB
Text

---
// Since this file will not be bundled by Tsup, it is referencing bundled files relative to dist/astro/
import type { AnalyticsProps } from '../index.d.ts';
type Props = Omit<AnalyticsProps, 'framework' | 'beforeSend'>;
const propsStr = JSON.stringify(Astro.props);
const paramsStr = JSON.stringify(Astro.params);
---
<vercel-analytics
data-props={propsStr}
data-params={paramsStr}
data-pathname={Astro.url.pathname}></vercel-analytics>
<script>
import { inject, pageview, computeRoute } from '../index.mjs';
function getBasePath(): string | undefined {
// !! important !!
// do not access env variables using import.meta.env[varname]
// some bundles won't replace the value at build time.
try {
return import.meta.env.PUBLIC_VERCEL_OBSERVABILITY_BASEPATH as
| string
| undefined;
} catch {
// do nothing
}
}
customElements.define(
'vercel-analytics',
class VercelAnalytics extends HTMLElement {
constructor() {
super();
try {
const props = JSON.parse(this.dataset.props ?? '{}');
const params = JSON.parse(this.dataset.params ?? '{}');
inject({
...props,
disableAutoTrack: true,
framework: 'astro',
basePath: getBasePath(),
beforeSend: window.webAnalyticsBeforeSend,
});
const path = this.dataset.pathname;
pageview({ route: computeRoute(path ?? '', params), path });
} catch (err) {
throw new Error(`Failed to parse WebAnalytics properties: ${err}`);
}
}
},
);
</script>