Skip to content

Commit 1853bde

Browse files
committed
add timestamp param to logevent
1 parent 310af98 commit 1853bde

File tree

4 files changed

+31
-31
lines changed

4 files changed

+31
-31
lines changed

amplitude.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,7 +1092,7 @@ AmplitudeClient.prototype.setGroup = function(groupType, groupName) {
10921092
var groups = {};
10931093
groups[groupType] = groupName;
10941094
var identify = new Identify().set(groupType, groupName);
1095-
this._logEvent(Constants.IDENTIFY_EVENT, null, null, identify.userPropertiesOperations, groups, null);
1095+
this._logEvent(Constants.IDENTIFY_EVENT, null, null, identify.userPropertiesOperations, groups, null, null);
10961096
};
10971097

10981098
/**
@@ -1234,7 +1234,7 @@ AmplitudeClient.prototype.identify = function(identify_obj, opt_callback) {
12341234
// only send if there are operations
12351235
if (Object.keys(identify_obj.userPropertiesOperations).length > 0) {
12361236
return this._logEvent(
1237-
Constants.IDENTIFY_EVENT, null, null, identify_obj.userPropertiesOperations, null, opt_callback
1237+
Constants.IDENTIFY_EVENT, null, null, identify_obj.userPropertiesOperations, null, null, opt_callback
12381238
);
12391239
}
12401240
} else {
@@ -1263,7 +1263,7 @@ AmplitudeClient.prototype.setVersionName = function setVersionName(versionName)
12631263
* Private logEvent method. Keeps apiProperties from being publicly exposed.
12641264
* @private
12651265
*/
1266-
AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventProperties, apiProperties, userProperties, groups, callback) {
1266+
AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventProperties, apiProperties, userProperties, groups, timestamp, callback) {
12671267
_loadCookieData(this); // reload cookie before each log event to sync event meta-data between windows and tabs
12681268
if (!eventType || this.options.optOut) {
12691269
if (type(callback) === 'function') {
@@ -1280,7 +1280,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
12801280
eventId = this.nextEventId();
12811281
}
12821282
var sequenceNumber = this.nextSequenceNumber();
1283-
var eventTime = new Date().getTime();
1283+
var eventTime = timestamp || new Date().getTime();
12841284
if (!this._sessionId || !this._lastEventTime || eventTime - this._lastEventTime > this.options.sessionTimeout) {
12851285
this._sessionId = eventTime;
12861286
}
@@ -1375,7 +1375,7 @@ AmplitudeClient.prototype.logEvent = function logEvent(eventType, eventPropertie
13751375
}
13761376
return -1;
13771377
}
1378-
return this._logEvent(eventType, eventProperties, null, null, null, opt_callback);
1378+
return this._logEvent(eventType, eventProperties, null, null, null, null, opt_callback);
13791379
};
13801380

13811381
/**
@@ -1401,7 +1401,7 @@ AmplitudeClient.prototype.logEventWithGroups = function(eventType, eventProperti
14011401
}
14021402
return -1;
14031403
}
1404-
return this._logEvent(eventType, eventProperties, null, null, groups, opt_callback);
1404+
return this._logEvent(eventType, eventProperties, null, null, groups, null, opt_callback);
14051405
};
14061406

14071407
/**
@@ -1463,7 +1463,7 @@ AmplitudeClient.prototype.logRevenue = function logRevenue(price, quantity, prod
14631463
special: 'revenue_amount',
14641464
quantity: quantity || 1,
14651465
price: price
1466-
}, null, null, null);
1466+
}, null, null, null, null);
14671467
};
14681468

14691469
/**

amplitude.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/amplitude-client.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,7 @@ AmplitudeClient.prototype.setGroup = function(groupType, groupName) {
611611
var groups = {};
612612
groups[groupType] = groupName;
613613
var identify = new Identify().set(groupType, groupName);
614-
this._logEvent(Constants.IDENTIFY_EVENT, null, null, identify.userPropertiesOperations, groups, null);
614+
this._logEvent(Constants.IDENTIFY_EVENT, null, null, identify.userPropertiesOperations, groups, null, null);
615615
};
616616

617617
/**
@@ -753,7 +753,7 @@ AmplitudeClient.prototype.identify = function(identify_obj, opt_callback) {
753753
// only send if there are operations
754754
if (Object.keys(identify_obj.userPropertiesOperations).length > 0) {
755755
return this._logEvent(
756-
Constants.IDENTIFY_EVENT, null, null, identify_obj.userPropertiesOperations, null, opt_callback
756+
Constants.IDENTIFY_EVENT, null, null, identify_obj.userPropertiesOperations, null, null, opt_callback
757757
);
758758
}
759759
} else {
@@ -782,7 +782,7 @@ AmplitudeClient.prototype.setVersionName = function setVersionName(versionName)
782782
* Private logEvent method. Keeps apiProperties from being publicly exposed.
783783
* @private
784784
*/
785-
AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventProperties, apiProperties, userProperties, groups, callback) {
785+
AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventProperties, apiProperties, userProperties, groups, timestamp, callback) {
786786
_loadCookieData(this); // reload cookie before each log event to sync event meta-data between windows and tabs
787787
if (!eventType || this.options.optOut) {
788788
if (type(callback) === 'function') {
@@ -799,7 +799,7 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert
799799
eventId = this.nextEventId();
800800
}
801801
var sequenceNumber = this.nextSequenceNumber();
802-
var eventTime = new Date().getTime();
802+
var eventTime = timestamp || new Date().getTime();
803803
if (!this._sessionId || !this._lastEventTime || eventTime - this._lastEventTime > this.options.sessionTimeout) {
804804
this._sessionId = eventTime;
805805
}
@@ -894,7 +894,7 @@ AmplitudeClient.prototype.logEvent = function logEvent(eventType, eventPropertie
894894
}
895895
return -1;
896896
}
897-
return this._logEvent(eventType, eventProperties, null, null, null, opt_callback);
897+
return this._logEvent(eventType, eventProperties, null, null, null, null, opt_callback);
898898
};
899899

