@rpcbase/client 0.227.0 → 0.231.0

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.
Files changed (237) hide show
  1. package/package.json +11 -113
  2. package/src/apiClient/getServerApiClient.ts +131 -0
  3. package/src/apiClient/index.ts +86 -0
  4. package/src/index.ts +3 -0
  5. package/src/initClient.ts +32 -0
  6. package/src/types.ts +7 -0
  7. package/AppProvider/AnalyticsContainer.js +0 -56
  8. package/AppProvider/debug.js +0 -4
  9. package/AppProvider/index.tsx +0 -79
  10. package/access-control/ACLForm/components/GrantField/OpSelector.tsx +0 -129
  11. package/access-control/ACLForm/components/GrantField/ResourceSelector.tsx +0 -86
  12. package/access-control/ACLForm/components/GrantField/UsersSelector.tsx +0 -96
  13. package/access-control/ACLForm/components/GrantField/grant-field.scss +0 -26
  14. package/access-control/ACLForm/components/GrantField/icons/CheckMark.tsx +0 -16
  15. package/access-control/ACLForm/components/GrantField/icons/CollapseArrow.tsx +0 -14
  16. package/access-control/ACLForm/components/GrantField/icons/ExpandArrow.tsx +0 -14
  17. package/access-control/ACLForm/components/GrantField/index.tsx +0 -91
  18. package/access-control/ACLForm/components/GrantsList.tsx +0 -48
  19. package/access-control/ACLForm/components/RoleForm.tsx +0 -134
  20. package/access-control/ACLForm/components/RoleView.tsx +0 -115
  21. package/access-control/ACLForm/components/RolesList.tsx +0 -79
  22. package/access-control/ACLForm/components/constants.tsx +0 -1
  23. package/access-control/ACLForm/components/resolver.ts +0 -57
  24. package/access-control/ACLForm/components/role-form.scss +0 -19
  25. package/access-control/ACLForm/index.tsx +0 -48
  26. package/access-control/ACLModal/acl-modal.scss +0 -7
  27. package/access-control/ACLModal/index.tsx +0 -66
  28. package/access-control/PolicyEditor/TargetSelector/QueryBuilder.tsx +0 -48
  29. package/access-control/PolicyEditor/TargetSelector/index.tsx +0 -5
  30. package/access-control/PolicyEditor/TargetSelector/query-builder.scss +0 -9
  31. package/access-control/PolicyEditor/index.tsx +0 -165
  32. package/access-control/index.ts +0 -3
  33. package/apiClient.js +0 -15
  34. package/auth/authProps.js +0 -8
  35. package/auth/components/AccountsList/AccountListItem.js +0 -61
  36. package/auth/components/AccountsList/account-list-item.scss +0 -5
  37. package/auth/components/AccountsList/index.js +0 -17
  38. package/auth/components/Footer/index.js +0 -11
  39. package/auth/components/ForgotPassword/forgot-password.scss +0 -37
  40. package/auth/components/ForgotPassword/index.js +0 -114
  41. package/auth/components/SetNewPassword/index.js +0 -130
  42. package/auth/components/SetNewPassword/set-new-password.scss +0 -47
  43. package/auth/components/SignIn/SignInEmailForm.tsx +0 -115
  44. package/auth/components/SignIn/index.js +0 -69
  45. package/auth/components/SignIn/sign-in.scss +0 -56
  46. package/auth/components/SignOut/index.js +0 -144
  47. package/auth/components/SignOut/sign-out.scss +0 -34
  48. package/auth/components/SignUp/SignUpEmailForm.tsx +0 -98
  49. package/auth/components/SignUp/index.js +0 -66
  50. package/auth/components/SignUp/sign-up.scss +0 -56
  51. package/auth/getTenantId.js +0 -12
  52. package/auth/getUid.js +0 -11
  53. package/auth/helpers/redirectSignIn.native.js +0 -9
  54. package/auth/helpers/redirectSignIn.web.js +0 -7
  55. package/auth/index.js +0 -146
  56. package/auth/signOut.js +0 -20
  57. package/auth/useAuthRouter.js +0 -56
  58. package/env.d.ts +0 -3
  59. package/firebase/index.js +0 -1
  60. package/firebase/sw.js +0 -1
  61. package/form/FileInput/FileUploadContext.tsx +0 -162
  62. package/form/FileInput/FileUploadForm/index.tsx +0 -139
  63. package/form/FileInput/FileUploadForm/usePreventUnload.js +0 -21
  64. package/form/FileInput/UploadButton.tsx +0 -23
  65. package/form/FileInput/constants.ts +0 -16
  66. package/form/FileInput/file-input.scss +0 -1
  67. package/form/FileInput/index.tsx +0 -21
  68. package/form/FileInput/upload-worker/get_file_hash.js +0 -63
  69. package/form/FileInput/upload-worker/index.js +0 -16
  70. package/form/FileInput/upload-worker/no_compress_exts.ts +0 -33
  71. package/form/FileInput/upload-worker/upload_file.js +0 -129
  72. package/form/Form.tsx +0 -23
  73. package/form/Input.tsx +0 -62
  74. package/form/SubmitButton/index.tsx +0 -58
  75. package/form/hook-form.tsx +0 -7
  76. package/form/index.tsx +0 -5
  77. package/getBaseUrl.js +0 -14
  78. package/getObjectId.ts +0 -31
  79. package/hashState.js +0 -158
  80. package/helpers/createBatcher/index.js +0 -36
  81. package/helpers/getInitials.js +0 -39
  82. package/helpers/onReady.js +0 -15
  83. package/helpers/post.js +0 -18
  84. package/helpers/postRPC.js +0 -42
  85. package/helpers/useRPC.js +0 -41
  86. package/helpers/useStoredValue/batchedGetStoredValues.js +0 -30
  87. package/helpers/useStoredValue/index.js +0 -107
  88. package/helpers/useStoredValue/setStoredValues.js +0 -14
  89. package/i18n/en/rb.nav.json +0 -13
  90. package/i18n/en/rb.sign_in.json +0 -11
  91. package/i18n/en/rb.sign_out.json +0 -5
  92. package/i18n/fr/rb.sign_in.json +0 -11
  93. package/i18n/fr/rb.sign_out.json +0 -5
  94. package/i18n/index.js +0 -63
  95. package/index.js +0 -6
  96. package/isEqualValues.js +0 -47
  97. package/jest.config.js +0 -16
  98. package/notifications/Notification/index.js +0 -36
  99. package/notifications/Notification/notification.scss +0 -1
  100. package/notifications/NotificationItem/HeaderStatus.js +0 -93
  101. package/notifications/NotificationItem/index.js +0 -65
  102. package/notifications/NotificationItem/notification-item.scss +0 -25
  103. package/notifications/NotificationsContainer/index.js +0 -37
  104. package/notifications/NotificationsContainer/notifications-container.scss +0 -38
  105. package/notifications/NotificationsContainer/useLLTs.js +0 -28
  106. package/notifications/NotificationsContext/index.js +0 -71
  107. package/notifications/NotificationsContext/useNotificationsList.js +0 -75
  108. package/notifications/NotificationsSettingsModal/SettingsForm.js +0 -52
  109. package/notifications/NotificationsSettingsModal/index.js +0 -48
  110. package/notifications/NotificationsSettingsModal/notifications-settings.scss +0 -1
  111. package/notifications/config.js +0 -1
  112. package/notifications/index.js +0 -4
  113. package/page.js +0 -9
  114. package/publish-output.txt +0 -0
  115. package/rpc.js +0 -32
  116. package/rr-trace/get_fingerprint.js +0 -10
  117. package/rr-trace/get_perf_vitals.js +0 -24
  118. package/rr-trace/get_session_id.js +0 -29
  119. package/rr-trace/index.js +0 -138
  120. package/rr-trace/write_session_data.js +0 -86
  121. package/rts/boot.js +0 -3
  122. package/rts/getUseDocument.js +0 -21
  123. package/rts/getUseQuery/index.js +0 -233
  124. package/rts/getUseQuery/useData.js +0 -55
  125. package/rts/index.js +0 -10
  126. package/rts/rts.js +0 -243
  127. package/rts/signout.ts +0 -8
  128. package/rts/store/constants.js +0 -3
  129. package/rts/store/debug.js +0 -24
  130. package/rts/store/get_collection.js +0 -55
  131. package/rts/store/index.js +0 -100
  132. package/rts/store/replace_query_keys.js +0 -30
  133. package/rts/store/satisfies_projection.js +0 -32
  134. package/rts/store/update_docs.js +0 -47
  135. package/storage/index.jest.js +0 -15
  136. package/storage/index.native.js +0 -38
  137. package/storage/index.web.js +0 -25
  138. package/types.ts +0 -6
  139. package/ui/ActivityIndicator/index.js +0 -113
  140. package/ui/Avatar/index.native.js +0 -31
  141. package/ui/Avatar/index.web.js +0 -37
  142. package/ui/Avatar/styles.js +0 -41
  143. package/ui/ErrorBoundary/index.js +0 -12
  144. package/ui/ExpandableFloatView/exp.scss +0 -15
  145. package/ui/ExpandableFloatView/index.tsx +0 -123
  146. package/ui/ExpandableFloatView/useBackdrop.js +0 -45
  147. package/ui/LottiePlayer/LottiePlayer.js +0 -4
  148. package/ui/LottiePlayer/index.js +0 -8
  149. package/ui/Modal/HashStateModal.js +0 -30
  150. package/ui/Modal/Modal.js +0 -93
  151. package/ui/Modal/ModalForm/AlertBanner.js +0 -82
  152. package/ui/Modal/ModalForm/index.js +0 -188
  153. package/ui/Modal/ModalForm/modal-form.scss +0 -63
  154. package/ui/Modal/index.js +0 -10
  155. package/ui/Modal/modal.scss +0 -101
  156. package/ui/Modal/withHashStateModal.js +0 -24
  157. package/ui/RedboxError/index.js +0 -3
  158. package/ui/Search/SearchHistory/index.js +0 -45
  159. package/ui/Search/SearchHistory/search-history.scss +0 -9
  160. package/ui/Search/SearchHistory/useSearchHistory.tsx +0 -57
  161. package/ui/Search/SearchResults/index.tsx +0 -90
  162. package/ui/Search/index.tsx +0 -298
  163. package/ui/Search/search.scss +0 -0
  164. package/ui/SelectPills/index.tsx +0 -96
  165. package/ui/SelectPills/select-pills.scss +0 -66
  166. package/ui/Tabs/index.tsx +0 -161
  167. package/ui/Tabs/tabs.scss +0 -53
  168. package/ui/Tree/index.js +0 -257
  169. package/ui/Tree/model.js +0 -71
  170. package/ui/Tree/node.js +0 -112
  171. package/ui/Tree/tree.scss +0 -98
  172. package/ui/UserAvatar/default_colors.json +0 -82
  173. package/ui/UserAvatar/index.js +0 -55
  174. package/ui/View/index.tsx +0 -17
  175. package/ui/View/index.web.js +0 -44
  176. package/ui/animations/checkmark.json +0 -1
  177. package/ui/helpers/SizeContext/index.tsx +0 -11
  178. package/ui/helpers/helpers.scss +0 -61
  179. package/ui/helpers/index.ts +0 -6
  180. package/ui/helpers/stopEventPropagation.js +0 -5
  181. package/ui/helpers/useActiveListItemIndex/index.tsx +0 -45
  182. package/ui/helpers/useScrollSelectorIntoView/index.tsx +0 -14
  183. package/ui/helpers/useThrottledMeasure/index.js +0 -47
  184. package/ui/helpers/withSuspense/index.js +0 -37
  185. package/ui/icons/AddAccount.tsx +0 -5
  186. package/ui/icons/Billing.tsx +0 -6
  187. package/ui/icons/Close.tsx +0 -14
  188. package/ui/icons/Organization.tsx +0 -5
  189. package/ui/icons/Signout.tsx +0 -5
  190. package/ui/icons/index.tsx +0 -6
  191. package/ui/nav/AccountsDropdown/SwitchAccounts.tsx +0 -28
  192. package/ui/nav/AccountsDropdown/accounts-dropdown.scss +0 -51
  193. package/ui/nav/AccountsDropdown/index.tsx +0 -90
  194. package/ui/nav/AccountsToggle/index.tsx +0 -24
  195. package/ui/nav/ContentView/ContentViewContext.ts +0 -23
  196. package/ui/nav/ContentView/index.tsx +0 -115
  197. package/ui/nav/HeaderContainer/header.scss +0 -52
  198. package/ui/nav/HeaderContainer/index.tsx +0 -23
  199. package/ui/nav/HeaderContainer/variables.scss +0 -1
  200. package/ui/nav/MorphingDropdown/MorphingDropdownContext.tsx +0 -151
  201. package/ui/nav/MorphingDropdown/MorphingDropdownMenu.tsx +0 -38
  202. package/ui/nav/MorphingDropdown/MorphingDropdownPortal.tsx +0 -166
  203. package/ui/nav/MorphingDropdown/MorphingDropdownToggle.tsx +0 -34
  204. package/ui/nav/MorphingDropdown/index.tsx +0 -16
  205. package/ui/nav/MorphingDropdown/morphing-dropdown.scss +0 -35
  206. package/ui/nav/NotificationsDropdown/index.tsx +0 -52
  207. package/ui/nav/NotificationsDropdown/notifications-dropdown.scss +0 -5
  208. package/ui/nav/NotificationsToggle/NotificationsGlyph.tsx +0 -54
  209. package/ui/nav/NotificationsToggle/index.tsx +0 -12
  210. package/ui/nav/NotificationsToggle/notification-animation.json +0 -1
  211. package/ui/nav/NotificationsToggle/notifications-toggle.scss +0 -26
  212. package/ui/nav/SidebarContainer/index.tsx +0 -48
  213. package/ui/nav/SidebarContainer/sidebar-container.scss +0 -21
  214. package/ui/nav/SlideoutContainer/components/Body.tsx +0 -19
  215. package/ui/nav/SlideoutContainer/components/Header.tsx +0 -23
  216. package/ui/nav/SlideoutContainer/components/Wrapper.tsx +0 -46
  217. package/ui/nav/SlideoutContainer/index.tsx +0 -50
  218. package/ui/nav/SlideoutContainer/slideout-container.scss +0 -40
  219. package/ui/nav/index.ts +0 -13
  220. package/ui/oauth/GitHub.js +0 -38
  221. package/ui/oauth/getGitHubSigninUrl.js +0 -30
  222. package/ui/oauth/index.js +0 -9
  223. package/ui/oauth/oauth.scss +0 -16
  224. package/ui/sortable-hoc/AutoScroller.js +0 -76
  225. package/ui/sortable-hoc/DragHandle.js +0 -31
  226. package/ui/sortable-hoc/Manager.js +0 -54
  227. package/ui/sortable-hoc/README.md +0 -1
  228. package/ui/sortable-hoc/SortableContainer/defaultGetHelperDimensions.js +0 -7
  229. package/ui/sortable-hoc/SortableContainer/defaultShouldCancelStart.js +0 -24
  230. package/ui/sortable-hoc/SortableContainer/index.js +0 -994
  231. package/ui/sortable-hoc/SortableContainer/props.js +0 -81
  232. package/ui/sortable-hoc/SortableElement.js +0 -111
  233. package/ui/sortable-hoc/SortableHandle.js +0 -45
  234. package/ui/sortable-hoc/drag-handle.scss +0 -14
  235. package/ui/sortable-hoc/index.js +0 -9
  236. package/ui/sortable-hoc/utils.js +0 -292
  237. package/ui/springs.ts +0 -17
