@memori.ai/memori-webcomponent 7.12.2 → 7.13.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memori.ai/memori-webcomponent",
3
- "version": "7.12.2",
3
+ "version": "7.13.0",
4
4
  "description": "WebComponent to integrate a Memori in your app or website",
5
5
  "author": "Memori Srl",
6
6
  "source": "src/index.tsx",
@@ -219,7 +219,7 @@
219
219
  "util": "^0.12.3"
220
220
  },
221
221
  "dependencies": {
222
- "@memori.ai/memori-react": "^7.12.2",
222
+ "@memori.ai/memori-react": "^7.13.0",
223
223
  "react": "17.0.2",
224
224
  "react-dom": "17.0.2"
225
225
  }
package/src/index.tsx CHANGED
@@ -1,9 +1,10 @@
1
1
  import ReactDOM from 'react-dom';
2
+ import type { Integration } from '@memori.ai/memori-api-client/dist/types';
2
3
  import Memori from '@memori.ai/memori-react';
3
4
 
4
- const parseJSONsafe = (json: string): { [key: string]: any } | null => {
5
+ const parseJSONsafe = <T = { [key: string]: any },>(json: string): T | null => {
5
6
  try {
6
- return JSON.parse(json);
7
+ return JSON.parse(json) as T;
7
8
  } catch (e) {
8
9
  return null;
9
10
  }
@@ -40,6 +41,10 @@ class MemoriWebComponent extends HTMLElement {
40
41
  }, {});
41
42
  const additionalInfo =
42
43
  parseJSONsafe(this.getAttribute('additionalInfo') || '{}') || {};
44
+ const integration = this.getAttribute('integration');
45
+ const parsedIntegration = integration
46
+ ? parseJSONsafe<Integration>(integration) || undefined
47
+ : undefined;
43
48
 
44
49
  if (tenantID) {
45
50
  ReactDOM.render(
@@ -48,6 +53,7 @@ class MemoriWebComponent extends HTMLElement {
48
53
  context={parsedContext}
49
54
  tenantID={tenantID}
50
55
  additionalInfo={additionalInfo}
56
+ integration={parsedIntegration}
51
57
  />,
52
58
  mountPoint
53
59
  );