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