Skip to content

Commit

Permalink
Merge pull request #19 from sigmacomputing/ioana/sharing-link-fixes
Browse files Browse the repository at this point in the history
Add env var description and fix URL
  • Loading branch information
pballai authored Sep 5, 2024
2 parents 157bb9d + 1ad98a4 commit aff410e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion embedding/sigma_embed_link_sharing/.env
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ EMBED_SECRET={your embed secret}
# Required Parameters
EMAIL={your embed test user email address}
EXTERNAL_USER_ID=123
EXTERNAL_USER_TEAM=Sales_People
EXTERNAL_USER_TEAM={your team that has access to the workbook you embedded}
ACCOUNT_TYPE=Pro
MODE=userbacked
SESSION_LENGTH=600
Expand Down
20 changes: 9 additions & 11 deletions embedding/sigma_embed_link_sharing/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -82,21 +82,19 @@ <h2>Sigma - Embed Link Sharing Sample</h2>
if (exploreKey) params.append("exploreKey", exploreKey);
if (bookmarkId) params.append("bookmarkId", bookmarkId);

const newUrl = `${window.location.origin}${
window.location.pathname
}?${params.toString()}`;
const paramsToString = params.toString();
const newUrl = paramsToString
? `${window.location.origin}${window.location.pathname}?${paramsToString}`
: `${window.location.origin}${window.location.pathname}`;
window.history.pushState({}, "", newUrl);
}

// Function to send sharing links back to Sigma
function sendSharingLinks() {
const baseUrl = window.location.origin + window.location.pathname;
const finalSharingLink =
currentExploreKey || currentBookmarkId
? `${baseUrl}?${
currentExploreKey ? `exploreKey=${currentExploreKey}` : ""
}${currentBookmarkId ? `&bookmarkId=${currentBookmarkId}` : ""}`
: baseUrl;
const sharingLink = currentBookmarkId
? `${baseUrl}?&bookmarkId=${currentBookmarkId}`
: baseUrl;

const sharingExplorationLink = currentExploreKey
? currentBookmarkId
Expand All @@ -105,13 +103,13 @@ <h2>Sigma - Embed Link Sharing Sample</h2>
: null;

console.log("Sending sharing links to Sigma:");
console.log("Final Sharing Link:", finalSharingLink);
console.log("Sharing Link:", baseUrl);
console.log("Sharing Exploration Link:", sharingExplorationLink);

iframe.contentWindow.postMessage(
{
type: "workbook:sharinglink:update",
sharingLink: finalSharingLink,
sharingLink: sharingLink,
sharingExplorationLink: sharingExplorationLink,
},
"https://app.sigmacomputing.com"
Expand Down

0 comments on commit aff410e

Please sign in to comment.