From 26dd38b96ca4dd5f52670e287dee16a0c9881d32 Mon Sep 17 00:00:00 2001 From: Andrey Sokolov Date: Thu, 31 Mar 2022 22:57:42 +0400 Subject: [PATCH] feat: Add versionId to tracking plan data (#518) --- src/amplitude-client.js | 9 ++++++++- src/options.js | 2 ++ test/amplitude-client.js | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/amplitude-client.js b/src/amplitude-client.js index 90c60b36..3611fa3a 100644 --- a/src/amplitude-client.js +++ b/src/amplitude-client.js @@ -1413,6 +1413,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent( branch: this.options.plan.branch || undefined, source: this.options.plan.source || undefined, version: this.options.plan.version || undefined, + versionId: this.options.plan.versionId || undefined, }; } @@ -1446,7 +1447,13 @@ AmplitudeClient.prototype._logEvent = function _logEvent( }; const _isObservePlanSet = function _isObservePlanSet(scope) { - return scope.options.plan && (scope.options.plan.source || scope.options.plan.branch || scope.options.plan.version); + return ( + scope.options.plan && + (scope.options.plan.source || + scope.options.plan.branch || + scope.options.plan.version || + scope.options.plan.versionId) + ); }; var _shouldTrackField = function _shouldTrackField(scope, field) { diff --git a/src/options.js b/src/options.js index 21826eb7..9c0887f5 100644 --- a/src/options.js +++ b/src/options.js @@ -35,6 +35,7 @@ import { version as libraryVersion } from '../package.json'; * @property {string} [plan.branch] The tracking plan branch name e.g. "main" * @property {string} [plan.source] The tracking plan source e.g. "web" * @property {string} [plan.version] The tracking plan version e.g. "1", "15" + * @property {string} [plan.versionId] The tracking plan version Id e.g. "9ec23ba0-275f-468f-80d1-66b88bff9529" * @property {string} [platform=`Web`] - Platform device is running on. Defaults to `Web` (browser, including mobile browsers). * @property {number} [savedMaxCount=`1000`] - Maximum number of events to save in localStorage. If more events are logged while offline, then old events are removed. * @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 { branch: '', source: '', version: '', + versionId: '', }, platform: 'Web', savedMaxCount: 1000, diff --git a/test/amplitude-client.js b/test/amplitude-client.js index 73ab0622..5198f5ef 100644 --- a/test/amplitude-client.js +++ b/test/amplitude-client.js @@ -901,6 +901,7 @@ describe('AmplitudeClient', function () { branch: 'my-feature-branch', source: 'web', version: '1.0.0', + versionId: '9ec23ba0-275f-468f-80d1-66b88bff9529', }; amplitude.init(apiKey, null, { plan: plan });