@equinor/fusion-framework-react-app 10.0.2 → 10.0.5

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.
@@ -1 +1 @@
1
- export declare const version = "10.0.2";
1
+ export declare const version = "10.0.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@equinor/fusion-framework-react-app",
3
- "version": "10.0.2",
3
+ "version": "10.0.5",
4
4
  "description": "",
5
5
  "main": "./dist/esm/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -117,14 +117,14 @@
117
117
  "directory": "packages/react"
118
118
  },
119
119
  "dependencies": {
120
- "@equinor/fusion-framework-app": "11.0.1",
120
+ "@equinor/fusion-framework-app": "11.0.3",
121
121
  "@equinor/fusion-framework-module": "6.0.0",
122
- "@equinor/fusion-framework-module-app": "8.0.0",
123
- "@equinor/fusion-framework-module-navigation": "7.0.1",
122
+ "@equinor/fusion-framework-module-app": "8.0.1",
123
+ "@equinor/fusion-framework-module-navigation": "7.0.2",
124
124
  "@equinor/fusion-framework-react": "8.0.0",
125
125
  "@equinor/fusion-framework-react-module": "4.0.0",
126
- "@equinor/fusion-framework-module-http": "8.0.0",
127
- "@equinor/fusion-framework-react-module-http": "11.0.0"
126
+ "@equinor/fusion-framework-react-module-http": "11.0.0",
127
+ "@equinor/fusion-framework-module-http": "8.0.0"
128
128
  },
129
129
  "devDependencies": {
130
130
  "@types/react": "^19.2.7",
@@ -136,20 +136,20 @@
136
136
  "typescript": "^5.9.3",
137
137
  "vitest": "^4.1.0",
138
138
  "@equinor/fusion-framework-module-ag-grid": "36.0.0",
139
- "@equinor/fusion-framework-module-analytics": "2.0.1",
139
+ "@equinor/fusion-framework-module-analytics": "2.0.3",
140
140
  "@equinor/fusion-framework-module-event": "6.0.0",
141
- "@equinor/fusion-framework-module-feature-flag": "2.0.0",
142
- "@equinor/fusion-framework-module-msal": "8.0.1",
141
+ "@equinor/fusion-framework-module-feature-flag": "2.0.1",
142
+ "@equinor/fusion-framework-react-module-context": "7.0.0",
143
143
  "@equinor/fusion-framework-react-module-bookmark": "6.0.0",
144
- "@equinor/fusion-observable": "9.0.0",
145
- "@equinor/fusion-framework-react-module-context": "7.0.0"
144
+ "@equinor/fusion-observable": "9.0.1",
145
+ "@equinor/fusion-framework-module-msal": "8.0.2"
146
146
  },
147
147
  "peerDependencies": {
148
148
  "@types/react": "^18.0.0 || ^19.0.0",
149
149
  "react": "^18.0.0 || ^19.0.0",
150
150
  "react-dom": "^18.0.0 || ^19.0.0",
151
151
  "rxjs": "^7.0.0",
152
- "@equinor/fusion-framework-module-msal": "^8.0.1"
152
+ "@equinor/fusion-framework-module-msal": "^8.0.2"
153
153
  },
