Skip to content

Commit 7374542

Browse files
committed
docs: add new documentation for application tracking SDK
1 parent 5a09aff commit 7374542

File tree

2 files changed

+157
-0
lines changed

2 files changed

+157
-0
lines changed
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"label": "Application",
3+
"position": 12
4+
}

website/docs/application/tracking.md

+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
---
2+
sidebar_position: 1
3+
---
4+
5+
# Application Tracking
6+
7+
Tianji provides a powerful SDK for tracking events and user behavior in your applications. This guide explains how to integrate and use the Application Tracking SDK in your projects.
8+
9+
## Installation
10+
11+
Install the Tianji react native SDK in your project:
12+
13+
```bash
14+
npm install tianji-react-native
15+
# or
16+
yarn add tianji-react-native
17+
# or
18+
pnpm add tianji-react-native
19+
```
20+
21+
## Initialization
22+
23+
Before using any tracking features, you need to initialize the Application SDK with your Tianji server URL and application ID:
24+
25+
```ts
26+
import { initApplication } from 'tianji-react-native';
27+
28+
initApplication({
29+
serverUrl: 'https://tianji.example.com', // Your Tianji server URL
30+
applicationId: 'your-application-id' // Your application identifier
31+
});
32+
```
33+
34+
## Tracking Events
35+
36+
You can track custom events in your application to monitor user actions and behaviors:
37+
38+
```ts
39+
import { reportApplicationEvent } from 'tianji-react-native';
40+
41+
// Track a simple event
42+
reportApplicationEvent('Button Clicked');
43+
44+
// Track an event with additional data
45+
reportApplicationEvent('Purchase Completed', {
46+
productId: 'product-123',
47+
price: 29.99,
48+
currency: 'USD'
49+
});
50+
```
51+
52+
## Screen Tracking
53+
54+
Track screen views in your application to understand user navigation patterns:
55+
56+
### Setting Current Screen
57+
58+
You can set the current screen information which will be included in subsequent events:
59+
60+
```ts
61+
import { updateCurrentApplicationScreen } from 'tianji-react-native';
62+
63+
// Update current screen when user navigates
64+
updateCurrentApplicationScreen('ProductDetails', { productId: 'product-123' });
65+
```
66+
67+
### Reporting Screen Views
68+
69+
Explicitly report screen view events:
70+
71+
```ts
72+
import { reportApplicationScreenView } from 'tianji-react-native';
73+
74+
// Report current screen view
75+
reportApplicationScreenView();
76+
77+
// Or report a specific screen view
78+
reportApplicationScreenView('Checkout', { cartItems: 3 });
79+
```
80+
81+
## User Identification
82+
83+
Identify users in your application to track their behavior across sessions:
84+
85+
```ts
86+
import { identifyApplicationUser } from 'tianji-react-native';
87+
88+
// Identify a user with their information
89+
identifyApplicationUser({
90+
id: 'user-123', // Unique user identifier
91+
92+
name: 'John Doe',
93+
// Add any other user properties
94+
plan: 'premium',
95+
signupDate: '2023-01-15'
96+
});
97+
```
98+
99+
## API Reference
100+
101+
### `initApplication(options)`
102+
103+
Initializes the application tracking SDK.
104+
105+
**Parameters:**
106+
107+
- `options`: ApplicationTrackingOptions
108+
- `serverUrl`: Your Tianji server URL (e.g., 'https://tianji.example.com')
109+
- `applicationId`: Your application identifier
110+
111+
### `reportApplicationEvent(eventName, eventData?, screenName?, screenParams?)`
112+
113+
Sends an application event to the Tianji server.
114+
115+
**Parameters:**
116+
117+
- `eventName`: Name of the event (max 50 chars)
118+
- `eventData`: (Optional) Event data object
119+
- `screenName`: (Optional) Screen name to override current screen
120+
- `screenParams`: (Optional) Screen parameters to override current screen params
121+
122+
### `updateCurrentApplicationScreen(name, params)`
123+
124+
Updates the current application screen information.
125+
126+
**Parameters:**
127+
128+
- `name`: Screen name
129+
- `params`: Screen parameters object
130+
131+
### `reportApplicationScreenView(screenName?, screenParams?)`
132+
133+
Sends a screen view event to the Tianji server.
134+
135+
**Parameters:**
136+
137+
- `screenName`: (Optional) Screen name to override current screen
138+
- `screenParams`: (Optional) Screen parameters to override current screen params
139+
140+
### `identifyApplicationUser(userInfo)`
141+
142+
Identifies a user in the application.
143+
144+
**Parameters:**
145+
146+
- `userInfo`: User identification data object
147+
148+
## Payload Limitations
149+
150+
- Language information: max 35 characters
151+
- Operating system information: max 20 characters
152+
- URL information: max 500 characters
153+
- Event name: max 50 characters

0 commit comments

Comments
 (0)