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

feat: add partner_id support #545

Merged
merged 1 commit into from
Jul 25, 2022
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
1 change: 1 addition & 0 deletions src/amplitude-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(
groups: utils.truncate(utils.validateGroups(groups)),
group_properties: utils.truncate(utils.validateProperties(groupProperties)),
user_agent: this._userAgent,
partner_id: this.options.partnerId || null,
};

if (_isObservePlanSet(this)) {
Expand Down
2 changes: 2 additions & 0 deletions src/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import { version as libraryVersion } from '../package.json';
* @property {boolean} [useDynamicConfig] - Enable dynamic configuration to find best server url for user.
* @property {boolean} [serverZoneBasedApi] - To update api endpoint with serverZone change or not. For data residency, recommend to enable it unless using own proxy server.
* @property {number} [sessionId=`null`] - The custom Session ID for the current session. *Note: This is not recommended unless you know what you are doing because the Session ID of a session is utilized for all session metrics in Amplitude.
* @property {string} [partnerId=`null`] - The partner id value
*/
export default {
apiEndpoint: Constants.EVENT_LOG_URL,
Expand Down Expand Up @@ -125,4 +126,5 @@ export default {
useDynamicConfig: false,
serverZoneBasedApi: false,
sessionId: null,
partnerId: '',
};
21 changes: 21 additions & 0 deletions test/amplitude-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4551,4 +4551,25 @@ describe('AmplitudeClient', function () {
requestStub.restore();
});
});

describe('partnerId Support', function () {
beforeEach(function () {
reset();
});

it('should include partner_id', function () {
const partnerId = 'test-partner-id';
amplitude.init(apiKey, null, { batchEvents: true, partnerId: partnerId });

amplitude.logEvent('testEvent1');
assert.equal(amplitude._unsentEvents[0].event.partner_id, partnerId);
});

it('should set partner_id default null', function () {
amplitude.init(apiKey, null, { batchEvents: true });

amplitude.logEvent('testEvent1');
assert.equal(amplitude._unsentEvents[0].event.partner_id, null);
});
});
});