@@ -19,10 +19,11 @@ const exampleTargetingContextAccessor = {
1919 getTargetingContext : ( ) => {
2020 const req = requestAccessor . getStore ( ) ;
2121 if ( req === undefined ) {
22- return { userId : undefined , groups : [ ] } ;
22+ return undefined ;
2323 }
24- // read user and groups from request query data
25- const { userId, groups } = req . query ;
24+ // read user and groups from request
25+ const userId = req . query . userId ?? req . body . userId ;
26+ const groups = req . query . groups ?? req . body . groups ;
2627 // return an ITargetingContext with the appropriate user info
2728 return { userId : userId , groups : groups ? groups . split ( "," ) : [ ] } ;
2829 }
@@ -43,7 +44,7 @@ applicationInsights.defaultClient.addTelemetryProcessor(createTargetingTelemetry
4344
4445const { load } = require ( "@azure/app-configuration-provider" ) ;
4546const { FeatureManager, ConfigurationMapFeatureFlagProvider } = require ( "@microsoft/feature-management" ) ;
46- const { createTelemetryPublisher, trackEvent } = require ( "@microsoft/feature-management-applicationinsights-node" ) ;
47+ const { createTelemetryPublisher } = require ( "@microsoft/feature-management-applicationinsights-node" ) ;
4748let appConfig ;
4849let featureManager ;
4950async function initializeConfig ( ) {
@@ -103,11 +104,11 @@ function startServer() {
103104 } ) ;
104105
105106 server . post ( "/api/like" , ( req , res ) => {
106- const { UserId } = req . body ;
107- if ( UserId === undefined ) {
107+ const { userId } = req . body ;
108+ if ( userId === undefined ) {
108109 return res . status ( 400 ) . send ( { error : "UserId is required" } ) ;
109110 }
110- trackEvent ( applicationInsights . defaultClient , UserId , { name : "Like" } ) ;
111+ applicationInsights . defaultClient . trackEvent ( { name : "Like" } ) ;
111112 res . status ( 200 ) . send ( { message : "Like event logged successfully" } ) ;
112113 } ) ;
113114
0 commit comments