900900
/**
@@ -920,7 +920,7 @@ AmplitudeClient.prototype.logEventWithGroups = function(eventType, eventProperti
920920
}
921921
return -1;
922922
}
923-
return this._logEvent(eventType, eventProperties, null, null, groups, opt_callback);
923+
return this._logEvent(eventType, eventProperties, null, null, groups, null, opt_callback);
924924
};
925925

926926
/**
@@ -982,7 +982,7 @@ AmplitudeClient.prototype.logRevenue = function logRevenue(price, quantity, prod
982982
special: 'revenue_amount',
983983
quantity: quantity || 1,
984984
price: price
985-
}, null, null, null);
985+
}, null, null, null, null);
986986
};
987987

988988
/**

test/browser/amplitudejs.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,26 +87,26 @@
8787
}
8888
</script>
8989
<script>
90-
amplitude.init('a2dbce0e18dfe5f8e74493843ff5c053', null, {includeReferrer: true, includeUtm: true, includeGclid: true}, function() {
90+
amplitude.init('a2dbce0e18dfe5f8e74493843ff5c053', null, {includeReferrer: true, includeUtm: true, includeGclid: true, deviceId: 'dcdf0a79-8676-5cc3-95fc-fa53517293ad'}, function() {
9191
alert(amplitude.options.deviceId);
9292
});
93-
amplitude.setVersionName('Web');
94-
amplitude.identify(new amplitude.Identify().add('photoCount', 1));
95-
amplitude.identify(new amplitude.Identify().add('photoCount', 1).set('gender', 'male').unset('karma'));
96-
amplitude.logEvent('pageLoad');
93+
// amplitude.setVersionName('Web');
94+
// amplitude.identify(new amplitude.Identify().add('photoCount', 1));
95+
// amplitude.identify(new amplitude.Identify().add('photoCount', 1).set('gender', 'male').unset('karma'));
96+
// amplitude.logEvent('pageLoad');
9797

98-
amplitude.getInstance('app2').logEvent('log event before init');
99-
amplitude.getInstance('app2').init('1d2fe1e104eb3f07a24e94d359f70fd5', 'checkers@gmail.com', {includeReferrer: true}, function(instance) {
100-
alert(instance.options.deviceId);
101-
});
102-
amplitude.getInstance('app2').identify(new amplitude.Identify().set('key', 'value'));
103-
amplitude.getInstance('app2').logEvent('app 2 page load');
98+
// amplitude.getInstance('app2').logEvent('log event before init');
99+
// amplitude.getInstance('app2').init('1d2fe1e104eb3f07a24e94d359f70fd5', 'checkers@gmail.com', {includeReferrer: true}, function(instance) {
100+
// alert(instance.options.deviceId);
101+
// });
102+
// amplitude.getInstance('app2').identify(new amplitude.Identify().set('key', 'value'));
103+
// amplitude.getInstance('app2').logEvent('app 2 page load');
104104

105-
amplitude.getInstance('app3').init('a2dbce0e18dfe5f8e74493843ff5c053', null, {batchEvents: true, eventUploadThreshold: 2});
106-
amplitude.getInstance('app3').logEvent('app3 page Load');
105+
// amplitude.getInstance('app3').init('a2dbce0e18dfe5f8e74493843ff5c053', null, {batchEvents: true, eventUploadThreshold: 2});
106+
// amplitude.getInstance('app3').logEvent('app3 page Load');
107107

108-
amplitude.getInstance('app4').init('1d2fe1e104eb3f07a24e94d359f70fd5', 'joe@gmail.com');
109-
amplitude.getInstance('app4').logEvent('app 4 page load');
108+
// amplitude.getInstance('app4').init('1d2fe1e104eb3f07a24e94d359f70fd5', 'joe@gmail.com');
109+
// amplitude.getInstance('app4').logEvent('app 4 page load');
110110
</script>
111111
<body>
112112
<h3>Amplitude JS Test</h3>

0 commit comments

Comments
 (0)