@amplitude/analytics-core
Advanced tools
Comparing version 2.2.6 to 2.2.7
@@ -9,2 +9,3 @@ import { BaseEvent, Config, CoreClient, Event, EventOptions, Identify, Plugin, Result, Revenue } from '@amplitude/analytics-types'; | ||
timeline: Timeline; | ||
isReady: boolean; | ||
protected q: Array<CallableFunction | typeof returnWrapper>; | ||
@@ -22,3 +23,5 @@ protected dispatchQ: Array<CallableFunction>; | ||
add(plugin: Plugin): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
_addPlugin(plugin: Plugin): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
remove(pluginName: string): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
_removePlugin(pluginName: string): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
dispatchWithCallback(event: Event, callback: (result: Result) => void): void; | ||
@@ -28,4 +31,5 @@ dispatch(event: Event): Promise<Result>; | ||
setOptOut(optOut: boolean): void; | ||
_setOptOut(optOut: boolean): void; | ||
flush(): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
} | ||
//# sourceMappingURL=core-client.d.ts.map |
@@ -13,2 +13,3 @@ Object.defineProperty(exports, "__esModule", { value: true }); | ||
this.initializing = false; | ||
this.isReady = false; | ||
this.q = []; | ||
@@ -30,2 +31,3 @@ this.dispatchQ = []; | ||
_a.sent(); | ||
this.isReady = true; | ||
return [2 /*return*/]; | ||
@@ -77,3 +79,9 @@ } | ||
return [7 /*endfinally*/]; | ||
case 10: return [2 /*return*/]; | ||
case 10: | ||
if (!this[queueName].length) return [3 /*break*/, 12]; | ||
return [4 /*yield*/, this.runQueuedFunctions(queueName)]; | ||
case 11: | ||
_b.sent(); | ||
_b.label = 12; | ||
case 12: return [2 /*return*/]; | ||
} | ||
@@ -104,17 +112,23 @@ }); | ||
AmplitudeCore.prototype.add = function (plugin) { | ||
if (!this.config) { | ||
this.q.push(this.add.bind(this, plugin)); | ||
if (!this.isReady) { | ||
this.q.push(this._addPlugin.bind(this, plugin)); | ||
return (0, return_wrapper_1.returnWrapper)(); | ||
} | ||
return this._addPlugin(plugin); | ||
}; | ||
AmplitudeCore.prototype._addPlugin = function (plugin) { | ||
return (0, return_wrapper_1.returnWrapper)(this.timeline.register(plugin, this.config)); | ||
}; | ||
AmplitudeCore.prototype.remove = function (pluginName) { | ||
if (!this.config) { | ||
this.q.push(this.remove.bind(this, pluginName)); | ||
if (!this.isReady) { | ||
this.q.push(this._removePlugin.bind(this, pluginName)); | ||
return (0, return_wrapper_1.returnWrapper)(); | ||
} | ||
return this._removePlugin(pluginName); | ||
}; | ||
AmplitudeCore.prototype._removePlugin = function (pluginName) { | ||
return (0, return_wrapper_1.returnWrapper)(this.timeline.deregister(pluginName)); | ||
}; | ||
AmplitudeCore.prototype.dispatchWithCallback = function (event, callback) { | ||
if (!this.config) { | ||
if (!this.isReady) { | ||
return callback((0, result_builder_1.buildResult)(event, 0, messages_1.CLIENT_NOT_INITIALIZED)); | ||
@@ -128,3 +142,3 @@ } | ||
return tslib_1.__generator(this, function (_a) { | ||
if (!this.config) { | ||
if (!this.isReady) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
@@ -170,6 +184,9 @@ _this.dispatchQ.push(_this.dispatchWithCallback.bind(_this, event, resolve)); | ||
AmplitudeCore.prototype.setOptOut = function (optOut) { | ||
if (!this.config) { | ||
this.q.push(this.setOptOut.bind(this, Boolean(optOut))); | ||
if (!this.isReady) { | ||
this.q.push(this._setOptOut.bind(this, Boolean(optOut))); | ||
return; | ||
} | ||
this._setOptOut(optOut); | ||
}; | ||
AmplitudeCore.prototype._setOptOut = function (optOut) { | ||
this.config.optOut = Boolean(optOut); | ||
@@ -176,0 +193,0 @@ }; |
@@ -9,2 +9,3 @@ import { BaseEvent, Config, CoreClient, Event, EventOptions, Identify, Plugin, Result, Revenue } from '@amplitude/analytics-types'; | ||
timeline: Timeline; | ||
isReady: boolean; | ||
protected q: Array<CallableFunction | typeof returnWrapper>; | ||
@@ -22,3 +23,5 @@ protected dispatchQ: Array<CallableFunction>; | ||
add(plugin: Plugin): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
_addPlugin(plugin: Plugin): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
remove(pluginName: string): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
_removePlugin(pluginName: string): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
dispatchWithCallback(event: Event, callback: (result: Result) => void): void; | ||
@@ -28,4 +31,5 @@ dispatch(event: Event): Promise<Result>; | ||
setOptOut(optOut: boolean): void; | ||
_setOptOut(optOut: boolean): void; | ||
flush(): import("@amplitude/analytics-types").AmplitudeReturn<void>; | ||
} | ||
//# sourceMappingURL=core-client.d.ts.map |
@@ -11,2 +11,3 @@ import { __awaiter, __generator, __values } from "tslib"; | ||
this.initializing = false; | ||
this.isReady = false; | ||
this.q = []; | ||
@@ -28,2 +29,3 @@ this.dispatchQ = []; | ||
_a.sent(); | ||
this.isReady = true; | ||
return [2 /*return*/]; | ||
@@ -75,3 +77,9 @@ } | ||
return [7 /*endfinally*/]; | ||
case 10: return [2 /*return*/]; | ||
case 10: | ||
if (!this[queueName].length) return [3 /*break*/, 12]; | ||
return [4 /*yield*/, this.runQueuedFunctions(queueName)]; | ||
case 11: | ||
_b.sent(); | ||
_b.label = 12; | ||
case 12: return [2 /*return*/]; | ||
} | ||
@@ -102,17 +110,23 @@ }); | ||
AmplitudeCore.prototype.add = function (plugin) { | ||
if (!this.config) { | ||
this.q.push(this.add.bind(this, plugin)); | ||
if (!this.isReady) { | ||
this.q.push(this._addPlugin.bind(this, plugin)); | ||
return returnWrapper(); | ||
} | ||
return this._addPlugin(plugin); | ||
}; | ||
AmplitudeCore.prototype._addPlugin = function (plugin) { | ||
return returnWrapper(this.timeline.register(plugin, this.config)); | ||
}; | ||
AmplitudeCore.prototype.remove = function (pluginName) { | ||
if (!this.config) { | ||
this.q.push(this.remove.bind(this, pluginName)); | ||
if (!this.isReady) { | ||
this.q.push(this._removePlugin.bind(this, pluginName)); | ||
return returnWrapper(); | ||
} | ||
return this._removePlugin(pluginName); | ||
}; | ||
AmplitudeCore.prototype._removePlugin = function (pluginName) { | ||
return returnWrapper(this.timeline.deregister(pluginName)); | ||
}; | ||
AmplitudeCore.prototype.dispatchWithCallback = function (event, callback) { | ||
if (!this.config) { | ||
if (!this.isReady) { | ||
return callback(buildResult(event, 0, CLIENT_NOT_INITIALIZED)); | ||
@@ -126,3 +140,3 @@ } | ||
return __generator(this, function (_a) { | ||
if (!this.config) { | ||
if (!this.isReady) { | ||
return [2 /*return*/, new Promise(function (resolve) { | ||
@@ -168,6 +182,9 @@ _this.dispatchQ.push(_this.dispatchWithCallback.bind(_this, event, resolve)); | ||
AmplitudeCore.prototype.setOptOut = function (optOut) { | ||
if (!this.config) { | ||
this.q.push(this.setOptOut.bind(this, Boolean(optOut))); | ||
if (!this.isReady) { | ||
this.q.push(this._setOptOut.bind(this, Boolean(optOut))); | ||
return; | ||
} | ||
this._setOptOut(optOut); | ||
}; | ||
AmplitudeCore.prototype._setOptOut = function (optOut) { | ||
this.config.optOut = Boolean(optOut); | ||
@@ -174,0 +191,0 @@ }; |
{ | ||
"name": "@amplitude/analytics-core", | ||
"version": "2.2.6", | ||
"version": "2.2.7", | ||
"description": "", | ||
@@ -44,3 +44,3 @@ "author": "Amplitude Inc", | ||
], | ||
"gitHead": "62e8e4aa56193545588e67ad5c431dabb4945e39" | ||
"gitHead": "31d0ac4efe31b8374f0bfb48eb51072f7cc6798a" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
381391
3717