Skip to content

Commit 44d00d7

Browse files
authored
fix(initialization): always return this in onInit (#300)
1 parent 6eb6f57 commit 44d00d7

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/amplitude-client.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import Constants from './constants';
33
import cookieStorage from './cookiestorage';
44
import MetadataStorage from '../src/metadata-storage';
5-
import getUtmData from './utm'; // Urchin Tracking Module
5+
import getUtmData from './utm'; // Urchin Tracking Module
66
import Identify from './identify';
77
import localStorage from './localstorage'; // jshint ignore:line
88
import md5 from 'blueimp-md5';
@@ -493,7 +493,7 @@ AmplitudeClient.prototype.isNewSession = function isNewSession() {
493493
*/
494494
AmplitudeClient.prototype.onInit = function (callback) {
495495
if (this._isInitialized) {
496-
callback();
496+
callback(this);
497497
} else {
498498
this._onInit.push(callback);
499499
}
@@ -874,12 +874,12 @@ AmplitudeClient.prototype.setUserId = function setUserId(userId) {
874874

875875
/**
876876
* Add user to a group or groups. You need to specify a groupType and groupName(s).
877-
*
877+
*
878878
* For example you can group people by their organization.
879879
* In that case, groupType is "orgId" and groupName would be the actual ID(s).
880880
* groupName can be a string or an array of strings to indicate a user in multiple gruups.
881881
* You can also call setGroup multiple times with different groupTypes to track multiple types of groups (up to 5 per app).
882-
*
882+
*
883883
* Note: this will also set groupType: groupName as a user property.
884884
* See the [advanced topics article](https://developers.amplitude.com/docs/setting-user-groups) for more information.
885885
* @public
@@ -1362,7 +1362,7 @@ AmplitudeClient.prototype.logEventWithTimestamp = function logEvent(eventType, e
13621362
* Log an event with eventType, eventProperties, and groups. Use this to set event-level groups.
13631363
* Note: the group(s) set only apply for the specific event type being logged and does not persist on the user
13641364
* (unless you explicitly set it with setGroup).
1365-
*
1365+
*
13661366
* See the [advanced topics article](https://developers.amplitude.com/docs/setting-user-groups) for more information.
13671367
* about groups and Count by Distinct on the Amplitude platform.
13681368
* @public
@@ -1404,7 +1404,7 @@ var _isNumber = function _isNumber(n) {
14041404
/**
14051405
* Log revenue with Revenue interface. The new revenue interface allows for more revenue fields like
14061406
* revenueType and event properties.
1407-
*
1407+
*
14081408
* See the [Revenue](https://amplitude.github.io/Amplitude-JavaScript/Revenue/)
14091409
* reference page for more information on the Revenue interface and logging revenue.
14101410
* @public
@@ -1487,7 +1487,7 @@ var _removeEvents = function _removeEvents(scope, eventQueue, maxId, status, res
14871487

14881488
var filteredEvents = [];
14891489
for (var i = 0; i < scope[eventQueue].length || 0; i++) {
1490-
const unsentEvent = scope[eventQueue][i];
1490+
const unsentEvent = scope[eventQueue][i];
14911491

14921492
if (unsentEvent.event.event_id > maxId) {
14931493
filteredEvents.push(unsentEvent);

0 commit comments

Comments
 (0)