Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc364cf1

Browse files
Merge branch 'master' into consent-management-private-beta
2 parents8b6a57b +6cd2acd commitc364cf1

31 files changed

+859
-1425
lines changed

‎Makefile‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ serve: package
5656
@docker run -p 4000:80 segment-docs:latest
5757

5858
catalog:
59-
@node scripts/catalog_papi.js
59+
@node scripts/catalog/index.js
6060

6161
# make the list of beta connections
6262
.PHONY: beta
@@ -163,7 +163,7 @@ docker-build:
163163

164164
.PHONY: private-destination
165165
private_destination:
166-
@node scripts/private-destination.js
166+
@node scripts/catalog/addPrivateDestination.js
167167
#.PHONY: docs
168168
#docs: node_modules
169169
#$(BIN)/webpack --mode=production

‎netlify.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
[context.branch-deploy]
1616
command ="yarn build"
17-
# ignore = "./scripts/ignore.sh"
17+
# ignore = "./scripts/ignore.sh"
1818

1919
[context.develop]
2020
command ="yarn develop"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
constpath=require('path');
2+
constfs=require('fs');
3+
const{ prompt}=require('enquirer');
4+
const{
5+
getDestinationData,
6+
checkExistingStatus
7+
}=require('./utilities_private_destinations.js');
8+
9+
constaddPrivateDestination=async()=>{
10+
letids=awaitcheckExistingStatus();
11+
ids.sort();
12+
13+
constDEST_ID=awaitprompt({
14+
type:'input',
15+
name:'id',
16+
message:'Enter the destination ID'
17+
});
18+
19+
20+
if(ids.includes(DEST_ID.id)){
21+
console.log("This destination is already captured.");
22+
return;
23+
}else{
24+
ids.push(DEST_ID.id);
25+
fs.writeFileSync(path.resolve(__dirname,`../../src/_data/catalog/destinations_private.yml`),'');
26+
}
27+
ids.sort();
28+
29+
for(constelementinids){
30+
letcurrentId=ids[element];
31+
awaitgetDestinationData(currentId);
32+
}
33+
};
34+
35+
addPrivateDestination();

‎scripts/catalog/catalog_papi.js‎

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
constpath=require('path');
2+
constfs=require('fs');
3+
constyaml=require('js-yaml');
4+
const{
5+
slugify,
6+
getCatalog,
7+
getConnectionModes,
8+
isCatalogItemHidden,
9+
sanitize,
10+
doesCatalogItemExist
11+
}=require('./utilities.js');
12+
13+
require('dotenv').config();
14+
15+
constPAPI_URL="https://api.segmentapis.com";
16+
17+
constregionalSupport=yaml.load(fs.readFileSync(path.resolve(__dirname,`../src/_data/regional-support.yml`)));
18+
19+
// This file keeps a list of known test sources that show up in the system.
20+
// Because we don't have a status value for sources, they end up showing in our catalog.
21+
// We use this below to prevent them from being written to yaml.
22+
consttestSources=yaml.load(fs.readFileSync(path.resolve(__dirname,`../src/_data/catalog/test_sources.yml`)));
23+
24+
25+
26+
constupdateWarehouses=async()=>{
27+
letwarehouses=[];
28+
letnextPageToken="MA==";
29+
letwarehousesUpdated=[];
30+
31+
while(nextPageToken!==undefined){
32+
constres=awaitgetCatalog(`${PAPI_URL}/catalog/warehouses/`,nextPageToken);
33+
warehouses=warehouses.concat(res.data.warehousesCatalog);
34+
nextPageToken=res.data.pagination.next;
35+
}
36+
37+
warehouses.sort((a,b)=>{
38+
if(a.name.toLowerCase()<b.name.toLowerCase()){
39+
return-1;
40+
}
41+
if(a.name.toLowerCase()>b.name.toLowerCase()){
42+
return1;
43+
}
44+
return0;
45+
});
46+
47+
constregionalWarehouseEndpoints=regionalSupport.warehouses.endpoint;
48+
constregionalWarehouseRegions=regionalSupport.warehouses.region;
49+
50+
warehouses.forEach(warehouse=>{
51+
letslug=slugify(warehouse.slug);
52+
letendpoints=['us'];
53+
letregions=['us'];
54+
leturl=`connections/storage/catalog/${slug}`;
55+
56+
if(regionalWarehouseEndpoints.includes(slug)){
57+
endpoints.push('eu');
58+
}
59+
60+
if(regionalWarehouseRegions.includes(slug)){
61+
regions.push('eu');
62+
}
63+
64+
letupdatedWarehouse={
65+
id:warehouse.id,
66+
display_name:warehouse.name,
67+
url,
68+
slug,
69+
endpoints,
70+
regions
71+
};
72+
73+
warehousesUpdated.push(updatedWarehouse);
74+
});
75+
76+
constoptions={
77+
noArrayIndent:true
78+
};
79+
consttodayDate=newDate().toISOString().slice(0,10);
80+
81+
// Create regional support YAML file
82+
letoutput="# AUTOGENERATED LIST OF CONNECTIONS THAT SUPPORT REGIONAL\n";
83+
output+="# Last updated "+todayDate+" \n";
84+
output+=yaml.dump({
85+
warehouses:warehousesUpdated
86+
},options);
87+
fs.writeFileSync(path.resolve(__dirname,`../src/_data/catalog/regional-supported.yml`),output);
88+
89+
console.log("warehouses done");
90+
};
91+
92+
// Execute the update functions
93+
updateWarehouses();
94+
updateSources();
95+
updateDestinations();

