@hanzo/insights-react 1.8.1 → 1.9.1

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 (42) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +40 -40
  3. package/dist/esm/index.js +48 -48
  4. package/dist/esm/index.js.map +1 -1
  5. package/dist/esm/surveys/index.js +12 -12
  6. package/dist/esm/surveys/index.js.map +1 -1
  7. package/dist/types/index.d.ts +29 -29
  8. package/dist/umd/index.js +55 -55
  9. package/dist/umd/index.js.map +1 -1
  10. package/dist/umd/surveys/index.js +16 -16
  11. package/dist/umd/surveys/index.js.map +1 -1
  12. package/package.json +38 -32
  13. package/src/components/{PostHogCaptureOnViewed.tsx → InsightsCaptureOnViewed.tsx} +12 -37
  14. package/src/components/{PostHogErrorBoundary.tsx → InsightsErrorBoundary.tsx} +13 -13
  15. package/src/components/{PostHogFeature.tsx → InsightsFeature.tsx} +14 -14
  16. package/src/components/__tests__/{PostHogCaptureOnViewed.test.tsx → InsightsCaptureOnViewed.test.tsx} +33 -33
  17. package/src/components/__tests__/{PostHogErrorBoundary.test.tsx → InsightsErrorBoundary.test.tsx} +17 -17
  18. package/src/components/__tests__/{PostHogFeature.test.tsx → InsightsFeature.test.tsx} +73 -73
  19. package/src/components/index.ts +6 -6
  20. package/src/context/InsightsContext.ts +9 -0
  21. package/src/context/InsightsProvider.tsx +108 -0
  22. package/src/context/__tests__/{PostHogContext.test.tsx → InsightsContext.test.tsx} +9 -9
  23. package/src/context/__tests__/{PostHogProvider.test.tsx → InsightsProvider.test.tsx} +33 -33
  24. package/src/context/index.ts +2 -2
  25. package/src/helpers/error-helpers.ts +2 -2
  26. package/src/hooks/__tests__/featureFlags.test.tsx +15 -15
  27. package/src/hooks/__tests__/useInsights.test.tsx +19 -0
  28. package/src/hooks/__tests__/useThumbSurvey.test.tsx +7 -7
  29. package/src/hooks/index.ts +1 -1
  30. package/src/hooks/useActiveFeatureFlags.ts +2 -2
  31. package/src/hooks/useFeatureFlagEnabled.ts +2 -2
  32. package/src/hooks/useFeatureFlagPayload.ts +2 -2
  33. package/src/hooks/useFeatureFlagResult.ts +2 -2
  34. package/src/hooks/useFeatureFlagVariantKey.ts +2 -2
  35. package/src/hooks/useInsights.ts +7 -0
  36. package/src/hooks/useThumbSurvey.ts +13 -13
  37. package/src/utils/type-utils.ts +2 -2
  38. package/surveys/package.json +1 -1
  39. package/src/context/PostHogContext.ts +0 -9
  40. package/src/context/PostHogProvider.tsx +0 -136
  41. package/src/hooks/__tests__/usePostHog.test.tsx +0 -19
  42. package/src/hooks/usePostHog.ts +0 -7
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020-2025 PostHog, Inc.
3
+ Copyright (c) 2020-2025 Insights, Inc.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,65 +1,65 @@
1
- # @posthog/react
1
+ # @hanzo/react
2
2
 
3
- React components and hooks for PostHog analytics integration.
3
+ React components and hooks for Insights analytics integration.
4
4
 
