diff --git a/app/config/events.php b/app/config/events.php index aeaf48081f..576962fbe0 100644 --- a/app/config/events.php +++ b/app/config/events.php @@ -440,15 +440,25 @@ return [ 'delete' => [ '$description' => 'This event triggers when an insight is deleted.', ], - 'dismiss' => [ - '$description' => 'This event triggers when an insight is dismissed.', + 'dismissals' => [ + '$model' => Response::MODEL_INSIGHT, + '$resource' => true, + '$description' => 'This event triggers on any insight dismissal event.', + 'create' => [ + '$description' => 'This event triggers when an insight is dismissed.', + ], ], 'ctas' => [ '$model' => Response::MODEL_INSIGHT_CTA, '$resource' => true, '$description' => 'This event triggers on any insight CTA event.', - 'trigger' => [ - '$description' => 'This event triggers when an insight CTA is executed.', + 'executions' => [ + '$model' => Response::MODEL_INSIGHT_CTA_EXECUTION, + '$resource' => true, + '$description' => 'This event triggers on any insight CTA execution event.', + 'create' => [ + '$description' => 'This event triggers when an insight CTA is executed.', + ], ], ], ], diff --git a/app/init/models.php b/app/init/models.php index e75cb89142..e1d7c81ed6 100644 --- a/app/init/models.php +++ b/app/init/models.php @@ -92,7 +92,7 @@ use Appwrite\Utopia\Response\Model\Identity; use Appwrite\Utopia\Response\Model\Index; use Appwrite\Utopia\Response\Model\Insight; use Appwrite\Utopia\Response\Model\InsightCta; -use Appwrite\Utopia\Response\Model\InsightCtaResult; +use Appwrite\Utopia\Response\Model\InsightCtaExecution; use Appwrite\Utopia\Response\Model\Installation; use Appwrite\Utopia\Response\Model\JWT; use Appwrite\Utopia\Response\Model\Key; @@ -511,7 +511,7 @@ Response::setModel(new MigrationReport()); Response::setModel(new MigrationFirebaseProject()); Response::setModel(new Insight()); Response::setModel(new InsightCta()); -Response::setModel(new InsightCtaResult()); +Response::setModel(new InsightCtaExecution()); // Tests (keep last) Response::setModel(new Mock()); diff --git a/src/Appwrite/Platform/Modules/Insights/Http/Cta/Trigger.php b/src/Appwrite/Platform/Modules/Insights/Http/CTA/Execution/Create.php similarity index 89% rename from src/Appwrite/Platform/Modules/Insights/Http/Cta/Trigger.php rename to src/Appwrite/Platform/Modules/Insights/Http/CTA/Execution/Create.php index 68d4dd73ec..523c742f2d 100644 --- a/src/Appwrite/Platform/Modules/Insights/Http/Cta/Trigger.php +++ b/src/Appwrite/Platform/Modules/Insights/Http/CTA/Execution/Create.php @@ -1,6 +1,6 @@ setHttpMethod(Action::HTTP_REQUEST_METHOD_POST) - ->setHttpPath('/v1/insights/:insightId/ctas/:ctaId/trigger') - ->desc('Trigger insight CTA') + ->setHttpPath('/v1/insights/:insightId/ctas/:ctaId/executions') + ->desc('Create insight CTA execution') ->groups(['api', 'insights']) ->label('scope', 'insights.write') - ->label('event', 'insights.[insightId].ctas.[ctaId].trigger') + ->label('event', 'insights.[insightId].ctas.[ctaId].executions.create') ->label('resourceType', RESOURCE_TYPE_INSIGHTS) - ->label('audits.event', 'insight.cta.trigger') + ->label('audits.event', 'insight.cta.execution.create') ->label('audits.resource', 'insight/{request.insightId}') ->label('abuse-key', 'projectId:{projectId},userId:{userId}') ->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT) @@ -46,15 +46,15 @@ class Trigger extends Action ->label('sdk', new Method( namespace: 'insights', group: 'insights', - name: 'triggerCta', + name: 'createCtaExecution', description: << $actionName, 'status' => $status, 'result' => $resultPayload, - ]), Response::MODEL_INSIGHT_CTA_RESULT); + ]), Response::MODEL_INSIGHT_CTA_EXECUTION); } } diff --git a/src/Appwrite/Platform/Modules/Insights/Http/Insights/Dismiss.php b/src/Appwrite/Platform/Modules/Insights/Http/Insights/Dismissal/Create.php similarity index 86% rename from src/Appwrite/Platform/Modules/Insights/Http/Insights/Dismiss.php rename to src/Appwrite/Platform/Modules/Insights/Http/Insights/Dismissal/Create.php index ab2ef38682..6430e35746 100644 --- a/src/Appwrite/Platform/Modules/Insights/Http/Insights/Dismiss.php +++ b/src/Appwrite/Platform/Modules/Insights/Http/Insights/Dismissal/Create.php @@ -1,6 +1,6 @@ setHttpMethod(Action::HTTP_REQUEST_METHOD_POST) - ->setHttpPath('/v1/insights/:insightId/dismiss') - ->desc('Dismiss insight') + ->setHttpPath('/v1/insights/:insightId/dismissals') + ->desc('Create insight dismissal') ->groups(['api', 'insights']) ->label('scope', 'insights.write') - ->label('event', 'insights.[insightId].dismiss') + ->label('event', 'insights.[insightId].dismissals.create') ->label('resourceType', RESOURCE_TYPE_INSIGHTS) - ->label('audits.event', 'insight.dismiss') + ->label('audits.event', 'insight.dismissal.create') ->label('audits.resource', 'insight/{response.$id}') ->label('abuse-key', 'projectId:{projectId},userId:{userId}') ->label('abuse-limit', APP_LIMIT_WRITE_RATE_DEFAULT) @@ -42,7 +42,7 @@ class Dismiss extends Action ->label('sdk', new Method( namespace: 'insights', group: 'insights', - name: 'dismiss', + name: 'createDismissal', description: <<addAction(GetInsight::getName(), new GetInsight()); $this->addAction(ListInsights::getName(), new ListInsights()); $this->addAction(UpdateInsight::getName(), new UpdateInsight()); - $this->addAction(DismissInsight::getName(), new DismissInsight()); $this->addAction(DeleteInsight::getName(), new DeleteInsight()); - - $this->addAction(TriggerCta::getName(), new TriggerCta()); + $this->addAction(CreateInsightDismissal::getName(), new CreateInsightDismissal()); + $this->addAction(CreateInsightCtaExecution::getName(), new CreateInsightCtaExecution()); } } diff --git a/src/Appwrite/Utopia/Response.php b/src/Appwrite/Utopia/Response.php index dc2c54d4a5..e2c04c0178 100644 --- a/src/Appwrite/Utopia/Response.php +++ b/src/Appwrite/Utopia/Response.php @@ -334,7 +334,7 @@ class Response extends SwooleResponse public const MODEL_INSIGHT = 'insight'; public const MODEL_INSIGHT_LIST = 'insightList'; public const MODEL_INSIGHT_CTA = 'insightCta'; - public const MODEL_INSIGHT_CTA_RESULT = 'insightCtaResult'; + public const MODEL_INSIGHT_CTA_EXECUTION = 'insightCtaExecution'; // Console public const MODEL_CONSOLE_VARIABLES = 'consoleVariables'; diff --git a/src/Appwrite/Utopia/Response/Model/InsightCtaResult.php b/src/Appwrite/Utopia/Response/Model/InsightCtaExecution.php similarity index 87% rename from src/Appwrite/Utopia/Response/Model/InsightCtaResult.php rename to src/Appwrite/Utopia/Response/Model/InsightCtaExecution.php index a6fe9addca..522105e3ef 100644 --- a/src/Appwrite/Utopia/Response/Model/InsightCtaResult.php +++ b/src/Appwrite/Utopia/Response/Model/InsightCtaExecution.php @@ -5,20 +5,20 @@ namespace Appwrite\Utopia\Response\Model; use Appwrite\Utopia\Response; use Appwrite\Utopia\Response\Model; -class InsightCtaResult extends Model +class InsightCtaExecution extends Model { public function __construct() { $this ->addRule('insightId', [ 'type' => self::TYPE_STRING, - 'description' => 'ID of the insight the CTA was triggered against.', + 'description' => 'ID of the insight the CTA was executed against.', 'default' => '', 'example' => '5e5ea5c16897e', ]) ->addRule('ctaId', [ 'type' => self::TYPE_STRING, - 'description' => 'ID of the CTA that was triggered.', + 'description' => 'ID of the CTA that was executed.', 'default' => '', 'example' => 'createIndex', ]) @@ -44,11 +44,11 @@ class InsightCtaResult extends Model public function getName(): string { - return 'InsightCtaResult'; + return 'InsightCtaExecution'; } public function getType(): string { - return Response::MODEL_INSIGHT_CTA_RESULT; + return Response::MODEL_INSIGHT_CTA_EXECUTION; } }