Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/core/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
**Ƭ Integration**: * `function` | `object`
*

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

___

62 changes: 31 additions & 31 deletions packages/core/docs/classes/analytics.client.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

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

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

Whether the client is ready to send events to Segment.

Expand All @@ -54,15 +54,15 @@ ___

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

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

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

When you learn more about who the group is, you can record that information with group.

**Parameters:**

| Param | Type | Description |
| Name | Type | Description |
| ------ | ------ | ------ |
| newId | `string` | The new ID you want to alias the existing ID to. The existing ID will be either the previousId if you have called identify, or the anonymous ID. |

Expand All @@ -75,15 +75,15 @@ ___

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

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

Catch React-Native bridge errors

These errors are emitted when calling the native counterpart.

**Parameters:**

| Param | Type |
| Name | Type |
| ------ | ------ |
| handler | [ErrorHandler]() |

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

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

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

Completely disable the sending of any analytics data.

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

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

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

Enable the sending of analytics data. Enabled by default.

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

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

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

Trigger an upload of all queued events.

Expand All @@ -139,20 +139,20 @@ ___

### group

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

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

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

When you learn more about who the group is, you can record that information with group.

**Parameters:**

| Param | Type | Default value | Description |
| Name | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| groupId | `string` | - | A database ID for this group. |
| `Default value` traits | `JsonMap` | {} | A dictionary of traits you know about the group. Things like: name, employees, etc. |
| `Default value` traits | [JsonMap]() | {} | A dictionary of traits you know about the group. Things like: name, employees, etc. |

**Returns:** `Promise`<`void`>

Expand All @@ -161,20 +161,20 @@ ___

### identify

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

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

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

When you learn more about who your user is, you can record that information with identify.

**Parameters:**

