diff --git a/src/amplitude-client.js b/src/amplitude-client.js index 701d2934..0a6e8c13 100644 --- a/src/amplitude-client.js +++ b/src/amplitude-client.js @@ -44,6 +44,7 @@ var AmplitudeClient = function AmplitudeClient(instanceName) { this._sending = false; this._updateScheduled = false; this._onInit = []; + this._onNewSession = []; // event meta data this._eventId = 0; @@ -172,6 +173,9 @@ AmplitudeClient.prototype.init = function init(apiKey, opt_userId, opt_config, o if (this.options.unsetParamsReferrerOnNewSession) { this._unsetUTMParams(); } + for (let i = 0; i < this._onNewSession.length; i++) { + this._onNewSession[i](this); + } this._newSession = true; this._sessionId = now; @@ -479,6 +483,10 @@ AmplitudeClient.prototype.onInit = function (callback) { } }; +AmplitudeClient.prototype.onNewSessionStart = function (callback) { + this._onNewSession.push(callback) +} + /** * Returns the id of the current session. * @public