Skip to content

Commit dc8fc60

Browse files
authored
Merge pull request #201 from Bang9/patch-1
feat: add default versionName to react-native
2 parents 8b5ed52 + c8e82b1 commit dc8fc60

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/amplitude-client.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,14 +193,16 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o
193193
DeviceInfo.getCarrier(),
194194
DeviceInfo.getModel(),
195195
DeviceInfo.getManufacturer(),
196+
DeviceInfo.getVersion(),
196197
DeviceInfo.getUniqueId(),
197198
]).then(values => {
198199
this.deviceInfo = {
199200
carrier: values[0],
200201
model: values[1],
201-
manufacturer: values[2]
202+
manufacturer: values[2],
203+
version: values[3]
202204
};
203-
initFromStorage(values[3]);
205+
initFromStorage(values[4]);
204206
this.runQueuedFunctions();
205207
if (type(opt_callback) === 'function') {
206208
opt_callback(this);
@@ -1142,6 +1144,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
11421144
let osVersion = this._ua.browser.major;
11431145
let deviceModel = this._ua.os.name;
11441146
let deviceManufacturer;
1147+
let versionName;
11451148
let carrier;
11461149
if (BUILD_COMPAT_REACT_NATIVE) {
11471150
osName = Platform.OS;
@@ -1150,6 +1153,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
11501153
carrier = this.deviceInfo.carrier;
11511154
deviceManufacturer = this.deviceInfo.manufacturer;
11521155
deviceModel = this.deviceInfo.model;
1156+
versionName = this.deviceInfo.version;
11531157
}
11541158
}
11551159

@@ -1166,7 +1170,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
11661170
event_id: eventId,
11671171
session_id: this._sessionId || -1,
11681172
event_type: eventType,
1169-
version_name: _shouldTrackField(this, 'version_name') ? (this.options.versionName || null) : null,
1173+
version_name: _shouldTrackField(this, 'version_name') ? (this.options.versionName || versionName || null) : null,
11701174
platform: _shouldTrackField(this, 'platform') ? this.options.platform : null,
11711175
os_name: _shouldTrackField(this, 'os_name') ? (osName || null) : null,
11721176
os_version: _shouldTrackField(this, 'os_version') ? (osVersion || null) : null,

0 commit comments

Comments
 (0)