154
154
  "peerDependenciesMeta": {
155
155
  "@equinor/fusion-framework-react-module-ag-grid": {
@@ -1,41 +1,148 @@
1
- ## Analytics
1
+ ## Analytics React Hooks
2
2
 
3
- The Fusion Framework Analytics Module provides an unified way to track analytics.
3
+ React hooks for tracking application feature usage through the Fusion analytics module.
4
4
 
5
- This is a hook to manually send features to track.
5
+ These hooks are available from `@equinor/fusion-framework-react-app/analytics`. The analytics module is enabled and configured by the hosting portal, so **apps running inside a Fusion portal can use these hooks immediately without any setup**.
6
6
 
7
- This hook can be used by app teams wanting to track a specific feature they use.
7
+ ### Why track feature usage?
8
+
9
+ Understanding how users interact with your application helps you make informed decisions about what to build, improve, or remove. Without usage data, you are guessing which features matter.
10
+
11
+ Common reasons to add feature tracking:
12
+
13
+ - **Measure adoption** — find out whether a newly released feature is actually being used, and by how many users across different contexts.
14
+ - **Identify unused features** — discover features that can be simplified or removed, reducing maintenance cost and complexity.
15
+ - **Understand user workflows** — see which paths users take through your application, revealing unexpected patterns or friction points.
16
+ - **Support data-driven prioritisation** — back up roadmap discussions with real usage numbers instead of assumptions.
17
+ - **Debug user-reported issues** — correlate analytics events with error reports to understand what the user was doing when something went wrong.
18
+
19
+ ### When to use `useTrackFeature`
20
+
21
+ Use `useTrackFeature` when you want to record a discrete user action or application milestone from a React component. Typical use cases include:
22
+
23
+ | Use case | What to track | Example event name |
24
+ |----------|---------------|-------------------|
25
+ | Button or action clicks | User triggers a specific workflow | `'export-clicked'`, `'filter-applied'` |
26
+ | Page or component views | A section of the app is displayed | `'dashboard-loaded'`, `'settings-opened'` |
27
+ | Feature gate checks | A feature behind a flag is accessed | `'beta-feature-used'` |
28
+ | Form submissions | A user completes a form or wizard step | `'report-submitted'`, `'wizard-step-3'` |
29
+ | Error recovery actions | A user retries or dismisses an error | `'retry-clicked'`, `'error-dismissed'` |
30
+ | Search and filtering | A user interacts with data exploration tools | `'search-executed'`, `'date-range-changed'` |
31
+
32
+ > [!TIP]
33
+ > You do not need to track every click. Focus on actions that answer a question about user behavior or feature value.
8
34
 
9
35
  ### useTrackFeature
10
36
 
11
- A hook to send feature used.
37
+ Returns a stable callback for tracking feature usage events. Each event automatically includes the current app key and active context as attributes, so downstream dashboards can group events by application and context without extra work.
12
38
 
13
- ```typescript
14
- const trackFeature = useTrackFeature();
39
+ **Signature:**
15
40
 
16
- trackFeature('foo');
41
+ ```typescript
42
+ function useTrackFeature(): (name: string, data?: AnyValueMap) => void;
17
43
  ```
18
44
 
19
- ```typescript
20
- const SomeComponent = () => {
45
+ | Parameter | Type | Description |
46
+ |-----------|------|-------------|
47
+ | `name` | `string` | Name of the feature being tracked |
48
+ | `data` | `AnyValueMap` (optional) | Additional key-value pairs to include with the event |
49
+
50
+ #### Track a button click
51
+
52
+ ```tsx
53
+ import { useCallback } from 'react';
54
+ import { useTrackFeature } from '@equinor/fusion-framework-react-app/analytics';
55
+
56
+ const MyButton = () => {
21
57
  const trackFeature = useTrackFeature();
22
58
 
23
- // Tracks when button is clicked.
24
- const handleOnClick = useCallback(() => {
59
+ const handleClick = useCallback(() => {
25
60
  trackFeature('button-clicked');
26
61
  }, [trackFeature]);
27
62
 
28
- // Triggers when the component is loaded.
63
+ return <button onClick={handleClick}>Click me</button>;
64
+ };
65
+ ```
66
+
67
+ #### Track with additional data
68
+
69
+ Pass a second argument to include custom attributes with the event:
70
+
71
+ ```tsx
72
+ import { useCallback } from 'react';
73
+ import { useTrackFeature } from '@equinor/fusion-framework-react-app/analytics';
74
+
75
+ const SaveButton = ({ section }: { section: string }) => {
76
+ const trackFeature = useTrackFeature();
77
+
78
+ const handleSave = useCallback(() => {
79
+ trackFeature('save-clicked', { section, timestamp: Date.now() });
80
+ }, [trackFeature, section]);
81
+
82
+ return <button onClick={handleSave}>Save</button>;
83
+ };
84
+ ```
85
+
86
+ #### Track on component mount
87
+
88
+ Use `useEffect` to track when a component or page loads:
89
+
90
+ ```tsx
91
+ import { useEffect } from 'react';
92
+ import { useTrackFeature } from '@equinor/fusion-framework-react-app/analytics';
93
+
94
+ const Dashboard = () => {
95
+ const trackFeature = useTrackFeature();
96
+
97
+ useEffect(() => {
98
+ trackFeature('dashboard-loaded');
99
+ }, [trackFeature]);
100
+
101
+ return <div>Dashboard content</div>;
102
+ };
103
+ ```
104
+
105
+ #### Combine click and mount tracking
106
+
107
+ ```tsx
108
+ import { useCallback, useEffect } from 'react';
109
+ import { useTrackFeature } from '@equinor/fusion-framework-react-app/analytics';
110
+
111
+ const SomeComponent = () => {
112
+ const trackFeature = useTrackFeature();
113
+
29
114
  useEffect(() => {
30
115
  trackFeature('SomeComponent loaded');
116
+ trackFeature('some feature happened', { extra: 'data', foo: 'bar' });
117
+ }, [trackFeature]);
31
118
 
32
- // Send additional data
33
- trackFeature('some feature happened', {
34
- extra: 'data',
35
- foo: 'bar',
36
- });
119
+ const handleOnClick = useCallback(() => {
120
+ trackFeature('button-clicked');
37
121
  }, [trackFeature]);
38
122
 
39
123
  return <button onClick={handleOnClick}>Click me</button>;
40
124
  };
41
125
  ```
126
+
127
+ ### Prerequisites
128
+
129
+ The analytics module must be enabled for these hooks to work. **In most cases, no app-level configuration is needed** — the hosting Fusion portal already enables and configures analytics with the appropriate adapters and collectors. Your app inherits this automatically.
130
+
131
+ If the module is not available (e.g. in a standalone or custom portal setup), `useTrackFeature` logs an exception via the telemetry provider instead of throwing, so your app will not crash.
132
+
133
+ #### Custom or standalone setups
134
+
135
+ If you are building a custom portal or running outside the standard Fusion portal, you need to enable the analytics module yourself:
136
+
137
+ ```typescript
138
+ import { enableAnalytics } from '@equinor/fusion-framework-module-analytics';
139
+ import { ConsoleAnalyticsAdapter } from '@equinor/fusion-framework-module-analytics/adapters';
140
+
141
+ const configure = (configurator) => {
142
+ enableAnalytics(configurator, (builder) => {
143
+ builder.setAdapter('console', async () => new ConsoleAnalyticsAdapter());
144
+ });
145
+ };
146
+ ```
147
+
148
+ See the [analytics module documentation](https://equinor.github.io/fusion-framework/modules/analytics/) for adapter and collector setup.
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  // Generated by genversion.
2
- export const version = '10.0.2';
2
+ export const version = '10.0.5';