'use client';
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var react_1 = __importDefault(require("react"));
var schema_1 = require("@qaing/schema");
var instance_1 = require("../../hooks/instance");
var amplitude_1 = __importDefault(require("../../utils/amplitude"));
var config_1 = require("../../utils/config");
var amplitudeKey = config_1.env.amplitudeKey;
exports.default = (function () {
    var data = (0, instance_1.useQAingSWR)(schema_1.schemas.user.getByMe).data;
    react_1.default.useEffect(function () {
        if (!amplitudeKey)
            return;
        amplitude_1.default.getInstance().init(amplitudeKey);
    }, []);
    react_1.default.useEffect(function () {
        if (!amplitudeKey)
            return;
        if (data && 'userEmail' in data) {
            var email = data.userEmail || null;
            amplitude_1.default.getInstance().setUserId(email);
        }
        else {
            amplitude_1.default.getInstance().setUserId(null);
        }
    }, [data]);
    return null;
});
//# sourceMappingURL=AmplitudeProvider.js.map