Overview
The Chat Analytics component provides comprehensive insights into how users interact with chat components across your platform. It helps educators and administrators understand usage patterns, identify popular topics, measure engagement levels, and make data-driven decisions to improve the learning experience.Creating a Chat Analytics Component
import StudyfetchSDK from '@studyfetch/sdk';
const client = new StudyfetchSDK({
apiKey: 'your-api-key',
baseURL: 'https://studyfetchapi.com',
});
const analyticsComponent = await client.v1.components.create({
name: 'Platform Chat Analytics Dashboard',
type: 'chat_analytics',
config: {
chatComponentId: 'chat-comp-123',
autoRefresh: true,
dateRange: 30,
enableExport: true,
refreshInterval: 5,
showSummary: true,
showTopics: true,
showUserStats: true
}
});
console.log('Chat Analytics component created:', analyticsComponent._id);
from studyfetch_sdk import StudyfetchSDK
client = StudyfetchSDK(
api_key="your-api-key",
base_url="https://studyfetchapi.com",
)
analytics_component = client.v1.components.create(
name="Platform Chat Analytics Dashboard",
type="chat_analytics",
config={
"chatComponentId": "chat-comp-123",
"autoRefresh": True,
"dateRange": 30,
"enableExport": True,
"refreshInterval": 5,
"showSummary": True,
"showTopics": True,
"showUserStats": True
}
)
print(f"Chat Analytics component created: {analytics_component._id}")
import com.studyfetch.javasdk.client.StudyfetchSdkClient;
import com.studyfetch.javasdk.client.okhttp.StudyfetchSdkOkHttpClient;
import com.studyfetch.javasdk.models.v1.components.ComponentResponse;
import com.studyfetch.javasdk.models.v1.components.ComponentCreateParams;
import java.util.List;
public class CreateChatAnalyticsComponent {
public static void main(String[] args) {
StudyfetchSdkClient client = StudyfetchSdkOkHttpClient.builder()
.fromEnv()
.baseUrl("https://studyfetchapi.com")
.build();
ComponentCreateParams params = ComponentCreateParams.builder()
.name("Platform Chat Analytics Dashboard")
.type(ComponentCreateParams.Type.CHAT_ANALYTICS)
.config(ComponentCreateParams.Config.ChatAnalyticsConfigDto.builder()
.chatComponentId("chat-comp-123")
.autoRefresh(true)
.dateRange(30.0)
.enableExport(true)
.refreshInterval(5.0)
.showSummary(true)
.showTopics(true)
.showUserStats(true)
.build())
.build();
ComponentResponse component = client.v1().components().create(params);
System.out.println("Chat Analytics component created: " + component._id());
}
}
using StudyfetchSDK;
using StudyfetchSDK.Models.V1.Components;
using System;
using System.Threading.Tasks;
public class CreateChatAnalyticsComponent
{
public static async Task CreateChatAnalytics()
{
var client = new StudyfetchSDKClient()
{
APIKey = Environment.GetEnvironmentVariable("STUDYFETCH_API_KEY"),
BaseUrl = new Uri("https://studyfetchapi.com")
};
var analyticsComponent = await client.V1.Components.Create(new()
{
Name = "Platform Chat Analytics Dashboard",
Type = StudyfetchSDK.Models.V1.Components.ComponentCreateParamsProperties.Type.ChatAnalytics,
Config = new StudyfetchSDK.Models.V1.Components.ComponentCreateParamsProperties.ConfigProperties.ChatAnalyticsConfigDto()
{
ChatComponentID = "chat-comp-123",
AutoRefresh = true,
DateRange = 30,
EnableExport = true,
RefreshInterval = 5,
ShowSummary = true,
ShowTopics = true,
ShowUserStats = true
}
});
Console.WriteLine($"Chat Analytics component created: {analyticsComponent._ID}");
}
}
Configuration Parameters
string
required
Name of the chat analytics component
string
required
Must be
chat_analyticsobject
required
Configuration options for the chat analytics component
Show config properties
Show config properties
string
required
ID of the chat component to analyze
boolean
default:"true"
Enable auto-refresh of analytics data
number
default:"30"
Default date range in days for analytics display
boolean
default:"true"
Enable CSV export functionality
number
default:"5"
Refresh interval in minutes (minimum: 1, maximum: 60)
boolean
default:"true"
Show summary section in analytics dashboard
boolean
default:"true"
Show top topics analysis section
boolean
default:"true"
Show user statistics and activity patterns
Response
{
"_id": "comp_123abc",
"name": "Platform Chat Analytics Dashboard",
"type": "chat_analytics",
"status": "active",
"config": {
"chatComponentId": "chat-comp-123",
"autoRefresh": true,
"dateRange": 30,
"enableExport": true,
"refreshInterval": 5,
"showSummary": true,
"showTopics": true,
"showUserStats": true
},
"createdAt": "2024-01-15T10:00:00Z",
"updatedAt": "2024-01-15T10:00:00Z",
"organizationId": "org_456def",
"usage": {
"interactions": 0,
"lastUsed": null
}
}
Embedding This Component
Once you’ve created a Chat Analytics component, you can embed it on your website using the embedding API.Generate Embed URL
const embedResponse = await client.v1.components.generateEmbed(analyticsComponent._id, {
// User tracking
userId: 'user-456',
studentName: 'Jane Smith', // Student name for display
groupIds: ['class-101', 'class-102'],
sessionId: 'session-789',
// Dimensions
width: '100%',
height: '800px',
// Token expiry
expiryHours: 24
});
embed_response = client.v1.components.generateEmbed(
component_id=analytics_component._id,
userId="user-456",
student_name="Jane Smith", # Student name for display
groupIds=["class-101", "class-102"],
sessionId="session-789",
width="100%",
height="800px",
expiryHours=24
)
import com.studyfetch.javasdk.client.StudyfetchSdkClient;
import com.studyfetch.javasdk.client.okhttp.StudyfetchSdkOkHttpClient;
import com.studyfetch.javasdk.models.v1.components.ComponentGenerateEmbedParams;
import com.studyfetch.javasdk.models.v1.components.ComponentGenerateEmbedResponse;
StudyfetchSdkClient client = StudyfetchSdkOkHttpClient.builder()
.fromEnv()
.baseURL("https://studyfetchapi.com")
.build();
ComponentGenerateEmbedParams params = ComponentGenerateEmbedParams.builder()
.id(analyticsComponent._id())
// User tracking
.userId("user-456")
.studentName("Jane Smith") // Student name for display
.groupIds(List.of("class-101", "class-102"))
.sessionId("session-789")
// Dimensions
.width("100%")
.height("800px")
// Token expiry
.expiryHours(24)
.build();
ComponentGenerateEmbedResponse embedResponse = client.v1().components()
.generateEmbed(params);
using StudyfetchSDK;
using StudyfetchSDK.Models.V1.Components;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
public class GenerateChatAnalyticsEmbed
{
public static async Task GenerateEmbed()
{
var client = new StudyfetchSDKClient()
{
APIKey = Environment.GetEnvironmentVariable("STUDYFETCH_API_KEY"),
BaseUrl = new Uri("https://studyfetchapi.com")
};
var embedResponse = await client.V1.Components.GenerateEmbed(new()
{
ID = "component_123abc", // Replace with your component ID
UserID = "user-456",
StudentName = "Jane Smith", // Student name for display
GroupIDs = new List<string> { "class-101", "class-102" },
Width = "100%",
Height = "600px"
});
Console.WriteLine($"Embed URL: {embedResponse.EmbedURL}");
Console.WriteLine($"Token: {embedResponse.Token}");
}
}
Embed in Your HTML
<iframe
src="https://embed.studyfetch.com/component/comp_123abc?token=..."
width="100%"
height="800px"
frameborder="0"
allow="clipboard-write"
style="border: 1px solid #e5e5e5; border-radius: 8px;">
</iframe>