Skip to content

Analytics


Handling Analytics Events

The InvestSuite SDK sends analytics events through the receiveAnalyticsEvent handover method. Your host app can capture these events and forward them to your analytics service (Firebase, Segment, Mixpanel, etc.).

Full Event Reference

For a complete list of all analytics events, their parameters, and usage examples, see the Analytics Events reference.


Receiving Analytics Events

Implement the receiveAnalyticsEvent method in your HandoversToHostService:

override fun receiveAnalyticsEvent(
    request: HandoversToHostServiceOuterClass.ReceiveAnalyticsEventRequest?,
    responseObserver: StreamObserver<HandoversToHostServiceOuterClass.ReceiveAnalyticsEventResponse?>?
) {
    val eventName = request?.name ?: ""
    val eventLocation = request?.eventLocation ?: ""
    val parameters = request?.parametersMap ?: emptyMap()

    // Forward to your analytics service
    analytics.logEvent(eventName, Bundle().apply {
        putString("event_location", eventLocation)
        parameters.forEach { (key, value) ->
            putString(key, value)
        }
    })

    val response = HandoversToHostServiceOuterClass.ReceiveAnalyticsEventResponse.newBuilder().build()
    responseObserver?.onNext(response)
    responseObserver?.onCompleted()
}
func receiveAnalyticsEvent(
    request: ReceiveAnalyticsEventRequest,
    context: FlutterEmbeddingGRPCCore.ServerContext
) async throws -> ReceiveAnalyticsEventResponse {
    let eventName = request.name
    let eventLocation = request.eventLocation
    let parameters = request.parameters

    // Forward to your analytics service
    Analytics.logEvent(eventName, parameters: [
        "event_location": eventLocation
    ].merging(parameters) { _, new in new })

    return ReceiveAnalyticsEventResponse()
}
receiveAnalyticsEvent(
    request: ReceiveAnalyticsEventRequest,
    _context: ServerCallContext
): Promise<ReceiveAnalyticsEventResponse> {
    const { name, eventLocation, parameters } = request;

    // Forward to your analytics service
    analytics.logEvent(name, {
        event_location: eventLocation,
        ...parameters,
    });

    return Promise.resolve(ReceiveAnalyticsEventResponse.create({}));
}
receiveAnalyticsEvent(
    request: ReceiveAnalyticsEventRequest,
    _context: ServerCallContext
): Promise<ReceiveAnalyticsEventResponse> {
    const { name, eventLocation, parameters } = request;

    // Forward to your analytics service (e.g., Google Analytics)
    gtag('event', name, {
        event_location: eventLocation,
        ...parameters,
    });

    return Promise.resolve(ReceiveAnalyticsEventResponse.create({}));
}

Event Structure

Every analytics event contains the following properties:

Property Type Description
name String The event name (max 40 characters for Firebase compatibility)
eventLocation String The screen/deeplink where the event was triggered
parameters Map Optional event-specific parameters

The eventLocation typically contains the deeplink path of the current screen (e.g., /self/portfolio/P123/composition), making it easy to track user journeys through the SDK.


See Also