Skip to content

Commit bcb340d

Browse files
fix: Dry Run for non-pre-render scenario (calcom#21893)
* Fix dry-run non-prerender scenario * Add test * Enable logging through cal.embed.logging=1
1 parent aabef47 commit bcb340d

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

packages/app-store/routing-forms/pages/routing-link/getUrlSearchParamsToForward.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,4 +328,26 @@ describe("getUrlSearchParamsToForward", () => {
328328
});
329329
expect(fromEntriesWithDuplicateKeys(result.entries())).toEqual(expectedParams);
330330
});
331+
332+
describe("Dry Run", () => {
333+
it("should add cal.routingFormResponseId=0 when formResponseId is 0", () => {
334+
const searchParams = new URLSearchParams("?query1=value1&query2=value2");
335+
const expectedParams = {
336+
"cal.routingFormResponseId": "0",
337+
query1: "value1",
338+
query2: "value2",
339+
};
340+
341+
const result = getUrlSearchParamsToForward({
342+
formResponse: {},
343+
fields: [],
344+
searchParams,
345+
teamMembersMatchingAttributeLogic: null,
346+
formResponseId: 0,
347+
queuedFormResponseId: null,
348+
attributeRoutingConfig: null,
349+
});
350+
expect(fromEntriesWithDuplicateKeys(result.entries())).toEqual(expectedParams);
351+
});
352+
});
331353
});

packages/app-store/routing-forms/pages/routing-link/getUrlSearchParamsToForward.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ export function getUrlSearchParamsToForward({
124124
...(teamMembersMatchingAttributeLogic
125125
? { ["cal.routedTeamMemberIds"]: teamMembersMatchingAttributeLogic.join(",") }
126126
: null),
127-
...(formResponseId ? { [ROUTING_FORM_RESPONSE_ID_QUERY_STRING]: String(formResponseId) } : null),
127+
...(typeof formResponseId === "number"
128+
? { [ROUTING_FORM_RESPONSE_ID_QUERY_STRING]: String(formResponseId) }
129+
: null),
128130
...(queuedFormResponseId ? { ["cal.queuedFormResponseId"]: queuedFormResponseId } : null),
129131
...attributeRoutingConfigParams,
130132
...(reroutingFormResponses

packages/embeds/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,11 @@ Cal.config = Cal.config || {};
156156
Cal.config.forwardQueryParams=true
157157
```
158158

159+
#### Enabling Logging
160+
You can enable logging for the embed by adding the `cal.embed.logging=1` query parameter to the URL of the page where the embed is placed. This is useful for debugging issues with the embed. It will log all important things in parent as well as in the iframe(i.e. child)
161+
162+
For example, if your page is `https.example.com/contact`, you can enable logging by visiting `https.example.com/contact?cal.embed.logging=1`.
163+
159164
### Advanced Features
160165

161166
#### Routing Prerendering System

packages/embeds/embed-core/src/embed.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,10 @@ export class Cal {
349349

350350
urlInstance.searchParams.set("embed", this.namespace);
351351

352-
if (calConfig.debug) {
353-
urlInstance.searchParams.set("debug", `${calConfig.debug}`);
352+
const pageParams = this.getQueryParamsFromPage();
353+
// cal.embed.logging=1 enabled logging in parent and by setting debug=true in iframe, it enables logging in iframe(child) as well
354+
if (calConfig.debug || pageParams["cal.embed.logging"] === "1") {
355+
urlInstance.searchParams.set("debug", "true");
354356
}
355357

356358
// Keep iframe invisible, till the embedded calLink sets its color-scheme. This is so that there is no flash of non-transparent(white/black) background

0 commit comments

Comments
 (0)