Repository URL to install this package:
|
Version:
2.0.1 ▾
|
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var _rollupPluginBabelHelpers = require('../../../_virtual/_rollupPluginBabelHelpers.js');
var helpers = require('./helpers.js');
var destinations = require('./destinations.js');
/**
* Initializes Avo.
*
* @async
* @private
* @param {TrackingApiOptions} options - The API client's options
* @return {Promise.<boolean>}
* @throws {TypeError} Thrown when Avo file is missing from options.
* @see https://github.com/amplitude/Amplitude-JavaScript/blob/18d0dab/src/options.js - options for version 5.11.0
*/
// eslint-disable-next-line require-await
var initAvo = /*#__PURE__*/function () {
var _ref = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(options) {
var avo, _options$env, env, _env$doodleEnv, doodleEnv, avoEnv, avoDestinations;
return regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
avo = options.avo, _options$env = options.env, env = _options$env === void 0 ? {} : _options$env;
_env$doodleEnv = env.doodleEnv, doodleEnv = _env$doodleEnv === void 0 ? '' : _env$doodleEnv;
if (avo) {
_context.next = 4;
break;
}
throw new TypeError('Please provide the Avo file as part of the API options. See https://www.avo.app/docs/implementation/devs-101#a-nameavo-generated-filea-avo-generated-file-containing-avo-functions');
case 4:
avoEnv = helpers.mapDoodleEnvToAvoEnv(doodleEnv);
avoDestinations = destinations.getAvoDestinations(options);
avo.initAvo.apply(avo, [{
env: avoEnv
}, {}, {}].concat(_rollupPluginBabelHelpers.toConsumableArray(avoDestinations)));
return _context.abrupt("return", true);
case 8:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return function initAvo(_x) {
return _ref.apply(this, arguments);
};
}();
/**
* Removes Avo.
*
* @async
* @private
* @param {TrackingApiOptions} options - The API client's options
* @return {Promise.<boolean>}
*/
// eslint-disable-next-line no-unused-vars,require-await
var removeAvo = /*#__PURE__*/function () {
var _ref2 = _rollupPluginBabelHelpers.asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(options) {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
while (1) {
switch (_context2.prev = _context2.next) {
case 0:
// Unset Avo
options.avo = null; // TODO: Figure out how to tell Avo to not track anymore; eg `noop` option?
// TODO: Figure out how to deal with Avo Destinations (eg Amplitude). Do we just remove cookies too?
return _context2.abrupt("return", true);
case 2:
case "end":
return _context2.stop();
}
}
}, _callee2);
}));
return function removeAvo(_x2) {
return _ref2.apply(this, arguments);
};
}();
exports.initAvo = initAvo;
exports.removeAvo = removeAvo;
//# sourceMappingURL=init.js.map