--[[
	Calls the given analytics function and passes the given values.
	Every analytics function sends the categoryIndex and subcategoryIndex from the store.
	assetTypeId: optional
]]


local function getUserId(state)
	if state.LocalUserId then
		return state.LocalUserId
	end

	if state.RobloxUser and state.RobloxUser.rbxuid then
		return tostring(state.RobloxUser.rbxuid)
	end

	return nil
end

return function(analyticsFunction, value, assetTypeId)
	return function(store)
		local categoryIndex = store:getState().AvatarExperience.AvatarEditor.Categories.category
		local subcategoryIndex = store:getState().AvatarExperience.AvatarEditor.Categories.subcategory
		local userId = getUserId(store:getState())
		analyticsFunction(value, categoryIndex, subcategoryIndex, assetTypeId, userId)
	end
end
