Skip to content

Commit cbedef9

Browse files
authored
Merge pull request #798 from devrnt/747-autoboot-is-not-booting-intercom-by-the-time-trackevent-is-called
747 autoboot is not booting intercom by the time trackevent is called
2 parents f65e3a7 + fec6233 commit cbedef9

File tree

17 files changed

+530
-89
lines changed

17 files changed

+530
-89
lines changed

.changeset/little-bikes-itch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'react-use-intercom': patch
3+
---
4+
5+
Fix initializing intercom api

.github/dependabot.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
- uses: preactjs/compressed-size-action@v2
3030
with:
3131
repo-token: '${{ secrets.GITHUB_TOKEN }}'
32-
pattern: "packages/**/dist/**/*.?(m)js"
32+
pattern: "packages/**/dist/**/*.?(c)js"

apps/examples/vite/.gitignore

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
pnpm-debug.log*
8+
lerna-debug.log*
9+
10+
node_modules
11+
dist
12+
dist-ssr
13+
*.local
14+
15+
# Editor directories and files
16+
.vscode/*
17+
!.vscode/extensions.json
18+
.idea
19+
.DS_Store
20+
*.suo
21+
*.ntvs*
22+
*.njsproj
23+
*.sln
24+
*.sw?

apps/examples/vite/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# react-use-intercom in a Vite app
2+
3+
Replace `INTERCOM_APP_ID` with your Intercom app id.

apps/examples/vite/eslint.config.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import js from '@eslint/js'
2+
import globals from 'globals'
3+
import react from 'eslint-plugin-react'
4+
import reactHooks from 'eslint-plugin-react-hooks'
5+
import reactRefresh from 'eslint-plugin-react-refresh'
6+
7+
export default [
8+
{ ignores: ['dist'] },
9+
{
10+
files: ['**/*.{js,jsx}'],
11+
languageOptions: {
12+
ecmaVersion: 2020,
13+
globals: globals.browser,
14+
parserOptions: {
15+
ecmaVersion: 'latest',
16+
ecmaFeatures: { jsx: true },
17+
sourceType: 'module',
18+
},
19+
},
20+
settings: { react: { version: '18.3' } },
21+
plugins: {
22+
react,
23+
'react-hooks': reactHooks,
24+
'react-refresh': reactRefresh,
25+
},
26+
rules: {
27+
...js.configs.recommended.rules,
28+
...react.configs.recommended.rules,
29+
...react.configs['jsx-runtime'].rules,
30+
...reactHooks.configs.recommended.rules,
31+
'react/jsx-no-target-blank': 'off',
32+
'react-refresh/only-export-components': [
33+
'warn',
34+
{ allowConstantExport: true },
35+
],
36+
},
37+
},
38+
]

apps/examples/vite/index.html

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>Vite + React</title>
8+
</head>
9+
<body>
10+
<div id="root"></div>
11+
<script type="module" src="/src/main.jsx"></script>
12+
</body>
13+
</html>

apps/examples/vite/package.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "vite-example",
3+
"private": true,
4+
"version": "0.0.0",
5+
"type": "module",
6+
"scripts": {
7+
"dev": "vite",
8+
"build": "vite build",
9+
"lint": "eslint .",
10+
"preview": "vite preview"
11+
},
12+
"dependencies": {
13+
"react": "^19.0.0",
14+
"react-dom": "^19.0.0",
15+
"react-use-intercom": "*"
16+
},
17+
"devDependencies": {
18+
"@eslint/js": "^9.19.0",
19+
"@types/react": "^19.0.8",
20+
"@types/react-dom": "^19.0.3",
21+
"@vitejs/plugin-react-swc": "^3.5.0",
22+
"eslint": "^9.19.0",
23+
"eslint-plugin-react": "^7.37.4",
24+
"eslint-plugin-react-hooks": "^5.0.0",
25+
"eslint-plugin-react-refresh": "^0.4.18",
26+
"globals": "^15.14.0",
27+
"vite": "^6.1.0"
28+
}
29+
}

apps/examples/vite/src/app.jsx

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import { useEffect } from 'react';
2+
import { IntercomProvider, useIntercom } from 'react-use-intercom';
3+
4+
const INTERCOM_APP_ID = 'jcabc7e3';
5+
6+
export function App() {
7+
return (
8+
<IntercomProvider
9+
appId={INTERCOM_APP_ID}
10+
autoBoot
11+
onShow={() => alert('show')}
12+
>
13+
<OurApp />
14+
</IntercomProvider>
15+
);
16+
}
17+
18+
function OurApp() {
19+
return (
20+
<main>
21+
<p>Our App</p>
22+
<TrackEvent />
23+
</main>
24+
);
25+
}
26+
27+
function TrackEvent() {
28+
const { trackEvent, boot, shutdown } = useIntercom();
29+
30+
useEffect(() => {
31+
trackEvent('event');
32+
}, [trackEvent]);
33+
34+
return (
35+
<>
36+
<p>Tracing event in effect</p>
37+
<button onClick={() => boot()}>Boot</button>
38+
<button onClick={() => shutdown()}>Shutdown</button>
39+
</>
40+
);
41+
}
42+
43+
export default App;

apps/examples/vite/src/main.jsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { StrictMode } from 'react';
2+
import { createRoot } from 'react-dom/client';
3+
4+
import { App } from './app.jsx';
5+
6+
createRoot(document.getElementById('root')).render(
7+
<StrictMode>
8+
<App />
9+
</StrictMode>,
10+
);

0 commit comments

Comments
 (0)