PageSourceSearch

https://posthog.com/component---src-pages-community-alerts-tsx-60ae4fc1ff8729837ea1.js

js posthog.com collected 2026-09-24 08:00:32 UTC 9,094 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkposthog_com=self.webpackChunkposthog_com||[]).push([[4606],{6734:function(e,t,n){var i=n(52184);e.exports=i.Promise},23488:function(e,t,n){n.r(t),n.d(t,{default:function(){return A}});var i=n(95114),s=n(30758),a=n(63629),o=n(49271),r=n(46521),l=n(2212),c=n(52914),d=n(62592),u=n(88647),h=n(46542),p=n(83795),m=(n(58855),n(75004)),f=n.n(m);const g="https://better-animal-d658c56969.strapiapp.com",b=f().stringify({fields:["name","slug","publishedAt","slackChannel"],populate:{topicSubscriptions:{fields:["id"]}},publicationState:"preview",pagination:{pageSize:200},sort:["name:asc"]},{encodeValuesOnly:!0}),x=f().stringify({fields:["label","slug"],pagination:{pageSize:200},sort:["label:asc"]},{encodeValuesOnly:!0}),v=f().stringify({fields:["label"],populate:{topics:{fields:["id"]}},pagination:{pageSize:100}},{encodeValuesOnly:!0});var y=n(40435),j=n(86070);const w=e=>{let{children:t}=e;return(0,j.jsx)("span",{className:"text-red dark:text-yellow font-semibold",children:t})},S=e=>{let{team:t}=e;return t.draft?(0,j.jsx)(h.A,{content:"This team is unpublished, so it doesn't show on /teams — but it still gets alerts",children:(0,j.jsx)("span",{className:"opacity-60 text-sm",children:"(draft)"})}):null},k=e=>{let{team:t,onRemove:n}=e;return(0,j.jsxs)("span",{className:"inline-flex items-center gap-1 border border-primary rounded bg-accent px-2 py-0.5 text-sm",children:[(0,j.jsx)(l.A,{to:"/teams/"+t.slug,state:{newWindow:!0},children:t.name}),(0,j.jsx)(S,{team:t}),!t.slackChannel&&(0,j.jsx)(h.A,{content:"No Slack channel set on this team, so nothing is posted. Set one on the team's page.",placement:"top",children:(0,j.jsx)("span",{children:(0,j.jsx)(w,{children:"no channel"})})}),(0,j.jsx)(h.A,{content:"Stop notifying "+t.name,placement:"top",children:(0,j.jsx)("button",{onClick:n,className:"opacity-60 hover:opacity-100",children:(0,j.jsx)(o.IconX,{className:"size-3"})})})]})};function A(){const{isModerator:e,isValidating:t}=(0,p.Jd)(),{topics:n,teams:o,loading:h,error:m,subscribeTeam:f,unsubscribeTeam:S}=function(){const{getJwt:e,isModerator:t}=(0,p.Jd)(),{0:n,1:i}=(0,s.useState)([]),{0:a,1:o}=(0,s.useState)([]),{0:r,1:l}=(0,s.useState)(!0),{0:c,1:d}=(0,s.useState)(null),u=async()=>{var t,n;const s=await e(),a=s?{Authorization:"Bearer "+s}:void 0,[r,l,c]=await Promise.all([fetch(g+"/api/teams?"+b,{headers:a}).then(e=>e.json()),fetch(g+"/api/topics?"+x).then(e=>e.json()),fetch(g+"/api/topic-groups?"+v).then(e=>e.json())]),d=(null!==(t=null==r?void 0:r.data)&&void 0!==t?t:[]).map(e=>{var t,n,i;return{id:e.id,name:e.attributes.name,slug:e.attributes.slug,slackChannel:null!==(t=e.attributes.slackChannel)&&void 0!==t?t:null,topicIDs:(null!==(n=null===(i=e.attributes.topicSubscriptions)||void 0===i?void 0:i.data)&&void 0!==n?n:[]).map(e=>e.id),draft:!e.attributes.publishedAt}}),u=new Map;for(const e of null!==(h=null==c?void 0:c.data)&&void 0!==h?h:[]){var h;for(const t of null!==(p=null===(m=e.attributes.topics)||void 0===m?void 0:m.data)&&void 0!==p?p:[]){var p,m;u.set(t.id,e.attributes.label)}}const f=(null!==(n=null==l?void 0:l.data)&&void 0!==n?n:[]).map(e=>{var t;return{id:e.id,label:e.attributes.label,slug:e.attributes.slug,group:null!==(t=u.get(e.id))&&void 0!==t?t:null,teams:d.filter(t=>t.topicIDs.includes(e.id))}});o(d),i(f)},h=async(t,n)=>{d(null);try{const i=await e(),s=await fetch(g+"/api/teams/"+t,{method:"PUT",body:JSON.stringify({data:n}),headers:{Authorization:"Bearer "+i,"content-type":"application/json"}});if(!s.ok)throw new Error("Strapi returned "+s.status);await u()}catch(i){d("Couldn't save: "+i.message)}};return(0,s.useEffect)(()=>{t&&(l(!0),d(null),u().catch(e=>d(e.message)).finally(()=>l(!1)))},[t]),{topics:n,teams:a,loading:r,error:c,fetchAlerts:u,subscribeTeam:(e,t)=>h(t,{topicSubscriptions:{connect:[e]}}),unsubscribeTeam:(e,t)=>h(t,{topicSubscriptions:{disconnect:[e]}})}}(),{0:A,1:N}=(0,s.useState)(!1);(0,s.useEffect)(()=>{t||e||(0,a.navigate)("/questions")},[e,t]);const C=n.filter(e=>
10===e.teams.length),T=o.filter(e=>e.topicIDs.length>0&&!e.slackChannel),O=A?C:n,P=(0,i.A)(O).sort((e,t)=>e.group!==t.group?e.group?t.group?e.group.localeCompare(t.group):-1:1:e.label.localeCompare(t.label));if(!e)return null;const W=P.map(e=>{var t;const n=o.filter(t=>!e.teams.some(e=>e.id===t.id));return{key:"topic-"+e.id,cells:[{content:(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)("div",{className:"font-semibold",children:e.label}),(0,j.jsx)("div",{className:"text-sm opacity-60",children:null!==(t=e.group)&&void 0!==t?t:(0,j.jsx)(w,{children:"no topic group — can't be picked when asking"})})]})},{content:e.teams.length>0?(0,j.jsx)("div",{className:"flex flex-wrap gap-1",children:e.teams.map(t=>(0,j.jsx)(k,{team:t,onRemove:()=>S(e.id,t.id)},t.id))}):(0,j.jsx)(w,{children:"Nobody is notified"})},{content:(0,j.jsx)(d.A,{search:!0,placeholder:"Add team...",value:void 0,onChange:t=>t&&f(e.id,t),options:n.map(e=>({label:e.name,value:e.id}))})}]}});return(0,j.jsxs)(y.Ay,{hideLeftSidebar:!0,hideRightSidebar:!0,children:[(0,j.jsx)(r._,{children:"Question alerts"}),(0,j.jsx)("p",{className:"text-sm opacity-75",children:"When someone asks a question, PostHog posts it to the Slack channel of every team subscribed to that question's topic. Set which teams a topic notifies here; set each team's Slack channel on its own team page. Changes take effect immediately — no deploy."}),(0,j.jsxs)("p",{className:"text-sm opacity-75",children:["A question only notifies Slack when it is ",(0,j.jsx)("em",{children:"created"}),". Adding a topic to an existing question updates the messages already posted, but never sends a new one."]}),h&&(0,j.jsx)(u.A,{}),m&&(0,j.jsx)("p",{className:"border border-primary rounded bg-accent p-3 text-red dark:text-yellow",children:m}),!h&&n.length>0&&(0,j.jsxs)(j.Fragment,{children:[(C.length>0||T.length>0)&&(0,j.jsxs)("div",{className:"bg-accent border border-primary p-4 rounded mb-6",children:[(0,j.jsxs)("ul",{className:"list-disc m-0 pl-4 text-sm space-y-1",children:[C.length>0&&(0,j.jsxs)("li",{children:[(0,j.jsx)(w,{children:C.length})," topic",1===C.length?"":"s"," ","notify nobody: ",C.map(e=>e.label).join(", ")]}),T.length>0&&(0,j.jsxs)("li",{children:[(0,j.jsx)(w,{children:T.length})," team",1===T.length?"":"s"," ","subscribe to topics but have no Slack channel, so nothing is posted. Set one on"," ",T.map((e,t)=>(0,j.jsxs)(s.Fragment,{children:[t>0&&", ",(0,j.jsx)(l.A,{to:"/teams/"+e.slug,state:{newWindow:!0},children:e.name})]},e.id)),"."]})]}),C.length>0&&(0,j.jsxs)("label",{className:"flex items-center gap-2 text-sm mt-3 mb-0",children:[(0,j.jsx)("input",{type:"checkbox",checked:A,onChange:e=>N(e.target.checked)}),"Only show topics that notify nobody"]})]}),(0,j.jsx)(c.A,{rowAlignment:"top",width:"full",columns:[{name:"Topic",width:"minmax(200px, 1fr)"},{name:"Notifies",width:"minmax(300px, 2fr)"},{name:"Add",width:"minmax(180px, auto)"}],rows:W})]})]})}},29053:function(e,t,n){var i=n(83743),s=n(69332),a=n(14861),o=n(47051)("species");e.exports=function(e,t){var n,r=i(e).constructor;return void 0===r||a(n=i(r)[o])?t:s(n)}},46521:function(e,t,n){n.d(t,{A:function(){return u},_:function(){return c}});var i=n(86654),s=n(94940),a=n(8462),o=n(84323),r=n(13630),l=n(86070);const c=e=>{let{children:t}=e;return(0,l.jsx)("h1",{className:"m-0 mb-6",children:t})},d=e=>{let{children:t,title:n,tableOfContents:i,menu:a,contentWidth:r}=e;return(0,l.jsx)(s.A,{hideWidthToggle:!0,hideSurvey:!0,sidebar:(0,l.jsx)(o.Ay,{}),tableOfContents:i,title:n,menuWidth:{right:320},menu:a,contentWidth:r,children:t})};function u(e){let{children:t,title:n,tableOfContents:s,parent:o,activeInternalMenu:c,menu:u,contentWidth:h}=e;return(0,l.jsxs)(i.A,{parent:o||r.BS,activeInternalMenu:c||r.BS.children[2],children:[(0,l.jsx)(a.Ay,{title:n+" - PostHog"}),(0,l.jsx)(d,{menu:u,title:n,tableOfContents:s,contentWidth:h,children:t})]})}},58855:function(e,t,n){var i=n(21118),s=n(82371),a=n(6734),o=n(3895),r=n(25791),l=n(60189),c=n(29053),d=n(89590),u=n(3232),h=a&&a.prototype;if(i({target:"Promise",proto:!0,real:!0,forced:!!a&&o(function(){h.finally.call({then:function(){}},function(){})})},{finally:function(e){var t=c(this,r("Promise")),n=l(e);return this.then(n?function(n){return d(t,e()).then(function(){return n})}:e,n?function(n){return d(t,e()).then(function(){throw n})}:e)}}),!s&&l(a)){var p=r("Promise").prototype.finally;h.finally!==p&&u(h,"finally",p,{unsafe:!0})}},69332:function(e,t,n){var i=n(16261),s=n(55599),a=TypeError;e.exports=function(e){if(i(e))return e;throw new a(s(e)+" is not a constructor")}},69427:function(e,t,n){var i=n(54354),s=TypeError,a=function(e){var t,n;this.promise=new e(function(e,i){if(void 0!==t||void 0!==n)throw new s("Bad Promise constructor");t=e,n=i}),this.resolve=i(t),this.reject=i(n)};e.exports.f=function(e){return new a(e)}},89590:function(e,t,n){var i=n(83743),s=n(66586),a=n(69427);e.exports=function(e,t){if(i(e),s(t)&&t.constructor===e)return t;var n=a.f(e);return(0,n.resolve)(t),n.promise}}}]);
2//# sourceMappingURL=component---src-pages-community-alerts-tsx-60ae4fc1ff8729837ea1.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.