Skip to content
This repository was archived by the owner on Nov 15, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion api_server/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
# Change Log

## [15.4.0] - 2024-4-4
## [15.4.0] - 2024-4-17

### Changed

- Updates to telemetry events
- A/B test open-in-IDE redirect pages

## [15.3.0] - 2024-3-14

Expand Down
4 changes: 2 additions & 2 deletions api_server/bin/api_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const DataCollections = {
msteams_conversations: require(ModuleDirectory + '/msteams_conversations/msteams_conversation'),
msteams_states: require(ModuleDirectory + '/msteams_states/msteams_state'),
msteams_teams: require(ModuleDirectory + '/msteams_teams/msteams_team'),
reposByCommitHash: require(ModuleDirectory + '/repos/repo_by_commit_hash')
reposByCommitHash: require(ModuleDirectory + '/repos/repo_by_commit_hash'),
entities: require(ModuleDirectory + '/entities/entity')
};

// establish our mongo collections, these include our DataCollections, but
Expand Down Expand Up @@ -67,7 +68,6 @@ const MongoCollections = Object.keys(DataCollections).concat([

// changes to Config will be available globally via the /config/writeable.js module
const Config = await ApiConfig.loadPreferredConfig({ wait: true });
Config.telemetry.segment.telemetryEndpoint = 'https://taxonomy-enforcer.service.newrelic.com'; // for now

// establish our logger
const Logger = new SimpleFileLogger(Config.apiServer.logger);
Expand Down
3 changes: 2 additions & 1 deletion api_server/bin/ensure-indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const AllModuleIndexes = {
msteams_teams: require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/msteams_teams/indexes'),
reposByCommitHash: require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/repos/repo_by_commit_hash_indexes'),
gitLensUsers: require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/users/gitlens_user_indexes'),
newRelicOrgs: require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/newrelic_comments/new_relic_org_indexes')
newRelicOrgs: require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/newrelic_comments/new_relic_org_indexes'),
entities: require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/entities/indexes')
};

const AllFinished = {
Expand Down
1 change: 1 addition & 0 deletions api_server/config/dev-secrets.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"STORAGE_MONGO_URL",
"TELEMETRY_SEGMENT_TOKEN",
"TELEMETRY_SEGMENT_WEB_TOKEN",
"TELEMETRY_ENDPOINT",
"UNIVERSAL_SECRETS_TELEMETRY",
"UNIVERSAL_SECRETS_TELEMETRY",
"SHARED_SECRETS_COMMENT_ENGINE",
Expand Down
6 changes: 5 additions & 1 deletion api_server/lib/test_base/codestream_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const RandomCodemarkFactory = require(process.env.CSSVC_BACKEND_ROOT + '/api_ser
const RandomReviewFactory = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/reviews/test/random_review_factory');
const RandomCodeErrorFactory = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/code_errors/test/random_code_error_factory');
const RandomNRCommentFactory = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/newrelic_comments/test/random_nr_comment_factory');
const RandomEntityFactory = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/entities/test/random_entity_factory');
const Assert = require('assert');
const BoundAsync = require(process.env.CSSVC_BACKEND_ROOT + '/shared/server_utils/bound_async');
const TestTeamCreator = require('./test_team_creator');
Expand Down Expand Up @@ -75,7 +76,10 @@ class CodeStreamAPITest extends APIRequestTest {
userFactory: this.userFactory,
codeErrorFactory: this.codeErrorFactory
});

this.entityFactory = new RandomEntityFactory({
apiRequester: this
});

this.userOptions = {
numRegistered: 2,
numUnregistered: 0,
Expand Down
5 changes: 3 additions & 2 deletions api_server/lib/util/deactivator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ const ObjectId = require('mongodb').ObjectId;
const UserIndexes = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/users/indexes');
const RepoIndexes = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/repos/indexes');
const StreamIndexes = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/streams/indexes');
const EntityIndexes = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/entities/indexes');

const COLLECTIONS = ['companies', 'teams', 'repos', 'users', 'streams', 'posts', 'codemarks', 'reviews', 'codeErrors', 'markers', 'markerLocations'];
const COLLECTIONS_FOR_TEAM = ['streams', 'posts', 'codemarks', 'reviews', 'codeErrors', 'markers', 'markerLocations'];
const COLLECTIONS = ['companies', 'teams', 'repos', 'users', 'streams', 'posts', 'codemarks', 'reviews', 'codeErrors', 'markers', 'markerLocations', 'entities'];
const COLLECTIONS_FOR_TEAM = ['streams', 'posts', 'codemarks', 'reviews', 'codeErrors', 'markers', 'markerLocations', 'entities'];

class Deleter {

Expand Down
17 changes: 16 additions & 1 deletion api_server/lib/util/deleter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ const ApiConfig = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/config/c
const ObjectId = require('mongodb').ObjectId;
const UserIndexes = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/users/indexes');
const RepoIndexes = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/repos/indexes');
const EntityIndexes = require(process.env.CSSVC_BACKEND_ROOT + '/api_server/modules/entities/indexes');

const COLLECTIONS = ['companies', 'teams', 'repos', 'users', 'streams', 'posts', 'codemarks', 'markers', 'markerLocations'];
const COLLECTIONS = ['companies', 'teams', 'repos', 'users', 'streams', 'posts', 'codemarks', 'markers', 'markerLocations', 'entities'];


class Deleter {
Expand All @@ -25,6 +26,7 @@ class Deleter {
await this.deleteCodemarks();
await this.deleteMarkers();
await this.deleteMarkerLocations();
await this.deleteEntities();
}

async openMongoClient () {
Expand Down Expand Up @@ -365,6 +367,19 @@ class Deleter {
throw `unable to delete marker locations: ${JSON.stringify(error)}`;
}
}

async deleteEntities () {
this.logger.log(`Deleting entities in team ${this.teamId}...`);
try {
await this.mongoClient.mongoCollections.entities.deleteByQuery(
{ teamId: this.teamId },
{ overrideHintRequired: true }
);
}
catch (error) {
throw `unable to delete entities: ${JSON.stringify(error)}`;
}
}
}

module.exports = Deleter;
4 changes: 3 additions & 1 deletion api_server/lib/util/restful/post_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class PostRequest extends RestfulRequest {

// after the request has been processed and response returned to the client....
async postProcess () {
await this.creator.postCreate();
if (this.creator) {
await this.creator.postCreate();
}
}

// describe this route for help
Expand Down
12 changes: 8 additions & 4 deletions api_server/modules/analytics/analytics_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,15 @@ class AnalyticsClient {
properties: data,
messageId: UUID(),
timestamp: new Date(),
type: "track"
type: "track",
anonymousId: UUID(),
};
data.session_id = data.session_id || UUID();

const nrUserId = options.user ? options.user.get('nrUserId') : options.nrUserId;
if (nrUserId) {
trackData.userId = nrUserId; //userId;
}
if (options.anonymousId) {
trackData.anonymousId = options.anonymousId;
}

if (this._requestSaysToTestTracking(options)) {
// we received a header in the request asking us to divert this tracking event
Expand All @@ -59,6 +59,10 @@ class AnalyticsClient {
}

//this.segment.track(trackData);
if (options.request) {
options.request.log('TRACKING TO ' + this.config.telemetryEndpoint + '/events');
options.request.log('trackData: ' + JSON.stringify(trackData));
}
Fetch(
this.config.telemetryEndpoint + '/events',
{
Expand Down
2 changes: 2 additions & 0 deletions api_server/modules/apiweb/apiweb.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class Web extends APIServerModule {
return JSON.stringify(obj);
});

Handlebars.registerHelper('eq', (a, b) => a == b);

// Not in use, but might be useful in the future
/**
* Format string with data
Expand Down
7 changes: 7 additions & 0 deletions api_server/modules/apiweb/newrelic_ide_redirect_request.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
const IdeRedirectRequest = require('./ide_redirect_request');
const { defaultCookieName, ides} = require('./config');


class NewRelicIdeRedirectRequest extends IdeRedirectRequest {
constructor(options) {
super(options);
this.abTest = Math.random() < 0.5 ? "feature_tabs" : "feature_bullets";
}

async prepareTemplateProps () {
this.redirectType = this.request.params.type.toLowerCase();
Expand Down Expand Up @@ -48,6 +53,7 @@ class NewRelicIdeRedirectRequest extends IdeRedirectRequest {
}
const launcherModel = this.createLauncherModel('');
this.templateProps = {
abTest: this.abTest,
pageType,
pageWhat,
analyticsContentType,
Expand Down Expand Up @@ -107,6 +113,7 @@ class NewRelicIdeRedirectRequest extends IdeRedirectRequest {
}
}).bind(this))();
const result = {
abTest: this.abTest,
environment,
ides: ides,
src: decodeURIComponent(this.parsedPayload.src || ''),
Expand Down
58 changes: 54 additions & 4 deletions api_server/modules/apiweb/styles/web.css
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,42 @@ h6 {
color: white!important;
text-decoration: underline;
}
.content-body-container {
max-width: 80%;
margin: 0 auto;
text-align: left;
}
.content-body-section-header {
margin-top: 28px;
}
.content-body-header {
font-size: xx-large;
}
.content-body-tab-container {
margin-top: 32px;
margin-bottom: 10px;
border-bottom: 1px solid #3c3c3c;
display: flex;
justify-content: space-between;
}
.content-body-tab-header {
font-size: larger;
cursor: pointer;
display: inline-block;
text-align: center;
padding-bottom: 5px;
margin-bottom: -1px;
}
.content-body-copy {
margin-bottom: 12px;
}
.content-body-tab {
display: none;
}
.content-active-tab {
/* display: block !important; */
border-bottom: 1px solid;
}
.box-border {
margin-top: 1rem;
padding: 1.5rem;
Expand Down Expand Up @@ -550,7 +586,7 @@ hr {

.interstitial-detail-wrapper {
padding: 30px;
margin: 0 0 40px 0;
margin: 10px 0 10px 0;
max-width: 704px;
margin-right: auto;
margin-left: auto;
Expand Down Expand Up @@ -637,8 +673,21 @@ hr {

.observability-gif {
width: 100%;
border-radius: 8px;
margin-top: 10px;
}

@media (max-width: 768px) {
.content-body-tab-icon {
display: none !important;
}
.content-body-tab-header {
display: flex;
align-items: center;
justify-content: center;
}
}

@media (min-width: 1px) {
.btn-block-wrap {
width: 100%;
Expand Down Expand Up @@ -767,11 +816,11 @@ span.dropdown-item:hover {
}
.navbar-light.bg-light {
background: #fff !important;
margin: 0 0 80px 0;
margin: 0 0 0 0;
}
.navbar-dark.bg-dark {
/* background: #1D252C !important; */
margin: 0 0 80px 0;
margin: 0 0 0 0;
border-bottom: 1px solid #2a3036;
padding: 15px 0 15px 0;
}
Expand All @@ -796,10 +845,11 @@ span.dropdown-item:hover {
}
.form-control {
border: 1px solid #383838 !important;
padding: 6px 0 0 0 !important;
}
.btn-light.form-control {
border: 1px solid rgb(227, 228, 228) !important;
height: 50px;
/* height: 50px; */
}
.lines-added {
color: #66aa66;
Expand Down
8 changes: 4 additions & 4 deletions api_server/modules/apiweb/templates/ide_redirect.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@
{{> partial_html_head }}
<script>
!function () {
CODESTREAM.track("codestream/ide_redirect displayed", {
window.CODESTREAM.track("codestream/ide_redirect displayed", {
"event_type": "modal_display",
"platform": "codestream",
"path": "N/A (codestream)",
"section": "N/A (codestream)",
"userId": "{{nrUserId}}",
"meta_data": "content: {{analyticsContentType}}",
"meta_data_2": "source: {{src}}",
"meta_data_3": "new_to_codestream: {{newToCodeStream}}",
"meta_data_4": "item_guid: {{itemGuid}}"
});
"meta_data_4": "item_guid: {{itemGuid}}",
"meta_data_5": "ab_test_version: {{abTest}}",
}, "{{nrUserId}}");
}();
</script>
<script>
Expand Down
3 changes: 2 additions & 1 deletion api_server/modules/apiweb/templates/partial_html_head.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
crossorigin="anonymous"></script>
<script>
window.CODESTREAM = window.CODESTREAM || {};
window.CODESTREAM.track = function(e, p) {
window.CODESTREAM.track = function(e, p, uid) {
var xhr = new XMLHttpRequest();
xhr.open('POST', '/web/track', true);
xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');
xhr.send(JSON.stringify({
event: e,
properties: p,
nrUserId: uid,
_csrf: "{{csrf}}"
}));
};
Expand Down
8 changes: 4 additions & 4 deletions api_server/modules/apiweb/templates/partial_launcher.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -422,28 +422,28 @@ window.CODESTREAM.openEditor = function(ide) {
function () {
//fail
const source = "{{src}}" || "shared_link";
CODESTREAM.track("codestream/ide_redirect failed", {
window.CODESTREAM.track("codestream/ide_redirect failed", {
"event_type": "response",
"platform": "codestream",
"path": "N/A (codestream)",
"section": "N/A (codestream)",
"meta_data": `ide_detail: ${moniker}`,
"meta_data_2": `selection_method: ${ideSelection}`,
"meta_data_3": `source: ${source}`
});
}, options.nrUserId);
console.log(`CodeStream: failed in ${(new Date() - startTime)/1000}s for Moniker=${moniker} Path=${protocol} IDESelection=${ideSelection}`);
}, function () {
//success
const source = "{{src}}" || "shared_link";
CODESTREAM.track("codestream/ide selected", {
window.CODESTREAM.track("codestream/ide selected", {
"event_type": "response",
"platform": "codestream",
"path": "N/A (codestream)",
"section": "N/A (codestream)",
"meta_data": `ide_detail: ${moniker}`,
"meta_data_2": `selection_method: ${ideSelection}`,
"meta_data_3": `source: ${source}`
});
}, options.nrUserId);
console.log(`CodeStream: success in ${(new Date() - startTime)/1000}s for Moniker=${moniker} Path=${protocol} IDESelection=${ideSelection}`);
});
}
Expand Down
Loading