5
- [SEE FULL DOCS](https://posthog.com/docs/libraries/react)
5
+ [SEE FULL DOCS](https://insights.hanzo.ai/docs/libraries/react)
6
6
 
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
- npm install @posthog/react posthog-js
10
+ npm install @hanzo/react @hanzo/insights
11
11
  ```
12
12
 
13
13
  ## Usage
14
14
 
15
15
  ### Setting up the Provider
16
16
 
17
- Wrap your application with `PostHogProvider` to make the PostHog client available throughout your app:
17
+ Wrap your application with `InsightsProvider` to make the Insights client available throughout your app:
18
18
 
19
19
  ```tsx
20
- import { PostHogProvider } from '@posthog/react'
20
+ import { InsightsProvider } from '@hanzo/react'
21
21
 
22
22
  function App() {
23
23
  return (
24
- <PostHogProvider apiKey="<YOUR_PROJECT_API_KEY>" options={{ api_host: 'https://us.i.posthog.com' }}>
24
+ <InsightsProvider apiKey="<YOUR_PROJECT_API_KEY>" options={{ api_host: 'https://us.i.insights.hanzo.ai' }}>
25
25
  <YourApp />
26
- </PostHogProvider>
26
+ </InsightsProvider>
27
27
  )
28
28
  }
29
29
  ```
30
30
 
31
- Or pass an existing PostHog client instance:
31
+ Or pass an existing Insights client instance:
32
32
 
33
33
  ```tsx
34
- import posthog from 'posthog-js'
35
- import { PostHogProvider } from '@posthog/react'
34
+ import insights from '@hanzo/insights'
35
+ import { InsightsProvider } from '@hanzo/react'
36
36
 
37
37
  // Initialize your client
38
- posthog.init('<YOUR_PROJECT_API_KEY>', { api_host: 'https://us.i.posthog.com' })
38
+ insights.init('<YOUR_PROJECT_API_KEY>', { api_host: 'https://us.i.insights.hanzo.ai' })
39
39
 
40
40
  function App() {
41
41
  return (
42
- <PostHogProvider client={posthog}>
42
+ <InsightsProvider client={insights}>
43
43
  <YourApp />
44
- </PostHogProvider>
44
+ </InsightsProvider>
45
45
  )
46
46
  }
47
47
  ```
48
48
 
49
49
  ### Hooks
50
50
 
51
- #### usePostHog
51
+ #### useInsights
52
52
 
53
- Access the PostHog client instance to capture events, identify users, etc.
53
+ Access the Insights client instance to capture events, identify users, etc.
54
54
 
55
55
  ```tsx
56
- import { usePostHog } from '@posthog/react'
56
+ import { useInsights } from '@hanzo/react'
57
57
 
58
58
  function MyComponent() {
59
- const posthog = usePostHog()
59
+ const insights = useInsights()
60
60
 
61
61
  const handleClick = () => {
62
- posthog.capture('button_clicked', { button_name: 'signup' })
62
+ insights.capture('button_clicked', { button_name: 'signup' })
63
63
  }
64
64
 
65
65
  return <button onClick={handleClick}>Sign Up</button>
@@ -71,7 +71,7 @@ function MyComponent() {
71
71
  Check if a feature flag is enabled for the current user.
72
72
 
73
73
  ```tsx
74
- import { useFeatureFlagEnabled } from '@posthog/react'
74
+ import { useFeatureFlagEnabled } from '@hanzo/react'
75
75
 
76
76
  function MyComponent() {
77
77
  const isEnabled = useFeatureFlagEnabled('new-feature')
@@ -88,7 +88,7 @@ function MyComponent() {
88
88
  Get the variant key for a multivariate feature flag.
89
89
 
90
90
  ```tsx
91
- import { useFeatureFlagVariantKey } from '@posthog/react'
91
+ import { useFeatureFlagVariantKey } from '@hanzo/react'
92
92
 
93
93
  function MyComponent() {
94
94
  const variant = useFeatureFlagVariantKey('experiment-flag')
@@ -108,7 +108,7 @@ function MyComponent() {
108
108
  Get the payload associated with a feature flag.
109
109
 
110
110
  ```tsx
111
- import { useFeatureFlagPayload } from '@posthog/react'
111
+ import { useFeatureFlagPayload } from '@hanzo/react'
112
112
 
113
113
  function MyComponent() {
114
114
  const payload = useFeatureFlagPayload('feature-with-payload')
@@ -122,7 +122,7 @@ function MyComponent() {
122
122
  Get all active feature flags for the current user.
123
123
 
124
124
  ```tsx
125
- import { useActiveFeatureFlags } from '@posthog/react'
125
+ import { useActiveFeatureFlags } from '@hanzo/react'
126
126
 
127
127
  function MyComponent() {
128
128
  const activeFlags = useActiveFeatureFlags()
@@ -139,60 +139,60 @@ function MyComponent() {
139
139
 
140
140
  ### Components
141
141
 
142
- #### PostHogFeature
142
+ #### InsightsFeature
143
143
 
144
144
  A component that renders content based on a feature flag's value. Automatically tracks feature views and interactions.
145
145
 
146
146
  ```tsx
147
- import { PostHogFeature } from '@posthog/react'
147
+ import { InsightsFeature } from '@hanzo/react'
148
148
 
149
149
  function MyComponent() {
150
150
  return (
151
- <PostHogFeature flag="new-cta" fallback={<OldButton />}>
151
+ <InsightsFeature flag="new-cta" fallback={<OldButton />}>
152
152
  <NewButton />
153
- </PostHogFeature>
153
+ </InsightsFeature>
154
154
  )
155
155
  }
156
156
 
157
157
  // With variant matching
158
158
  function MyComponent() {
159
159
  return (
160
- <PostHogFeature flag="experiment" match="test" fallback={<ControlVersion />}>
160
+ <InsightsFeature flag="experiment" match="test" fallback={<ControlVersion />}>
161
161
  <TestVersion />
162
- </PostHogFeature>
162
+ </InsightsFeature>
163
163
  )
164
164
  }
165
165
 
166
166
  // With payload as render function
167
167
  function MyComponent() {
168
168
  return (
169
- <PostHogFeature flag="banner-config">
169
+ <InsightsFeature flag="banner-config">
170
170
  {(payload) => <Banner title={payload.title} color={payload.color} />}
171
- </PostHogFeature>
171
+ </InsightsFeature>
172
172
  )
173
173
  }
174
174
  ```
175
175
 
176
- #### PostHogErrorBoundary
176
+ #### InsightsErrorBoundary
177
177
 
178
- An error boundary that captures React errors and reports them to PostHog.
178
+ An error boundary that captures React errors and reports them to Insights.
179
179
 
180
180
  ```tsx
181
- import { PostHogErrorBoundary } from '@posthog/react'
181
+ import { InsightsErrorBoundary } from '@hanzo/react'
182
182
 
183
183
  function App() {
184
184
  return (
185
- <PostHogProvider apiKey="<YOUR_PROJECT_API_KEY>">
186
- <PostHogErrorBoundary>
185
+ <InsightsProvider apiKey="<YOUR_PROJECT_API_KEY>">
186
+ <InsightsErrorBoundary>
187
187
  <YourApp />
188
- </PostHogErrorBoundary>
189
- </PostHogProvider>
188
+ </InsightsErrorBoundary>
189
+ </InsightsProvider>
190
190
  )
191
191
  }
192
192
  ```
193
193
 
194
- Please see the main [PostHog docs](https://www.posthog.com/docs).
194
+ Please see the main [Insights docs](https://www.insights.hanzo.ai/docs).
195
195
 
196
196
  ## Questions?
197
197
 
198
- ### [Check out our community page.](https://posthog.com/posts)
198
+ ### [Check out our community page.](https://insights.hanzo.ai/posts)
package/dist/esm/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import posthogJs from '@hanzo/insights';
1
+ import insightsJs from '@hanzo/insights';
2
2
  import React, { createContext, useRef, useMemo, useEffect, useContext, useState, useCallback, Children } from 'react';
3
3
 
4
- var PostHogContext = createContext({
5
- client: posthogJs,
4
+ var InsightsContext = createContext({
5
+ client: insightsJs,
6
6
  bootstrap: undefined,
7
7
  });
8
8
 
@@ -35,25 +35,25 @@ function isDeepEqual(obj1, obj2, visited) {
35
35
  return true;
36
36
  }
37
37
 
38
- function PostHogProvider(_a) {
38
+ function InsightsProvider(_a) {
39
39
  var _b, _c;
40
40
  var children = _a.children, client = _a.client, apiKey = _a.apiKey, options = _a.options;
41
41
  var previousInitializationRef = useRef(null);
42
- var posthog = useMemo(function () {
42
+ var insights = useMemo(function () {
43
43
  if (client) {
44
44
  if (apiKey) {
45
- console.warn('[PostHog.js] You have provided both `client` and `apiKey` to `PostHogProvider`. `apiKey` will be ignored in favour of `client`.');
45
+ console.warn('[Insights] You have provided both `client` and `apiKey` to `InsightsProvider`. `apiKey` will be ignored in favour of `client`.');
46
46
  }
47
47
  if (options) {
48
- console.warn('[PostHog.js] You have provided both `client` and `options` to `PostHogProvider`. `options` will be ignored in favour of `client`.');
48
+ console.warn('[Insights] You have provided both `client` and `options` to `InsightsProvider`. `options` will be ignored in favour of `client`.');
49
49
  }
50
50
  return client;
51
51
  }
52
52
  if (apiKey) {
53
- return posthogJs;
53
+ return insightsJs;
54
54
  }
55
- console.warn('[PostHog.js] No `apiKey` or `client` were provided to `PostHogProvider`. Using default global `window.posthog` instance. You must initialize it manually. This is not recommended behavior.');
56
- return posthogJs;
55
+ console.warn('[Insights] No `apiKey` or `client` were provided to `InsightsProvider`. Using default global instance. You must initialize it manually. This is not recommended behavior.');
56
+ return insightsJs;
57
57
  }, [client, apiKey, JSON.stringify(options)]);
58
58
  useEffect(function () {
59
59
  if (client) {
@@ -61,10 +61,10 @@ function PostHogProvider(_a) {
61
61
  }
62
62
  var previousInitialization = previousInitializationRef.current;
63
63
  if (!previousInitialization) {
64
- if (posthogJs.__loaded) {
65
- console.warn('[PostHog.js] `posthog` was already loaded elsewhere. This may cause issues.');
64
+ if (insightsJs.__loaded) {
65
+ console.warn('[Insights] `insights` was already loaded elsewhere. This may cause issues.');
66
66
  }
67
- posthogJs.init(apiKey, options);
67
+ insightsJs.init(apiKey, options);
68
68
  previousInitializationRef.current = {
69
69
  apiKey: apiKey,
70
70
  options: options !== null && options !== void 0 ? options : {},
@@ -72,10 +72,10 @@ function PostHogProvider(_a) {
72
72
  }
73
73
  else {
74
74
  if (apiKey !== previousInitialization.apiKey) {
75
- console.warn("[PostHog.js] You have provided a different `apiKey` to `PostHogProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop.");
75
+ console.warn("[Insights] You have provided a different `apiKey` to `InsightsProvider` than the one that was already initialized. This is not supported by our provider and we'll keep using the previous key. If you need to toggle between API Keys you need to control the `client` yourself and pass it in as a prop rather than an `apiKey` prop.");
76
76
  }
77
77
  if (options && !isDeepEqual(options, previousInitialization.options)) {
78
- posthogJs.set_config(options);
78
+ insightsJs.set_config(options);
79
79
  }
80
80
  previousInitializationRef.current = {
81
81
  apiKey: apiKey,
@@ -83,7 +83,7 @@ function PostHogProvider(_a) {
83
83
  };
84
84
  }
85
85
  }, [client, apiKey, JSON.stringify(options)]);
86
- return (React.createElement(PostHogContext.Provider, { value: { client: posthog, bootstrap: (_b = options === null || options === void 0 ? void 0 : options.bootstrap) !== null && _b !== void 0 ? _b : (_c = client === null || client === void 0 ? void 0 : client.config) === null || _c === void 0 ? void 0 : _c.bootstrap } }, children));
86
+ return (React.createElement(InsightsContext.Provider, { value: { client: insights, bootstrap: (_b = options === null || options === void 0 ? void 0 : options.bootstrap) !== null && _b !== void 0 ? _b : (_c = client === null || client === void 0 ? void 0 : client.config) === null || _c === void 0 ? void 0 : _c.bootstrap } }, children));
87
87
  }
88
88
 
89
89
  var isFunction = function (f) {
@@ -98,7 +98,7 @@ var isNull = function (x) {
98
98
 
99
99
  function useFeatureFlagEnabled(flag) {
100
100
  var _a, _b;
101
- var _c = useContext(PostHogContext), client = _c.client, bootstrap = _c.bootstrap;
101
+ var _c = useContext(InsightsContext), client = _c.client, bootstrap = _c.bootstrap;
102
102
  var _d = useState(function () { return client.isFeatureEnabled(flag); }), featureEnabled = _d[0], setFeatureEnabled = _d[1];
103
103
  useEffect(function () {
104
104
  return client.onFeatureFlags(function () {
@@ -114,7 +114,7 @@ function useFeatureFlagEnabled(flag) {
114
114
 
115
115
  function useFeatureFlagPayload(flag) {
116
116
  var _a;
117
- var _b = useContext(PostHogContext), client = _b.client, bootstrap = _b.bootstrap;
117
+ var _b = useContext(InsightsContext), client = _b.client, bootstrap = _b.bootstrap;
118
118
  var _c = useState(function () { return client.getFeatureFlagPayload(flag); }), featureFlagPayload = _c[0], setFeatureFlagPayload = _c[1];
119
119
  useEffect(function () {
120
120
  return client.onFeatureFlags(function () {
@@ -129,7 +129,7 @@ function useFeatureFlagPayload(flag) {
129
129
 
130
130
  function useFeatureFlagResult(flag) {
131
131
  var _a, _b;
132
- var _c = useContext(PostHogContext), client = _c.client, bootstrap = _c.bootstrap;
132
+ var _c = useContext(InsightsContext), client = _c.client, bootstrap = _c.bootstrap;
133
133
  var _d = useState(function () { return client.getFeatureFlagResult(flag); }), result = _d[0], setResult = _d[1];
134
134
  useEffect(function () {
135
135
  return client.onFeatureFlags(function () {
@@ -153,7 +153,7 @@ function useFeatureFlagResult(flag) {
153
153
 
154
154
  function useActiveFeatureFlags() {
155
155
  var _a;
156
- var _b = useContext(PostHogContext), client = _b.client, bootstrap = _b.bootstrap;
156
+ var _b = useContext(InsightsContext), client = _b.client, bootstrap = _b.bootstrap;
157
157
  var _c = useState(function () { return client.featureFlags.getFlags(); }), featureFlags = _c[0], setFeatureFlags = _c[1];
158
158
  useEffect(function () {
159
159
  return client.onFeatureFlags(function (flags) {
@@ -168,7 +168,7 @@ function useActiveFeatureFlags() {
168
168
 
169
169
  function useFeatureFlagVariantKey(flag) {
170
170
  var _a;
171
- var _b = useContext(PostHogContext), client = _b.client, bootstrap = _b.bootstrap;
171
+ var _b = useContext(InsightsContext), client = _b.client, bootstrap = _b.bootstrap;
172
172
  var _c = useState(function () {
173
173
  return client.getFeatureFlag(flag);
174
174
  }), featureFlagVariantKey = _c[0], setFeatureFlagVariantKey = _c[1];
@@ -183,8 +183,8 @@ function useFeatureFlagVariantKey(flag) {
183
183
  return featureFlagVariantKey;
184
184
  }
185
185
 
186
- var usePostHog = function () {
187
- var client = useContext(PostHogContext).client;
186
+ var useInsights = function () {
187
+ var client = useContext(InsightsContext).client;
188
188
  return client;
189
189
  };
190
190
 
@@ -286,24 +286,24 @@ function VisibilityAndClickTrackers(_a) {
286
286
  return React.createElement(React.Fragment, null, trackedChildren);
287
287
  }
288
288
 
289
- function PostHogFeature(_a) {
289
+ function InsightsFeature(_a) {
290
290
  var flag = _a.flag, match = _a.match, children = _a.children, fallback = _a.fallback, visibilityObserverOptions = _a.visibilityObserverOptions, trackInteraction = _a.trackInteraction, trackView = _a.trackView, props = __rest(_a, ["flag", "match", "children", "fallback", "visibilityObserverOptions", "trackInteraction", "trackView"]);
291
291
  var payload = useFeatureFlagPayload(flag);
292
292
  var variant = useFeatureFlagVariantKey(flag);
293
- var posthog = usePostHog();
293
+ var insights = useInsights();
294
294
  var shouldTrackInteraction = trackInteraction !== null && trackInteraction !== void 0 ? trackInteraction : true;
295
295
  var shouldTrackView = trackView !== null && trackView !== void 0 ? trackView : true;
296
296
  if (!isUndefined(variant)) {
297
297
  if (isUndefined(match) || variant === match) {
298
298
  var childNode = isFunction(children) ? children(payload) : children;
299
- return (React.createElement(VisibilityAndClickTrackers, __assign({ flag: flag, options: visibilityObserverOptions, trackInteraction: shouldTrackInteraction, trackView: shouldTrackView, onInteract: function () { return captureFeatureInteraction({ flag: flag, posthog: posthog, flagVariant: variant }); }, onView: function () { return captureFeatureView({ flag: flag, posthog: posthog, flagVariant: variant }); } }, props), childNode));
299
+ return (React.createElement(VisibilityAndClickTrackers, __assign({ flag: flag, options: visibilityObserverOptions, trackInteraction: shouldTrackInteraction, trackView: shouldTrackView, onInteract: function () { return captureFeatureInteraction({ flag: flag, insights: insights, flagVariant: variant }); }, onView: function () { return captureFeatureView({ flag: flag, insights: insights, flagVariant: variant }); } }, props), childNode));
300
300
  }
301
301
  }
302
302
  return React.createElement(React.Fragment, null, fallback);
303
303
  }
304
304
  function captureFeatureInteraction(_a) {
305
305
  var _b;
306
- var flag = _a.flag, posthog = _a.posthog, flagVariant = _a.flagVariant;
306
+ var flag = _a.flag, insights = _a.insights, flagVariant = _a.flagVariant;
307
307
  var properties = {
308
308
  feature_flag: flag,
309
309
  $set: (_b = {}, _b["$feature_interaction/".concat(flag)] = flagVariant !== null && flagVariant !== void 0 ? flagVariant : true, _b),
@@ -311,11 +311,11 @@ function captureFeatureInteraction(_a) {
311
311
  if (typeof flagVariant === 'string') {
312
312
  properties.feature_flag_variant = flagVariant;
313
313
  }
314
- posthog.capture('$feature_interaction', properties);
314
+ insights.capture('$feature_interaction', properties);
315
315
  }
316
316
  function captureFeatureView(_a) {
317
317
  var _b;
318
- var flag = _a.flag, posthog = _a.posthog, flagVariant = _a.flagVariant;
318
+ var flag = _a.flag, insights = _a.insights, flagVariant = _a.flagVariant;
319
319
  var properties = {
320
320
  feature_flag: flag,
321
321
  $set: (_b = {}, _b["$feature_view/".concat(flag)] = flagVariant !== null && flagVariant !== void 0 ? flagVariant : true, _b),
@@ -323,31 +323,31 @@ function captureFeatureView(_a) {
323
323
  if (typeof flagVariant === 'string') {
324
324
  properties.feature_flag_variant = flagVariant;
325
325
  }
326
- posthog.capture('$feature_view', properties);
326
+ insights.capture('$feature_view', properties);
327
327
  }
328
328
 
329
329
  function TrackedChild(_a) {
330
330
  var child = _a.child, index = _a.index, name = _a.name, properties = _a.properties, observerOptions = _a.observerOptions;
331
331
  var trackedRef = useRef(false);
332
- var posthog = usePostHog();
332
+ var insights = useInsights();
333
333
  var onIntersect = useCallback(function (entry) {
334
334
  if (entry.isIntersecting && !trackedRef.current) {
335
- posthog.capture('$element_viewed', __assign({ element_name: name, child_index: index }, properties));
335
+ insights.capture('$element_viewed', __assign({ element_name: name, child_index: index }, properties));
336
336
  trackedRef.current = true;
337
337
  }
338
- }, [posthog, name, index, properties]);
338
+ }, [insights, name, index, properties]);
339
339
  return (React.createElement(VisibilityAndClickTracker, { onIntersect: onIntersect, trackView: true, options: observerOptions }, child));
340
340
  }
341
- function PostHogCaptureOnViewed(_a) {
341
+ function InsightsCaptureOnViewed(_a) {
342
342
  var name = _a.name, properties = _a.properties, observerOptions = _a.observerOptions, trackAllChildren = _a.trackAllChildren, children = _a.children, props = __rest(_a, ["name", "properties", "observerOptions", "trackAllChildren", "children"]);
343
343
  var trackedRef = useRef(false);
344
- var posthog = usePostHog();
344
+ var insights = useInsights();
345
345
  var onIntersect = useCallback(function (entry) {
346
346
  if (entry.isIntersecting && !trackedRef.current) {
347
- posthog.capture('$element_viewed', __assign({ element_name: name }, properties));
347
+ insights.capture('$element_viewed', __assign({ element_name: name }, properties));
348
348
  trackedRef.current = true;
349
349
  }
350
- }, [posthog, name, properties]);
350
+ }, [insights, name, properties]);
351
351
  if (trackAllChildren) {
352
352
  var trackedChildren = Children.map(children, function (child, index) {
353
353
  return (React.createElement(TrackedChild, { key: index, child: child, index: index, name: name, properties: properties, observerOptions: observerOptions }));
@@ -362,17 +362,17 @@ var INITIAL_STATE = {
362
362
  exceptionEvent: null,
363
363
  error: null,
364
364
  };
365
- var __POSTHOG_ERROR_MESSAGES = {
366
- INVALID_FALLBACK: '[PostHog.js][PostHogErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element.',
365
+ var __INSIGHTS_ERROR_MESSAGES = {
366
+ INVALID_FALLBACK: '[Insights][InsightsErrorBoundary] Invalid fallback prop, provide a valid React element or a function that returns a valid React element.',
367
367
  };
368
- var PostHogErrorBoundary = (function (_super) {
369
- __extends(PostHogErrorBoundary, _super);
370
- function PostHogErrorBoundary(props) {
368
+ var InsightsErrorBoundary = (function (_super) {
369
+ __extends(InsightsErrorBoundary, _super);
370
+ function InsightsErrorBoundary(props) {
371
371
  var _this = _super.call(this, props) || this;
372
372
  _this.state = INITIAL_STATE;
373
373
  return _this;
374
374
  }
375
- PostHogErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
375
+ InsightsErrorBoundary.prototype.componentDidCatch = function (error, errorInfo) {
376
376
  var additionalProperties = this.props.additionalProperties;
377
377
  var currentProperties;
378
378
  if (isFunction(additionalProperties)) {
@@ -390,7 +390,7 @@ var PostHogErrorBoundary = (function (_super) {
390
390
  exceptionEvent: exceptionEvent,
391
391
  });
392
392
  };
393
- PostHogErrorBoundary.prototype.render = function () {
393
+ InsightsErrorBoundary.prototype.render = function () {
394
394
  var _a = this.props, children = _a.children, fallback = _a.fallback;
395
395
  var state = this.state;
396
396
  if (state.componentStack == null) {
@@ -406,11 +406,11 @@ var PostHogErrorBoundary = (function (_super) {
406
406
  if (React.isValidElement(element)) {
407
407
  return element;
408
408
  }
409
- console.warn(__POSTHOG_ERROR_MESSAGES.INVALID_FALLBACK);
409
+ console.warn(__INSIGHTS_ERROR_MESSAGES.INVALID_FALLBACK);
410
410
  return React.createElement(React.Fragment, null);
411
411
  };
412
- PostHogErrorBoundary.contextType = PostHogContext;
413
- return PostHogErrorBoundary;
412
+ InsightsErrorBoundary.contextType = InsightsContext;
413
+ return InsightsErrorBoundary;
414
414
  }(React.Component));
415
415
 
416
416
  var setupReactErrorHandler = function (client, callback) {
@@ -422,5 +422,5 @@ var setupReactErrorHandler = function (client, callback) {
422
422
  };
423
423
  };
424
424
 
425
- export { PostHogCaptureOnViewed, PostHogContext, PostHogErrorBoundary, PostHogFeature, PostHogProvider, captureFeatureInteraction, captureFeatureView, setupReactErrorHandler, useActiveFeatureFlags, useFeatureFlagEnabled, useFeatureFlagPayload, useFeatureFlagResult, useFeatureFlagVariantKey, usePostHog };
425
+ export { InsightsCaptureOnViewed, InsightsContext, InsightsErrorBoundary, InsightsFeature, InsightsProvider, captureFeatureInteraction, captureFeatureView, setupReactErrorHandler, useActiveFeatureFlags, useFeatureFlagEnabled, useFeatureFlagPayload, useFeatureFlagResult, useFeatureFlagVariantKey, useInsights };
426
426
  //# sourceMappingURL=index.js.map