From 3ebd677788069b6dc75dd631709d0e0635fee97c Mon Sep 17 00:00:00 2001 From: devrnt Date: Sat, 8 Feb 2025 11:07:16 +0100 Subject: [PATCH 1/5] Add nextjs app router example --- .../{nextjs => nextjs-app-router}/.gitignore | 0 apps/examples/nextjs-app-router/README.md | 3 + .../nextjs-app-router/app/intercom.jsx | 17 ++ .../examples/nextjs-app-router/app/layout.jsx | 13 ++ apps/examples/nextjs-app-router/app/page.jsx | 13 ++ apps/examples/nextjs-app-router/package.json | 16 ++ .../nextjs-app-router/sandbox.config.json | 6 + apps/examples/nextjs-page-router/.gitignore | 34 ++++ .../{nextjs => nextjs-page-router}/README.md | 2 +- .../package.json | 2 +- .../pages/_app.js | 0 .../pages/api/hello.js | 0 .../pages/index.js | 0 .../public/favicon.ico | Bin .../public/vercel.svg | 0 .../sandbox.config.json | 0 .../styles/Home.module.css | 0 .../styles/globals.css | 0 pnpm-lock.yaml | 169 +++++++++++++++++- 19 files changed, 272 insertions(+), 3 deletions(-) rename apps/examples/{nextjs => nextjs-app-router}/.gitignore (100%) create mode 100644 apps/examples/nextjs-app-router/README.md create mode 100644 apps/examples/nextjs-app-router/app/intercom.jsx create mode 100644 apps/examples/nextjs-app-router/app/layout.jsx create mode 100644 apps/examples/nextjs-app-router/app/page.jsx create mode 100644 apps/examples/nextjs-app-router/package.json create mode 100644 apps/examples/nextjs-app-router/sandbox.config.json create mode 100644 apps/examples/nextjs-page-router/.gitignore rename apps/examples/{nextjs => nextjs-page-router}/README.md (54%) rename apps/examples/{nextjs => nextjs-page-router}/package.json (86%) rename apps/examples/{nextjs => nextjs-page-router}/pages/_app.js (100%) rename apps/examples/{nextjs => nextjs-page-router}/pages/api/hello.js (100%) rename apps/examples/{nextjs => nextjs-page-router}/pages/index.js (100%) rename apps/examples/{nextjs => nextjs-page-router}/public/favicon.ico (100%) rename apps/examples/{nextjs => nextjs-page-router}/public/vercel.svg (100%) rename apps/examples/{nextjs => nextjs-page-router}/sandbox.config.json (100%) rename apps/examples/{nextjs => nextjs-page-router}/styles/Home.module.css (100%) rename apps/examples/{nextjs => nextjs-page-router}/styles/globals.css (100%) diff --git a/apps/examples/nextjs/.gitignore b/apps/examples/nextjs-app-router/.gitignore similarity index 100% rename from apps/examples/nextjs/.gitignore rename to apps/examples/nextjs-app-router/.gitignore diff --git a/apps/examples/nextjs-app-router/README.md b/apps/examples/nextjs-app-router/README.md new file mode 100644 index 00000000..800689a4 --- /dev/null +++ b/apps/examples/nextjs-app-router/README.md @@ -0,0 +1,3 @@ +# react-use-intercom in NextJS (App Router) + +Replace `INTERCOM_APP_ID` with your Intercom app id. \ No newline at end of file diff --git a/apps/examples/nextjs-app-router/app/intercom.jsx b/apps/examples/nextjs-app-router/app/intercom.jsx new file mode 100644 index 00000000..c412a3c7 --- /dev/null +++ b/apps/examples/nextjs-app-router/app/intercom.jsx @@ -0,0 +1,17 @@ +'use client'; + +import { IntercomProvider } from 'react-use-intercom'; + +const INTERCOM_APP_ID = 'jcabc7e3'; + +export function OurIntercomProvider({ children }) { + return ( + + + + {children} + + + + ); +} diff --git a/apps/examples/nextjs-app-router/app/layout.jsx b/apps/examples/nextjs-app-router/app/layout.jsx new file mode 100644 index 00000000..89942847 --- /dev/null +++ b/apps/examples/nextjs-app-router/app/layout.jsx @@ -0,0 +1,13 @@ +import { OurIntercomProvider } from './intercom'; + +export default function RootLayout({ children }) { + return ( + + + + {children} + + + + ); +} \ No newline at end of file diff --git a/apps/examples/nextjs-app-router/app/page.jsx b/apps/examples/nextjs-app-router/app/page.jsx new file mode 100644 index 00000000..b6a7206d --- /dev/null +++ b/apps/examples/nextjs-app-router/app/page.jsx @@ -0,0 +1,13 @@ +'use client'; + +import { useIntercom } from "react-use-intercom"; + +export default function Home() { + const { boot } = useIntercom(); + + return ( +
+ +
+ ); +} \ No newline at end of file diff --git a/apps/examples/nextjs-app-router/package.json b/apps/examples/nextjs-app-router/package.json new file mode 100644 index 00000000..2f23607e --- /dev/null +++ b/apps/examples/nextjs-app-router/package.json @@ -0,0 +1,16 @@ +{ + "name": "nextjs-app-router-example", + "version": "0.1.0", + "private": true, + "scripts": { + "dev": "next dev --port 3001", + "build": "next build", + "start": "next start" + }, + "dependencies": { + "next": "^14.0.0", + "react": "^18.2.0", + "react-dom": "^18.2.0", + "react-use-intercom": "workspace:*" + } +} \ No newline at end of file diff --git a/apps/examples/nextjs-app-router/sandbox.config.json b/apps/examples/nextjs-app-router/sandbox.config.json new file mode 100644 index 00000000..8ff86f74 --- /dev/null +++ b/apps/examples/nextjs-app-router/sandbox.config.json @@ -0,0 +1,6 @@ +{ + "container": { + "port": 3001, + "startScript": "dev" + } +} diff --git a/apps/examples/nextjs-page-router/.gitignore b/apps/examples/nextjs-page-router/.gitignore new file mode 100644 index 00000000..1437c53f --- /dev/null +++ b/apps/examples/nextjs-page-router/.gitignore @@ -0,0 +1,34 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# local env files +.env.local +.env.development.local +.env.test.local +.env.production.local + +# vercel +.vercel diff --git a/apps/examples/nextjs/README.md b/apps/examples/nextjs-page-router/README.md similarity index 54% rename from apps/examples/nextjs/README.md rename to apps/examples/nextjs-page-router/README.md index 4f74ba64..35fbb25e 100644 --- a/apps/examples/nextjs/README.md +++ b/apps/examples/nextjs-page-router/README.md @@ -1,3 +1,3 @@ -# react-use-intercom in NextJS +# react-use-intercom in NextJS (Page Router) Replace `INTERCOM_APP_ID` with your Intercom app id. diff --git a/apps/examples/nextjs/package.json b/apps/examples/nextjs-page-router/package.json similarity index 86% rename from apps/examples/nextjs/package.json rename to apps/examples/nextjs-page-router/package.json index 49b5ae59..cdc1160d 100644 --- a/apps/examples/nextjs/package.json +++ b/apps/examples/nextjs-page-router/package.json @@ -1,6 +1,6 @@ { "private": true, - "name": "nextjs-example", + "name": "nextjs-page-router-example", "scripts": { "dev": "next dev", "build": "next build", diff --git a/apps/examples/nextjs/pages/_app.js b/apps/examples/nextjs-page-router/pages/_app.js similarity index 100% rename from apps/examples/nextjs/pages/_app.js rename to apps/examples/nextjs-page-router/pages/_app.js diff --git a/apps/examples/nextjs/pages/api/hello.js b/apps/examples/nextjs-page-router/pages/api/hello.js similarity index 100% rename from apps/examples/nextjs/pages/api/hello.js rename to apps/examples/nextjs-page-router/pages/api/hello.js diff --git a/apps/examples/nextjs/pages/index.js b/apps/examples/nextjs-page-router/pages/index.js similarity index 100% rename from apps/examples/nextjs/pages/index.js rename to apps/examples/nextjs-page-router/pages/index.js diff --git a/apps/examples/nextjs/public/favicon.ico b/apps/examples/nextjs-page-router/public/favicon.ico similarity index 100% rename from apps/examples/nextjs/public/favicon.ico rename to apps/examples/nextjs-page-router/public/favicon.ico diff --git a/apps/examples/nextjs/public/vercel.svg b/apps/examples/nextjs-page-router/public/vercel.svg similarity index 100% rename from apps/examples/nextjs/public/vercel.svg rename to apps/examples/nextjs-page-router/public/vercel.svg diff --git a/apps/examples/nextjs/sandbox.config.json b/apps/examples/nextjs-page-router/sandbox.config.json similarity index 100% rename from apps/examples/nextjs/sandbox.config.json rename to apps/examples/nextjs-page-router/sandbox.config.json diff --git a/apps/examples/nextjs/styles/Home.module.css b/apps/examples/nextjs-page-router/styles/Home.module.css similarity index 100% rename from apps/examples/nextjs/styles/Home.module.css rename to apps/examples/nextjs-page-router/styles/Home.module.css diff --git a/apps/examples/nextjs/styles/globals.css b/apps/examples/nextjs-page-router/styles/globals.css similarity index 100% rename from apps/examples/nextjs/styles/globals.css rename to apps/examples/nextjs-page-router/styles/globals.css diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 1e9106e7..f44a75c4 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -57,7 +57,22 @@ importers: specifier: workspace:* version: link:../../../packages/react-use-intercom - apps/examples/nextjs: + apps/examples/nextjs-app-router: + dependencies: + next: + specifier: ^14.0.0 + version: 14.2.23(react-dom@18.3.1(react@18.3.1))(react@18.3.1) + react: + specifier: ^18.2.0 + version: 18.3.1 + react-dom: + specifier: ^18.2.0 + version: 18.3.1(react@18.3.1) + react-use-intercom: + specifier: workspace:* + version: link:../../../packages/react-use-intercom + + apps/examples/nextjs-page-router: dependencies: next: specifier: 13.4.7 @@ -1644,60 +1659,117 @@ packages: '@next/env@13.4.7': resolution: {integrity: sha512-ZlbiFulnwiFsW9UV1ku1OvX/oyIPLtMk9p/nnvDSwI0s7vSoZdRtxXNsaO+ZXrLv/pMbXVGq4lL8TbY9iuGmVw==} + '@next/env@14.2.23': + resolution: {integrity: sha512-CysUC9IO+2Bh0omJ3qrb47S8DtsTKbFidGm6ow4gXIG6reZybqxbkH2nhdEm1tC8SmgzDdpq3BIML0PWsmyUYA==} + '@next/swc-darwin-arm64@13.4.7': resolution: {integrity: sha512-VZTxPv1b59KGiv/pZHTO5Gbsdeoxcj2rU2cqJu03btMhHpn3vwzEK0gUSVC/XW96aeGO67X+cMahhwHzef24/w==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] + '@next/swc-darwin-arm64@14.2.23': + resolution: {integrity: sha512-WhtEntt6NcbABA8ypEoFd3uzq5iAnrl9AnZt9dXdO+PZLACE32z3a3qA5OoV20JrbJfSJ6Sd6EqGZTrlRnGxQQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + '@next/swc-darwin-x64@13.4.7': resolution: {integrity: sha512-gO2bw+2Ymmga+QYujjvDz9955xvYGrWofmxTq7m70b9pDPvl7aDFABJOZ2a8SRCuSNB5mXU8eTOmVVwyp/nAew==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] + '@next/swc-darwin-x64@14.2.23': + resolution: {integrity: sha512-vwLw0HN2gVclT/ikO6EcE+LcIN+0mddJ53yG4eZd0rXkuEr/RnOaMH8wg/sYl5iz5AYYRo/l6XX7FIo6kwbw1Q==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + '@next/swc-linux-arm64-gnu@13.4.7': resolution: {integrity: sha512-6cqp3vf1eHxjIDhEOc7Mh/s8z1cwc/l5B6ZNkOofmZVyu1zsbEM5Hmx64s12Rd9AYgGoiCz4OJ4M/oRnkE16/Q==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + '@next/swc-linux-arm64-gnu@14.2.23': + resolution: {integrity: sha512-uuAYwD3At2fu5CH1wD7FpP87mnjAv4+DNvLaR9kiIi8DLStWSW304kF09p1EQfhcbUI1Py2vZlBO2VaVqMRtpg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + '@next/swc-linux-arm64-musl@13.4.7': resolution: {integrity: sha512-T1kD2FWOEy5WPidOn1si0rYmWORNch4a/NR52Ghyp4q7KyxOCuiOfZzyhVC5tsLIBDH3+cNdB5DkD9afpNDaOw==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] + '@next/swc-linux-arm64-musl@14.2.23': + resolution: {integrity: sha512-Mm5KHd7nGgeJ4EETvVgFuqKOyDh+UMXHXxye6wRRFDr4FdVRI6YTxajoV2aHE8jqC14xeAMVZvLqYqS7isHL+g==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + '@next/swc-linux-x64-gnu@13.4.7': resolution: {integrity: sha512-zaEC+iEiAHNdhl6fuwl0H0shnTzQoAoJiDYBUze8QTntE/GNPfTYpYboxF5LRYIjBwETUatvE0T64W6SKDipvg==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + '@next/swc-linux-x64-gnu@14.2.23': + resolution: {integrity: sha512-Ybfqlyzm4sMSEQO6lDksggAIxnvWSG2cDWnG2jgd+MLbHYn2pvFA8DQ4pT2Vjk3Cwrv+HIg7vXJ8lCiLz79qoQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + '@next/swc-linux-x64-musl@13.4.7': resolution: {integrity: sha512-X6r12F8d8SKAtYJqLZBBMIwEqcTRvUdVm+xIq+l6pJqlgT2tNsLLf2i5Cl88xSsIytBICGsCNNHd+siD2fbWBA==} engines: {node: '>= 10'} cpu: [x64] os: [linux] + '@next/swc-linux-x64-musl@14.2.23': + resolution: {integrity: sha512-OSQX94sxd1gOUz3jhhdocnKsy4/peG8zV1HVaW6DLEbEmRRtUCUQZcKxUD9atLYa3RZA+YJx+WZdOnTkDuNDNA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + '@next/swc-win32-arm64-msvc@13.4.7': resolution: {integrity: sha512-NPnmnV+vEIxnu6SUvjnuaWRglZzw4ox5n/MQTxeUhb5iwVWFedolPFebMNwgrWu4AELwvTdGtWjqof53AiWHcw==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] + '@next/swc-win32-arm64-msvc@14.2.23': + resolution: {integrity: sha512-ezmbgZy++XpIMTcTNd0L4k7+cNI4ET5vMv/oqNfTuSXkZtSA9BURElPFyarjjGtRgZ9/zuKDHoMdZwDZIY3ehQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + '@next/swc-win32-ia32-msvc@13.4.7': resolution: {integrity: sha512-6Hxijm6/a8XqLQpOOf/XuwWRhcuc/g4rBB2oxjgCMuV9Xlr2bLs5+lXyh8w9YbAUMYR3iC9mgOlXbHa79elmXw==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] + '@next/swc-win32-ia32-msvc@14.2.23': + resolution: {integrity: sha512-zfHZOGguFCqAJ7zldTKg4tJHPJyJCOFhpoJcVxKL9BSUHScVDnMdDuOU1zPPGdOzr/GWxbhYTjyiEgLEpAoFPA==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + '@next/swc-win32-x64-msvc@13.4.7': resolution: {integrity: sha512-sW9Yt36Db1nXJL+mTr2Wo0y+VkPWeYhygvcHj1FF0srVtV+VoDjxleKtny21QHaG05zdeZnw2fCtf2+dEqgwqA==} engines: {node: '>= 10'} cpu: [x64] os: [win32] + '@next/swc-win32-x64-msvc@14.2.23': + resolution: {integrity: sha512-xCtq5BD553SzOgSZ7UH5LH+OATQihydObTrCTvVzOro8QiWYKdBVwcB2Mn2MLMo6DGW9yH1LSPw7jS7HhgJgjw==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + '@nicolo-ribaudo/eslint-scope-5-internals@5.1.1-v1': resolution: {integrity: sha512-54/JRvkLIzzDWshCWfuhadfrfZVPiElY8Fcgmg1HroEly/EDSszzhBAsarCux+D/kOslTRquNzuyGSmUSTTHGg==} @@ -2121,6 +2193,9 @@ packages: '@socket.io/component-emitter@3.1.2': resolution: {integrity: sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA==} + '@swc/counter@0.1.3': + resolution: {integrity: sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==} + '@swc/helpers@0.4.14': resolution: {integrity: sha512-4C7nX/dvpzB7za4Ql9K81xK3HPxCpHMgwTZVyf+9JQ6VUbn9jjZVN7/Nkdz/Ugzs2CSjqnL/UPXroiVBVHUWUw==} @@ -2130,6 +2205,9 @@ packages: '@swc/helpers@0.5.1': resolution: {integrity: sha512-sJ902EfIzn1Fa+qYmjdQqh8tPsoxyBz+8yBKC2HKUxyezKJFwPGOn7pv4WY6QuQW//ySQi5lJjA/ZT9sNWWNTg==} + '@swc/helpers@0.5.5': + resolution: {integrity: sha512-KGYxvIOXcceOAbEk4bi/dVLEK9z8sZ0uBB3Il5b1rhfClSpcX0yfRO0KmTkqR2cnQDymwLB+25ZyMzICg/cm/A==} + '@szmarczak/http-timer@4.0.6': resolution: {integrity: sha512-4BAffykYOgO+5nzBWYwE3W90sBgLJoUPRWWcL8wlyiM8IB8ipJz3UMJ9KXQd1RKQXpKp8Tutn80HZtWsu2u76w==} engines: {node: '>=10'} @@ -5864,6 +5942,24 @@ packages: sass: optional: true + next@14.2.23: + resolution: {integrity: sha512-mjN3fE6u/tynneLiEg56XnthzuYw+kD7mCujgVqioxyPqbmiotUCGJpIZGS/VaPg3ZDT1tvWxiVyRzeqJFm/kw==} + engines: {node: '>=18.17.0'} + hasBin: true + peerDependencies: + '@opentelemetry/api': ^1.1.0 + '@playwright/test': ^1.41.2 + react: ^18.2.0 + react-dom: ^18.2.0 + sass: ^1.3.0 + peerDependenciesMeta: + '@opentelemetry/api': + optional: true + '@playwright/test': + optional: true + sass: + optional: true + no-case@3.0.4: resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} @@ -6459,6 +6555,10 @@ packages: resolution: {integrity: sha512-E398TUmfAYFPBSdzgeieK2Y1+1cpdxJx8yXbK/m57nRhKSmk1GB2tO4lbLBtlkfPQTDKfe4Xqv1ASWPpayPEig==} engines: {node: ^10 || ^12 || >=14} + postcss@8.4.31: + resolution: {integrity: sha512-PS08Iboia9mts/2ygV3eLpY5ghnUcfLV/EXTOW1E2qYxJKGGBUtNjN76FYHnMs36RmARn41bC0AZmn+rR0OVpQ==} + engines: {node: ^10 || ^12 || >=14} + postcss@8.5.1: resolution: {integrity: sha512-6oz2beyjc5VMn/KV1pPw8fliQkhBXrVn1Z3TVyqZxU8kZpzEKhBdmCFqI6ZbmGtamQvQGuU1sgPTk8ZrXDD7jQ==} engines: {node: ^10 || ^12 || >=14} @@ -9870,33 +9970,62 @@ snapshots: '@next/env@13.4.7': {} + '@next/env@14.2.23': {} + '@next/swc-darwin-arm64@13.4.7': optional: true + '@next/swc-darwin-arm64@14.2.23': + optional: true + '@next/swc-darwin-x64@13.4.7': optional: true + '@next/swc-darwin-x64@14.2.23': + optional: true + '@next/swc-linux-arm64-gnu@13.4.7': optional: true + '@next/swc-linux-arm64-gnu@14.2.23': + optional: true + '@next/swc-linux-arm64-musl@13.4.7': optional: true + '@next/swc-linux-arm64-musl@14.2.23': + optional: true + '@next/swc-linux-x64-gnu@13.4.7': optional: true + '@next/swc-linux-x64-gnu@14.2.23': + optional: true + '@next/swc-linux-x64-musl@13.4.7': optional: true + '@next/swc-linux-x64-musl@14.2.23': + optional: true + '@next/swc-win32-arm64-msvc@13.4.7': optional: true + '@next/swc-win32-arm64-msvc@14.2.23': + optional: true + '@next/swc-win32-ia32-msvc@13.4.7': optional: true + '@next/swc-win32-ia32-msvc@14.2.23': + optional: true + '@next/swc-win32-x64-msvc@13.4.7': optional: true + '@next/swc-win32-x64-msvc@14.2.23': + optional: true + '@nicolo-ribaudo/eslint-scope-5-internals@5.1.1-v1': dependencies: eslint-scope: 5.1.1 @@ -10359,6 +10488,8 @@ snapshots: '@socket.io/component-emitter@3.1.2': {} + '@swc/counter@0.1.3': {} + '@swc/helpers@0.4.14': dependencies: tslib: 2.8.1 @@ -10372,6 +10503,11 @@ snapshots: dependencies: tslib: 2.8.1 + '@swc/helpers@0.5.5': + dependencies: + '@swc/counter': 0.1.3 + tslib: 2.8.1 + '@szmarczak/http-timer@4.0.6': dependencies: defer-to-connect: 2.0.1 @@ -15224,6 +15360,31 @@ snapshots: - '@babel/core' - babel-plugin-macros + next@14.2.23(react-dom@18.3.1(react@18.3.1))(react@18.3.1): + dependencies: + '@next/env': 14.2.23 + '@swc/helpers': 0.5.5 + busboy: 1.6.0 + caniuse-lite: 1.0.30001698 + graceful-fs: 4.2.11 + postcss: 8.4.31 + react: 18.3.1 + react-dom: 18.3.1(react@18.3.1) + styled-jsx: 5.1.1(react@18.3.1) + optionalDependencies: + '@next/swc-darwin-arm64': 14.2.23 + '@next/swc-darwin-x64': 14.2.23 + '@next/swc-linux-arm64-gnu': 14.2.23 + '@next/swc-linux-arm64-musl': 14.2.23 + '@next/swc-linux-x64-gnu': 14.2.23 + '@next/swc-linux-x64-musl': 14.2.23 + '@next/swc-win32-arm64-msvc': 14.2.23 + '@next/swc-win32-ia32-msvc': 14.2.23 + '@next/swc-win32-x64-msvc': 14.2.23 + transitivePeerDependencies: + - '@babel/core' + - babel-plugin-macros + no-case@3.0.4: dependencies: lower-case: 2.0.2 @@ -15758,6 +15919,12 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.1 + postcss@8.4.31: + dependencies: + nanoid: 3.3.8 + picocolors: 1.1.1 + source-map-js: 1.2.1 + postcss@8.5.1: dependencies: nanoid: 3.3.8 From 6765371d996a15b74ff98cb4635ee80c0fc70542 Mon Sep 17 00:00:00 2001 From: devrnt Date: Sat, 8 Feb 2025 11:19:13 +0100 Subject: [PATCH 2/5] Drop workspace protocol in examples Tweak the pnpm config, so it first looks for local packages and fallback to remote registry --- .npmrc | 2 ++ apps/examples/README.md | 5 +++++ apps/examples/gatsby/package.json | 2 +- apps/examples/gatsby/sandbox.config.json | 5 ----- apps/examples/nextjs-app-router/package.json | 2 +- apps/examples/nextjs-app-router/sandbox.config.json | 6 ------ apps/examples/nextjs-page-router/package.json | 2 +- apps/examples/nextjs-page-router/sandbox.config.json | 6 ------ pnpm-lock.yaml | 6 +++--- 9 files changed, 13 insertions(+), 23 deletions(-) create mode 100644 apps/examples/README.md delete mode 100644 apps/examples/gatsby/sandbox.config.json delete mode 100644 apps/examples/nextjs-app-router/sandbox.config.json delete mode 100644 apps/examples/nextjs-page-router/sandbox.config.json diff --git a/.npmrc b/.npmrc index 0b2bb043..10fedb0c 100644 --- a/.npmrc +++ b/.npmrc @@ -1,2 +1,4 @@ auto-install-peers = true node-linker=hoisted +# This allows us to use workspace packages if available, otherwise pull from the remote registry +link-workspace-packages = true \ No newline at end of file diff --git a/apps/examples/README.md b/apps/examples/README.md new file mode 100644 index 00000000..21995331 --- /dev/null +++ b/apps/examples/README.md @@ -0,0 +1,5 @@ +# Examples + +* [gatsby](https://stackblitz.com/github/devrnt/react-use-intercom/tree/main/apps/examples/gatsby) +* [nextjs-page-router](https://stackblitz.com/github/devrnt/react-use-intercom/tree/main/apps/examples/nextjs-page-router) +* [nextjs-app-router](https://stackblitz.com/github/devrnt/react-use-intercom/tree/main/apps/examples/nextjs-app-router) \ No newline at end of file diff --git a/apps/examples/gatsby/package.json b/apps/examples/gatsby/package.json index 0669ad07..ec72a6b5 100644 --- a/apps/examples/gatsby/package.json +++ b/apps/examples/gatsby/package.json @@ -16,6 +16,6 @@ "gatsby": "^5.5.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-use-intercom": "workspace:*" + "react-use-intercom": "*" } } diff --git a/apps/examples/gatsby/sandbox.config.json b/apps/examples/gatsby/sandbox.config.json deleted file mode 100644 index d2e8a952..00000000 --- a/apps/examples/gatsby/sandbox.config.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "container": { - "port": 8000 - } -} \ No newline at end of file diff --git a/apps/examples/nextjs-app-router/package.json b/apps/examples/nextjs-app-router/package.json index 2f23607e..d0bd0ef3 100644 --- a/apps/examples/nextjs-app-router/package.json +++ b/apps/examples/nextjs-app-router/package.json @@ -11,6 +11,6 @@ "next": "^14.0.0", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-use-intercom": "workspace:*" + "react-use-intercom": "*" } } \ No newline at end of file diff --git a/apps/examples/nextjs-app-router/sandbox.config.json b/apps/examples/nextjs-app-router/sandbox.config.json deleted file mode 100644 index 8ff86f74..00000000 --- a/apps/examples/nextjs-app-router/sandbox.config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "container": { - "port": 3001, - "startScript": "dev" - } -} diff --git a/apps/examples/nextjs-page-router/package.json b/apps/examples/nextjs-page-router/package.json index cdc1160d..76e7c3ea 100644 --- a/apps/examples/nextjs-page-router/package.json +++ b/apps/examples/nextjs-page-router/package.json @@ -10,6 +10,6 @@ "next": "13.4.7", "react": "^18.2.0", "react-dom": "^18.2.0", - "react-use-intercom": "workspace:*" + "react-use-intercom": "*" } } diff --git a/apps/examples/nextjs-page-router/sandbox.config.json b/apps/examples/nextjs-page-router/sandbox.config.json deleted file mode 100644 index f693d213..00000000 --- a/apps/examples/nextjs-page-router/sandbox.config.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "container": { - "port": 3000, - "startScript": "dev" - } -} diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f44a75c4..6c392c62 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -54,7 +54,7 @@ importers: specifier: ^18.2.0 version: 18.3.1(react@18.3.1) react-use-intercom: - specifier: workspace:* + specifier: '*' version: link:../../../packages/react-use-intercom apps/examples/nextjs-app-router: @@ -69,7 +69,7 @@ importers: specifier: ^18.2.0 version: 18.3.1(react@18.3.1) react-use-intercom: - specifier: workspace:* + specifier: '*' version: link:../../../packages/react-use-intercom apps/examples/nextjs-page-router: @@ -84,7 +84,7 @@ importers: specifier: ^18.2.0 version: 18.3.1(react@18.3.1) react-use-intercom: - specifier: workspace:* + specifier: '*' version: link:../../../packages/react-use-intercom apps/playground: From 8dc1694530462a5626cf7a459b279cff626634f2 Mon Sep 17 00:00:00 2001 From: devrnt Date: Sat, 8 Feb 2025 11:41:32 +0100 Subject: [PATCH 3/5] All-in on stackblitz StackBlitz doesn't support node 22 yet, but we'll ignore that for now --- .github/ISSUE_TEMPLATE/bug_report.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 9cd5d415..472bb557 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -17,8 +17,10 @@ Steps to reproduce the behavior: 3. Scroll down to '....' 4. See error -**Codesandbox link** -Include a codesandox will help us to investigate the issue quicker. +**StackBlitz link** +Include a StackBLitz will help us to investigate the issue quicker. + +[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz_small.svg)](https://stackblitz.com/fork/github/devrnt/react-use-intercom/) **Expected behavior** A clear and concise description of what you expected to happen. From b26759b118ff832fcec3b112caaac4d25f0921fa Mon Sep 17 00:00:00 2001 From: devrnt Date: Sat, 8 Feb 2025 11:50:20 +0100 Subject: [PATCH 4/5] Fix update e2e test --- apps/playground/cypress/e2e/update.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/apps/playground/cypress/e2e/update.ts b/apps/playground/cypress/e2e/update.ts index 7254cf12..1eb09ee4 100644 --- a/apps/playground/cypress/e2e/update.ts +++ b/apps/playground/cypress/e2e/update.ts @@ -18,6 +18,5 @@ describe('update', () => { app_id: 'jcabc7e3', name: 'ponas', }); - cy.get('.intercom-lightweight-app-launcher-icon-open').should('not.exist'); }); }); From e83efea83d85415d8aa682777e298352109e93fa Mon Sep 17 00:00:00 2001 From: devrnt Date: Sat, 8 Feb 2025 11:51:50 +0100 Subject: [PATCH 5/5] Remove manual timeouts in cypress --- apps/playground/cypress/e2e/visitorId.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/apps/playground/cypress/e2e/visitorId.ts b/apps/playground/cypress/e2e/visitorId.ts index 1a60993f..72086f31 100644 --- a/apps/playground/cypress/e2e/visitorId.ts +++ b/apps/playground/cypress/e2e/visitorId.ts @@ -22,11 +22,8 @@ describe('getVisitorId', () => { cy.get('[data-cy=boot]').click(); cy.wait('@intercomPing'); - // FIXME: something goes wrong here in the pipeline - cy.get('button[data-cy="visitorId"]').click({ timeout: 10000 }); + cy.get('button[data-cy="visitorId"]').click(); - cy.wait(10000); - - cy.get('p[data-cy="visitorIdValue"]', { timeout: 10000 }).should('exist'); + cy.get('p[data-cy="visitorIdValue"]').should('exist'); }); });