Skip to content

Commit

Permalink
Merge branch 'develop' into Panandhan22-patch-11
Browse files Browse the repository at this point in the history
  • Loading branch information
pwseg authored Nov 26, 2024
2 parents 95042ab + 86379e0 commit 891d8d1
Show file tree
Hide file tree
Showing 529 changed files with 39,521 additions and 18,529 deletions.
4 changes: 2 additions & 2 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ CODEOWNERS @segmentio/segment-doc-team
/src/unify @pwseg

# Protocols owners
/src/protocols @forstisabella
/src/protocols @forstisabella @pwseg

# Storage owners
/src/connections/storage @forstisabella
/src/connections/storage @forstisabella @pwseg
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Sources pages check if the source is a cloud-app, then include information about

## Edit pages

Content with in each `.md` file is markdown. For information about styling, and available extensions, see `_src/utils/formatguide.md` or the live version [here](https://segment.com/docs/utils/formatguide).
Content with in each `.md` file is markdown. For information about styling, and available extensions, see `_src/utils/formatguide.md` or the live version in the [utils section of the docs](/docs/utils/formatguide).

## Building a preview

Expand Down Expand Up @@ -109,6 +109,7 @@ Front matter variables have unique functions, including the following:
- `hide-boilerplate`: defaults to false. When true, none of the content from `destination-footer.md` is appended to the destination page.
- `hide-cmodes`: defaults to false. A renaming of "rewrite" for more clarity, hides the connection modes table in the boilerplate.
- `hide-personas-partial`: defaults to false. When true, hides the section of content from `destination-footer.md` that talks about being able to receive personas data.
- `hide_actions`: used to hide individual actions. Requires the `id` and `name` of each action.
- `integration_type`: This is set in the `_config.yml` on three paths to add a noun (Source, Destination, or Warehouse) to the end of the title, and the end of the title tag in the html layout. It also controls the layout and icon for some of these.
- `source-type`: These are only used to supplement when a Cloud App in the sources path doesn't appear in the Config API list, and needs its type explicitly set. It runs some logic in the `cloud-app-note.md` to explain which cloud-apps are object vs event sources.
- `private`: Used to indicate that a destination is not publicly available (Private Beta or Pilot status), and is not available in the public catalog. When `private: true`, the build pulls integration metadata from `src/_data/catalog/destinations_private.yml`. To update the list of private destinations, use the `make private_destination` command, and enter the integration's ID when prompted.
Expand Down
15 changes: 12 additions & 3 deletions scripts/catalog/updateDestinations.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ require('dotenv').config();

const PAPI_URL = "https://api.segmentapis.com";

// Function to remove hidden fields from action
const removeHiddenFields=function (actions) {
return actions.map(action => ({
...action,
fields: action.fields.filter(field => !field.hidden)
})
);
}


const updateDestinations = async () => {
let destinations = [];
Expand Down Expand Up @@ -88,9 +97,9 @@ const updateDestinations = async () => {
settings.forEach(setting => {
setting.description = sanitize(setting.description);
});
let actions = destination.actions;
let presets = destination.presets;

let actions = removeHiddenFields(destination.actions);
let presets = destination.presets;

const clone = (obj) => Object.assign({}, obj);
const renameKey = (object, key, newKey) => {
Expand Down
62 changes: 32 additions & 30 deletions scripts/catalog/updateSources.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@ const PAPI_URL = "https://api.segmentapis.com";

const regionalSupport = yaml.load(fs.readFileSync(path.resolve(__dirname, `../../src/_data/regional-support.yml`)));

// This file keeps a list of known test sources that show up in the system.
// This file keeps a list of known test sources that show up in the system.
// Because we don't have a status value for sources, they end up showing in our catalog.
// We use this below to prevent them from being written to yaml.
const testSources = yaml.load(fs.readFileSync(path.resolve(__dirname, `../../src/_data/catalog/test_sources.yml`)));


const updateSources = async () => {
let sources = []; // Initialize an empty array to hold all sources
let sourcesUpdated = []; // Initialize an empty array to hold all sources that have been updated
let regionalSourcesUpdated = []; // Initialize an empty array to hold updated source regional information
let nextPageToken = "MA=="; // Set the initial page token to the first page
let categories = new Set(); // Initialize an empty set to hold all categories
let sourceCategories = []; // Initialize an empty array to hold all source categories
let sources = []; // Initialize an empty array to hold all sources
let sourcesUpdated = []; // Initialize an empty array to hold all sources that have been updated
let regionalSourcesUpdated = []; // Initialize an empty array to hold updated source regional information
let nextPageToken = "MA=="; // Set the initial page token to the first page
let categories = new Set(); // Initialize an empty set to hold all categories
let sourceCategories = []; // Initialize an empty array to hold all source categories


// Get all sources from the catalog
while (nextPageToken !== undefined) {
const res = await getCatalog(`${PAPI_URL}/catalog/sources/`, nextPageToken);
sources = sources.concat(res.data.sourcesCatalog);
nextPageToken = res.data.pagination.next;
}

// Sort the sources alphabetically
sources.sort((a, b) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
Expand All @@ -46,7 +46,7 @@ const updateSources = async () => {
}
return 0;
});

// Set the list of categories for libraries
const libraryCategories = [
'server',
Expand All @@ -55,20 +55,20 @@ const updateSources = async () => {
'roku',
'website'
];

// Here, define some sources that are real, but that we want to hide.
const hiddenSources = [
'amp',
'factual-engine',
'twilio-event-streams-beta',
'ibm-watson-assistant'
];

// More regional stuff
const regionalSourceEndpoint = regionalSupport.sources.endpoint;
const regionalSourceRegion = regionalSupport.sources.region;


// Loop through all sources and create a new object with the data we want
sources.forEach(source => {
let slug = slugify(source.name, "sources");
Expand All @@ -77,14 +77,14 @@ const updateSources = async () => {
let regions = ['us'];
let endpoints = ['us'];
let mainCategory = source.categories[0] ? source.categories[0].toLowerCase() : '';

if (libraryCategories.includes(mainCategory)) {
url = `connections/sources/catalog/libraries/${mainCategory}/${slug}`;
} else {
url = `connections/sources/catalog/cloud-apps/${slug}`;
mainCategory = 'cloud-app';
}

// Sort the settings alphabetically
settings.sort((a, b) => {
if (a.name.toLowerCase() < b.name.toLowerCase()) {
Expand All @@ -95,19 +95,19 @@ const updateSources = async () => {
}
return 0;
});

if (hiddenSources.includes(slug)) {
hidden = true;
}

if (regionalSourceEndpoint.includes(slug)) {
endpoints.push('eu');
}

if (regionalSourceRegion.includes(slug)) {
regions.push('eu');
}

// If the source ID is in the list of test sources, skip it.
// If it's not, add it to the list of sources to be written to yaml.
if (testSources.includes(source.id)) {
Expand All @@ -128,13 +128,15 @@ const updateSources = async () => {
url: source.logos.default
},
categories: source.categories,
status: source.status,
partnerOwned: source.partnerOwned
};
sourcesUpdated.push(updatedSource);
doesCatalogItemExist(updatedSource);
}

source.categories.reduce((s, e) => s.add(e), categories);

// Sources don't yet have regional information in the Public API, so we write that info here.
let updatedRegional = {
id: source.id,
Expand All @@ -147,7 +149,7 @@ const updateSources = async () => {
};
regionalSourcesUpdated.push(updatedRegional);
});

const sourceArray = Array.from(categories);
sourceArray.forEach(category => {
sourceCategories.push({
Expand All @@ -164,36 +166,36 @@ const updateSources = async () => {
return 0;
});
});

const options = {
noArrayIndent: false
};
const todayDate = new Date().toISOString().slice(0, 10);

// Create source catalog YAML file
let output = "# AUTOGENERATED FROM PUBLIC API. DO NOT EDIT\n";
output += "# sources last updated " + todayDate + " \n";
output += yaml.dump({
items: sourcesUpdated
}, options);
fs.writeFileSync(path.resolve(__dirname, `../../src/_data/catalog/sources.yml`), output);

// Create source-category mapping YAML file
output = "# AUTOGENERATED FROM PUBLIC API. DO NOT EDIT\n";
output += "# source categories last updated " + todayDate + " \n";
output += yaml.dump({
items: sourceCategories
}, options);
fs.writeFileSync(path.resolve(__dirname, `../../src/_data/catalog/source_categories.yml`), output);

// Create regional support YAML file
output = yaml.dump({
sources: regionalSourcesUpdated
}, options);
fs.writeFileSync(path.resolve(__dirname, `../../src/_data/catalog/regional-supported.yml`), output);

console.log("sources done");
};


exports.updateSources = updateSources;
exports.updateSources = updateSources;
8 changes: 2 additions & 6 deletions scripts/catalog/utilities.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,7 @@ const doesCatalogItemExist = (item) => {
let content = `---\ntitle: '${item.display_name} Source'\nhidden: true\n---`;

if (!docsPath.includes('/sources/')) {
let betaFlag = '';
if (item.status === 'PUBLIC_BETA') {
betaFlag = 'beta: true\n';
}
content = `---\ntitle: '${item.display_name} Destination'\nhidden: true\nid: ${item.id}\npublished: false\n${betaFlag}---\n`;
content = `---\ntitle: '${item.display_name} Destination'\nhidden: true\nid: ${item.id}\npublished: false\n`;
}

fs.mkdirSync(docsPath);
Expand Down Expand Up @@ -172,4 +168,4 @@ exports.getCatalog = getCatalog;
exports.getConnectionModes = getConnectionModes;
exports.isCatalogItemHidden = isCatalogItemHidden;
exports.sanitize = sanitize;
exports.doesCatalogItemExist = doesCatalogItemExist;
exports.doesCatalogItemExist = doesCatalogItemExist;
26 changes: 0 additions & 26 deletions src/_data/catalog/beta_sources.yml

This file was deleted.

2 changes: 1 addition & 1 deletion src/_data/catalog/destination_categories.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# AUTOGENERATED FROM PUBLIC API. DO NOT EDIT
# destination categories last updated 2024-07-30
# destination categories last updated 2024-11-21
items:
- display_name: A/B Testing
slug: a-b-testing
Expand Down
Loading

0 comments on commit 891d8d1

Please sign in to comment.