forked from StellarSplit/StellarSplit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconditional-tracking-example.ts
More file actions
54 lines (48 loc) · 1.37 KB
/
Copy pathconditional-tracking-example.ts
File metadata and controls
54 lines (48 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { Injectable } from "@nestjs/common";
import { ActivitiesService } from "./activities.service";
/**
* Example 7: Conditional Activity Tracking
* Track activities based on user preferences
*/
@Injectable()
export class ConditionalTrackingExample {
constructor(private readonly activitiesService: ActivitiesService) {}
async trackActivityIfEnabled(
userId: string,
activityType: string,
splitId: string,
metadata: any
) {
// Check user preferences (this would come from a user settings service)
const userPreferences = await this.getUserPreferences(userId);
if (!userPreferences.activityFeedEnabled) {
return; // Skip tracking
}
// Check if this specific activity type is enabled
if (userPreferences.disabledActivityTypes?.includes(activityType)) {
return; // Skip tracking
}
// Track the activity
switch (activityType) {
case "payment_made":
await this.activitiesService.trackPaymentMade(
userId,
splitId,
metadata.amount,
metadata.txHash,
metadata
);
break;
// ... other cases
}
}
private async getUserPreferences(userId: string): Promise<{
activityFeedEnabled: boolean;
disabledActivityTypes: string[];
}> {
return {
activityFeedEnabled: true,
disabledActivityTypes: [], // now string[]
};
}
}