add op.js to public site
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
|
||||
apps/public/public/op.js
|
||||
packages/sdk/profileId.txt
|
||||
packages/sdk/test.ts
|
||||
dump.sql
|
||||
|
||||
@@ -69,6 +69,7 @@ COPY --from=prod /app/packages/db/node_modules /app/packages/db/node_modules
|
||||
# COPY --from=prod /app/packages/queue/node_modules /app/packages/queue/node_modules
|
||||
|
||||
RUN pnpm db:codegen
|
||||
RUN pnpm js:codegen
|
||||
|
||||
WORKDIR /app/apps/public
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client';
|
||||
|
||||
import { useState } from 'react';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import {
|
||||
Dialog,
|
||||
@@ -14,6 +14,14 @@ import {
|
||||
export function JoinWaitlist() {
|
||||
const [value, setValue] = useState('');
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
// @ts-ignore
|
||||
window.openpanel.event('waitlist_success');
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Dialog open={open} onOpenChange={setOpen}>
|
||||
|
||||
@@ -3,6 +3,7 @@ import { cn } from '@/utils/cn';
|
||||
import '@/styles/globals.css';
|
||||
|
||||
import type { Metadata } from 'next';
|
||||
import Script from 'next/script';
|
||||
|
||||
import { defaultMeta } from './meta';
|
||||
|
||||
@@ -23,6 +24,13 @@ export default async function RootLayout({
|
||||
<body className={cn('min-h-screen font-sans antialiased grainy')}>
|
||||
{children}
|
||||
</body>
|
||||
<Script
|
||||
src="/op.js"
|
||||
data-url="https://api.openpanel.dev"
|
||||
data-client-id="301c6dc1-424c-4bc3-9886-a8beab09b615"
|
||||
data-track-screen-views="1"
|
||||
data-track-outgoing-links="1"
|
||||
/>
|
||||
</html>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ export default function Test() {
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
mixan.event('custom_click', {
|
||||
// @ts-ignore
|
||||
window.openpanel.event('custom_click', {
|
||||
custom_string: 'test',
|
||||
custom_number: 1,
|
||||
});
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
"module": "index.ts",
|
||||
"scripts": {
|
||||
"db:codegen": "pnpm -r --filter db run codegen",
|
||||
"js:codegen": "pnpm -r --filter sdk-web run build-for-openpanel",
|
||||
"migrate": "pnpm -r --filter db run migrate",
|
||||
"migrate:deploy": "pnpm -r --filter db run migrate:deploy",
|
||||
"dev": "pnpm -r dev",
|
||||
|
||||
@@ -81,6 +81,8 @@ export class MixanWeb extends Mixan<MixanWebOptions> {
|
||||
} else {
|
||||
window.addEventListener('locationchange', () => this.screenView());
|
||||
}
|
||||
|
||||
this.screenView();
|
||||
}
|
||||
|
||||
public screenView(properties?: Record<string, unknown>): void {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
"module": "index.ts",
|
||||
"scripts": {
|
||||
"build": "rm -rf dist && tsup",
|
||||
"build-for-openpanel": "pnpm build && cp dist/cdn.global.js ../../apps/public/public/op.js",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --check \"**/*.{mjs,ts,md,json}\"",
|
||||
"typecheck": "tsc --noEmit"
|
||||
|
||||
@@ -41,11 +41,11 @@ function createApi(_url: string, clientId: string, clientSecret?: string) {
|
||||
...(options ?? {}),
|
||||
})
|
||||
.then(async (res) => {
|
||||
if (res.status !== 200) {
|
||||
if (res.status !== 200 && res.status !== 202) {
|
||||
return retry(attempt, resolve);
|
||||
}
|
||||
|
||||
const response = await res.json();
|
||||
const response = await res.text();
|
||||
|
||||
if (!response) {
|
||||
return resolve(null);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"format": ["cjs", "esm", "iife"],
|
||||
"dts": true,
|
||||
"splitting": false,
|
||||
"sourcemap": true,
|
||||
"sourcemap": false,
|
||||
"clean": true,
|
||||
"minify": true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user