@knime/hub-features 1.17.1 → 1.18.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @knime/hub-features
2
2
 
3
+ ## 1.18.1
4
+
5
+ ### Patch Changes
6
+
7
+ - d9aeb5f: add property to embedding context to determine if analytics can be used
8
+
9
+ ## 1.18.0
10
+
11
+ ### Minor Changes
12
+
13
+ - 22473f0: Add analytics generic event to embedding SDK
14
+
3
15
  ## 1.17.1
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@knime/hub-features",
3
- "version": "1.17.1",
3
+ "version": "1.18.1",
4
4
  "description": "Vue components & composables for shared hub features",
5
5
  "repository": {
6
6
  "type": "git",
@@ -53,6 +53,8 @@ const defaultvalidator: EmbeddingContextValidator = () => ({
53
53
  error: null,
54
54
  });
55
55
 
56
+ const PARENT_ORIGIN = "*";
57
+
56
58
  /**
57
59
  * Wait for host application to send a message containing the embedding context
58
60
  */
@@ -98,19 +100,25 @@ export const waitForContext = (
98
100
 
99
101
  // send message to parent after postmessage listener has been set-up
100
102
  logger().info("Awaiting to receive embedding context");
101
- window.parent.postMessage({ type: MESSAGES.AWAITING_EMBEDDING_CONTEXT }, "*");
103
+ window.parent.postMessage(
104
+ { type: MESSAGES.AWAITING_EMBEDDING_CONTEXT },
105
+ PARENT_ORIGIN,
106
+ );
102
107
 
103
108
  return promise;
104
109
  };
105
110
 
106
111
  export const sendEmbeddingFailureMessage = (error: unknown) => {
107
- window.parent.postMessage({ type: MESSAGES.EMBEDDING_FAILED, error }, "*");
112
+ window.parent.postMessage(
113
+ { type: MESSAGES.EMBEDDING_FAILED, error },
114
+ PARENT_ORIGIN,
115
+ );
108
116
  };
109
117
 
110
118
  export const dispatchGenericEventToHost = (event: GenericEvent) => {
111
119
  window.parent.postMessage(
112
120
  { type: MESSAGES.GENERIC_EVENT, payload: event },
113
- "*",
121
+ PARENT_ORIGIN,
114
122
  );
115
123
  };
116
124
 
@@ -119,6 +127,6 @@ export const notifyActivityChange = (userActivityInfo: UserActivityInfo) => {
119
127
 
120
128
  window.parent.postMessage(
121
129
  { type: MESSAGES.USER_ACTIVITY, payload: userActivityInfo },
122
- "*",
130
+ PARENT_ORIGIN,
123
131
  );
124
132
  };
@@ -8,7 +8,9 @@ export type EmbeddingContext = {
8
8
  wsConnectionUri: string;
9
9
  /**
10
10
  * @deprecated URI of the WS used by the embedded application.
11
- * Last used in AP 5.8.0
11
+ * Last used in AP 5.8.0. From 5.9.0 and onwards `wsConnectionUri` is preferred.
12
+ * Although, the AP still references the url for compatibility with older embedders
13
+ * that don't use the new property `wsConnectionUri`
12
14
  */
13
15
  url?: string;
14
16
  /**
@@ -32,6 +34,10 @@ export type EmbeddingContext = {
32
34
  * are being made on the page
33
35
  */
34
36
  userIdleTimeout?: number;
37
+ /**
38
+ * Whether the embedded application can send analytic and tracking events
39
+ */
40
+ enableAnalytics?: boolean;
35
41
  };
36
42
 
37
43
  type ShowNotificationEvent = {
@@ -56,10 +62,20 @@ type HostNavigationRequestEvent = {
56
62
  | { intent: "navigate"; href: string; openIn: "_blank" | "_parent" };
57
63
  };
58
64
 
65
+ type AnalyticsEvent = {
66
+ kind: "analytics";
67
+ payload: {
68
+ category: string;
69
+ name: string;
70
+ data: unknown;
71
+ };
72
+ };
73
+
59
74
  export type GenericEvent =
60
75
  | ShowNotificationEvent
61
76
  | ClearNotificationEvent
62
- | HostNavigationRequestEvent;
77
+ | HostNavigationRequestEvent
78
+ | AnalyticsEvent;
63
79
 
64
80
  export type GenericEventByKind<K extends GenericEvent["kind"]> = Extract<
65
81
  GenericEvent,