Skip to content

Commit

Permalink
[AC-1863] Send initiationPath on organization or user signup (#7747)
Browse files Browse the repository at this point in the history
* Sent initiation path for organization and user signups

* Rename organizationQueryParameter > organizationTypeQueryParameter

* Jared's feedback

* Split PM & SM initiation path
  • Loading branch information
amorask-bitwarden authored Feb 26, 2024
1 parent 4cf911a commit f53af7c
Show file tree
Hide file tree
Showing 20 changed files with 366 additions and 350 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ export class RegisterFormComponent extends BaseRegisterComponent {
async ngOnInit() {
await super.ngOnInit();
this.referenceData = this.referenceDataValue;

if (this.queryParamEmail) {
this.formGroup.get("email")?.setValue(this.queryParamEmail);
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
[subLabel]="subLabels.createAccount"
[addSubLabelSpacing]="true"
>
<app-register-form [isInTrialFlow]="true" (createdAccount)="accountCreated($event)">
<app-register-form
[referenceDataValue]="referenceEventRequest"
[isInTrialFlow]="true"
(createdAccount)="accountCreated($event)"
>
</app-register-form>
</app-vertical-step>
<app-vertical-step
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { Component, ViewChild } from "@angular/core";
import { Component, OnInit, ViewChild } from "@angular/core";
import { UntypedFormBuilder, Validators } from "@angular/forms";
import { Router } from "@angular/router";

import { OrganizationBillingServiceAbstraction as OrganizationBillingService } from "@bitwarden/common/billing/abstractions/organization-billing.service";
import { PlanType } from "@bitwarden/common/billing/enums";
import { ReferenceEventRequest } from "@bitwarden/common/models/request/reference-event.request";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";

import { VerticalStepperComponent } from "../../trial-initiation/vertical-stepper/vertical-stepper.component";
Expand All @@ -12,7 +13,7 @@ import { VerticalStepperComponent } from "../../trial-initiation/vertical-steppe
selector: "app-secrets-manager-trial-free-stepper",
templateUrl: "secrets-manager-trial-free-stepper.component.html",
})
export class SecretsManagerTrialFreeStepperComponent {
export class SecretsManagerTrialFreeStepperComponent implements OnInit {
@ViewChild("stepper", { static: false }) verticalStepper: VerticalStepperComponent;

formGroup = this.formBuilder.group({
Expand All @@ -39,13 +40,20 @@ export class SecretsManagerTrialFreeStepperComponent {

organizationId: string;

referenceEventRequest: ReferenceEventRequest;

constructor(
protected formBuilder: UntypedFormBuilder,
protected i18nService: I18nService,
protected organizationBillingService: OrganizationBillingService,
private router: Router,
) {}

ngOnInit(): void {
this.referenceEventRequest = new ReferenceEventRequest();
this.referenceEventRequest.initiationPath = "Secrets Manager trial from marketing website";
}

accountCreated(email: string): void {
this.formGroup.get("email")?.setValue(email);
this.subLabels.createAccount = email;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
[subLabel]="createAccountLabel"
[addSubLabelSpacing]="true"
>
<app-register-form [isInTrialFlow]="true" (createdAccount)="accountCreated($event)">
<app-register-form
[referenceDataValue]="referenceEventRequest"
[isInTrialFlow]="true"
(createdAccount)="accountCreated($event)"
>
</app-register-form>
</app-vertical-step>
<app-vertical-step
Expand All @@ -24,21 +28,22 @@
</button>
</app-vertical-step>
<app-vertical-step label="{{ 'billing' | i18n | titlecase }}" [subLabel]="billingSubLabel">
<app-secrets-manager-trial-billing-step
<app-trial-billing-step
*ngIf="stepper.selectedIndex === 2"
[organizationInfo]="{
name: formGroup.get('name').value,
email: formGroup.get('email').value
email: formGroup.get('email').value,
type: productType
}"
[subscriptionType]="paidSubscriptionType"
[subscriptionProduct]="SubscriptionProduct.SecretsManager"
(steppedBack)="steppedBack()"
(organizationCreated)="organizationCreated($event)"
></app-secrets-manager-trial-billing-step>
></app-trial-billing-step>
</app-vertical-step>
<app-vertical-step label="{{ 'confirmationDetails' | i18n | titlecase }}">
<app-trial-confirmation-details
[email]="formGroup.get('email').value"
[orgLabel]="subscriptionType"
[orgLabel]="organizationTypeQueryParameter"
></app-trial-confirmation-details>
<div class="tw-mb-3 tw-flex">
<button type="button" bitButton buttonType="primary" (click)="navigateTo('vault')">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
import { Component, Input, ViewChild } from "@angular/core";

import { VerticalStepperComponent } from "../../trial-initiation/vertical-stepper/vertical-stepper.component";
import { SecretsManagerTrialFreeStepperComponent } from "../secrets-manager/secrets-manager-trial-free-stepper.component";
import { ProductType } from "@bitwarden/common/enums";

import {
OrganizationCreatedEvent,
SubscriptionType,
} from "./secrets-manager-trial-billing-step.component";
SubscriptionProduct,
TrialOrganizationType,
} from "../../../billing/accounts/trial-initiation/trial-billing-step.component";
import { VerticalStepperComponent } from "../../trial-initiation/vertical-stepper/vertical-stepper.component";
import { SecretsManagerTrialFreeStepperComponent } from "../secrets-manager/secrets-manager-trial-free-stepper.component";

@Component({
selector: "app-secrets-manager-trial-paid-stepper",
templateUrl: "secrets-manager-trial-paid-stepper.component.html",
})
export class SecretsManagerTrialPaidStepperComponent extends SecretsManagerTrialFreeStepperComponent {
@ViewChild("stepper", { static: false }) verticalStepper: VerticalStepperComponent;
@Input() subscriptionType: string;
@Input() organizationTypeQueryParameter: string;

billingSubLabel = this.i18nService.t("billingTrialSubLabel");
organizationId: string;
Expand All @@ -31,16 +33,24 @@ export class SecretsManagerTrialPaidStepperComponent extends SecretsManagerTrial

get createAccountLabel() {
const organizationType =
this.paidSubscriptionType == SubscriptionType.Enterprise ? "Enterprise" : "Teams";
this.productType === ProductType.TeamsStarter
? "Teams Starter"
: ProductType[this.productType];
return `Before creating your ${organizationType} organization, you first need to log in or create a personal account.`;
}

get paidSubscriptionType() {
switch (this.subscriptionType) {
get productType(): TrialOrganizationType {
switch (this.organizationTypeQueryParameter) {
case "enterprise":
return SubscriptionType.Enterprise;
return ProductType.Enterprise;
case "families":
return ProductType.Families;
case "teams":
return SubscriptionType.Teams;
return ProductType.Teams;
case "teamsStarter":
return ProductType.TeamsStarter;
}
}

protected readonly SubscriptionProduct = SubscriptionProduct;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
class="tw-flex tw-h-auto tw-w-full tw-gap-5 tw-rounded-t tw-bg-secondary-100"
>
<h2 class="tw-pb-4 tw-pl-4 tw-pt-5 tw-text-base tw-font-bold tw-uppercase">
{{ "startYour7DayFreeTrialOfBitwardenSecretsManagerFor" | i18n: subscriptionType }}
{{
"startYour7DayFreeTrialOfBitwardenSecretsManagerFor"
| i18n: organizationTypeQueryParameter
}}
</h2>
<environment-selector
class="tw-mr-4 tw-mt-6 tw-flex-shrink-0 tw-text-end"
Expand All @@ -32,7 +35,7 @@ <h2 class="tw-pb-4 tw-pl-4 tw-pt-5 tw-text-base tw-font-bold tw-uppercase">
></app-secrets-manager-trial-free-stepper>
<app-secrets-manager-trial-paid-stepper
*ngIf="!freeOrganization"
[subscriptionType]="subscriptionType"
[organizationTypeQueryParameter]="organizationTypeQueryParameter"
></app-secrets-manager-trial-paid-stepper>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ import { Subject, takeUntil } from "rxjs";
templateUrl: "secrets-manager-trial.component.html",
})
export class SecretsManagerTrialComponent implements OnInit, OnDestroy {
subscriptionType: string;
organizationTypeQueryParameter: string;

private destroy$ = new Subject<void>();

constructor(private route: ActivatedRoute) {}

ngOnInit(): void {
this.route.queryParams.pipe(takeUntil(this.destroy$)).subscribe((queryParameters) => {
this.subscriptionType = queryParameters.org;
this.organizationTypeQueryParameter = queryParameters.org;
});
}

Expand All @@ -25,6 +25,6 @@ export class SecretsManagerTrialComponent implements OnInit, OnDestroy {
}

get freeOrganization() {
return this.subscriptionType === "free";
return this.organizationTypeQueryParameter === "free";
}
}
Loading

0 comments on commit f53af7c

Please sign in to comment.