UNPKG

@teamsparta/cross-platform-logger

Version:

```typescript import * as CPL from "@teamsparta/cross-platform-logger";

44 lines 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AmplitudeLog = void 0; var amplitude = require("@amplitude/analytics-browser"); var utils_1 = require("./utils"); var AmplitudeLog = /** @class */ (function () { function AmplitudeLog(amplitude_key, amplitude_browser_options) { var _this = this; this.setEventDate = function (date) { var identifyEvent = new _this._client.Identify(); identifyEvent.set('event_date', date.toISOString().split('T')[0]); _this._client.identify(identifyEvent); }; this.send = function (key, data) { if (data === void 0) { data = {}; } _this.setEventDate(new Date()); _this._client.track(key, data); }; this.useSendBeacon = function () { _this._client.setTransport('beacon'); _this._client.flush(); }; this.getInstance = function () { return _this._client; }; if ((0, utils_1.isClient)()) { try { if (amplitude_browser_options) { amplitude.init(amplitude_key, amplitude_browser_options); } else { amplitude.init(amplitude_key); } this._client = amplitude; } catch (err) { console.error('Amplitude init failed:', err); } } } return AmplitudeLog; }()); exports.AmplitudeLog = AmplitudeLog; //# sourceMappingURL=amplitude.js.map