npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@capawesome/capacitor-posthog

v6.0.0

Published

Unofficial Capacitor plugin for PostHog SDK.

Downloads

156

Readme

@capawesome/capacitor-posthog

Unofficial Capacitor plugin for PostHog.[^1]

Installation

npm install @capawesome/capacitor-posthog posthog-js
npx cap sync

Android

Variables

This plugin will use the following project variables (defined in your app’s variables.gradle file):

  • $androidxCoreKtxVersion version of androidx.core:core-ktx (default: 1.13.1)

Configuration

No configuration required for this plugin.

Demo

A working example can be found here: robingenz/capacitor-plugin-demo

Usage

import { Posthog } from '@capawesome/capacitor-posthog';

const alias = async () => {
  await Posthog.alias({
    alias: 'new-distinct-id',
  });
};

const capture = async () => {
  await Posthog.capture({
    event: 'event',
    properties: {
      key: 'value',
    },
  });
};

const flush = async () => {
  await Posthog.flush();
};

const group = async () => {
  await Posthog.group({
    type: 'group',
    key: 'key',
    groupProperties: {
      key: 'value',
    },
  });
};

const identify = async () => {
  await Posthog.identify({
    distinctId: 'distinct-id',
    userProperties: {
      key: 'value',
    },
  });
};

const register = async () => {
  await Posthog.register({
    key: 'super-property',
    value: 'super-value',
  });
};

const reset = async () => {
  await Posthog.reset();
};

const screen = async () => {
  await Posthog.screen({
    screenTitle: 'screen',
    properties: {
      key: 'value',
    },
  });
};

const setup = async () => {
  await Posthog.setup({
    apiKey: 'YOUR_API_KEY',
    host: 'https://eu.i.posthog.com',
    });
};

const unregister = async () => {
  await Posthog.unregister({
    key: 'super-property',
  });
};

API

alias(...)

alias(options: AliasOptions) => Promise<void>

Assign another distinct ID to the current user.

| Param | Type | | ------------- | ----------------------------------------------------- | | options | AliasOptions |

Since: 6.0.0


capture(...)

capture(options: CaptureOptions) => Promise<void>

Capture an event.

| Param | Type | | ------------- | --------------------------------------------------------- | | options | CaptureOptions |

Since: 6.0.0


flush()

flush() => Promise<void>

Flush all events in the queue.

Only available on Android and iOS.

Since: 6.0.0


group(...)

group(options: GroupOptions) => Promise<void>

Associate the events for that user with a group.

| Param | Type | | ------------- | ----------------------------------------------------- | | options | GroupOptions |

Since: 6.0.0


identify(...)

identify(options: IdentifyOptions) => Promise<void>

Identify the current user.

| Param | Type | | ------------- | ----------------------------------------------------------- | | options | IdentifyOptions |

Since: 6.0.0


register(...)

register(options: RegisterOptions) => Promise<void>

Register a new super property. This property will be sent with every event.

| Param | Type | | ------------- | ----------------------------------------------------------- | | options | RegisterOptions |

Since: 6.0.0


reset()

reset() => Promise<void>

Reset the current user's ID and anonymous ID.

Since: 6.0.0


screen(...)

screen(options: ScreenOptions) => Promise<void>

Send a screen event.

Only available on Android and iOS.

| Param | Type | | ------------- | ------------------------------------------------------- | | options | ScreenOptions |

Since: 6.0.0


setup(...)

setup(options: SetupOptions) => Promise<void>

Setup the PostHog SDK with the provided options.

Attention: This method should be called before any other method.

| Param | Type | | ------------- | ----------------------------------------------------- | | options | SetupOptions |

Since: 6.0.0


unregister(...)

unregister(options: UnregisterOptions) => Promise<void>

Remove a super property.

| Param | Type | | ------------- | --------------------------------------------------------------- | | options | UnregisterOptions |

Since: 6.0.0


Interfaces

AliasOptions

| Prop | Type | Description | Since | | ----------- | ------------------- | -------------------------------------------------- | ----- | | alias | string | The new distinct ID to assign to the current user. | 6.0.0 |

CaptureOptions

| Prop | Type | Description | Since | | ---------------- | ------------------------------------------------------------ | -------------------------------------- | ----- | | event | string | The name of the event to capture. | 6.0.0 | | properties | Record<string, any> | The properties to send with the event. | 6.0.0 |

GroupOptions

| Prop | Type | Description | Since | | --------------------- | ------------------------------------------------------------ | -------------------------------------------- | ----- | | type | string | The group type. | 6.0.0 | | key | string | The group key. | 6.0.0 | | groupProperties | Record<string, any> | The properties to send with the group event. | 6.0.0 |

IdentifyOptions

| Prop | Type | Description | Since | | -------------------- | ------------------------------------------------------------ | ----------------------------- | ----- | | distinctId | string | The distinct ID of the user. | 6.0.0 | | userProperties | Record<string, any> | The person properties to set. | 6.0.0 |

RegisterOptions

| Prop | Type | Description | Since | | ----------- | ------------------- | -------------------------------- | ----- | | key | string | The name of the super property. | 6.0.0 | | value | any | The value of the super property. | 6.0.0 |

ScreenOptions

| Prop | Type | Description | Since | | ----------------- | ------------------------------------------------------------ | --------------------------------------------- | ----- | | screenTitle | string | The name of the screen. | 6.0.0 | | properties | Record<string, any> | The properties to send with the screen event. | 6.0.0 |

SetupOptions

| Prop | Type | Description | Default | Since | | ------------ | ------------------- | ------------------------------------ | --------------------------------------- | ----- | | apiKey | string | The API key of your PostHog project. | | 6.0.0 | | host | string | The host of your PostHog instance. | 'https://us.i.posthog.com' | 6.0.0 |

UnregisterOptions

| Prop | Type | Description | Since | | --------- | ------------------- | ----------------------------------------- | ----- | | key | string | The name of the super property to remove. | 6.0.0 |

Type Aliases

Record

Construct a type with a set of properties K of type T

{ [P in K]: T; }

Changelog

See CHANGELOG.md.

License

See LICENSE.

[^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by PostHog, Inc. or any of their affiliates or subsidiaries.