@memori.ai/memori-webcomponent 2.7.0 → 2.7.2

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": "2.7.0",
3
+ "version": "2.7.2",
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": "^2.7.0",
222
+ "@memori.ai/memori-react": "^2.7.1",
223
223
  "react": "17.0.2",
224
224
  "react-dom": "17.0.2"
225
225
  }
package/src/index.tsx CHANGED
@@ -1,7 +1,14 @@
1
1
  import ReactDOM from 'react-dom';
2
-
3
2
  import Memori from '@memori.ai/memori-react';
4
3
 
4
+ const parseJSONsafe = (json: string): { [key: string]: any } | null => {
5
+ try {
6
+ return JSON.parse(json);
7
+ } catch (e) {
8
+ return null;
9
+ }
10
+ };
11
+
5
12
  class MemoriWebComponent extends HTMLElement {
6
13
  connectedCallback() {
7
14
  const wrapper = document.createElement('div');
@@ -34,10 +41,17 @@ class MemoriWebComponent extends HTMLElement {
34
41
  const [key, value] = cur.split(':').map(t => t.trim());
35
42
  return { ...acc, [key]: value };
36
43
  }, {});
44
+ const additionalInfo =
45
+ parseJSONsafe(this.getAttribute('additionalInfo') || '{}') || {};
37
46
 
38
47
  if (tenantID) {
39
48
  ReactDOM.render(
40
- <Memori {...props} context={parsedContext} tenantID={tenantID} />,
49
+ <Memori
50
+ {...props}
51
+ context={parsedContext}
52
+ tenantID={tenantID}
53
+ additionalInfo={additionalInfo}
54
+ />,
41
55
  mountPoint
42
56
  );
43
57
  } else {