Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify telemetry inside the ULP #922

Merged
merged 1 commit into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/helper/request-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ function RequestBuilder(options) {
this._telemetryInfo = options._telemetryInfo || null;
this._timesToRetryFailedRequests = options._timesToRetryFailedRequests;
this.headers = options.headers || {};
this._universalLoginPage = options.universalLoginPage;
}

RequestBuilder.prototype.setCommonConfiguration = function(ongoingRequest, options) {
Expand Down Expand Up @@ -97,7 +98,8 @@ RequestBuilder.prototype.setCommonConfiguration = function(ongoingRequest, optio
};

RequestBuilder.prototype.getTelemetryData = function() {
var clientInfo = this._telemetryInfo || { name: 'auth0.js', version: version.raw };
var telemetryName = this._universalLoginPage ? 'auth0.js-ulp' : 'auth0.js';
var clientInfo = this._telemetryInfo || { name: telemetryName, version: version.raw };
var jsonClientInfo = JSON.stringify(clientInfo);
return base64Url.encode(jsonClientInfo);
};
Expand Down
1 change: 1 addition & 0 deletions src/web-auth/hosted-pages.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import assert from '../helper/assert';
function HostedPages(client, options) {
this.baseOptions = options;
this.client = client;
this.baseOptions.universalLoginPage = true;
this.request = new RequestBuilder(this.baseOptions);

this.warn = new Warn({
Expand Down
8 changes: 8 additions & 0 deletions test/helper/request-builder.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ describe('helpers requestBuilder', function() {
version: version.raw
});
});
it('should use ulp telemetry when `universalLoginPage` is true', function() {
var rb = new RequestBuilder({ _telemetryInfo: null, universalLoginPage: true });
var telemetry = rb.getTelemetryData();
expect(JSON.parse(base64url.decode(telemetry))).to.be.eql({
name: 'auth0.js-ulp',
version: version.raw
});
});
});
describe('with noHeaders:false', function() {
before(function() {
Expand Down
2 changes: 1 addition & 1 deletion test/web-auth/hosted-pages.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import WebAuth from '../../src/web-auth';
import TransactionManager from '../../src/web-auth/transaction-manager';
import RequestBuilder from '../../src/helper/request-builder';

var telemetryInfo = new RequestBuilder({}).getTelemetryData();
var telemetryInfo = new RequestBuilder({ universalLoginPage: true }).getTelemetryData();

describe('auth0.WebAuth._universalLogin', function() {
beforeEach(function() {
Expand Down