13
| <![CDATA[<script>
var viewLoadingStarted = Date.now();
var skipCheckPowerBIAccessToken = true;
var powerBIAccessToken = 'any';
var reportId = 'any';
var getExplorationUrl = '/public/';
var getConceptualSchemaUrl = '/public/reports/conceptualschema';
var queryDataUrl = '/public/reports/querydata';
var resourceLoaderUrl = '/public/reports/resourcePackage/';
var routingUrl = '/public/routing/cluster/';
var resourceLoaderIncludePackageId = true;
var isLoadReportMessagePending = false;
var isReportControllerInitialized = false;
var isAnonymousEmbed = true;
var accessToken;
var oDataFilter;
var resourceKey;
var resolveClusterError;
var modelsAndExplorationPromise;
var modelsAndExplorationResponse;
var frontLoadStatus;
var frontLoadError;
var conceptualSchemaPromise;
var conceptualSchemaResponse;
var loadingState = "#Loading#";
var errorState = "#Error#";
var isConceptualSchemaCached;
var isModelsAndExplorationCached;
var conceptualSchemaDuration;
var clusterResolutionFrontLoadStartTime = null;
var clusterResolutionFrontLoadEndTime = null;
var modelsAndExplorationFrontLoadStartTime = null;
var modelsAndExplorationFrontLoadEndTime = null;
var conceptualSchemaFrontLoadStartTime = null;
var conceptualSchemaFrontLoadEndTime = null;
var reportThumbnailPromise;
var reportThumbnailResponse;
var reportThumbnailFrontLoadStartTime;
var reportThumbnailFrontLoadEndTime;
var reportThumbnailDuration;
var reportThumbnailRequestId;
var reportThumbnailResponseRequestId;
var responseRequestId;
var conceptualSchemaRequestId;
var conceptualSchemaResponseRequestId;
var modelsAndExplorationRequestId;
var certifiedTelemetryEmbed = true;
var isOptimizePublishToWebEnabled = '' === "true";
var powerBISpinnerImprovements = true;
var reportThumbnailPrefix = "ReportThumbnail";
var modelsAndExplorationPrefix = "ModelsAndExploration";
var conceptualSchemaPrefix = "conceptualSchema";
var globalUseNativePromise = 'false';
var feUrl = 'https://app.powerbi.com';
var clusterAssignmentRecord = {"FixedClusterUri":"https://wabi-south-central-us-redirect.analysis.windows.net/","TTLSeconds":300,"RuleDescription":"","Clients":[{"Name":"trident-web","AppInsightsConnectionString":"InstrumentationKey=64d56471-807d-41d8-a331-67e38c1bbd8c","AppInsightsId":"64d56471-807d-41d8-a331-67e38c1bbd8c"}]};
var resolvedClusterUri = 'https://wabi-south-central-us-redirect.analysis.windows.net/';
var cleanUpAppInsightsEvents = true;
//register for messages from parent window
window.addEventListener("message", receiveMessage, false);
//handle message from parent window
function receiveMessage(event) {
if (event.data) {
try {
var messageData;
try {
messageData = JSON.parse(event.data);
} catch (e) {
messageData = event.data;
}
if (messageData.action === 'setPage') {
if (!messageData.pageName) {
return;
}
var pageName = messageData.pageName;
if (isReportControllerInitialized) {
setPage(pageName);
}
}
}
catch (e) {
var embedReportLoadMessage = {
event: 'error',
error: 'Invalid message data:' + e.message,
};
window.parent.postMessage(JSON.stringify(embedReportLoadMessage), '*');
return;
}
}
}
function resolveCluster() {
try {
var activityId = telemetrySessionId;
var requestId = '34232591-7aa1-41d7-8967-082dc6eff152';
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
try {
if(xhr.readyState == XMLHttpRequest.DONE) {
clusterResolutionFrontLoadEndTime = Date.now();
var response = JSON.parse(xhr.responseText);
if(response.FixedClusterUri) {
resolvedClusterUri = response.FixedClusterUri;
if(allowPublishToWebPreLoadFlag) {
getModelsAndExplorationAndConceptualSchema();
}
}
else {
resolveClusterError = "FixedClusterUri is empty, activityid:" + activityId + "requestid:" + requestId;
}
}
}
catch(e) {
resolveClusterError = "Exception:"+e.message +", activityid:" + activityId + "requestid:" + requestId;
}
}
var apimClusterUri = getAPIMUrl(clusterUri);
xhr.open("GET", apimClusterUri + routingUrl + tenantId);
setGETRequestHeaders(xhr, telemetrySessionId, requestId, resourceKey);
clusterResolutionFrontLoadStartTime = Date.now();
xhr.send();
}
catch(e) {
resolveClusterError = "Exception:"+e.message +", activityid:" + activityId + "requestid:" + requestId;
}
}
function getModelsAndExploration() {
try {
var activityId = telemetrySessionId;
var requestId = 'f4414bb4-c4be-4e18-813d-9af480b68488';
if(!resolvedClusterUri) {
return;
}
var resolvedAPIMCluster = getAPIMUrl(resolvedClusterUri);
url = resolvedAPIMCluster + "/public/reports/" + resourceKey + "/modelsAndExploration?preferReadOnlySession=true";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
try{
var status = xhr.status;
if(xhr.readyState == XMLHttpRequest.DONE) {
modelsAndExplorationFrontLoadEndTime = Date.now();
var isSuccess = status >= 200 && status < 300 || status === 304;
frontLoadStatus = status;
if(isSuccess) {
var response = xhrBuildResponse(xhr, activityId, requestId);
modelsAndExplorationPromise.resolve(response);
var data = JSON.parse(response.responseText);
responseRequestId = xhr.getResponseHeader('requestId');
isModelsAndExplorationCached = responseRequestId && responseRequestId !== requestId ? true: false;
modelsAndExplorationRequestId = responseRequestId ? responseRequestId : requestId;
}
else {
try {
modelsAndExplorationPromise.reject(xhrBuildResponse(xhr, activityId, requestId, true /*isError*/));
}
catch (e) {
modelsAndExplorationPromise.reject(buildExceptionResponse(activityId, requestId, e, modelsAndExplorationPrefix));
}
}
}
}
catch(e) {
modelsAndExplorationPromise.reject(buildExceptionResponse(activityId, requestId, e, modelsAndExplorationPrefix));
}
}
xhr.open("GET", url);
setGETRequestHeaders(xhr, telemetrySessionId, requestId, resourceKey);
modelsAndExplorationFrontLoadStartTime = Date.now();
xhr.send();
}
catch(e) {
modelsAndExplorationPromise.reject(buildExceptionResponse(activityId, requestId, e, modelsAndExplorationPrefix));
}
}
function getConceptualSchema() {
try {
conceptualSchemaFrontLoadStartTime = Date.now();
conceptualSchemaResponse = loadingState;
var activityId = telemetrySessionId;
var requestId = '56021cee-462a-49e9-9e6c-8ead6e03b08a';
var resolvedAPIMCluster = getAPIMUrl(resolvedClusterUri);
url = resolvedAPIMCluster + "/public/reports/" + resourceKey + "/conceptualschema";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
try {
conceptualSchemaFrontLoadEndTime = Date.now();
var status = xhr.status;
if(xhr.readyState == XMLHttpRequest.DONE) {
var isSuccess = status >= 200 && status < 300 || status === 304;
if(isSuccess) {
var response = xhrBuildResponse(xhr, activityId, requestId);
conceptualSchemaPromise.resolve(response);
var data = JSON.parse(response.responseText);
conceptualSchemaDuration = conceptualSchemaFrontLoadEndTime - conceptualSchemaFrontLoadStartTime;
responseRequestId = xhr.getResponseHeader('requestId');
isConceptualSchemaCached = responseRequestId && responseRequestId !== requestId ? true: false;
conceptualSchemaRequestId = requestId;
conceptualSchemaResponseRequestId = responseRequestId ? responseRequestId : requestId;
setConceptualSchema(data);
}
else {
conceptualSchemaResponse = errorState;
try {
conceptualSchemaPromise.reject(xhrBuildResponse(xhr, activityId, requestId, true /*isError*/));
}
catch (e) {
conceptualSchemaPromise.reject(buildExceptionResponse(activityId, requestId, e, conceptualSchemaPrefix));
}
}
}
}
catch(e) {
conceptualSchemaResponse = errorState;
conceptualSchemaPromise.reject(buildExceptionResponse(activityId, requestId, e, conceptualSchemaPrefix));
}
}
xhr.open("GET", url);
setGETRequestHeaders(xhr, telemetrySessionId, requestId, resourceKey);
xhr.send();
}
catch(e) {
conceptualSchemaResponse = errorState;
conceptualSchemaPromise.reject(buildExceptionResponse(activityId, requestId, e, conceptualSchemaPrefix));
}
}
function getReportThumbnail() {
try {
reportThumbnailFrontLoadStartTime = Date.now();
var activityId = telemetrySessionId;
var requestId = 'edd5d168-95e9-44fb-ac1a-c3b4b61655ea';
var resolvedAPIMCluster = getAPIMUrl(resolvedClusterUri);
url = resolvedAPIMCluster + "/public/reports/" + resourceKey + "/thumbnail";
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
try {
reportThumbnailFrontLoadEndTime = Date.now();
var status = xhr.status;
if(xhr.readyState == XMLHttpRequest.DONE) {
var isSuccess = status >= 200 && status < 300 || status === 304;
if(isSuccess) {
var response = xhrBuildResponse(xhr, activityId, requestId);
reportThumbnailPromise.resolve(response);
var data = JSON.parse(response.responseText);
reportThumbnailDuration = reportThumbnailFrontLoadEndTime - reportThumbnailFrontLoadStartTime;
responseRequestId = xhr.getResponseHeader('requestId');
reportThumbnailRequestId = requestId;
reportThumbnailResponseRequestId = responseRequestId ? responseRequestId : requestId;
}
// This is when customer has changed the thumbnail to report from the UI but forgot to change the iframe url in the webside it is embedded in.
// on recieving 404 on getThumnail call, we want to load the report instead of rejecting the promise as customer expected.
else if(status == 404)
{
var response = xhrBuildResponse(xhr, activityId, requestId);
reportThumbnailPromise.resolve(response);
}
else {
if (reportThumbnailPromise) {
try {
reportThumbnailPromise.reject(xhrBuildResponse(xhr, activityId, requestId, true /*isError*/));
}
catch (e) {
// Cannot parse an error out of the response
reportThumbnailPromise.reject(buildExceptionResponse(activityId, requestId, e, reportThumbnailPrefix));
}
}
}
}
}
catch(e) {
if (reportThumbnailPromise) {
reportThumbnailPromise.reject(buildExceptionResponse(activityId, requestId, e, reportThumbnailPrefix));
}
}
}
xhr.open("GET", url);
setGETRequestHeaders(xhr, telemetrySessionId, requestId, resourceKey);
xhr.send();
}catch(e) {
if (reportThumbnailPromise) {
reportThumbnailPromise.reject(buildExceptionResponse(activityId, requestId, e, reportThumbnailPrefix));
}
}
}
function setGETRequestHeaders(xhr, activityId, requestId, resourceKey) {
xhr.setRequestHeader('Accept', 'application/json');
xhr.setRequestHeader('ActivityId', activityId);
xhr.setRequestHeader('RequestId', requestId);
xhr.setRequestHeader('X-PowerBI-ResourceKey', resourceKey);
}
function setPOSTRequestHeaders(xhr, activityId, requestId, resourceKey) {
setGETRequestHeaders(xhr, activityId, requestId, resourceKey);
xhr.setRequestHeader('Content-Type', 'application/json');
}
function setConceptualSchema(data) {
// TODO - Waiting for New API to make the decision if data will be array or single schema
conceptualSchemaResponse = data;
}
function getAPIMUrl(clusterUri) {
var parser = document.createElement('a');
parser.href = clusterUri;
var protocol = parser.protocol;
var hostname = parser.hostname;
var hostNameTakens = hostname.split(".");
hostNameTakens[0] = hostNameTakens[0].replace("-redirect", "");
hostNameTakens[0] = hostNameTakens[0].replace("global-", "");
hostNameTakens[0] += "-api";
var apiHostName = hostNameTakens.join(".");
return protocol + "//" + apiHostName;
}
function isResponseCached(responseRequestId, requestId) {
if(responseRequestId && responseRequestId !== requestId) {
return true;
}
return false;
}
function defer() {
var res, rej;
var promise = new Promise(function (resolve, reject) {
res = resolve;
rej = reject;
});
promise.resolve = function (result) {
res(result);
};
promise.reject = function (error) {
rej(error);
};
return promise;
}
function xhrBuildResponse(xhr, activityId, requestId, isError) {
var response = {
activityId: activityId,
requestId: requestId,
status: xhr.status,
responseText: xhr.responseText
};
xhrResponse = xhr.response && JSON.parse(xhr.response);
if (!isError)
response["data"] = xhrResponse;
else
response["error"] = xhrResponse && xhrResponse.error;
return response;
}
function buildExceptionResponse(activityId, requestId, exception, prefix) {
return {
activityId: activityId,
requestId: requestId,
status: unknownErrorCode,
error: {
message: prefix + " Exception: " + exception.message,
code: "FrontLoadException",
},
}
}
function getModelsAndExplorationAndConceptualSchema() {
if (isOptimizePublishToWebEnabled) {
reportThumbnailPromise = defer();
getReportThumbnail();
} else {
modelsAndExplorationPromise = defer();
conceptualSchemaPromise = defer();
getModelsAndExploration();
getConceptualSchema();
}
}
var baseUrl = window.location.protocol + '//' + window.location.host;
var powerbi = {
session : {
userInfo: {
alternateEmail: '',
}
}
};
powerbi.telemetrySamplingRules = 'embed';
powerbi.build = '13.0.21669.112';
powerbi.buildDetails = '13.0.21669.112';
powerbi.clientVersion = '2309.4.15949-train';
powerbi.cvUrl = 'https://pbivisuals.powerbi.com';
powerbi.visualCDNBlobContainerUrl = 'prod';
powerbi.common = {};
powerbi.common.cultureInfo = 'en-US';
powerbi.common.formattingLocale = 'en-US';
var layoutTheme = 'fluent-no-header-teal';
var useCDN = 'True';
var clusterUri = 'https://api.powerbi.com';
var cdnUrl = 'https://content.powerapps.com/resource/powerbiwfe';
var previousTenantId = '';
var telemetrySessionId = '18f0d232-b501-4e3f-adb4-2c7455338f2a';
var sessionSource = "Embed";
var wfeClusterName = 'app-PBI-WFE-BRAZIL-SOUTH';
var allowTelemetry = true;
var appInsightsV2InstrKey = '64d56471-807d-41d8-a331-67e38c1bbd8c';
var appInsightsV2EndpointUrl = '';
var initialDashboardContainer = undefined;
var appLoadError = undefined;
var allowPublishToWebPreLoadFlag = false;
var reportQueryString = new RegExp('[\\?&]r=([^&#]*)').exec(window.location.href);
if (reportQueryString) {
try {
var embedCode = decodeURIComponent(reportQueryString[1]);
var encodedReport = JSON.parse(atob(embedCode));
var tenantId = encodedReport.t;
resourceKey = encodedReport.k;
if (resolvedClusterUri == '') {
resolvedClusterUri = undefined;
resolveCluster();
} else if(allowPublishToWebPreLoadFlag) {
getModelsAndExplorationAndConceptualSchema();
}
}
catch(e) {
resolveClusterError = "Exception: " + e.message + ", activityid: " + telemetrySessionId;
}
}
</script>]]>
|