@cognite/reveal-widget 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -9,6 +9,40 @@ This package exposes `RevealWidget` and the types needed to drive it via
9
9
  `RevealWidgetController`. More capabilities from the broader Reveal Components toolkit
10
10
  will be exposed here incrementally over time.
11
11
 
12
+ ## Usage tracking (Mixpanel)
13
+
14
+ `RevealWidget` can report anonymous usage events to a Cognite-owned Mixpanel project. This
15
+ tells us which features of the widget are actually used (loading a resource, styling
16
+ instances, moving the camera, etc.) so we can prioritize development. No event payload
17
+ includes page URLs, referrers, resource IDs, or any other identifying data.
18
+
19
+ `RevealWidget` requires an `appIdentifier` prop so aggregate usage can be attributed
20
+ correctly. The optional `tracking` prop lets you change where events go:
21
+
22
+ ```tsx
23
+ // Reports to the default Cognite Mixpanel project (the default when `tracking` is omitted).
24
+ <RevealWidget viewerOptions={...} appIdentifier="my-app" />
25
+
26
+ // Opt out entirely — no events are sent anywhere.
27
+ <RevealWidget viewerOptions={...} appIdentifier="my-app" tracking={{ disabled: true }} />
28
+
29
+ // Report to your own Mixpanel project instead of Cognite's.
30
+ <RevealWidget
31
+ viewerOptions={...}
32
+ appIdentifier="my-app"
33
+ tracking={{ mixpanelToken: 'your-own-project-token' }}
34
+ />
35
+
36
+ // Route events through your own tracking/analytics pipeline instead of Mixpanel.
37
+ <RevealWidget
38
+ viewerOptions={...}
39
+ appIdentifier="my-app"
40
+ tracking={{ usageMetricsTracker: { track: (event, properties) => myOwnTracker(event, properties) } }}
41
+ />
42
+ ```
43
+
44
+ See `RevealWidgetTrackingProps` for the full set of options.
45
+
12
46
  ## Install
13
47
 
14
48
  ```bash
package/dist/index.d.ts CHANGED
@@ -3,22 +3,21 @@ import { CameraState, Cognite3DViewerOptions, NodeAppearance } from '@cognite/re
3
3
  import { DmsUniqueIdentifier, ExternalId, Space } from '@cognite/reveal-components/data-providers';
4
4
  import { AssetId } from '@cognite/reveal-components/data-providers/cache';
5
5
  import { AddReveal3DResource, AllResourceIdentifier, BaseAddOptions, CadAddOptions, NewCadModelStyling as CadModelStyling, CadResourceIdentifier, Classic3DResourceIdentifier, DM3DResourceIdentifier, Image360AddOptions, Image360DMResourceIdentifier, Image360EventsResourceIdentifier, Image360IconCullingOptions, Image360ResourceIdentifier, PointCloudAddOptions, PointCloudResourceIdentifier, SceneAddOptions, SceneResourceIdentifier, ThreeDResourceIdentifier } from '@cognite/reveal-components/data-providers/types';
6
- import { InstanceId } from '@cognite/reveal-components/utilities';
6
+ import { RevealWidgetTrackingProps } from '@cognite/reveal-components/ui/components';
7
+ import { InstanceId, UsageMetricsTracker } from '@cognite/reveal-components/utilities';
7
8
  import { InstanceStylingGroup } from '@cognite/reveal-components/utilities/modelIds';
8
9
  import { TreeIndexStylingGroup } from '@cognite/reveal-components/utilities/styling';
9
- export type { AddReveal3DResource, AllResourceIdentifier, AssetId, BaseAddOptions, CadAddOptions, CadModelStyling, CadResourceIdentifier, Classic3DResourceIdentifier, DM3DResourceIdentifier, DmsUniqueIdentifier, ExternalId, Image360AddOptions, Image360DMResourceIdentifier, Image360EventsResourceIdentifier, Image360IconCullingOptions, Image360ResourceIdentifier, InstanceId, InstanceStylingGroup, PointCloudAddOptions, PointCloudResourceIdentifier, SceneAddOptions, SceneResourceIdentifier, Space, ThreeDResourceIdentifier, TreeIndexStylingGroup, };
10
+ export type { AddReveal3DResource, AllResourceIdentifier, AssetId, BaseAddOptions, CadAddOptions, CadModelStyling, CadResourceIdentifier, Classic3DResourceIdentifier, DM3DResourceIdentifier, DmsUniqueIdentifier, ExternalId, Image360AddOptions, Image360DMResourceIdentifier, Image360EventsResourceIdentifier, Image360IconCullingOptions, Image360ResourceIdentifier, InstanceId, InstanceStylingGroup, UsageMetricsTracker, PointCloudAddOptions, PointCloudResourceIdentifier, RevealWidgetTrackingProps, SceneAddOptions, SceneResourceIdentifier, Space, ThreeDResourceIdentifier, TreeIndexStylingGroup, };
10
11
  /**
11
12
  * Public API surface for the standalone `@cognite/reveal-widget` npm package.
12
13
  *
13
14
  * `RevealWidget` here is the real, unmodified implementation from
14
15
  * `@cognite/reveal-components` — there is no runtime wrapper. `@cognite/reveal-components`
15
- * is a `dependencies` entry (not `devDependencies`), so it and its own published
16
- * dependencies (`@cognite/signal-utils`, `@cognite/underscore`) are treated as external
17
- * and resolved as real npm imports rather than bundled into this package's output. The
18
- * resource/identifier types above are re-exported directly from
19
- * `@cognite/reveal-components`'s narrow, already-subpath-exported type barrels
20
- * (`./data-providers/types`, `./utilities/modelIds`, `./utilities`), which an external
21
- * consumer resolves normally since that package is published.
16
+ * is a `dependencies` entry, so it and its own published dependencies (`@cognite/signal-utils`,
17
+ * `@cognite/underscore`) are treated as external. The resource/identifier types above are
18
+ * re-exported directly from `@cognite/reveal-components`'s narrow, already-subpath-exported
19
+ * type barrels (`./data-providers/types`, `./utilities/modelIds`, `./utilities`), which an
20
+ * external consumer resolves normally since that package is published.
22
21
  *
23
22
  * `Reveal3DResourceHandle`, `RevealWidgetController`, `RevealWidgetCameraController`, and
24
23
  * `RevealWidgetProps` below are still hand-declared, because their real counterparts (only
@@ -27,6 +26,16 @@ export type { AddReveal3DResource, AllResourceIdentifier, AssetId, BaseAddOption
27
26
  * and not meaningful for an external consumer anyway. `src/index.test.ts` has compile-time-only
28
27
  * (`// @ts-expect-error`-driven) tests asserting these hand-written types stay structurally
