Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(1-3247): remove explicit "in project" text from change request event text #9091

Merged
merged 4 commits into from
Jan 14, 2025

Conversation

thomasheartman
Copy link
Contributor

@thomasheartman thomasheartman commented Jan 13, 2025

We got an event for a scheduled application success today that looked a little something like this:

Successfully applied the scheduled change request #1168 in the production environment in project eg by gaston in project eg.

Notice that we're stating the project twice (once with a link (removed here) and once without).

This PR removes the redundancy in CR events:

The project is already included in the changeRequest variable, which
is populated in src/lib/addons/feature-event-formatter-md.ts by
the generateChangeRequestLink function.

The (current) definition is:

    generateChangeRequestLink(event: IEvent): string | undefined {
        const { preData, data, project, environment } = event;
        const changeRequestId =
            data?.changeRequestId || preData?.changeRequestId;
        if (project && changeRequestId) {
            const url = `${this.unleashUrl}/projects/${project}/change-requests/${changeRequestId}`;
            const text = `#${changeRequestId}`;
            const featureLink = this.generateFeatureLink(event);
            const featureText = featureLink
                ? ` for feature flag ${this.bold(featureLink)}`
                : '';
            const environmentText = environment
                ? ` in the ${this.bold(environment)} environment`
                : '';
            const projectLink = this.generateProjectLink(event);
            const projectText = project
                ? ` in project ${this.bold(projectLink)}`
                : '';
            if (this.linkStyle === LinkStyle.SLACK) {
                return `${this.bold(`<${url}|${text}>`)}${featureText}${environmentText}${projectText}`;
            } else {
                return `${this.bold(`[${text}](${url})`)}${featureText}${environmentText}${projectText}`;
            }
        }
    }

Which includes links, env, and project info already.

…ent text

The project is already included in the `changeRequest` variable, which
is  is populated in `src/lib/addons/feature-event-formatter-md.ts` by
the `generateChangeRequestLink` function.

The (current) definition is:

```typescript
    generateChangeRequestLink(event: IEvent): string | undefined {
        const { preData, data, project, environment } = event;
        const changeRequestId =
            data?.changeRequestId || preData?.changeRequestId;
        if (project && changeRequestId) {
            const url = `${this.unleashUrl}/projects/${project}/change-requests/${changeRequestId}`;
            const text = `#${changeRequestId}`;
            const featureLink = this.generateFeatureLink(event);
            const featureText = featureLink
                ? ` for feature flag ${this.bold(featureLink)}`
                : '';
            const environmentText = environment
                ? ` in the ${this.bold(environment)} environment`
                : '';
            const projectLink = this.generateProjectLink(event);
            const projectText = project
                ? ` in project ${this.bold(projectLink)}`
                : '';
            if (this.linkStyle === LinkStyle.SLACK) {
                return `${this.bold(`<${url}|${text}>`)}${featureText}${environmentText}${projectText}`;
            } else {
                return `${this.bold(`[${text}](${url})`)}${featureText}${environmentText}${projectText}`;
            }
        }
    }
```

Which includes links, env, and project info already.
Copy link

vercel bot commented Jan 13, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 13, 2025 2:03pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Jan 13, 2025 2:03pm

Copy link
Contributor

github-actions bot commented Jan 13, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Copy link
Contributor

@gastonfournier gastonfournier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG!

@thomasheartman thomasheartman merged commit 6a7dcb9 into main Jan 14, 2025
11 checks passed
@thomasheartman thomasheartman deleted the fix(1-3247)/change-request-event-formatting branch January 14, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants