Skip to content
This repository has been archived by the owner on Jun 27, 2023. It is now read-only.

Commit

Permalink
feat(core): add native configuration method
Browse files Browse the repository at this point in the history
  • Loading branch information
fathy authored and fathy committed Oct 8, 2018
1 parent 9aeafa3 commit 19c4fae
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 41 deletions.
4 changes: 2 additions & 2 deletions packages/core/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
**Ƭ Integration**: * `function` | `object`
*

*Defined in [analytics.ts:180](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L180)*
*Defined in analytics.ts:228*

___
<a id="writekey"></a>
Expand All @@ -36,7 +36,7 @@ ___
**Ƭ WriteKey**: * `string` &#124; `object`
*

*Defined in [analytics.ts:182](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L182)*
*Defined in analytics.ts:230*

___

69 changes: 53 additions & 16 deletions packages/core/docs/classes/analytics.client.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
* [reset](analytics.client.md#reset)
* [screen](analytics.client.md#screen)
* [track](analytics.client.md#track)
* [useNativeConfiguration](analytics.client.md#usenativeconfiguration)

---

Expand All @@ -37,7 +38,7 @@

**● ready**: *`false`* = false

*Defined in [analytics.ts:14](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L14)*
*Defined in analytics.ts:14*

Whether the client is ready to send events to Segment.

Expand All @@ -53,7 +54,7 @@ ___

**alias**(newId: *`string`*): `Promise`<`void`>

*Defined in [analytics.ts:125](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L125)*
*Defined in analytics.ts:173*

Merge two user identities, effectively connecting two sets of user data as one. This may not be supported by all integrations.

Expand All @@ -74,7 +75,7 @@ ___

**catch**(handler: *[ErrorHandler]()*): `this`

*Defined in [analytics.ts:27](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L27)*
*Defined in analytics.ts:27*

Catch React-Native bridge errors

Expand All @@ -95,7 +96,7 @@ ___

**configure**(): [Configuration](../interfaces/analytics.chainedconfiguration.configuration.md)

*Defined in [analytics.ts:53](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L53)*
*Defined in analytics.ts:101*

Configure the Analytics module.

Expand All @@ -120,7 +121,7 @@ ___

**disable**(): `Promise`<`void`>

*Defined in [analytics.ts:164](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L164)*
*Defined in analytics.ts:212*

Completely disable the sending of any analytics data.

Expand All @@ -135,7 +136,7 @@ ___

**enable**(): `Promise`<`void`>

*Defined in [analytics.ts:154](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L154)*
*Defined in analytics.ts:202*

Enable the sending of analytics data. Enabled by default.

Expand All @@ -150,7 +151,7 @@ ___

**flush**(): `Promise`<`void`>

*Defined in [analytics.ts:145](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L145)*
*Defined in analytics.ts:193*

Trigger an upload of all queued events.

Expand All @@ -165,7 +166,7 @@ ___

**group**(groupId: *`string`*, traits?: *`JsonMap`*): `Promise`<`void`>

*Defined in [analytics.ts:112](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L112)*
*Defined in analytics.ts:160*

Associate a user with a group, organization, company, project, or w/e _you_ call them.

Expand All @@ -187,7 +188,7 @@ ___

**identify**(user: *`string`*, traits?: *`JsonMap`*): `Promise`<`void`>

*Defined in [analytics.ts:100](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L100)*
*Defined in analytics.ts:148*

Associate a user with their unique ID and record traits about them.

Expand All @@ -209,13 +210,34 @@ ___

**middleware**(middleware: *[Middleware]()*): `this`

*Defined in [analytics.ts:33](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L33)*
*Defined in analytics.ts:65*

Append a new middleware to the middleware chain.

Middlewares are a powerful mechanism that can augment the events collected by the SDK. A middleware is a simple function that is invoked by the Segment SDK and can be used to monitor, modify or reject events.

Middlewares are invoked for all events, including automatically tracked events, and external event sources like Adjust and Optimizely. This offers you the ability the customize those messages to fit your use case even if the event was sent outside your source code.

The key thing to observe here is that the output produced by the first middleware feeds into the second. This allows you to chain and compose independent middlewares!

For example, you might want to record the device year class with your events. Previously, you would have to do this everywhere you trigger an event with the Segment SDK. With middlewares, you can do this in a single place :

```js
import DeviceYearClass from 'react-native-device-year-class'

analytics.middleware(async ({next, context}) =>
next({
...context,
device_year_class: await DeviceYearClass()
})
)
```

**Parameters:**

| Param | Type |
| ------ | ------ |
| middleware | [Middleware]() |
| Param | Type | Description |
| ------ | ------ | ------ |
| middleware | [Middleware]() | |

**Returns:** `this`

Expand All @@ -226,7 +248,7 @@ ___

**reset**(): `Promise`<`void`>

*Defined in [analytics.ts:135](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L135)*
*Defined in analytics.ts:183*

Reset any user state that is cached on the device.

Expand All @@ -241,7 +263,7 @@ ___

**screen**(name: *`string`*, properties?: *`JsonMap`*): `Promise`<`void`>

*Defined in [analytics.ts:86](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L86)*
*Defined in analytics.ts:134*

Record the screens or views your users see.

Expand All @@ -263,7 +285,7 @@ ___

**track**(event: *`string`*, properties?: *`JsonMap`*): `Promise`<`void`>

*Defined in [analytics.ts:68](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L68)*
*Defined in analytics.ts:116*

Record the actions your users perform.

Expand All @@ -279,4 +301,19 @@ When a user performs an action in your app, you'll want to track that action for
**Returns:** `Promise`<`void`>

___
<a id="usenativeconfiguration"></a>

### useNativeConfiguration

**useNativeConfiguration**(): `this`

*Defined in analytics.ts:77*

Use the native configuration.

You'll need to call this method when you configure Analytics's singleton using the native API.

**Returns:** `this`

___

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

*Inherited from [Base](analytics.chainedconfiguration.base.md).[android](analytics.chainedconfiguration.base.md#android)*

*Defined in [analytics.ts:203](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L203)*
*Defined in analytics.ts:251*

Access Android specific settings

Expand All @@ -43,7 +43,7 @@ ___

**disableDeviceId**(): `this`

*Defined in [analytics.ts:257](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L257)*
*Defined in analytics.ts:305*

Disable the collection of the device identifier. Enabled by default.

Expand All @@ -62,7 +62,7 @@ ___

**flushInterval**(every: *`number`*): `this`

*Defined in [analytics.ts:264](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L264)*
*Defined in analytics.ts:312*

Set the interval at which the client should flush events. The client will automatically flush events to Segment every [flushInterval](analytics.chainedconfiguration.android.md#flushinterval) duration, regardless of [flushAt](analytics.chainedconfiguration.configuration.md#flushat).

Expand All @@ -83,7 +83,7 @@ ___

*Inherited from [Base](analytics.chainedconfiguration.base.md).[ios](analytics.chainedconfiguration.base.md#ios)*

*Defined in [analytics.ts:199](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L199)*
*Defined in analytics.ts:247*

Access iOS specific settings

Expand All @@ -98,7 +98,7 @@ ___

*Inherited from [Base](analytics.chainedconfiguration.base.md).[setup](analytics.chainedconfiguration.base.md#setup)*

*Defined in [analytics.ts:195](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L195)*
*Defined in analytics.ts:243*

Finalize the configuration and initialize the Analytics client.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

**android**(): [Android](analytics.chainedconfiguration.android.md)

*Defined in [analytics.ts:203](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L203)*
*Defined in analytics.ts:251*

Access Android specific settings

Expand All @@ -43,7 +43,7 @@ ___

**ios**(): [iOS](analytics.chainedconfiguration.ios.md)

*Defined in [analytics.ts:199](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L199)*
*Defined in analytics.ts:247*

Access iOS specific settings

Expand All @@ -56,7 +56,7 @@ ___

**setup**(writeKey: *[WriteKey](../#writekey)*): `Promise`<[Client](../classes/analytics.client.md)>

*Defined in [analytics.ts:195](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L195)*
*Defined in analytics.ts:243*

Finalize the configuration and initialize the Analytics client.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

*Inherited from [Base](analytics.chainedconfiguration.base.md).[android](analytics.chainedconfiguration.base.md#android)*

*Defined in [analytics.ts:203](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L203)*
*Defined in analytics.ts:251*

Access Android specific settings

Expand All @@ -47,7 +47,7 @@ ___

**debug**(): `this`

*Defined in [analytics.ts:233](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L233)*
*Defined in analytics.ts:281*

**Returns:** `this`

Expand All @@ -58,7 +58,7 @@ ___

**flushAt**(at: *`number`*): `this`

*Defined in [analytics.ts:228](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L228)*
*Defined in analytics.ts:276*

The number of queued events that the analytics client should flush at.

Expand All @@ -81,7 +81,7 @@ ___

*Inherited from [Base](analytics.chainedconfiguration.base.md).[ios](analytics.chainedconfiguration.base.md#ios)*

*Defined in [analytics.ts:199](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L199)*
*Defined in analytics.ts:247*

Access iOS specific settings

Expand All @@ -94,7 +94,7 @@ ___

**recordScreenViews**(): `this`

*Defined in [analytics.ts:212](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L212)*
*Defined in analytics.ts:260*

Whether the analytics client should automatically make a screen call when a view controller is added to a view hierarchy. Because the iOS underlying implementation uses method swizzling, we recommend initializing the analytics client as early as possible (before any screens are displayed).

Expand All @@ -109,7 +109,7 @@ ___

*Inherited from [Base](analytics.chainedconfiguration.base.md).[setup](analytics.chainedconfiguration.base.md#setup)*

*Defined in [analytics.ts:195](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L195)*
*Defined in analytics.ts:243*

Finalize the configuration and initialize the Analytics client.

Expand All @@ -128,7 +128,7 @@ ___

**trackAppLifecycleEvents**(): `this`

*Defined in [analytics.ts:217](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L217)*
*Defined in analytics.ts:265*

Enable the automatic tracking of application lifecycle events, such as "Application Installed", "Application Updated" and "Application Opened".

Expand All @@ -141,7 +141,7 @@ ___

**trackAttributionData**(): `this`

*Defined in [analytics.ts:221](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L221)*
*Defined in analytics.ts:269*

Whether the analytics client should automatically track attribution data from enabled providers using the mobile service.

Expand All @@ -154,7 +154,7 @@ ___

**using**(...integrations: *[Integration](../#integration)[]*): `this`

*Defined in [analytics.ts:232](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L232)*
*Defined in analytics.ts:280*

Register a set of integrations to be used with this Analytics instance.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

*Inherited from [Base](analytics.chainedconfiguration.base.md).[android](analytics.chainedconfiguration.base.md#android)*

*Defined in [analytics.ts:203](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L203)*
*Defined in analytics.ts:251*

Access Android specific settings

Expand All @@ -45,7 +45,7 @@ ___

*Inherited from [Base](analytics.chainedconfiguration.base.md).[ios](analytics.chainedconfiguration.base.md#ios)*

*Defined in [analytics.ts:199](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L199)*
*Defined in analytics.ts:247*

Access iOS specific settings

Expand All @@ -60,7 +60,7 @@ ___

*Inherited from [Base](analytics.chainedconfiguration.base.md).[setup](analytics.chainedconfiguration.base.md#setup)*

*Defined in [analytics.ts:195](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L195)*
*Defined in analytics.ts:243*

Finalize the configuration and initialize the Analytics client.

Expand All @@ -79,7 +79,7 @@ ___

**trackAdvertising**(): `this`

*Defined in [analytics.ts:240](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L240)*
*Defined in analytics.ts:288*

Whether the analytics client should track advertisting info.

Expand All @@ -92,7 +92,7 @@ ___

**trackDeepLinks**(): `this`

*Defined in [analytics.ts:246](https://github.com/segmentio/analytics-react-native/blob/master/packages/core/src/analytics.ts#L246)*
*Defined in analytics.ts:294*

Whether the analytics client should automatically track deep links.

Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@segment/analytics-react-native",
"version": "0.0.1",
"version": "0.0.1-alpha.2",
"description": "The hassle-free way to add analytics to your React-Native app.",
"license": "MIT",
"main": "build/cjs/index.js",
Expand Down
Loading

0 comments on commit 19c4fae

Please sign in to comment.