29
28
  * compatible with the real implementation — update both together when the real API changes.
29
+ * `RevealWidgetTrackingProps` (and its arms) don't have this problem — they only reference
30
+ * `UsageMetricsTracker`, so they're imported and re-exported directly from `./ui/components`
31
+ * rather than hand-declared.
32
+ *
33
+ * `tracking`/`appIdentifier` (on `RevealWidgetProps`) plumb through to the real `RevealWidget`'s
34
+ * usage-tracking seam, which reports to a dedicated, named `mixpanel-browser` instance *by
35
+ * default* — not Fusion's own `@cognite/metrics`/Mixpanel setup, since `@cognite/reveal-widget`
36
+ * is also consumed outside this monorepo. Pass `tracking: { disabled: true }` to opt out
37
+ * entirely, or `tracking: { mixpanelToken }` (with `appIdentifier`) to report to your own
38
+ * Mixpanel project instead.
30
39
  */
31
40
  export declare const Default3DStyles: {
32
41
  Highlighted: {
@@ -112,5 +121,12 @@ export type RevealWidgetProps = {
112
121
  * The widget calls this with `undefined` when the component unmounts or this callback changes
113
122
  */
114
123
  setControllerRef?: (controller: RevealWidgetController | undefined) => void;
124
+ /**
125
+ * Reports which application is using the widget and which of its features are being triggered
126
+ * (e.g. adding a resource, moving the camera). See `RevealWidgetTrackingProps` for the options.
127
+ */
128
+ tracking?: RevealWidgetTrackingProps;
129
+ /** Identifies the host application */
130
+ appIdentifier: string;
115
131
  };
116
132
  export declare const RevealWidget: (props: PropsWithChildren<RevealWidgetProps>) => ReactElement;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cognite/reveal-widget",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -24,7 +24,7 @@
24
24
  "ml-matrix": "^6.12.1",
25
25
  "random-seed": "^0.3.0",
26
26
  "three": "0.184.0",
27
- "@cognite/reveal-components": "1.0.1",
27
+ "@cognite/reveal-components": "1.0.2",
28
28
  "@cognite/aura": "0.3.5"
29
29
  },
30
30
  "devDependencies": {