diff --git a/src/amplitude-client.js b/src/amplitude-client.js index cafdc344..325dfe61 100644 --- a/src/amplitude-client.js +++ b/src/amplitude-client.js @@ -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)) { diff --git a/src/options.js b/src/options.js index 9c0887f5..e582a846 100644 --- a/src/options.js +++ b/src/options.js @@ -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, @@ -125,4 +126,5 @@ export default { useDynamicConfig: false, serverZoneBasedApi: false, sessionId: null, + partnerId: '', }; diff --git a/test/amplitude-client.js b/test/amplitude-client.js index 5198f5ef..3ffe552f 100644 --- a/test/amplitude-client.js +++ b/test/amplitude-client.js @@ -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); + }); + }); });