‎scripts/catalog/index.js‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const{updateSources}=require('./updateSources.js');
2+
const{updateDestinations}=require('./updateDestinations.js');
3+
const{updateWarehouses}=require('./updateWarehouses.js');
4+
const{updatePrivateDestinations}=require('./updatePrivateDestinations.js');
5+
6+
updateSources();
7+
updateWarehouses();
8+
9+
// Wait for the main catalog to update before updating the private destinations
10+
asyncfunctiondestinations(){
11+
awaitupdateDestinations()
12+
updatePrivateDestinations();
13+
}
14+
15+
16+
17+
destinations();
Lines changed: 195 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,195 @@
1+
constpath=require('path');
2+
constfs=require('fs');
3+
constyaml=require('js-yaml');
4+
const{
5+
slugify,
6+
getCatalog,
7+
getConnectionModes,
8+
isCatalogItemHidden,
9+
sanitize,
10+
doesCatalogItemExist
11+
}=require('./utilities.js');
12+
13+
require('dotenv').config();
14+
15+
constPAPI_URL="https://api.segmentapis.com";
16+
17+
18+
constupdateDestinations=async()=>{
19+
letdestinations=[];
20+
letdestinationsUpdated=[];
21+
letdestinationCategories=[];
22+
letcategories=newSet();
23+
letnextPageToken="MA==";
24+
25+
// Get all destinations from the Public API
26+
while(nextPageToken!==undefined){
27+
constres=awaitgetCatalog(`${PAPI_URL}/catalog/destinations/`,nextPageToken);
28+
destinations=destinations.concat(res.data.destinationsCatalog);
29+
nextPageToken=res.data.pagination.next;
30+
}
31+
32+
// Sort the destinations alphabetically
33+
destinations.sort((a,b)=>{
34+
if(a.name.toLowerCase()<b.name.toLowerCase()){
35+
return-1;
36+
}
37+
if(a.name.toLowerCase()>b.name.toLowerCase()){
38+
return1;
39+
}
40+
return0;
41+
});
42+
43+
// Loop through all destinations and create a new object with the data we want
44+
destinations.forEach(destination=>{
45+
letendpoints=[];
46+
letregions=[];
47+
48+
letslug=slugify(destination.name,"destinations");
49+
50+
if(typeofdestination.supportedRegions!="undefined"){
51+
regions=destination.supportedRegions;
52+
}else{
53+
regions.push('us-west-2','eu-west-1');
54+
}
55+
56+
if(typeofdestination.regionEndpoints!="undefined"){
57+
endpoints=destination.regionEndpoints;
58+
}else{
59+
endpoints.push('US');
60+
}
61+
62+
leturl=`connections/destinations/catalog/${slug}`;
63+
64+
lettempCategories=[destination.categories];
65+
tempCategories=tempCategories.filter(category=>category!='');
66+
tempCategories=tempCategories.flat();
67+
68+
letconnection_modes=getConnectionModes({
69+
components:destination.components,
70+
platforms:destination.supportedPlatforms,
71+
browserUnbundling:destination.supportedFeatures.browserUnbundling,
72+
browserUnbundlingPublic:destination.supportedFeatures.browserUnbundlingPublic,
73+
methods:destination.supportedMethods
74+
});
75+
76+
letsettings=destination.options;
77+
78+
settings.sort((a,b)=>{
79+
if(a.name.toLowerCase()<b.name.toLowerCase()){
80+
return-1;
81+
}
82+
if(a.name.toLowerCase()>b.name.toLowerCase()){
83+
return1;
84+
}
85+
return0;
86+
});
87+
88+
settings.forEach(setting=>{
89+
setting.description=sanitize(setting.description);
90+
});
91+
92+
letactions=destination.actions;
93+
letpresets=destination.presets;
94+
95+
constclone=(obj)=>Object.assign({},obj);
96+
constrenameKey=(object,key,newKey)=>{
97+
constclonedObj=clone(object);
98+
consttargetKey=clonedObj[key];
99+
deleteclonedObj[key];
100+
101+
clonedObj[newKey]=targetKey;
102+
returnclonedObj;
103+
};
104+
105+
// I honestly don't remember why I did this.
106+
// I think someone wanted to mention support for the Screen method to whatever destination that is
107+
destination.supportedMethods.screen=false;
108+
if(destination.id=='63e42b47479274407b671071'){
109+
destination.supportedMethods.screen=true;
110+
}
111+
112+
// Pageview is renamed to Page
113+
destination.supportedMethods=renameKey(destination.supportedMethods,'pageview','page');
114+
115+
// All updated destination information gets added to this object
116+
letupdatedDestination={
117+
id:destination.id,
118+
display_name:destination.name,
119+
name:destination.name,
120+
slug,
121+
hidden:isCatalogItemHidden(url),
122+
endpoints,
123+
regions,
124+
url,
125+
previous_names:destination.previousNames,
126+
website:destination.website,
127+
status:destination.status,
128+
categories:tempCategories,
129+
logo:{
130+
url:destination.logos.default
131+
},
132+
mark:{
133+
url:destination.logos.mark
134+
},
135+
methods:destination.supportedMethods,
136+
platforms:destination.supportedPlatforms,
137+
components:destination.components,
138+
browserUnbundlingSupported:destination.supportedFeatures.browserUnbundling,
139+
browserUnbundlingPublic:destination.supportedFeatures.browserUnbundlingPublic,
140+
replay:destination.supportedFeatures.replay,
141+
connection_modes,
142+
settings,
143+
actions,
144+
presets
145+
};
146+
147+
// Add the updated destination to the destinationsUpdated array
148+
destinationsUpdated.push(updatedDestination);
149+
doesCatalogItemExist(updatedDestination);
150+
tempCategories.reduce((s,e)=>s.add(e),categories);
151+
});
152+
153+
constdestinationArray=Array.from(categories);
154+
destinationArray.forEach(category=>{
155+
destinationCategories.push({
156+
display_name:category,
157+
slug:slugify(category)
158+
});
159+
destinationCategories.sort((a,b)=>{
160+
if(a.display_name.toLowerCase()<b.display_name.toLowerCase()){
161+
return-1;
162+
}
163+
if(a.display_name.toLowerCase()>b.display_name.toLowerCase()){
164+
return1;
165+
}
166+
return0;
167+
});
168+
});
169+
170+
constoptions={
171+
noArrayIndent:true
172+
};
173+
consttodayDate=newDate().toISOString().slice(0,10);
174+
175+
// Create destination catalog YAML file
176+
letoutput="# AUTOGENERATED FROM PUBLIC API. DO NOT EDIT\n";
177+
output+="# destination data last updated "+todayDate+" \n";
178+
output+=yaml.dump({
179+
items:destinationsUpdated
180+
},options);
181+
fs.writeFileSync(path.resolve(__dirname,`../../src/_data/catalog/destinations.yml`),output);
182+
183+
// Create destination-category mapping YAML file
184+
output="# AUTOGENERATED FROM PUBLIC API. DO NOT EDIT\n";
185+
output+="# destination categories last updated "+todayDate+" \n";
186+
output+=yaml.dump({
187+
items:destinationCategories
188+
},options);
189+
fs.writeFileSync(path.resolve(__dirname,`../../src/_data/catalog/destination_categories.yml`),output);
190+
191+
console.log("destinations done");
192+
};
193+
194+
195+
exports.updateDestinations=updateDestinations;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
const{
2+
getDestinationData,
3+
checkExistingStatus
4+
}=require('./utilities_private_destinations.js');
5+
6+
constupdatePrivateDestinations=async()=>{
7+
letids=awaitcheckExistingStatus();
8+
ids.sort();
9+
10+
for(constelementinids){
11+
letcurrentId=ids[element];
12+
awaitgetDestinationData(currentId);
13+
}
14+
console.log("private destinations done");
15+
};
16+
17+
exports.updatePrivateDestinations=updatePrivateDestinations;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp