@literal.ai/literator-react-native
Version:
In minutes, see all your screens automatically mapped into user flows and annotated with analytics events.
54 lines (41 loc) • 1.8 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _reactNative = require("react-native");
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
const LINKING_ERROR = `The package 'literator-react-native' doesn't seem to be linked. Make sure: \n\n` + _reactNative.Platform.select({
ios: "- You have run 'pod install'\n",
default: ''
}) + '- You rebuilt the app after installing the package\n' + '- You are not using Expo managed workflow\n';
const LiteratorModule = _reactNative.NativeModules.LiteratorModule ? _reactNative.NativeModules.LiteratorModule : new Proxy({}, {
get() {
throw new Error(LINKING_ERROR);
}
});
const logMessage = message => {
console.log('Literator-React => ' + message);
};
class Literator {
static async start(accessToken) {
if (!Literator.started) {
logMessage('start()');
const promiseResult = LiteratorModule.start(accessToken);
Literator.started = true;
return promiseResult;
}
return Promise.resolve(false);
}
static async sendAnalytics(eventName) {
let properties = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
let tag = arguments.length > 2 ? arguments[2] : undefined;
let debugProps = JSON.stringify(properties);
logMessage(`sendAnalytics(${eventName} => ${debugProps}), tag=${tag}`); // return Promise.resolve(true);
const promiseResult = LiteratorModule.sendAnalytics(eventName, properties, tag);
return promiseResult;
}
}
exports.default = Literator;
_defineProperty(Literator, "started", false);
//# sourceMappingURL=index.js.map
;