@teamvortexsoftware/vortex-react-native 0.0.4 → 0.0.5
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 +1 -1
- package/src/hooks/useVortexInvite.ts +20 -10
- package/src/shared/api.ts +5 -3
package/package.json
CHANGED
|
@@ -60,7 +60,7 @@ export function useVortexInvite({
|
|
|
60
60
|
|
|
61
61
|
const has = useMemo(() => {
|
|
62
62
|
const flags = extractFeatureFlags(widgetConfiguration);
|
|
63
|
-
console.
|
|
63
|
+
console.log("[Vortex] Invite has", flags);
|
|
64
64
|
return flags;
|
|
65
65
|
}, [widgetConfiguration]);
|
|
66
66
|
|
|
@@ -95,23 +95,22 @@ export function useVortexInvite({
|
|
|
95
95
|
}, 2000);
|
|
96
96
|
}, []);
|
|
97
97
|
|
|
98
|
-
|
|
99
98
|
// Fetch widget configuration if needed
|
|
100
99
|
useEffect(() => {
|
|
101
100
|
// Case: If `widgetConfiguration` is already set, do nothing
|
|
102
101
|
if (widgetConfiguration) {
|
|
103
|
-
console.
|
|
102
|
+
console.log(
|
|
104
103
|
"[Vortex] Invite Already has widgetConfiguration, skipping fetch",
|
|
105
104
|
);
|
|
106
105
|
return;
|
|
107
106
|
}
|
|
108
107
|
if (!jwt) {
|
|
109
|
-
console.
|
|
108
|
+
console.log("[Vortex] Invite JWT is required");
|
|
110
109
|
return;
|
|
111
110
|
}
|
|
112
111
|
|
|
113
112
|
const fetchData = async () => {
|
|
114
|
-
console.
|
|
113
|
+
console.log("[Vortex] Invite Fetching Data...");
|
|
115
114
|
setFetching(true);
|
|
116
115
|
setLoading(true);
|
|
117
116
|
setError(null);
|
|
@@ -124,7 +123,7 @@ export function useVortexInvite({
|
|
|
124
123
|
);
|
|
125
124
|
if (result?.data?.widgetConfiguration) {
|
|
126
125
|
setWidgetConfiguration(result.data.widgetConfiguration);
|
|
127
|
-
console.
|
|
126
|
+
console.log(
|
|
128
127
|
"[Vortex] Invite Successfully fetched widgetConfiguration",
|
|
129
128
|
JSON.stringify(result.data.widgetConfiguration),
|
|
130
129
|
);
|
|
@@ -134,6 +133,17 @@ export function useVortexInvite({
|
|
|
134
133
|
throw new Error(error);
|
|
135
134
|
}
|
|
136
135
|
} catch (err) {
|
|
136
|
+
if (err instanceof Error) {
|
|
137
|
+
const fetchError = err as any;
|
|
138
|
+
console.error("[Vortex] Invite Error Details:", {
|
|
139
|
+
message: fetchError.message,
|
|
140
|
+
status: fetchError.status || "unknown",
|
|
141
|
+
statusText: fetchError.statusText,
|
|
142
|
+
body: fetchError.body,
|
|
143
|
+
stack: fetchError.stack,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
|
|
137
147
|
console.error("[Vortex] Invite Error", err);
|
|
138
148
|
setError({
|
|
139
149
|
message: (err as Error).message || "Something went wrong!",
|
|
@@ -150,11 +160,11 @@ export function useVortexInvite({
|
|
|
150
160
|
const handleInviteClick = async () => {
|
|
151
161
|
try {
|
|
152
162
|
if (!widgetConfiguration?.id) {
|
|
153
|
-
console.
|
|
163
|
+
console.log("[Vortex Invite] Widget configuration ID is required");
|
|
154
164
|
return;
|
|
155
165
|
}
|
|
156
166
|
// const url = `${host}/api/v1/no-auth/components/widget-configuration/${widgetConfigurationId}/invite`; // TODO should we use options.widgetHost?.value ?
|
|
157
|
-
console.
|
|
167
|
+
console.log("[Vortex] Invite Sending invitation", {
|
|
158
168
|
email,
|
|
159
169
|
widgetId,
|
|
160
170
|
environmentId,
|
|
@@ -223,7 +233,7 @@ export function useVortexInvite({
|
|
|
223
233
|
message: shareableLink,
|
|
224
234
|
title: "Share Invite Link",
|
|
225
235
|
});
|
|
226
|
-
console.
|
|
236
|
+
console.log("[Vortex] Link Shared", "The invite link has been shared.");
|
|
227
237
|
if (onSuccess) {
|
|
228
238
|
onSuccess({
|
|
229
239
|
type: "share",
|
|
@@ -248,7 +258,7 @@ export function useVortexInvite({
|
|
|
248
258
|
throw new Error("No shareable link available");
|
|
249
259
|
}
|
|
250
260
|
await Clipboard.setString(shareableLink);
|
|
251
|
-
console.
|
|
261
|
+
console.log(
|
|
252
262
|
"[Vortex] Link Copied to clipboard",
|
|
253
263
|
"The invite link has been copied.",
|
|
254
264
|
);
|
package/src/shared/api.ts
CHANGED
|
@@ -12,20 +12,22 @@ class VortexClient {
|
|
|
12
12
|
environmentId: string,
|
|
13
13
|
) {
|
|
14
14
|
const url = `${this.baseUrl}/api/v1/environment/${environmentId}/widgets/${widgetId}`;
|
|
15
|
-
console.
|
|
15
|
+
console.log("[VortexClient] getWidgetConfiguration", { url });
|
|
16
16
|
|
|
17
17
|
const response = await fetch(url, {
|
|
18
18
|
headers: { Authorization: `Bearer ${jwt}` },
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
if (!response.ok) {
|
|
22
|
+
const body = await response.text();
|
|
23
|
+
console.error("[VortexClient] getWidgetConfiguration", { status: response.status, body });
|
|
22
24
|
throw new Error(
|
|
23
|
-
`Error fetching widget configuration: ${response.status}`,
|
|
25
|
+
`Error fetching widget configuration from ${url}: ${response.status}`,
|
|
24
26
|
);
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
const data = await response.json();
|
|
28
|
-
console.
|
|
30
|
+
console.log("[VortexClient] getWidgetConfiguration", { data });
|
|
29
31
|
return data;
|
|
30
32
|
}
|
|
31
33
|
|