Skip to content

Commit 7b343ea

Browse files
authored
feat: add partner_id support (#545)
1 parent 27b4957 commit 7b343ea

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/amplitude-client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(
14071407
groups: utils.truncate(utils.validateGroups(groups)),
14081408
group_properties: utils.truncate(utils.validateProperties(groupProperties)),
14091409
user_agent: this._userAgent,
1410+
partner_id: this.options.partnerId || null,
14101411
};
14111412

14121413
if (_isObservePlanSet(this)) {

src/options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { version as libraryVersion } from '../package.json';
5454
* @property {boolean} [useDynamicConfig] - Enable dynamic configuration to find best server url for user.
5555
* @property {boolean} [serverZoneBasedApi] - To update api endpoint with serverZone change or not. For data residency, recommend to enable it unless using own proxy server.
5656
* @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.
57+
* @property {string} [partnerId=`null`] - The partner id value
5758
*/
5859
export default {
5960
apiEndpoint: Constants.EVENT_LOG_URL,
@@ -125,4 +126,5 @@ export default {
125126
useDynamicConfig: false,
126127
serverZoneBasedApi: false,
127128
sessionId: null,
129+
partnerId: '',
128130
};

test/amplitude-client.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4551,4 +4551,25 @@ describe('AmplitudeClient', function () {
45514551
requestStub.restore();
45524552
});
45534553
});
4554+
4555+
describe('partnerId Support', function () {
4556+
beforeEach(function () {
4557+
reset();
4558+
});
4559+
4560+
it('should include partner_id', function () {
4561+
const partnerId = 'test-partner-id';
4562+
amplitude.init(apiKey, null, { batchEvents: true, partnerId: partnerId });
4563+
4564+
amplitude.logEvent('testEvent1');
4565+
assert.equal(amplitude._unsentEvents[0].event.partner_id, partnerId);
4566+
});
4567+
4568+
it('should set partner_id default null', function () {
4569+
amplitude.init(apiKey, null, { batchEvents: true });
4570+
4571+
amplitude.logEvent('testEvent1');
4572+
assert.equal(amplitude._unsentEvents[0].event.partner_id, null);
4573+
});
4574+
});
45544575
});

0 commit comments

Comments
 (0)