Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EMBR-4336 updated docs for RN 5.0 release #1

Merged
merged 7 commits into from
Sep 26, 2024
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
32 changes: 32 additions & 0 deletions docs/react-native/4x/features/current-device-id-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
title: Current Device ID API
sidebar_position: 9
description: Get the Device ID.
---
# Current Device ID API

import GetSessionId from '@site/shared/get-session-id.md';

<GetSessionId />

## Integration Steps

In order to use this feature, you will need to follow two steps:

1. Make sure your app is using at least version `4.0.0` of the Embrace SDK.
2. Implement the API call to obtain the current Device ID.


```javascript
import {getDeviceId} from '@embrace-io/react-native';

const myMethod = () =>{
getDeviceId().then(deviceId=>{
console.log("Embrace Device Id", deviceId)
})
}
```

import CallSupport from '@site/shared/call-support.md';

<CallSupport />
37 changes: 37 additions & 0 deletions docs/react-native/4x/features/current-session-id-api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Current Session ID API
sidebar_position: 9
description: Track the current Embrace session by getting its ID.
---
# Current Session ID API

import GetSessionId from '@site/shared/get-session-id.md';

<GetSessionId />

## Integration Steps

In order to use this feature, you will need to follow two steps:

1. Make sure your app is using at least version `3.15.0` of the Embrace SDK.
2. Implement the API call to obtain the current Session ID.
3. The method will return a String with the SessionId or null if there is no active session.


```javascript
import {getCurrentSessionId} from '@embrace-io/react-native';

const myMethod = () =>{
getCurrentSessionId().then(sessionId=>{
console.log("Embrace Session Id", sessionId)
})
}
```

:::warning Important
If you call `getCurrentSessionId()` inside the `AppState change` listener; keep in mind that this is the moment when the session is ending, and a new one is starting. Therefore, there is a high chance that you will get the session ID of the session that is still ending. You might need to delay the call or obtain the session ID at any other point of the app lifecycle to make sure the session ID you get is the one you are looking for.
:::

import CallSupport from '@site/shared/call-support.md';

<CallSupport />
66 changes: 66 additions & 0 deletions docs/react-native/4x/features/identify-users.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: Identify Users
description: Get to know the users of your React Native application with the Embrace SDK
sidebar_position: 2
---

# Know Your Users

Embrace offers two ways you can annotate sessions with information that will help developers and customer service agents find
sessions for an unhappy user.

1. [**User Personas**](/react-native/4x/features/identify-users#user-personas). This is data you can set and update about the user of a session.
1. [**Session Properties**](/react-native/4x/features/identify-users#session-properties). This is data you use to track information about the device or the session itself.

## User Personas

Embrace offers a set of methods to pass information about your users.

```javascript
import {setUserIdentifier} from '@embrace-io/react-native';

setUserIdentifier('internal_random_id_1234');
```

The above call annotates the session with a user identifier that you can use later to search for this user.
For more methods on setting user values, you can see the [source code](/api/react-native/).

:::warning Important
Remember that this data will be uploaded to Embrace, so think about the privacy of your users and only include data you are willing to share.
We recommend using an anonymized or hashed user ID that only your agents can search for.
:::

You can also set customized values for specific use cases or segments of users.

```javascript
import {addUserPersona} from '@embrace-io/react-native';

addUserPersona('high_value_cart');
```

In the above example, the session is annotated with `"high_value_cart"`.
This will help you identify users who have a certain dollar value in their shopping cart so you can prioritize fixing bugs that affect such users.

## Session Properties

Session Properties are another way to annotate the session.
The difference between session properties and [user personas](/react-native/4x/features/identify-users#user-personas) is that the former are for items relating to the session or the device and not necessarily to the user.
However, you are free to use both mechanisms interchangeably.

Here is an example of setting a session property:

```javascript
import {addSessionProperty} from '@embrace-io/react-native';

addSessionProperty('launch type', 'normal', false);
```

import PropertyLimit from '@site/shared/property-limit.md';

<PropertyLimit />

In the above, the `'launch type'` property is set with a value of `'normal'`.
This is to indicate normal launches by the user.
When the app is launched via a push notification tap, you can set the value `"push"`.
This can help to understand issues that are hurting push notification adoption rates.
For example, you could prioritize fixing the issues that affect customers that use push notifications, since they generally provide higher lifetime value.
14 changes: 14 additions & 0 deletions docs/react-native/4x/features/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Feature Reference
description: Learn about the advanced ways Embrace can help your application
sidebar_position: 2
---

# React Native Feature Reference

Embrace's SDK includes many advanced features that you can enable to help you understand more about
how your application is performing in production.

1. [**Know your users.**](/react-native/4x/features/identify-users/) Add your own custom identifiers to users and sessions to make sure you can aggregate and find sessions correctly.
2. [**Tracking Components.**](/react-native/4x/features/tracking-components/) Track the mounting and unmounting of React Components for your React Native application using the Embrace SDK.
3. [**Current Session ID API.**](/react-native/4x/features/current-session-id-api.md) This API lets you know what the current Session Id is in case you need to track it separately.
62 changes: 62 additions & 0 deletions docs/react-native/4x/features/last-run-end-state.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
title: Last Run End State
description: Understand if the previous app instance ended in a crash
sidebar_position: 10
---

# Last Run End State API

This API enables customers to automatically/programmatically understand if the previous app instance ended in a crash. Depending on your use case, having the ability to query an API to understand if the previous app instance ended in a crash will enable you to adjust the behavior or UI of your app after a crash has occurred.

**What do we mean by previous app instance?**

A cold launch, basically. If the app gets backgrounded/resumed so a new session starts, the value returned will not change. So:

1. App crashes
2. App is relaunched
3. `getLastRunEndState` returns "crashed"
4. App is sent to background
5. App is resumed, starting a new session
6. `getLastRunEndState` still returns "crashed"
7. App exits cleanly
8. App is relaunched
9. `getLastRunEndState` returns "clean exit"

## Integration Steps

In order to use this feature, you will need to follow two steps:

1. Make sure your app is using the latest version of the Embrace SDK or at least React Native SDK 3.15.0
2. Implement the API call after starting the SDK to receive the state of the last run.

```javascript
useEffect(() => {
getLastRunEndState().then(resp => {

console.log('LastRunEndState', resp);
});

}, []);
```

**Important Notes**

:::warning Important
- The API can only be called after the SDK has been started. If a call is made prior to starting the Embrace SDK you will get a response of `INVALID`
- It will return that a crash occurred if the app crashed any time since the app last came to the foreground. This includes if the app crashed while running in the background.
:::

### Version

This feature is included in Embrace SDK version 3.15.0 and above.

### Possible Values

```typescript
/// Used to represent the end state of the last run of the application.
export type SessionStatus = 'INVALID' | 'CRASH' | 'CLEAN_EXIT';
```

import CallSupport from '@site/shared/call-support.md';

<CallSupport />
Loading