@product7/product7-js 0.3.8 → 0.3.9

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": "@product7/product7-js",
3
- "version": "0.3.8",
3
+ "version": "0.3.9",
4
4
  "description": "JavaScript SDK for integrating Product7 feedback widgets into any website",
5
5
  "main": "dist/product7-js.js",
6
6
  "module": "src/index.js",
@@ -89,8 +89,9 @@ export class APIService extends BaseAPIService {
89
89
  status: true,
90
90
  data: {
91
91
  contact_id: 'mock_contact_' + Date.now(),
92
- email: metadata.email,
92
+ email: metadata.email || '',
93
93
  name: metadata.name || '',
94
+ avatar: metadata.avatar || '',
94
95
  is_new: true,
95
96
  },
96
97
  };
@@ -98,21 +99,22 @@ export class APIService extends BaseAPIService {
98
99
  return mockResponse;
99
100
  }
100
101
 
102
+ const payload = {};
103
+
104
+ if (metadata.email) payload.email = metadata.email;
105
+ if (metadata.user_id) payload.user_id = metadata.user_id;
106
+ if (metadata.name) payload.name = metadata.name;
107
+ if (metadata.avatar) payload.avatar = metadata.avatar;
108
+ if (metadata.attributes) payload.attributes = metadata.attributes;
109
+ if (metadata.company) payload.company = metadata.company;
110
+
101
111
  const response = await this._makeRequest('/widget/identify', {
102
112
  method: 'POST',
103
113
  headers: {
104
114
  'Content-Type': 'application/json',
105
115
  Authorization: `Bearer ${this.sessionToken}`,
106
116
  },
107
- body: JSON.stringify({
108
- // user_id: metadata.user_id || null,
109
- email: metadata.email || '',
110
- // name: metadata.name || '',
111
- // phone: metadata.phone || '',
112
- // company: metadata.company || '',
113
- // avatar_url: metadata.avatar_url || '',
114
- // metadata: metadata.custom_fields || {},
115
- }),
117
+ body: JSON.stringify(payload),
116
118
  });
117
119
 
118
120
  if (response?.status && response?.data) {