Skip to content

Commit

Permalink
chore: add analytics events (appsmithorg#32385)
Browse files Browse the repository at this point in the history
## Description
Add analytics event

Fixes appsmithorg#32018
## Automation

/ok-to-test tags="tag.Templates"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]  
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/8540471637>
> Commit: `0a121e609363c33955d6abd36260ac13bcf7ae10`
> Cypress dashboard url: <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8540471637&attempt=1"
target="_blank">Click here!</a>
> All cypress tests have passed 🎉🎉🎉

<!-- end of auto-generated comment: Cypress test results  -->



<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Introduced a new analytics event `TEMPLATE_FORK` to better track
template forking activities.
- **Refactor**
- Updated the event tracking in template forking processes to use the
new `TEMPLATE_FORK` event for enhanced clarity and specificity.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
AnaghHegde authored Apr 4, 2024
1 parent 2f57d80 commit 8471ea6
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public enum AnalyticsEvents {
UPDATE_LAYOUT,
PUBLISH_APPLICATION("publish_APPLICATION"),
FORK,
TEMPLATE_FORK,
PAGE_REORDER,
GENERATE_CRUD_PAGE("generate_CRUD_PAGE"),
CREATE_SUPERUSER,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,12 @@ public Mono<ApplicationImportDTO> importApplicationFromTemplate(String templateI
final Map<String, Object> data = Map.of(
FieldName.APPLICATION_ID, application.getId(),
FieldName.WORKSPACE_ID, application.getWorkspaceId(),
FieldName.TEMPLATE_APPLICATION_NAME, application.getName(),
FieldName.TEMPLATE_APPLICATION_NAME, application.getForkedFromTemplateTitle(),
FieldName.SOURCE, "Templates page",
FieldName.EVENT_DATA, eventData);

return analyticsService
.sendObjectEvent(AnalyticsEvents.FORK, applicationTemplate, data)
.sendObjectEvent(AnalyticsEvents.TEMPLATE_FORK, applicationTemplate, data)
.thenReturn(applicationImportDTO);
});
}
Expand Down Expand Up @@ -291,34 +291,57 @@ public Mono<ApplicationImportDTO> mergeTemplateWithApplication(
branchName,
applicationJson,
pagesToImport))
.map(importableArtifact -> (Application) importableArtifact);
.map(importableArtifact -> (Application) importableArtifact)
.zipWith(Mono.just(
applicationJson.getExportedApplication().getName()));
}
return importService
.mergeArtifactExchangeJsonWithImportableArtifact(
organizationId, applicationId, branchName, applicationJson, pagesToImport)
.map(importableArtifact -> (Application) importableArtifact);
organizationId, applicationId, null, applicationJson, pagesToImport)
.map(importableArtifact -> (Application) importableArtifact)
.zipWith(Mono.just(
applicationJson.getExportedApplication().getName()));
})
.flatMap(application -> importService.getArtifactImportDTO(
application.getWorkspaceId(), application.getId(), application, ArtifactType.APPLICATION))
.flatMap(importableArtifactDTO -> {
ApplicationImportDTO applicationImportDTO = (ApplicationImportDTO) importableArtifactDTO;
responseUtils.updateApplicationWithDefaultResources(applicationImportDTO.getApplication());
Application application = applicationImportDTO.getApplication();
ApplicationTemplate applicationTemplate = new ApplicationTemplate();
applicationTemplate.setId(templateId);
final Map<String, Object> eventData = Map.of(
FieldName.APP_MODE, ApplicationMode.EDIT.toString(), FieldName.APPLICATION, application);

final Map<String, Object> data = Map.of(
FieldName.APPLICATION_ID, application.getId(),
FieldName.WORKSPACE_ID, application.getWorkspaceId(),
FieldName.TEMPLATE_APPLICATION_NAME, application.getName(),
FieldName.SOURCE, "Templates page",
FieldName.EVENT_DATA, eventData);

return analyticsService
.sendObjectEvent(AnalyticsEvents.FORK, applicationTemplate, data)
.thenReturn(applicationImportDTO);
.flatMap(tuple -> {
Application application = tuple.getT1();
String templateTitle = tuple.getT2();
application.setForkedFromTemplateTitle(templateTitle);
return importService
.getArtifactImportDTO(
application.getWorkspaceId(),
application.getId(),
application,
ArtifactType.APPLICATION)
.flatMap(importableArtifactDTO -> {
ApplicationImportDTO applicationImportDTO =
(ApplicationImportDTO) importableArtifactDTO;
responseUtils.updateApplicationWithDefaultResources(
applicationImportDTO.getApplication());
Application application1 = applicationImportDTO.getApplication();
ApplicationTemplate applicationTemplate = new ApplicationTemplate();
applicationTemplate.setId(templateId);
final Map<String, Object> eventData = Map.of(
FieldName.APP_MODE,
ApplicationMode.EDIT.toString(),
FieldName.APPLICATION,
application);

final Map<String, Object> data = Map.of(
FieldName.APPLICATION_ID,
application1.getId(),
FieldName.WORKSPACE_ID,
application1.getWorkspaceId(),
FieldName.TEMPLATE_APPLICATION_NAME,
templateTitle,
FieldName.SOURCE,
"Add New page",
FieldName.EVENT_DATA,
eventData);

return analyticsService
.sendObjectEvent(AnalyticsEvents.TEMPLATE_FORK, applicationTemplate, data)
.thenReturn(applicationImportDTO);
});
});

return Mono.create(
Expand Down

0 comments on commit 8471ea6

Please sign in to comment.