| Param | Type | Default value | Description |
| Name | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| user | `string` | - | database ID (or email address) for this user. If you don't have a userId but want to record traits, you should pass nil. For more information on how we generate the UUID and Apple's policies on IDs, see [https://segment.io/libraries/ios#ids](https://segment.io/libraries/ios#ids) |
| `Default value` traits | `JsonMap` | {} | A dictionary of traits you know about the user. Things like: email, name, plan, etc. |
| `Default value` traits | [JsonMap]() | {} | A dictionary of traits you know about the user. Things like: email, name, plan, etc. |

**Returns:** `Promise`<`void`>

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

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

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

Append a new middleware to the middleware chain.

Expand All @@ -210,7 +210,7 @@ analytics.middleware(async ({next, context}) =>

**Parameters:**

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

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

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

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

Reset any user state that is cached on the device.

Expand All @@ -236,20 +236,20 @@ ___

### screen

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

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

Record the screens or views your users see.

When a user views a screen in your app, you'll want to record that here. For some tools like Google Analytics and Flurry, screen views are treated specially, and are different from "events" kind of like "page views" on the web. For services that don't treat "screen views" specially, we map "screen" straight to "track" with the same parameters. For example, Mixpanel doesn't treat "screen views" any differently. So a call to "screen" will be tracked as a normal event in Mixpanel, but get sent to Google Analytics and Flurry as a "screen".

**Parameters:**

| Param | Type | Default value | Description |
| Name | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| name | `string` | - | The title of the screen being viewed. We recommend using human-readable names like 'Photo Feed' or 'Completed Purchase Screen'. |
| `Default value` properties | `JsonMap` | {} | A dictionary of properties for the screen view event. If the event was 'Added to Shopping Cart', it might have properties like price, productType, etc. |
| `Default value` properties | [JsonMap]() | {} | A dictionary of properties for the screen view event. If the event was 'Added to Shopping Cart', it might have properties like price, productType, etc. |

**Returns:** `Promise`<`void`>

Expand All @@ -260,9 +260,9 @@ ___

▸ **setup**(writeKey: *`string`*, configuration?: *[Configuration](../interfaces/analytics.configuration.md)*): `Promise`<`void`>

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

Setup the Analytics module. All calls made before are queued and executed if the configuration was successful.
Setup the Analytics module. All calls made before are queued and only executed if the configuration was successful.

```js
await analytics.setup('YOUR_WRITE_KEY', {
Expand All @@ -276,7 +276,7 @@ await analytics.setup('YOUR_WRITE_KEY', {

**Parameters:**

| Param | Type | Default value | Description |
| Name | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| writeKey | `string` | - | Your Segment.io write key |
| `Default value` configuration | [Configuration](../interfaces/analytics.configuration.md) | {} | An optional [Configuration](../interfaces/analytics.configuration.md) object. |
Expand All @@ -288,20 +288,20 @@ ___

### track

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

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

Record the actions your users perform.

When a user performs an action in your app, you'll want to track that action for later analysis. Use the event name to say what the user did, and properties to specify any interesting details of the action.

**Parameters:**

| Param | Type | Default value | Description |
| Name | Type | Default value | Description |
| ------ | ------ | ------ | ------ |
| event | `string` | - | The name of the event you're tracking. We recommend using human-readable names like \`Played a Song\` or \`Updated Status\`. |
| `Default value` properties | `JsonMap` | {} | A dictionary of properties for the event. If the event was 'Added to Shopping Cart', it might have properties like price, productType, etc. |
| `Default value` properties | [JsonMap]() | {} | A dictionary of properties for the event. If the event was 'Added to Shopping Cart', it might have properties like price, productType, etc. |

**Returns:** `Promise`<`void`>

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

▸ **useNativeConfiguration**(): `this`

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

Use the native configuration.

Expand Down
16 changes: 8 additions & 8 deletions packages/core/docs/interfaces/analytics.configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
**● android**: * `undefined` &#124; `object`
*

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

Android specific settings.

Expand All @@ -42,7 +42,7 @@ ___
**● debug**: * `undefined` &#124; `false` &#124; `true`
*

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

___
<a id="flushat"></a>
Expand All @@ -52,7 +52,7 @@ ___
**● flushAt**: * `undefined` &#124; `number`
*

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

The number of queued events that the analytics client should flush at. Setting this to `1` will not queue any events and will use more battery.

Expand All @@ -66,7 +66,7 @@ ___
**● ios**: * `undefined` &#124; `object`
*

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

iOS specific settings.

Expand All @@ -78,7 +78,7 @@ ___
**● recordScreenViews**: * `undefined` &#124; `false` &#124; `true`
*

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

Whether the analytics client should automatically track application lifecycle events, such as "Application Installed", "Application Updated" and "Application Opened".

Expand All @@ -92,7 +92,7 @@ ___
**● trackAppLifecycleEvents**: * `undefined` &#124; `false` &#124; `true`
*

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

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.

Expand All @@ -106,7 +106,7 @@ ___
**● trackAttributionData**: * `undefined` &#124; `false` &#124; `true`
*

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

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

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

**● using**: *[Integration](../#integration)[]*

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

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

Expand Down
5 changes: 2 additions & 3 deletions packages/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,8 @@ export const configure = async (
}: Analytics.Configuration
): Promise<Configuration> => {
await Promise.all(
using.map(
async integration =>
typeof integration === 'function' ? await integration() : null
using.map(async integration =>
typeof integration === 'function' ? await integration() : null
)
)

Expand Down
58 changes: 29 additions & 29 deletions packages/core/src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,47 +13,47 @@ export interface MiddlewarePayload<T extends string, D extends {}> {

export interface TrackPayload
extends MiddlewarePayload<
'track',
{
event: string
properties: JsonMap
}
> {}
'track',
{
event: string
properties: JsonMap
}
> {}

export interface ScreenPayload
extends MiddlewarePayload<
'screen',
{
name: string
properties: JsonMap
}
> {}
'screen',
{
name: string
properties: JsonMap
}
> {}

export interface IdentifyPayload
extends MiddlewarePayload<
'identify',
{
user: string
traits: JsonMap
}
> {}
'identify',
{
user: string
traits: JsonMap
}
> {}

export interface GroupPayload
extends MiddlewarePayload<
'group',
{
groupId: string
traits: JsonMap
}
> {}
'group',
{
groupId: string
traits: JsonMap
}
> {}

export interface AliasPayload
extends MiddlewarePayload<
'alias',
{
newId: string
}
> {}
'alias',
{
newId: string
}
> {}

export interface Context extends JsonMap {
library: {
Expand Down
Loading