Skip to content

Commit 5301900

Browse files
committed
v14.5.3
1 parent fa3cf97 commit 5301900

File tree

8 files changed

+51
-27
lines changed

8 files changed

+51
-27
lines changed

build/cjs/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/esm/index.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

demo/index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,16 @@
158158
<div class="sidebar-block" style="width: 67%"></div>
159159
<div class="sidebar-block" style="width: 55%"></div>
160160

161-
<div style="padding: 20px 25px 25px 30px;">
162-
<gleap-checklist
163-
floating="true"
164-
checklistid="67f0ccc770eef2e4332c5237"
165-
></gleap-checklist>
166-
</div>
161+
<div style="padding: 20px 25px 25px 30px"></div>
167162
</aside>
168163

169164
<!-- Main content wireframe blocks -->
170165
<main class="main-placeholder" id="main1">
171166
<div style="max-width: 600px; margin: auto">
167+
<gleap-checklist
168+
sharedKey="project_X1"
169+
checklistid="67f0ccc770eef2e4332c5237"
170+
></gleap-checklist>
172171
</div>
173172
</main>
174173

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gleap",
3-
"version": "14.5.2",
3+
"version": "14.5.3",
44
"main": "build/cjs/index.js",
55
"module": "build/esm/index.mjs",
66
"exports": {

published/14.5.3/index.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

published/latest/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/ChecklistNetworkManager.js

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,29 @@ class ChecklistNetworkManager {
126126
});
127127
}
128128

129+
/**
130+
* @private
131+
* Creates a cache key from outboundId and sharedKey
132+
* @param {string} outboundId - The public/outbound checklist ID.
133+
* @param {string|undefined} sharedKey - Optional shared key.
134+
* @returns {string} Combined cache key.
135+
*/
136+
_createCacheKey(outboundId, sharedKey) {
137+
return sharedKey ? `${outboundId}::${sharedKey}` : outboundId;
138+
}
139+
129140
/**
130141
* Validates an outbound checklist ID, returning a Promise for the internal ID.
131142
* Manages caching and deduplicates requests.
132143
* @param {string} outboundId - The public/outbound checklist ID.
144+
* @param {string} [sharedKey] - Optional shared key for the checklist.
133145
* @returns {Promise<string>} A promise that resolves with the internal checklist ID.
134146
*/
135-
validateChecklist(outboundId) {
147+
validateChecklist(outboundId, sharedKey) {
148+
const cacheKey = this._createCacheKey(outboundId, sharedKey);
149+
136150
// 1. Check cache for final result (success or error)
137-
const cachedResult = this.validationCache.get(outboundId);
151+
const cachedResult = this.validationCache.get(cacheKey);
138152
if (cachedResult) {
139153
if (cachedResult.status === RequestStatus.SUCCESS) {
140154
return Promise.resolve(cachedResult.internalId);
@@ -144,35 +158,38 @@ class ChecklistNetworkManager {
144158
}
145159

146160
// 2. Check for an ongoing request
147-
if (this.validationRequests.has(outboundId)) {
148-
return this.validationRequests.get(outboundId);
161+
if (this.validationRequests.has(cacheKey)) {
162+
return this.validationRequests.get(cacheKey);
149163
}
150-
164+
151165
// 3. Start a new request
152166
const apiUrl = this._getApiUrl();
153167
if (!apiUrl) {
154168
const error = new Error(
155169
"ChecklistNetworkManager: Gleap API URL not configured."
156170
);
157-
this.validationCache.set(outboundId, {
171+
this.validationCache.set(cacheKey, {
158172
status: RequestStatus.ERROR,
159173
error,
160174
});
161175
return Promise.reject(error);
162176
}
163177

164178
const url = `${apiUrl}/outbound/checklists?${this._getQueryParams()}`;
165-
const requestPromise = this._makeRequest("POST", url, { outboundId })
179+
const requestPromise = this._makeRequest("POST", url, {
180+
outboundId,
181+
sharedKey,
182+
})
166183
.then((responseData) => {
167184
if (responseData && responseData.id) {
168-
this.validationCache.set(outboundId, {
185+
this.validationCache.set(cacheKey, {
169186
status: RequestStatus.SUCCESS,
170187
internalId: responseData.id,
171188
});
172189
return responseData.id;
173190
} else {
174191
const error = new Error("Validation response missing checklist ID.");
175-
this.validationCache.set(outboundId, {
192+
this.validationCache.set(cacheKey, {
176193
status: RequestStatus.ERROR,
177194
error: responseData || error,
178195
});
@@ -181,19 +198,19 @@ class ChecklistNetworkManager {
181198
})
182199
.catch((error) => {
183200
// Store the error object itself in the cache
184-
this.validationCache.set(outboundId, {
201+
this.validationCache.set(cacheKey, {
185202
status: RequestStatus.ERROR,
186203
error,
187204
});
188205
throw error; // Re-throw so callers can catch it
189206
})
190207
.finally(() => {
191208
// Remove from pending requests map once done (success or fail)
192-
this.validationRequests.delete(outboundId);
209+
this.validationRequests.delete(cacheKey);
193210
});
194211

195212
// Store the promise for potential concurrent requests
196-
this.validationRequests.set(outboundId, requestPromise);
213+
this.validationRequests.set(cacheKey, requestPromise);
197214
return requestPromise;
198215
}
199216

src/GleapChecklist.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,14 @@ export const registerGleapChecklist = () => {
9696

9797
// --- Observed Attributes ---
9898
static get observedAttributes() {
99-
return ["checklistId", "info", "progressbar", "dark", "floating"];
99+
return [
100+
"checklistId",
101+
"info",
102+
"progressbar",
103+
"dark",
104+
"floating",
105+
"sharedKey",
106+
];
100107
}
101108

102109
// --- Lifecycle Callbacks ---
@@ -298,8 +305,10 @@ export const registerGleapChecklist = () => {
298305
this.checklistData = null;
299306
this._hasLoaded = false;
300307
this.renderResponse();
308+
const sharedKey = this.getAttribute("sharedKey");
309+
301310
this._networkManager
302-
.validateChecklist(outboundId)
311+
.validateChecklist(outboundId, sharedKey)
303312
.then((internalId) => {
304313
if (!this.isConnected || !this._isSessionReady || !internalId) {
305314
return;
@@ -572,9 +581,7 @@ export const registerGleapChecklist = () => {
572581
return `
573582
<div part="${className}" class="${
574583
isHeader ? "checklist-floating-header" : "checklist-floating-launcher"
575-
} ${
576-
renderDoneState ? "checklist-floating-launcher--done" : ""
577-
}">
584+
} ${renderDoneState ? "checklist-floating-launcher--done" : ""}">
578585
<div class="floating-header">
579586
<div class="floating-circular-progress">
580587
<svg viewBox="0 0 20 20">

0 commit comments

Comments
 (0)