Skip to content

Commit 26dd38b

Browse files
authored
feat: Add versionId to tracking plan data (#518)
1 parent 36adf79 commit 26dd38b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

src/amplitude-client.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1413,6 +1413,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(
14131413
branch: this.options.plan.branch || undefined,
14141414
source: this.options.plan.source || undefined,
14151415
version: this.options.plan.version || undefined,
1416+
versionId: this.options.plan.versionId || undefined,
14161417
};
14171418
}
14181419

@@ -1446,7 +1447,13 @@ AmplitudeClient.prototype._logEvent = function _logEvent(
14461447
};
14471448

14481449
const _isObservePlanSet = function _isObservePlanSet(scope) {
1449-
return scope.options.plan && (scope.options.plan.source || scope.options.plan.branch || scope.options.plan.version);
1450+
return (
1451+
scope.options.plan &&
1452+
(scope.options.plan.source ||
1453+
scope.options.plan.branch ||
1454+
scope.options.plan.version ||
1455+
scope.options.plan.versionId)
1456+
);
14501457
};
14511458

14521459
var _shouldTrackField = function _shouldTrackField(scope, field) {

src/options.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import { version as libraryVersion } from '../package.json';
3535
* @property {string} [plan.branch] The tracking plan branch name e.g. "main"
3636
* @property {string} [plan.source] The tracking plan source e.g. "web"
3737
* @property {string} [plan.version] The tracking plan version e.g. "1", "15"
38+
* @property {string} [plan.versionId] The tracking plan version Id e.g. "9ec23ba0-275f-468f-80d1-66b88bff9529"
3839
* @property {string} [platform=`Web`] - Platform device is running on. Defaults to `Web` (browser, including mobile browsers).
3940
* @property {number} [savedMaxCount=`1000`] - Maximum number of events to save in localStorage. If more events are logged while offline, then old events are removed.
4041
* @property {boolean} [saveEvents=`true`] - If `true`, saves events to localStorage and removes them upon successful upload. *Note: Without saving events, events may be lost if the user navigates to another page before the events are uploaded.*
@@ -87,6 +88,7 @@ export default {
8788
branch: '',
8889
source: '',
8990
version: '',
91+
versionId: '',
9092
},
9193
platform: 'Web',
9294
savedMaxCount: 1000,

test/amplitude-client.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,7 @@ describe('AmplitudeClient', function () {
901901
branch: 'my-feature-branch',
902902
source: 'web',
903903
version: '1.0.0',
904+
versionId: '9ec23ba0-275f-468f-80d1-66b88bff9529',
904905
};
905906
amplitude.init(apiKey, null, { plan: plan });
906907

0 commit comments

Comments
 (0)