@rimori/react-client 0.4.12-next.3 → 0.4.12-next.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
12
12
|
import { EventBusHandler, RimoriClient, StandaloneClient } from '@rimori/client';
|
|
13
|
+
import posthog from 'posthog-js';
|
|
13
14
|
import ContextMenu from '../components/ContextMenu';
|
|
14
15
|
import { useTheme } from '../hooks/ThemeSetter';
|
|
15
16
|
const PluginContext = createContext(null);
|
|
@@ -20,6 +21,22 @@ export const PluginProvider = ({ children, pluginId, settings }) => {
|
|
|
20
21
|
const [theme, setTheme] = useState(undefined);
|
|
21
22
|
const [userInfo, setUserInfo] = useState(null);
|
|
22
23
|
useTheme(theme);
|
|
24
|
+
// Init PostHog once per plugin iframe
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!posthog.__loaded) {
|
|
27
|
+
posthog.init('phc_l4vPVZxtjlcQUDivoh5TaUL6oDe8K2lig89405cGnsv', {
|
|
28
|
+
cookieless_mode: 'always',
|
|
29
|
+
api_host: 'https://eu.i.posthog.com',
|
|
30
|
+
defaults: '2026-01-30',
|
|
31
|
+
loaded: (ph) => {
|
|
32
|
+
ph.register({
|
|
33
|
+
application: 'frontend',
|
|
34
|
+
pluginId: pluginId,
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
23
40
|
const isSidebar = applicationMode === 'sidebar';
|
|
24
41
|
const isSettings = applicationMode === 'settings';
|
|
25
42
|
useEffect(() => {
|
|
@@ -45,6 +62,12 @@ export const PluginProvider = ({ children, pluginId, settings }) => {
|
|
|
45
62
|
});
|
|
46
63
|
}
|
|
47
64
|
}, [pluginId, standaloneClient, client]);
|
|
65
|
+
// Identify user in PostHog when userInfo is available
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
if (userInfo === null || userInfo === void 0 ? void 0 : userInfo.user_id) {
|
|
68
|
+
posthog.identify(userInfo.user_id);
|
|
69
|
+
}
|
|
70
|
+
}, [userInfo === null || userInfo === void 0 ? void 0 : userInfo.user_id]);
|
|
48
71
|
// Listen for RimoriInfo updates and update userInfo
|
|
49
72
|
useEffect(() => {
|
|
50
73
|
if (!client)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rimori/react-client",
|
|
3
|
-
"version": "0.4.12-next.
|
|
3
|
+
"version": "0.4.12-next.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"@tiptap/react": "^2.26.1",
|
|
44
44
|
"@tiptap/starter-kit": "^2.26.1",
|
|
45
45
|
"html2canvas": "1.4.1",
|
|
46
|
+
"posthog-js": "^1.360.2",
|
|
46
47
|
"react-icons": "5.4.0",
|
|
47
48
|
"tiptap-markdown": "^0.8.10"
|
|
48
49
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { createContext, useContext, ReactNode, useEffect, useState } from 'react';
|
|
2
2
|
import { EventBusHandler, RimoriClient, StandaloneClient } from '@rimori/client';
|
|
3
3
|
import type { UserInfo } from '@rimori/client';
|
|
4
|
+
import posthog from 'posthog-js';
|
|
4
5
|
import ContextMenu from '../components/ContextMenu';
|
|
5
6
|
import { useTheme } from '../hooks/ThemeSetter';
|
|
6
7
|
import { Theme } from '@rimori/client';
|
|
@@ -29,6 +30,23 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children, plugin
|
|
|
29
30
|
|
|
30
31
|
useTheme(theme);
|
|
31
32
|
|
|
33
|
+
// Init PostHog once per plugin iframe
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
if (!posthog.__loaded) {
|
|
36
|
+
posthog.init('phc_l4vPVZxtjlcQUDivoh5TaUL6oDe8K2lig89405cGnsv', {
|
|
37
|
+
cookieless_mode: 'always',
|
|
38
|
+
api_host: 'https://eu.i.posthog.com',
|
|
39
|
+
defaults: '2026-01-30',
|
|
40
|
+
loaded: (ph) => {
|
|
41
|
+
ph.register({
|
|
42
|
+
application: 'frontend',
|
|
43
|
+
pluginId: pluginId,
|
|
44
|
+
});
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}, []);
|
|
49
|
+
|
|
32
50
|
const isSidebar = applicationMode === 'sidebar';
|
|
33
51
|
const isSettings = applicationMode === 'settings';
|
|
34
52
|
|
|
@@ -60,6 +78,13 @@ export const PluginProvider: React.FC<PluginProviderProps> = ({ children, plugin
|
|
|
60
78
|
}
|
|
61
79
|
}, [pluginId, standaloneClient, client]);
|
|
62
80
|
|
|
81
|
+
// Identify user in PostHog when userInfo is available
|
|
82
|
+
useEffect(() => {
|
|
83
|
+
if (userInfo?.user_id) {
|
|
84
|
+
posthog.identify(userInfo.user_id);
|
|
85
|
+
}
|
|
86
|
+
}, [userInfo?.user_id]);
|
|
87
|
+
|
|
63
88
|
// Listen for RimoriInfo updates and update userInfo
|
|
64
89
|
useEffect(() => {
|
|
65
90
|
if (!client) return;
|