From 6f797462e4e11b5e6f3f7e725c42b3f639b3b9ca Mon Sep 17 00:00:00 2001 From: reslear Date: Wed, 5 Oct 2022 16:53:56 +0300 Subject: [PATCH] docs: usage instruction --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 946f9ff..f5115e1 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,29 @@ npx cap sync - Capacitor 3 is recommended for this version - Version 1.0.0 will target Capacitor 4 +## Usage + +First need initialize plugin with you [writeKey](https://segment.com/docs/connections/find-writekey/), and then use track methods: + +```ts +import { Segment } from '@joinflux/capacitor-segment' + +Segment.initialize({ + key: 'you write key', +}) + +// see API section with other methods +Segment.track({ eventName: 'Hello World'}) +``` + +For prevent crashing app in HMR on init hook, recommended handling exception: + +```ts +await Segment.initialize({ + // ... +}).catch((e) => console.error(e)) +``` + ## API