Skip to content

Commit d8dd1fe

Browse files
Split the Flutter documentation sections
1 parent ace3473 commit d8dd1fe

File tree

5 files changed

+320
-311
lines changed

5 files changed

+320
-311
lines changed

fern/docs/pages/plug-sdk/flutter.mdx

Lines changed: 7 additions & 311 deletions
Original file line numberDiff line numberDiff line change
@@ -1,314 +1,10 @@
1-
This section describes the process of integrating the DevRev SDK with your Flutter app.
1+
# DevRev SDK for Flutter
22

3-
## Requirements
3+
This section provides documentation for integrating and using the DevRev SDK in your Flutter app.
44

5-
- Flutter 3.0.0 or higher.
6-
- Dart 2.17.0 or later.
7-
- A minimum deployment target of Android 5.0 (API level 21) or iOS 11.
5+
## Documentation Sections
86

9-
## Installation
10-
11-
To install the DevRev SDK, run the following command:
12-
13-
```sh
14-
flutter pub add devrev_sdk
15-
```
16-
17-
## Set up the DevRev SDK
18-
19-
1. Open the DevRev web app at [https://app.devrev.ai](https://app.devrev.ai) and go to the **Settings** page.
20-
2. Under **PLuG settings**, copy the value under **Your unique App ID**.
21-
3. After obtaining the credentials, you can configure the DevRev SDK in your app.
22-
23-
<Callout intent="note">
24-
The DevRev SDK must be configured before you can use any of its features.
25-
</Callout>
26-
27-
The SDK will be ready for use once you execute the following configuration method:
28-
29-
```dart
30-
DevRev.configure(appID);
31-
```
32-
33-
## Identification
34-
35-
To access certain features of the DevRev SDK, user identification is required.
36-
37-
The identification function should be placed appropriately in your app after the user logs in. If you have the user information available at app launch, call the function after the `DevRev.configure(appID)` method.
38-
39-
<Callout intent="note">
40-
On iOS, if you haven't previously identified the user, the DevRev SDK will automatically create an anonymous user for you immediately after the SDK is configured.
41-
</Callout>
42-
43-
<Callout intent="note">
44-
The `Identity` structure allows for custom fields in the user, organization, and account traits. These fields must be configured through the DevRev app before they can be utilized. For more information, refer to [Object customization](https://devrev.ai/docs/product/object-customization).
45-
</Callout>
46-
47-
You can select from the following methods to identify users within your application:
48-
49-
### Anonymous identification
50-
51-
The anonymous identification method allows you to create an anonymous user with an optional user identifier, ensuring that no other data is stored or associated with the user.
52-
53-
```dart
54-
DevRev.identifyAnonymousUser(userID);
55-
```
56-
57-
### Unverified identification
58-
59-
The unverified identification method identifies users with a unique identifier, but it does not verify their identity with the DevRev backend.
60-
61-
```dart
62-
DevRev.identifyUnverifiedUser(userID, organizationID);
63-
```
64-
65-
### Verified identification
66-
67-
The verified identification method identifies users with a unique identifier and verifies their identity with the DevRev backend.
68-
69-
```dart
70-
DevRev.identifyVerifiedUser(userID, sessionToken);
71-
```
72-
73-
### Update the user
74-
75-
You can update the user's information using the following method:
76-
77-
```dart
78-
DevRev.updateUser(identity);
79-
```
80-
81-
<Callout intent="note">
82-
The `userID` property cannot be updated.
83-
</Callout>
84-
85-
### Logout
86-
87-
You can log out the current user by using the following method:
88-
89-
```dart
90-
DevRev.logout(deviceID);
91-
```
92-
93-
The user will be logged out by clearing their credentials, as well as unregistering the device from receiving push notifications, and stopping the session recording.
94-
95-
## PLuG support chat
96-
97-
Once user identification is complete, you can start using the chat (conversations) dialog supported by our DevRev SDK. The support chat feature can be shown as a modal screen from the top-most screen.
98-
99-
<Callout intent="note">
100-
This functionality requires the SDK to be configured and the user to be identified, whether they are unverified or anonymous.
101-
</Callout>
102-
103-
To show the support chat screen in your app, you can use the following method:
104-
105-
```dart
106-
DevRev.showSupport();
107-
```
108-
109-
### Creating a new support conversation
110-
111-
You can initiate a new support conversation directly from your app. This method displays the support chat screen and simultaneously creates a new conversation.
112-
113-
```dart
114-
DevRev.createSupportConversation();
115-
```
116-
117-
## Analytics
118-
119-
The DevRev SDK allows you to send custom analytic events by using a properties map. You can track these events using the following function:
120-
121-
<Callout intent="note">
122-
This functionality requires the SDK to be configured and the user to be identified, whether they are unverified or anonymous.
123-
</Callout>
124-
125-
```dart
126-
DevRev.trackEvent(name, properties);
127-
```
128-
129-
## Session analytics
130-
131-
The DevRev SDK offers session analytics features to help you understand how users interact with your app.
132-
133-
### Opting-in or out
134-
135-
Session analytics features are opted-in by default, enabling them from the start. However, you can opt-out using the following method:
136-
137-
```dart
138-
DevRev.stopAllMonitoring();
139-
```
140-
141-
To opt back in, use the following method:
142-
143-
```dart
144-
DevRev.resumeAllMonitoring();
145-
```
146-
147-
### Session recording
148-
149-
You can enable session recording to capture user interactions with your app.
150-
151-
<Callout intent="note">
152-
The session recording feature is opt-out and is enabled by default.
153-
</Callout>
154-
155-
The session recording feature includes the following methods to control the recording:
156-
157-
| Method | Action |
158-
|--------------------------------------------------------------------|-----------------------------------------------------------|
159-
|`DevRev.startRecording()` | Starts the session recording. |
160-
|`DevRev.stopRecording()` | Ends the session recording and uploads it to the portal. |
161-
|`DevRev.pauseRecording()` | Pauses the ongoing session recording. |
162-
|`DevRev.resumeRecording()` | Resumes a paused session recording. |
163-
164-
### Session properties
165-
166-
You can add custom properties to the session recording to help you understand the context of the session. The properties are defined as a map of string values.
167-
168-
```dart
169-
DevRev.addSessionProperties(properties);
170-
```
171-
172-
To clear the session properties in scenarios such as user logout or when the session ends, use the following method:
173-
174-
```dart
175-
DevRev.clearSessionProperties();
176-
```
177-
178-
### Timers
179-
180-
The DevRev SDK offers a timer mechanism to measure the time spent on specific tasks, allowing you to track events such as response time, loading time, or any other duration-based metrics.
181-
182-
The mechanism utilizes balanced start and stop methods, both of which accept a timer name and an optional dictionary of properties.
183-
184-
To start a timer, use the following method:
185-
186-
```dart
187-
DevRev.startTimer(name, properties);
188-
```
189-
190-
To stop a timer, use the following method:
191-
192-
```dart
193-
DevRev.stopTimer(name, properties);
194-
```
195-
196-
### Screen tracking
197-
198-
The DevRev SDK offers automatic screen tracking to help you understand how users navigate through your app. Although view controllers are automatically tracked, you can manually track screens using the following method:
199-
200-
```dart
201-
DevRev.trackScreenName(screenName);
202-
```
203-
204-
## Push notifications
205-
206-
You can configure your app to receive push notifications from the DevRev SDK. The SDK is designed to handle push notifications and execute actions based on the notification's content.
207-
208-
The DevRev backend sends push notifications to your app to alert users about new messages in the PLuG support chat.
209-
210-
### Configuration
211-
212-
To receive push notifications, you need to configure your DevRev organization by following the instructions in the [push notifications](https://developer.devrev.ai/public/sdks/mobile/push-notification) section.
213-
214-
### Register for push notifications
215-
216-
<Callout intent="note">
217-
Push notifications require SDK configuration and user identification, whether unverified or anonymous, to ensure delivery to the correct user.
218-
</Callout>
219-
220-
The DevRev SDK offers a method to register your device for receiving push notifications. You can register for push notifications using the following method:
221-
222-
```dart
223-
DevRev.registerDeviceToken(deviceID, deviceToken);
224-
```
225-
226-
On Android devices, the `deviceToken` should be the Firebase Cloud Messaging (FCM) token value, while on iOS devices, it should be the Apple Push Notification Service (APNS) token.
227-
228-
### Unregister from push notifications
229-
230-
If your app no longer needs to receive push notifications, you can unregister the device.
231-
232-
Use the following method to unregister the device:
233-
234-
```dart
235-
DevRev.unregisterDevice(deviceID);
236-
```
237-
238-
### Processing push notifications
239-
240-
#### Android
241-
242-
On Android, notifications are implemented as data messages to offer flexibility. However, this means that automatic click processing isn't available. To handle notification clicks, developers need to intercept the click event, extract the payload, and pass it to a designated method for processing. This custom approach enables tailored notification handling in Android applications.
243-
244-
To process the notification, use the following method:
245-
246-
```dart
247-
DevRev.processPushNotification(payload);
248-
```
249-
250-
Here, the `message` object from the notification payload should be passed to this function.
251-
252-
For example:
253-
254-
```dart
255-
final notificationPayload = {
256-
"message": {
257-
"title": "New Message",
258-
"body": "You have received a new message.",
259-
"data": {
260-
"messageId": "12345",
261-
"sender": "John Doe"
262-
}
263-
}
264-
};
265-
266-
final messageJson = notificationPayload["message"];
267-
268-
if (messageJson != null) {
269-
DevRev.processPushNotification(jsonEncode(messageJson));
270-
}
271-
```
272-
273-
#### iOS
274-
275-
On iOS devices, you must pass the received push notification payload to the DevRev SDK for processing. The SDK will then handle the notification and execute the necessary actions.
276-
277-
```dart
278-
DevRev.processPushNotification(payload);
279-
```
280-
281-
For example:
282-
283-
```dart
284-
DevRev.processPushNotification(jsonEncode(payload));
285-
```
286-
287-
## Troubleshooting
288-
289-
- **Issue**: Support chat won't show.
290-
**Solution**: Ensure you have correctly called one of the identification methods: `DevRev.identifyUnverifiedUser(...)`, `DevRev.identifyVerifiedUser(...)`, or `DevRev.identifyAnonymousUser(...)`.
291-
292-
- **Issue**: Not receiving push notifications.
293-
**Solution**: Ensure that your app is configured to receive push notifications and that your device is registered with the DevRev SDK.
294-
295-
## Migration Guide
296-
297-
This guide will help you transition from the legacy UserExperior SDK to the new DevRev SDK in your Flutter application. Below is a feature equivalence chart and detailed instructions for migrating.
298-
299-
### Feature Equivalence Chart
300-
301-
| Feature | UserExperior SDK | DevRev SDK |
302-
|-|-|-|
303-
| Installation | `user_experior: ^<version>` | `devrev_sdk_flutter: ^<version>` |
304-
| Initialization | `userExperior.startRecording(appID)` | `DevRev.configure(appID)` |
305-
| User Identification | `userExperior.setUserIdentifier(userIdentifier)` | `DevRev.identifyAnonymousUser(userID)`<br>`DevRev.identifyUnverifiedUser(userID, organizationID)`<br>`DevRev.identifyVerifiedUser(userID, sessionToken)`<br>`DevRev.logout(deviceID)` |
306-
| Event Tracking | `userExperior.logEvent(name)` | `DevRev.trackEvent(name, properties)` |
307-
| Session Recording | `userExperior.stopRecording()`<br>`userExperior.pauseRecording()`<br>`userExperior.resumeRecording()` | `DevRev.startRecording()`<br>`DevRev.stopRecording()`<br>`DevRev.pauseRecording()`<br>`DevRev.resumeRecording()`<br>`DevRev.processAllOnDemandSessions()` |
308-
| Opting in/out | `userExperior.optOut()`<br>`userExperior.optIn()`<br>`userExperior.getOptOutStatus()` | `DevRev.stopAllMonitoring()`<br>`DevRev.resumeAllMonitoring()` |
309-
| Session Properties | `userExperior.setUserProperties(properties)` | `DevRev.addSessionProperties(properties)`<br>`DevRev.clearSessionProperties()` |
310-
| Timers | `userExperior.startTimer(timerName, properties)`<br>`userExperior.endTimer(timerName, properties)` | `DevRev.startTimer(name, properties)`<br>`DevRev.endTimer(name, properties)` |
311-
| PLuG support chat | Not supported. | `DevRev.showSupport()`<br> `DevRev.createSupportConversation()` |
312-
| Push Notifications | Not supported. | `DevRev.registerDeviceToken(deviceID, deviceToken)`<br>`DevRev.unregisterDevice(deviceID)` |
313-
314-
---
7+
- [Quickstart Guide](./flutter/quickstart)
8+
- [Features](./flutter/features)
9+
- [Troubleshooting](./flutter/troubleshooting)
10+
- [Migration Guide](./flutter/migration-guide)

0 commit comments

Comments
 (0)