@capawesome/capacitor-posthog
Version:
Unofficial Capacitor plugin for PostHog SDK.
74 lines (67 loc) • 2.29 kB
JavaScript
var capacitorPosthog = (function (exports, core, posthog) {
'use strict';
const Posthog = core.registerPlugin('Posthog', {
web: () => Promise.resolve().then(function () { return web; }).then(m => new m.PosthogWeb()),
});
class PosthogWeb extends core.WebPlugin {
async alias(options) {
posthog.alias(options.alias);
}
async capture(options) {
posthog.capture(options.event, options.properties);
}
async getFeatureFlag(options) {
const value = posthog.getFeatureFlag(options.key);
return value === undefined ? { value: null } : { value };
}
async getFeatureFlagPayload(options) {
return { value: posthog.getFeatureFlagPayload(options.key) };
}
async flush() {
this.throwUnimplementedError();
}
async group(options) {
posthog.group(options.type, options.key, options.groupProperties);
}
async identify(options) {
posthog.identify(options.distinctId, options.userProperties);
}
async isFeatureEnabled(options) {
const enabled = posthog.isFeatureEnabled(options.key);
return { enabled: enabled || false };
}
async register(options) {
posthog.register({
[options.key]: options.value,
});
}
async reloadFeatureFlags() {
posthog.reloadFeatureFlags();
}
async reset() {
posthog.reset();
}
async screen(_options) {
this.throwUnimplementedError();
}
async setup(options) {
const host = options.host || 'https://us.i.posthog.com';
posthog.init(options.apiKey, {
api_host: host,
});
}
async unregister(options) {
posthog.unregister(options.key);
}
throwUnimplementedError() {
throw this.unimplemented('Not implemented on web.');
}
}
var web = /*#__PURE__*/Object.freeze({
__proto__: null,
PosthogWeb: PosthogWeb
});
exports.Posthog = Posthog;
return exports;
})({}, capacitorExports, posthog);
//# sourceMappingURL=plugin.js.map