Skip to content

Commit 8c2d12d

Browse files
author
Or Shemesh
committed
Merged PR 275402: New API setSdkInfo in service + version bump 2.21.1
sdkType tells us which SDK wrapper performs the actions, e.g: powerbi-client-react, powerbi-client-angular... To update it we should pass the type in the header 'x-sdk-type` which is populated in the service constructor. Therefore, each wrapper needs to pass the correct sdkType when initiating the service (see example: [Pull Request 274150](https://dev.azure.com/powerbi/Embedded/_git/powerbi-client-react/pullrequest/274150)). **What is the problem?** if user injects a new powerbi service to the wrapper and doesn't use the default service, the sdkType won't be populated. As a result, I created new API in the service, so we could update in each wrapper the sdk type after the service is created. In addition, create new header `x-sdk-wrapper-version`.
1 parent c1188f0 commit 8c2d12d

File tree

7 files changed

+49
-14
lines changed

7 files changed

+49
-14
lines changed

dist/powerbi-client.d.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// powerbi-client v2.21.0
1+
// powerbi-client v2.21.1
22
// Copyright (c) Microsoft Corporation.
33
// Licensed under the MIT License.
44
declare module "config" {
@@ -2057,6 +2057,7 @@ declare module "service" {
20572057
onError?: (error: any) => any;
20582058
version?: string;
20592059
type?: string;
2060+
sdkWrapperVersion?: string;
20602061
}
20612062
export interface IService {
20622063
hpm: HttpPostMessage;
@@ -2254,6 +2255,14 @@ declare module "service" {
22542255
* @param {HTMLElement} [element=undefined]
22552256
*/
22562257
preload(config: IComponentEmbedConfiguration | IEmbedConfigurationBase, element?: HTMLElement): HTMLIFrameElement;
2258+
/**
2259+
* Use this API to set SDK info
2260+
*
2261+
* @hidden
2262+
* @param {string} type
2263+
* @returns {void}
2264+
*/
2265+
setSdkInfo(type: string, version: string): void;
22572266
}
22582267
}
22592268
declare module "bookmarksManager" {

dist/powerbi.js

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// powerbi-client v2.21.0
1+
// powerbi-client v2.21.1
22
// Copyright (c) Microsoft Corporation.
33
// Licensed under the MIT License.
44
(function webpackUniversalModuleDefinition(root, factory) {
@@ -8931,7 +8931,7 @@ exports.BookmarksManager = BookmarksManager;
89318931
Object.defineProperty(exports, "__esModule", { value: true });
89328932
/** @ignore */ /** */
89338933
var config = {
8934-
version: '2.21.0',
8934+
version: '2.21.1',
89358935
type: 'js'
89368936
};
89378937
exports.default = config;
@@ -10044,12 +10044,13 @@ var window_post_message_proxy_1 = __webpack_require__(/*! window-post-message-pr
1004410044
var http_post_message_1 = __webpack_require__(/*! http-post-message */ "./node_modules/http-post-message/dist/httpPostMessage.js");
1004510045
var powerbi_router_1 = __webpack_require__(/*! powerbi-router */ "./node_modules/powerbi-router/dist/router.js");
1004610046
var config_1 = __webpack_require__(/*! ./config */ "./src/config.ts");
10047-
var hpmFactory = function (wpmp, defaultTargetWindow, sdkVersion, sdkType) {
10047+
var hpmFactory = function (wpmp, defaultTargetWindow, sdkVersion, sdkType, sdkWrapperVersion) {
1004810048
if (sdkVersion === void 0) { sdkVersion = config_1.default.version; }
1004910049
if (sdkType === void 0) { sdkType = config_1.default.type; }
1005010050
return new http_post_message_1.HttpPostMessage(wpmp, {
1005110051
'x-sdk-type': sdkType,
10052-
'x-sdk-version': sdkVersion
10052+
'x-sdk-version': sdkVersion,
10053+
'x-sdk-wrapper-version': sdkWrapperVersion,
1005310054
}, defaultTargetWindow);
1005410055
};
1005510056
exports.hpmFactory = hpmFactory;
@@ -12410,7 +12411,7 @@ var Service = /** @class */ (function () {
1241012411
if (config === void 0) { config = {}; }
1241112412
var _this = this;
1241212413
this.wpmp = wpmpFactory(config.wpmpName, config.logMessages);
12413-
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type);
12414+
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type, config.sdkWrapperVersion);
1241412415
this.router = routerFactory(this.wpmp);
1241512416
this.uniqueSessionId = utils.generateUUID();
1241612417
/**
@@ -12836,6 +12837,17 @@ var Service = /** @class */ (function () {
1283612837
};
1283712838
return iframeContent;
1283812839
};
12840+
/**
12841+
* Use this API to set SDK info
12842+
*
12843+
* @hidden
12844+
* @param {string} type
12845+
* @returns {void}
12846+
*/
12847+
Service.prototype.setSdkInfo = function (type, version) {
12848+
this.hpm.defaultHeaders['x-sdk-type'] = type;
12849+
this.hpm.defaultHeaders['x-sdk-wrapper-version'] = version;
12850+
};
1283912851
/**
1284012852
* A list of components that this service can embed
1284112853
*/

dist/powerbi.min.js

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

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "powerbi-client",
3-
"version": "2.21.0",
3+
"version": "2.21.1",
44
"description": "JavaScript library for embedding Power BI into your apps. Provides service which makes it easy to embed different types of components and an object model which allows easy interaction with these components such as changing pages, applying filters, and responding to data selection.",
55
"main": "dist/powerbi.js",
66
"types": "dist/powerbi-client.d.ts",

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
/** @ignore *//** */
55
const config = {
6-
version: '2.21.0',
6+
version: '2.21.1',
77
type: 'js'
88
};
99

src/factories.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ export {
1616
IRouterFactory
1717
};
1818

19-
export const hpmFactory: IHpmFactory = (wpmp, defaultTargetWindow, sdkVersion = config.version, sdkType = config.type) => {
19+
export const hpmFactory: IHpmFactory = (wpmp, defaultTargetWindow, sdkVersion = config.version, sdkType = config.type, sdkWrapperVersion?: string) => {
2020
return new HttpPostMessage(wpmp, {
2121
'x-sdk-type': sdkType,
22-
'x-sdk-version': sdkVersion
22+
'x-sdk-version': sdkVersion,
23+
'x-sdk-wrapper-version': sdkWrapperVersion,
2324
}, defaultTargetWindow);
2425
};
2526

src/service.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export interface IServiceConfiguration extends IDebugOptions {
8585
onError?: (error: any) => any;
8686
version?: string;
8787
type?: string;
88+
sdkWrapperVersion?: string;
8889
}
8990

9091
export interface IService {
@@ -159,7 +160,7 @@ export class Service implements IService {
159160
*/
160161
constructor(hpmFactory: IHpmFactory, wpmpFactory: IWpmpFactory, routerFactory: IRouterFactory, config: IServiceConfiguration = {}) {
161162
this.wpmp = wpmpFactory(config.wpmpName, config.logMessages);
162-
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type);
163+
this.hpm = hpmFactory(this.wpmp, null, config.version, config.type, config.sdkWrapperVersion);
163164
this.router = routerFactory(this.wpmp);
164165
this.uniqueSessionId = utils.generateUUID();
165166

@@ -632,4 +633,16 @@ export class Service implements IService {
632633

633634
return iframeContent;
634635
}
636+
637+
/**
638+
* Use this API to set SDK info
639+
*
640+
* @hidden
641+
* @param {string} type
642+
* @returns {void}
643+
*/
644+
setSdkInfo(type: string, version: string): void {
645+
this.hpm.defaultHeaders['x-sdk-type'] = type;
646+
this.hpm.defaultHeaders['x-sdk-wrapper-version'] = version;
647+
}
635648
}

0 commit comments

Comments
 (0)