@@ -1,71 +0,0 @@
1
- /* @flow */
2
- import {useEffect, createContext, useContext} from "react"
3
-
4
- import {useNotificationsList} from "./useNotificationsList"
5
-
6
- // const ICONS_MAP = {
7
- // warning: "warning",
8
- // error: "danger",
9
- // }
10
-
11
- export const NotificationsContext = createContext()
12
-
13
- export const NotificationsProvider = ({value, children}) => {
14
- const [notifications, setNotifications] = useNotificationsList([])
15
-
16
- const addNotification = ({
17
- id,
18
- title,
19
- body,
20
- timestamp = Date.now(),
21
- zIndex = 2000,
22
- isLoading = false,
23
- }) => {
24
- const notification = {
25
- id: id || `notif-${Date.now().toString()}`,
26
- title,
27
- body,
28
- timestamp,
29
- zIndex,
30
- level: "toast",
31
- isLoading,
32
- // icon: ICONS_MAP.error,
33
- }
34
-
35
- setNotifications((current) => {
36
- const next = [...current]
37
- next.push(notification)
38
- return next
39
- })
40
-
41
- const dismiss = () => {
42
- setNotifications((current) => {
43
- const next = [...current]
44
- return next.filter((n) => n.id !== id)
45
- })
46
- }
47
-
48
- const update = (payload) => {
49
- setNotifications((current) => {
50
- const next = [...current]
51
- return next.map((n) => {
52
- if (n.id === id) {
53
- // n.isLoading = false
54
- Object.assign(n, payload)
55
- }
56
- return n
57
- })
58
- })
59
- }
60
-
61
- return {dismiss, update}
62
- }
63
-
64
- return (
65
- <NotificationsContext.Provider value={{notifications, setNotifications, addNotification}}>
66
- {children}
67
- </NotificationsContext.Provider>
68
- )
69
- }
70
-
71
- export const useNotifications = () => useContext(NotificationsContext)
@@ -1,75 +0,0 @@
1
- /* eslint-disable */
2
- /* @flow */
3
- import {useState, useEffect} from "react"
4
-
5
- import {useQuery} from "../../rts"
6
-
7
- import {ON_NOTIFICATION_RECEIVED_EVENT} from "../config"
8
-
9
- export const useNotificationsList = (initial = []) => {
10
- const [allNotifications, setAllNotifications] = useState(initial)
11
-
12
- const notificationsQuery = useQuery(
13
- "Notification",
14
- {
15
- $or: [{ack_at_ms: null}, {ack_at_ms: {$exists: false}}],
16
- },
17
- {
18
- projection: {
19
- _owners: 0,
20
- },
21
- },
22
- )
23
-
24
- useEffect(() => {
25
- if (!notificationsQuery.data) return
26
-
27
- // console.log("NOTIFS TMP RETURN", notificationsQuery.data)
28
- return
29
-
30
- // console.log("got new notifs data", notificationsQuery.data)
31
-
32
- // get all current ids
33
- const allNotificationsIds = allNotifications.filter((n) => !!n.id).map((n) => n.id)
34
-
35
- const insertNotifications = notificationsQuery.data.filter(
36
- (n) => !allNotificationsIds.includes(n._id),
37
- )
38
-
39
- const notificationsDataIds = notificationsQuery.data.map((n) => n._id)
40
-
41
- // remove all notifications that are from the notifications collection
42
- const removeNotificationsIds = allNotifications
43
- .filter((n) => !!n.id && n.col === "Notification")
44
- .filter((n) => !notificationsDataIds.includes(n.id))
45
- .map((n) => n.id)
46
-
47
- // update our notifications
48
- if (insertNotifications.length > 0 || removeNotificationsIds.length > 0) {
49
- setAllNotifications((previous) => {
50
- // copy and remove old notifs
51
- const nextNotifs = [...previous].filter((n) => !removeNotificationsIds.includes(n.id))
52
-
53
- const formattedNotifications = insertNotifications.map((n) => {
54
- return {
55
- id: n._id,
56
- col: "Notification",
57
- ...n.notification,
58
- timestamp: n.server_timestamp_ms,
59
- }
60
- })
61
-
62
- nextNotifs.unshift(...formattedNotifications)
63
- return nextNotifs
64
- })
65
- }
66
-
67
- // play animation if we added anything
68
- if (insertNotifications.length > 0) {
69
- const ev = new CustomEvent(ON_NOTIFICATION_RECEIVED_EVENT)
70
- document.body.dispatchEvent(ev)
71
- }
72
- }, [notificationsQuery.data, allNotifications])
73
-
74
- return [allNotifications, setAllNotifications]
75
- }
@@ -1,52 +0,0 @@
1
- /* @flow */
2
- import Form from "react-bootstrap/Form"
3
- import TimePicker from "react-time-picker"
4
-
5
- import {useStoredValue} from "../../helpers/useStoredValue"
6
-
7
-
8
- const TIME_FORMAT = "HH:mm"
9
-
10
- const timePickerProps = {
11
- format: TIME_FORMAT,
12
- maxDetail: "minute",
13
- renderSecondHand: false,
14
- }
15
-
16
- const SettingsForm = () => {
17
- const [isEnabled, setIsEnabled] = useStoredValue("has_notifications_enabled", "yes")
18
-
19
- const [fromTime, setFromTime] = useStoredValue("notifications_from_time", "09:00")
20
- const [toTime, setToTime] = useStoredValue("notifications_to_time", "22:00")
21
-
22
- const onToggleNotifications = (e) => {
23
- setIsEnabled(e.target.checked ? "yes" : "no")
24
- }
25
-
26
- return (
27
- <div className="px-2 py-3">
28
- <div>
29
- <div className="h6 fw-bold">Enable Notifications</div>
30
- <Form.Check
31
- type="switch"
32
- id="toggle-notifications-switch"
33
- label={`Notifications are ${isEnabled ? "enabled" : "disabled"}`}
34
- checked={isEnabled === "yes"}
35
- onChange={onToggleNotifications}
36
- />
37
- </div>
38
-
39
- <div className="mt-3">
40
- <div className="h6 fw-bold">Notifications are allowed:</div>
41
- <div className="">
42
- <span className="me-2">From:</span>
43
- <TimePicker onChange={setFromTime} value={fromTime} {...timePickerProps} />
44
- <span className="me-2">To:</span>
45
- <TimePicker onChange={setToTime} value={toTime} {...timePickerProps} />
46
- </div>
47
- </div>
48
- </div>
49
- )
50
- }
51
-
52
- export default SettingsForm
@@ -1,48 +0,0 @@
1
- /* @flow */
2
- import ActivityIndicator from "../../ui/ActivityIndicator"
3
- import Modal, {withHashStateModal} from "../../ui/Modal"
4
-
5
- // import TemplatesView from "./TemplatesView"
6
- // import {TemplateContextProvider} from "./TemplateContext"
7
-
8
- // import DialogAnimatedPreview from "./components/DialogAnimatedPreview"
9
- // import TogglePreviewButton from "./components/TogglePreviewButton"
10
-
11
- import SettingsForm from "./SettingsForm"
12
-
13
- import BellGlyph from "static/icons/notifications/bell-glyph.svg"
14
-
15
- import "./notifications-settings.scss"
16
-
17
-
18
- const NotificationsSettingsModal = ({onHide}) => {
19
- const isLoading = false
20
-
21
- return (
22
- <Modal className="channel-templates-modal" show scrollable={false} onHide={onHide}>
23
- <Modal.Header className="close-top" closeButton>
24
- <BellGlyph className="me-2 align-self-start mt-1" width={22} fill={"#0d6efd"} />
25
- <div>
26
- <div>Notifications</div>
27
- </div>
28
- </Modal.Header>
29
- <Modal.Body className="p-0" style={{maxHeight: "70vh", overflow: "visible"}}>
30
- {isLoading && (
31
- <div className="d-flex flex-row align-items-center">
32
- <ActivityIndicator size={24} />
33
- <div className="ms-2">Loading text...</div>
34
- </div>
35
- )}
36
-
37
- <SettingsForm />
38
- </Modal.Body>
39
- <Modal.Footer className="d-flex justify-content-between">
40
- <div>
41
- For more info see <a href="/docs/notifications">/docs/notifications</a>
42
- </div>
43
- </Modal.Footer>
44
- </Modal>
45
- )
46
- }
47
-
48
- export default withHashStateModal(NotificationsSettingsModal, "showNotificationsSettingsModal")
@@ -1 +0,0 @@
1
- export const ON_NOTIFICATION_RECEIVED_EVENT = "ON_NOTIFICATION_RECEIVED_EVENT"
@@ -1,4 +0,0 @@
1
- export * from "./NotificationsContext"
2
- export * from "./NotificationsContainer"
3
-
4
- export * from "./config"
package/page.js DELETED
@@ -1,9 +0,0 @@
1
- /* @flow */
2
- import page from "page"
3
-
4
- import {hashStateMiddleware} from "./hashState"
5
-
6
- // custom event handler to get hash state changes when navigating with url
7
- page(hashStateMiddleware)
8
-
9
- export default page
File without changes
package/rpc.js DELETED
@@ -1,32 +0,0 @@
1
- /* @flow */
2
- import axios from "axios"
3
- import {Platform} from "react-native"
4
-
5
- import {SERVER_PORT} from "env"
6
-
7
-
8
- export const rpcClientPost = async(rpcName, payload) => {
9
- const baseUrl = `http://localhost:${SERVER_PORT}`
10
- const rpcUrl = `/rpc/${rpcName.replace("server/", "")}`
11
-
12
- const reqUrl = `${baseUrl}${rpcUrl}`
13
-
14
- const headers = {}
15
- if (Platform.OS !== "web") {
16
- headers["user-agent"] = "rb-rpc-client/dev"
17
- }
18
-
19
- let res
20
- try {
21
- res = await axios.post(reqUrl, payload, {
22
- withCredentials: true,
23
- headers,
24
- })
25
- } catch (err) {
26
- console.log("RPC got err", err)
27
- console.log(err.message)
28
- console.log(err.response)
29
- }
30
-
31
- return res.data
32
- }
@@ -1,10 +0,0 @@
1
- /* @flow */
2
- import FingerprintJS from "@fingerprintjs/fingerprintjs"
3
-
4
- const get_fingerprint = async() => {
5
- const fp = await FingerprintJS.load()
6
- const fp_result = await fp.get()
7
- return fp_result.visitorId
8
- }
9
-
10
- export default get_fingerprint
@@ -1,24 +0,0 @@
1
- /* @flow */
2
- import {getTTFB, getFCP} from "web-vitals"
3
-
4
- let _ttfb = null
5
- let _fcp = null
6
-
7
- getTTFB(({value}) => {
8
- _ttfb = value
9
- })
10
-
11
- getFCP(({value}) => {
12
- _fcp = value
13
- })
14
-
15
- const get_perf_vitals = async() => {
16
- return {
17
- perf_vitals: {
18
- ttfb: _ttfb,
19
- fcp: _fcp,
20
- }
21
- }
22
- }
23
-
24
- export default get_perf_vitals
@@ -1,29 +0,0 @@
1
- /* @flow */
2
- import * as uuid from "uuid"
3
-
4
- const SESSION_STORAGE_KEY = "rb::rr-trace-session-uuid"
5
- const LOCAL_STORAGE_KEY = "rb::rr-trace-storage-uuid"
6
-
7
- // runtime: regenrated each time the page realoads
8
- const runtime_id = uuid.v4()
9
- // session
10
- let session_id = sessionStorage.getItem(SESSION_STORAGE_KEY)
11
- if (!session_id) {
12
- session_id = uuid.v4()
13
- sessionStorage.setItem(SESSION_STORAGE_KEY, session_id)
14
- }
15
- // storage id: kept as long as the local storage isn't cleared
16
- let storage_id = localStorage.getItem(LOCAL_STORAGE_KEY)
17
- if (!storage_id) {
18
- storage_id = uuid.v4()
19
- localStorage.setItem(LOCAL_STORAGE_KEY, storage_id)
20
- }
21
-
22
- // TODO: add user_id if is authenticated
23
-
24
- const get_session_id = () => {
25
- return {runtime_id, session_id, storage_id}
26
- }
27
-
28
-
29
- export default get_session_id
package/rr-trace/index.js DELETED
@@ -1,138 +0,0 @@
1
- /* @flow */
2
- import * as rrweb from "rrweb"
3
-
4
- import * as env from "env"
5
-
6
- import write_session_data from "./write_session_data"
7
- import get_session_id from "./get_session_id"
8
-
9
- const SAVE_INTERVAL = 11000
10
- // TODO: sessions should not last longer than 10 minutes
11
- const MAX_SESSION_LENGTH = 30 * 1000 // 10s
12
-
13
- // when was the session started
14
- const start_time = Date.now()
15
-
16
- // rr events store
17
- const events = []
18
-
19
- //
20
- const is_session_over = () => {
21
- const now = Date.now()
22
- const delta = now - start_time
23
- return delta > MAX_SESSION_LENGTH
24
- }
25
-
26
- // POST payload to rr-trace backend
27
- const send_payload = async(payload) => {
28
- if (!env.RR_TRACE_URL) {
29
- console.log("send_payload: RR_TRACE_URL is not set, returning")
30
- return
31
- }
32
-
33
- // TODO: body compression
34
- const body = JSON.stringify(payload)
35
-
36
- const url = `${env.RR_TRACE_URL}/rb-api/v1/write_events`
37
-
38
- try {
39
- const fetch_response = await fetch(url, {
40
- method: "POST",
41
- cache: "no-cache",
42
- credentials: "include",
43
- headers: {
44
- "Content-Type": "application/json"
45
- },
46
- referrerPolicy: "no-referrer",
47
- body,
48
- })
49
- const json = await fetch_response.json()
50
- if (json.status !== "ok") {
51
- console.log("status not ok", json)
52
- }
53
- } catch(err) {
54
- console.log(err)
55
- }
56
- }
57
-
58
-
59
- // while has events, shift array, add to new array
60
- // send events to backend
61
- const send_events = async() => {
62
- const events_payload = []
63
-
64
- let should_break = false
65
- // force stop loop after a short delay
66
- setTimeout(() => {
67
- should_break = true
68
- }, 100)
69
-
70
- while (events.length > 0 && !should_break) {
71
- const ev = events.shift()
72
- events_payload.push(ev)
73
- }
74
-
75
- if (events_payload.length > 0) {
76
- // console.log("SEND PAYLOAD", JSON.stringify(events_payload, null, 2))
77
- await send_payload({
78
- events: events_payload,
79
- session_id: get_session_id(),
80
- })
81
- }
82
- }
83
-
84
- const init = async() => {
85
- // rrweb record
86
- const stop_recording = rrweb.record({
87
- inlineStylesheet: false,
88
- emit(event) {
89
- // if event contains html snapshot, replace the vendor script tag ?
90
- // if (event.type === 2 && event.data?.node?.childNodes) {
91
- // console.log("got dom snapshot", event)
92
- // }
93
- events.push(event)
94
-
95
- if (is_session_over()) {
96
- console.log("session exceeded timeout, stopping recording")
97
- stop_recording()
98
- }
99
- },
100
- })
101
-
102
- await write_session_data()
103
- }
104
-
105
-
106
- const delay = (time) => new Promise((resolve) => setTimeout(resolve, time))
107
-
108
- // send new events to backend every 1500 ms + random delay
109
- const send_interval = setInterval(async() => {
110
- const random_time = Math.floor(Math.random() * 500)
111
- await delay(random_time)
112
-
113
- send_events()
114
-
115
- if (is_session_over()) {
116
- console.log("session timeout, clear interval")
117
- clearInterval(send_interval)
118
- }
119
- }, SAVE_INTERVAL)
120
-
121
- export default {init}
122
-
123
- // TODO:
124
- // send last events before window unload
125
- // fetch + keepalive with 64kb max payload and 30s timeout
126
- // window.addEventListener("beforeunload", async(event) => {
127
- // const res = await hello({hello: "world"})
128
- // console.log("unload alert res", res)
129
- // // event.returnValue = "hello wlert"
130
- // })
131
-
132
- // window.onunload = function() {
133
- // fetch("/analytics", {
134
- // method: 'POST',
135
- // body: "statistics",
136
- // keepalive: true
137
- // });
138
- // };
@@ -1,86 +0,0 @@
1
- /* @flow */
2
- import {RR_TRACE_URL} from "env"
3
-
4
- import get_fingerprint from "./get_fingerprint"
5
- import get_perf_vitals from "./get_perf_vitals"
6
- import get_session_id from "./get_session_id"
7
-
8
- const get_screen = () => ({
9
- screen_w: window.screen.width,
10
- screen_h: window.screen.height,
11
- window_w: window.innerWidth,
12
- window_h: window.innerHeight,
13
- pixel_ratio: window.devicePixelRatio,
14
- orientation: window.screen.orientation?.type,
15
- })
16
-
17
- const get_analytics_data = async() => {
18
- const payload = {
19
- date_now: Date.now()
20
- }
21
- // screen info
22
- Object.assign(payload, get_screen())
23
-
24
- // nav info
25
- Object.assign(payload, {
26
- referrer: window.document.referrer,
27
- location: window.location.href,
28
- language: navigator.language,
29
- user_agent: navigator.userAgent,
30
- })
31
-
32
- // Battery (WARNING: battery api is deprecated)
33
- if (typeof navigator.getBattery === "function") {
34
- const battery = await navigator.getBattery()
35
- Object.assign(payload, {
36
- battery_charging: battery.charging,
37
- battery_level: battery.level
38
- })
39
- }
40
-
41
- // get fingerprint
42
- // TODO: save fingerprint to localStorage and check if it changed across sessions
43
- const visitor_id = await get_fingerprint()
44
- payload.visitor_id = visitor_id
45
-
46
- // runtime ids
47
- Object.assign(payload, {...get_session_id()})
48
-
49
- const perf_vitals = await get_perf_vitals()
50
- Object.assign(payload, perf_vitals)
51
-
52
- return payload
53
- }
54
-
55
-
56
- const write_session_data = async() => {
57
- if (!RR_TRACE_URL) {
58
- console.log("RR_TRACE_URL is not set, skipping")
59
- return
60
- }
61
-
62
- const payload = await get_analytics_data()
63
-
64
- try {
65
- const url = `${RR_TRACE_URL}/rb-api/v1/write_session_data`
66
- const fetch_response = await fetch(url, {
67
- method: "POST",
68
- cache: "no-cache",
69
- credentials: "include",
70
- headers: {
71
- "Content-Type": "application/json"
72
- },
73
- referrerPolicy: "no-referrer",
74
- body: JSON.stringify(payload), // TODO: compress + encrypt
75
- })
76
-
77
- console.log("write_session_data: got fetch response", fetch_response)
78
- } catch (err) {
79
- console.log("failed to fetch write_session_data", err)
80
- console.log("Error", JSON.stringify(err))
81
- console.log(err)
82
- }
83
-
84
- }
85
-
86
- export default write_session_data
package/rts/boot.js DELETED
@@ -1,3 +0,0 @@
1
- /* @flow */
2
-
3
- import "./store"
@@ -1,21 +0,0 @@
1
- /* @flow */
2
- import {getUseQuery} from "./getUseQuery"
3
-
4
-
5
- export const getUseDocument = (registerQuery) => (...args) => {
6
-
7
- const useQuery = getUseQuery(registerQuery)
8
-
9
- const res = useQuery(...args)
10
-
11
- let data
12
- // WARNING: cache will always return [] when there are no matching documents, but we want null instead
13
- if (Array.isArray(res.data) && res.data.length === 0 && res.source === "cache") {
14
- data = null
15
- } else if (Array.isArray(res.data) && res.data.length > 0) {
16
- // TODO: should we throw if res.data.length > 1 ? ie: there are more than one matching document
17
- data = res.data[0]
18
- }
19
-
20
- return {...res, data}
21
- }