customerio-gist-web 0.0.0-test-oidc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. package/.github/workflows/eslint.yml +26 -0
  2. package/.github/workflows/release.yml +46 -0
  3. package/.github/workflows/release_hotfix.yml +41 -0
  4. package/.github/workflows/release_version.yml +57 -0
  5. package/.mise/config.toml +2 -0
  6. package/CODEOWNERS +2 -0
  7. package/LICENSE +21 -0
  8. package/README.md +29 -0
  9. package/dist/gist.min.js +1 -0
  10. package/eslint.config.mjs +10 -0
  11. package/examples/index.html +126 -0
  12. package/examples/styles.css +55 -0
  13. package/index.d.ts +1 -0
  14. package/index.js +2 -0
  15. package/package.json +49 -0
  16. package/src/gist.js +128 -0
  17. package/src/index.js +2 -0
  18. package/src/managers/custom-attribute-manager.js +82 -0
  19. package/src/managers/gist-properties-manager.js +36 -0
  20. package/src/managers/locale-manager.js +16 -0
  21. package/src/managers/message-broadcast-manager.js +107 -0
  22. package/src/managers/message-component-manager.js +192 -0
  23. package/src/managers/message-manager.js +314 -0
  24. package/src/managers/message-user-queue-manager.js +80 -0
  25. package/src/managers/page-component-manager.js +19 -0
  26. package/src/managers/queue-manager.js +216 -0
  27. package/src/managers/user-manager.js +88 -0
  28. package/src/services/log-service.js +19 -0
  29. package/src/services/network.js +81 -0
  30. package/src/services/queue-service.js +75 -0
  31. package/src/services/settings.js +65 -0
  32. package/src/templates/embed.js +69 -0
  33. package/src/templates/message.js +57 -0
  34. package/src/utilities/event-emitter.js +12 -0
  35. package/src/utilities/local-storage.js +86 -0
  36. package/src/utilities/log.js +7 -0
  37. package/src/utilities/preview-mode.js +20 -0
  38. package/test.sh +4 -0
  39. package/webpack.config.js +11 -0
@@ -0,0 +1,26 @@
1
+ name: Lint Codebase
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - develop
7
+ push:
8
+ branches:
9
+ - develop
10
+
11
+ jobs:
12
+ lint:
13
+ runs-on: ubuntu-latest
14
+
15
+ steps:
16
+ - name: Checkout code
17
+ uses: actions/checkout@v3
18
+ - name: Setup Node.js
19
+ uses: actions/setup-node@v3
20
+ with:
21
+ node-version: '20'
22
+ - name: Install dependencies
23
+ run: npm install
24
+ - name: Run ESLint
25
+ run: npx eslint . --max-warnings=0
26
+
@@ -0,0 +1,46 @@
1
+ name: Release Gist Web
2
+ run-name: Release gist-web
3
+
4
+ on:
5
+ pull_request:
6
+ types:
7
+ - opened
8
+ - synchronize
9
+ - reopened
10
+
11
+ permissions:
12
+ id-token: write
13
+ contents: read
14
+
15
+ jobs:
16
+ release:
17
+ runs-on: ubuntu-latest
18
+ environment: release
19
+ env:
20
+ AWS_ACCESS_KEY_ID: ${{ secrets.GIST_WEB_AWS_KEY_ID }}
21
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.GIST_WEB_AWS_SECRET_ACCESS_KEY }}
22
+ AWS_BUCKET: 'gist-code'
23
+ CLOUDFLARE_ACCESS_TOKEN: ${{ secrets.CLOUDFLARE_ACCESS_TOKEN }}
24
+ CLOUDFLARE_ZONE_ID: 3310bc68d22035edbc12d5d4a4fd278c
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - name: Use Node.js ${{ matrix.node-version }}
28
+ uses: actions/setup-node@v4
29
+ with:
30
+ node-version: 20
31
+ registry-url: 'https://registry.npmjs.org'
32
+
33
+ - name: Install npm 11.5.1+ for OIDC support
34
+ run: npm install -g npm@latest
35
+
36
+ - name: Build
37
+ shell: bash
38
+ run: |
39
+ npm install
40
+ npm run build:prod
41
+
42
+ - name: Set test version
43
+ run: npm version 0.0.0-test-oidc --no-git-tag-version
44
+
45
+ - name: Publish to NPM
46
+ run: npm publish --tag test-oidc
@@ -0,0 +1,41 @@
1
+ name: Release hotfix from master
2
+
3
+ on:
4
+ workflow_dispatch:
5
+
6
+ jobs:
7
+ release:
8
+ runs-on: ubuntu-latest
9
+ steps:
10
+ - uses: actions/checkout@v3
11
+ with:
12
+ fetch-depth: 0
13
+ ref: master
14
+ token: ${{ secrets.SRE_GHACTIONS_TOKEN }}
15
+ - uses: actions-ecosystem/action-get-latest-tag@b7c32daec3395a9616f88548363a42652b22d435 # v1.6.0
16
+ id: get-latest-tag
17
+ - uses: actions-ecosystem/action-bump-semver@8f82919001e67c7561b5f240af5df8234d2ac3fc # v1.0.0
18
+ id: bump-semver
19
+ with:
20
+ current_version: ${{ steps.get-latest-tag.outputs.tag }}
21
+ level: patch
22
+ - name: Release Package
23
+ shell: bash
24
+ env:
25
+ GIT_AUTH_TOKEN: ${{ secrets.SRE_GHACTIONS_TOKEN }}
26
+ run: |
27
+ git config user.name "ami-ci"
28
+ git config user.email "<>"
29
+
30
+ # Update the package.json version. Skip the git tag, we'll do that later
31
+ npm version ${{ steps.bump-semver.outputs.new_version }} --no-git-tag-version
32
+
33
+ # Commit the changed package.json file to master
34
+ git add package.json
35
+ git commit -m "Bump version to ${{ steps.bump-semver.outputs.new_version }}"
36
+ git push origin master
37
+
38
+ # Tag the new version
39
+ git tag ${{ steps.bump-semver.outputs.new_version }}
40
+ git push origin ${{ steps.bump-semver.outputs.new_version }}
41
+
@@ -0,0 +1,57 @@
1
+ name: Release new version from develop
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ component:
7
+ description: 'Semantic version component to bump'
8
+ type: choice
9
+ required: true
10
+ options:
11
+ - 'patch'
12
+ - 'minor'
13
+ - 'major'
14
+ default: 'patch'
15
+
16
+ jobs:
17
+ release:
18
+ runs-on: ubuntu-latest
19
+ steps:
20
+ - uses: actions/checkout@v3
21
+ with:
22
+ fetch-depth: 0
23
+ ref: develop
24
+ token: ${{ secrets.SRE_GHACTIONS_TOKEN }}
25
+ - uses: actions-ecosystem/action-get-latest-tag@b7c32daec3395a9616f88548363a42652b22d435 # v1.6.0
26
+ id: get-latest-tag
27
+ - uses: actions-ecosystem/action-bump-semver@8f82919001e67c7561b5f240af5df8234d2ac3fc # v1.0.0
28
+ id: bump-semver
29
+ with:
30
+ current_version: ${{ steps.get-latest-tag.outputs.tag }}
31
+ level: ${{ inputs.component }}
32
+ - name: Release Package
33
+ shell: bash
34
+ env:
35
+ GIT_AUTH_TOKEN: ${{ secrets.SRE_GHACTIONS_TOKEN }}
36
+ run: |
37
+ git config user.name "ami-ci"
38
+ git config user.email "<>"
39
+ git checkout develop
40
+
41
+ # Update the package.json version. Skip the git tag, we'll do that later
42
+ npm version ${{ steps.bump-semver.outputs.new_version }} --no-git-tag-version
43
+
44
+ # Commit the changed package.json & package-lock.json files to develop
45
+ git add package.json package-lock.json
46
+ git commit -m "Bump version to ${{ steps.bump-semver.outputs.new_version }}"
47
+ git push origin develop
48
+
49
+ # Merge develop into master
50
+ git checkout master
51
+ git merge develop
52
+ git push origin master
53
+
54
+ # Tag the new version
55
+ git tag ${{ steps.bump-semver.outputs.new_version }}
56
+ git push origin ${{ steps.bump-semver.outputs.new_version }}
57
+
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ node = '20'
package/CODEOWNERS ADDED
@@ -0,0 +1,2 @@
1
+ # The catch-all default code owners for this repository
2
+ * @customerio/squad-in-app
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 Customer IO
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Gist for Web
2
+
3
+ ## Testing
4
+
5
+ - Clone repo
6
+ - Run `npm start`
7
+ - Navigate to: `http://127.0.0.1:8081/examples/`
8
+
9
+ ## Build Locally
10
+
11
+ - `npm run build:prod`
12
+
13
+ ## Releases
14
+
15
+ ### Feature release process
16
+
17
+ - Merge PR into develop
18
+ - Head over to the repo's feature release [action page](https://github.com/customerio/gist-web/actions/workflows/release_version.yml).
19
+ - Select **Run Workflow**
20
+ - Choose between:
21
+ - *patch* - Bug/hot fixes
22
+ - *minor* - New features
23
+ - *major* - New / replaced APIs (usually breaking)
24
+
25
+ ### Hotfix release process
26
+
27
+ - Merge PR into master
28
+ - Head over to the repo's hotfix release [action page](https://github.com/customerio/gist-web/actions/workflows/release_hotfix.yml).
29
+ - Select **Run Workflow**
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Gist=t():e.Gist=t()}(this,(()=>(()=>{var e={998:(e,t,n)=>{"use strict";n.d(t,{A:()=>Ue});class s{on(e,t){var n=this[e];n?n.push(t):this[e]=[t]}dispatch(e,t){var n=this[e];n&&n.forEach((e=>e(t)))}}function i(e){Ue.config&&Ue.config.logging&&console.log(`Gist: ${e}`)}const a=365,o="gist.web.isPersistingSession";function r(e,t,n=null){var s=n;s||(s=new Date).setDate(s.getDate()+a);const i={value:t,expiry:s};g().setItem(e,JSON.stringify(i))}function c(e){return l(e)}function u(e){g().removeItem(e)}function d(){const e=sessionStorage.getItem(o);return null===e?(sessionStorage.setItem(o,"true"),!0):"true"===e}function g(){return d()?localStorage:sessionStorage}function l(e){if(!e)return null;try{const t=g().getItem(e);if(!t)return null;const n=JSON.parse(t);if(!n.expiry)return n.value;const s=new Date,i=new Date(n.expiry),a=e.startsWith("gist.web.message.broadcasts")&&!e.endsWith("shouldShow")&&!e.endsWith("numberOfTimesShown")||e.startsWith("gist.web.message.user")&&!e.endsWith("seen"),o=new Date(s.getTime()+366e4);return a&&i.getTime()>o.getTime()||s.getTime()>i.getTime()?(u(e),null):n.value}catch(t){i(`Error checking key ${e} for expiry: ${t}`)}return null}var m,f=new Uint8Array(16);function h(){if(!m&&!(m="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return m(f)}const p=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;for(var w=[],v=0;v<256;++v)w.push((v+256).toString(16).substr(1));const y=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(w[e[t+0]]+w[e[t+1]]+w[e[t+2]]+w[e[t+3]]+"-"+w[e[t+4]]+w[e[t+5]]+"-"+w[e[t+6]]+w[e[t+7]]+"-"+w[e[t+8]]+w[e[t+9]]+"-"+w[e[t+10]]+w[e[t+11]]+w[e[t+12]]+w[e[t+13]]+w[e[t+14]]+w[e[t+15]]).toLowerCase();if(!function(e){return"string"==typeof e&&p.test(e)}(n))throw TypeError("Stringified UUID is invalid");return n},b=function(e,t,n){var s=(e=e||{}).random||(e.rng||h)();if(s[6]=15&s[6]|64,s[8]=63&s[8]|128,t){n=n||0;for(var i=0;i<16;++i)t[n+i]=s[i];return t}return y(s)},S="gist.web.userQueueUseSSE",I="gist.web.activeSSEConnection";let $,E=30;const x={RENDERER_HOST:"https://code.gist.build",ENGINE_API_ENDPOINT:{prod:"https://engine.api.gist.build",dev:"https://engine.api.dev.gist.build",local:"http://engine.api.local.gist.build:82"},GIST_QUEUE_API_ENDPOINT:{prod:"https://consumer.cloud.gist.build",dev:"https://consumer.cloud.dev.gist.build",local:"http://api.local.gist.build:86"},GIST_QUEUE_REALTIME_API_ENDPOINT:{prod:"https://realtime.cloud.gist.build",dev:"https://realtime.cloud.dev.gist.build",local:"http://api.local.gist.build:3000"},GIST_VIEW_ENDPOINT:{prod:"https://renderer.gist.build/3.0",dev:"https://renderer.gist.build/3.0",local:"http://app.local.gist.build:8080/web"},getSdkId:function(){return $||($=b()),$},useSSE:function(){return c(S)??!1},setUseSSEFlag:function(e){r(S,e,new Date((new Date).getTime()+6e4)),i(`Set user uses SSE to "${e}"`)},removeActiveSSEConnection:function(){u(I)},setActiveSSEConnection:function(){r(I,x.getSdkId(),new Date((new Date).getTime()+x.getSSEHeartbeat()))},hasActiveSSEConnection:function(){return c(I)??!1},isSSEConnectionManagedBySDK:function(){return c(I)===x.getSdkId()},getSSEHeartbeat:function(){return 1e3*(E+5)},setSSEHeartbeat:function(e){e&&e>0&&(E=e)}};function T(){const e=x.GIST_QUEUE_API_ENDPOINT[Ue.config.env],t={"X-CIO-Site-Id":Ue.config.siteId,"X-CIO-Client-Platform":"web"},n=_();async function s(n,s={}){const i=e+n,a=new AbortController,o=setTimeout((()=>a.abort()),5e3);try{const e=await fetch(i,{method:s.method||"GET",headers:{...t,...s.headers||{}},body:s.method&&"GET"!==s.method.toUpperCase()?s.body:void 0,signal:a.signal});clearTimeout(o);const n=e.headers.get("content-type")?.includes("application/json"),r=n?await e.json():await e.text(),c=Object.fromEntries(e.headers.entries());if(e.status<200||e.status>=400)throw{response:{status:e.status,data:r,headers:c}};return{status:e.status,headers:c,data:r}}catch(e){throw clearTimeout(o),e.response||(e.response={status:0,data:e.message||"Unknown error"}),e}}return null!=n&&(t["X-Gist-Encoded-User-Token"]=n),s.post=(e,t={},n={})=>s(e,{method:"POST",body:JSON.stringify(t),headers:{"Content-Type":"application/json",...n.headers||{}}}),s}const D="gist.web.userLocale";var k=600,C=!1;const M="gist.web.userQueueNextPullCheck",R="gist.web.sessionId";function q(){var e=c(R);return e||(e=b()),r(R,e,new Date((new Date).getTime()+18e5)),e}const P="gist.web.userToken",A="gist.web.usingGuestUserToken",L="gist.web.guestUserToken";function N(){return null!==c(A)}function U(){return c(P)}function W(){if(null===U()){var e=c(L);null==e&&(e=b(),r(L,e),i(`Set guest user token "${e}" with expiry date set to 1 year from today`)),r(P,e),r(A,!0),i(`Using anonymous session with token: "${e}"`)}}async function O(){var e=U();return null===e?null:await async function(e){const t=(new TextEncoder).encode(e),n=await crypto.subtle.digest("SHA-256",t);return Array.from(new Uint8Array(n)).map((e=>e.toString(16).padStart(2,"0"))).join("")}(e)}function _(){var e=U();return null===e?null:btoa(e)}function H(e){const t={isEmbedded:!1,elementId:"",hasRouteRule:!1,routeRule:"",position:"",hasPosition:!1,shouldScale:!1,campaignId:null,messageWidth:414,overlayColor:"#00000033",persistent:!1,exitClick:!1,hasCustomWidth:!1},n=e?.properties?.gist;return n?{isEmbedded:!!n.elementId,elementId:n.elementId||"",hasRouteRule:!!n.routeRuleWeb,routeRule:n.routeRuleWeb||"",position:n.position||"",hasPosition:!!n.position,shouldScale:!!n.scale,campaignId:n.campaignId??null,messageWidth:n.messageWidth>0?n.messageWidth:t.messageWidth,hasCustomWidth:n.messageWidth>0,overlayColor:n.overlayColor||t.overlayColor,persistent:!!n.persistent,exitClick:!!n.exitClick}:t}var G=["x-gist-top","x-gist-floating-top","x-gist-bottom","x-gist-floating-bottom","x-gist-floating-bottom-left","x-gist-floating-bottom-right","x-gist-floating-top-left","x-gist-floating-top-right"];const j=e=>new Promise((t=>setTimeout(t,e))),V=["x-gist-top","x-gist-bottom","x-gist-floating-top","x-gist-floating-bottom"];function z(e){var t=X(e);if(t)return t.style&&t.style.height&&"0px"!=t.style.height}function F(e,t){const n=document.getElementById(e);n&&(n.onload=function(){!function(e,t){const n=document.getElementById(e);n&&n.contentWindow&&n.contentWindow.postMessage({options:t},"*")}(e,t)})}function B(){var e=document.querySelector("#gist-embed-message");e&&e.parentNode.removeChild(e)}function Q(e){return`gist-${e}`}function J(){var e=document.querySelector(".gist-message");e&&e.classList.add("gist-visible")}function X(e){try{return document.querySelector(`#${e}`)||null}catch{return null}}const K="gist.web.customAttributes";let Y=new Map;function Z(){const e=Array.from(Y.entries()),t=new Date;t.setDate(t.getDate()+30),r(K,e,t),i(`Saved ${Y.size} custom attributes to storage with TTL of 30 days`)}!function(){const e=c(K);if(e)try{Y=new Map(e)}catch{Y=new Map}else Y=new Map}();const ee="gist.web.message.broadcasts",te=60;async function ne(e){const t=await ae();if(!t)return;const n=new Date;n.setMinutes(n.getMinutes()+te),r(t,e.filter(ie),n)}async function se(e,t){return c(e).find((e=>e.queueId===t))}function ie(e){return e.properties&&e.properties.gist&&e.properties.gist.broadcast}async function ae(){const e=await O();return e?`${ee}.${e}`:null}function oe(e,t){return`${e}.${t}.numberOfTimesShown`}function re(e,t){return`${e}.${t}.shouldShow`}const ce="gist.web.message.user",ue=60;async function de(e){const t=await ge();if(!t)return;const n=e.filter((e=>!(e.properties&&e.properties.gist&&e.properties.gist.broadcast))),s=new Date;s.setMinutes(s.getMinutes()+ue),r(t,n,s)}async function ge(){const e=await O();return e?`${ce}.${e}`:null}async function le(){const e=await O();return e?`${ce}.${e}.seen`:null}async function me(e){const t=await O();return t?`${ce}.${t}.message.${e}.loading`:null}async function fe(e){if(Ue.isDocumentVisible){if(Ue.overlayInstanceId)return i(`Message ${Ue.overlayInstanceId} already showing.`),null;var t=H(e);return e.instanceId=b(),e.overlay=!0,e.firstLoad=!0,e.shouldResizeHeight=!0,e.shouldScale=t.shouldScale,e.renderStartTime=(new Date).getTime(),Ue.overlayInstanceId=e.instanceId,Ue.currentMessages.push(e),be(e)}return i("Document hidden, not showing message now."),null}async function he(e,t){return Ue.isDocumentVisible?(e.instanceId=b(),e.overlay=!1,e.firstLoad=!0,e.shouldScale=!1,e.elementId=t,e.shouldResizeHeight=!z(t),e.renderStartTime=(new Date).getTime(),Ue.currentMessages.push(e),be(e,t)):(i("Document hidden, not showing message now."),null)}async function pe(e){e?(Ue.messageDismissed(e),e.overlay?await ye(!0,e):ve(e)):i(`Message with instance id: ${e.instanceId} not found`)}async function we(e){var t=H(e);e?t.persistent&&(i("Persistent message dismissed, logging view"),await De(e),await Se(e)):i(`Message with instance id: ${e.instanceId} not found`)}function ve(e){var t;$e(e.instanceId),(t=X(e.elementId))&&(t.classList.remove("gist-visible"),t.style.removeProperty("height"),t.innerHTML="")}async function ye(e,t){e?await async function(){var e=document.querySelector(".gist-message");e&&(e.classList.remove("gist-visible"),await j(300)),B()}():B(),0==Ue.currentMessages.length&&(window.removeEventListener("message",Te),window.removeEventListener("touchstart",xe)),$e(t.instanceId),Ue.overlayInstanceId=null}function be(e,t=null){if(t&&function(e){var t=X(e);return!(!t||!t.classList.contains("gist-visible"))}(t))return i(`Message ${e.messageId} already showing in element ${t}.`),null;var n={endpoint:x.ENGINE_API_ENDPOINT[Ue.config.env],siteId:Ue.config.siteId,dataCenter:Ue.config.dataCenter,messageId:e.messageId,instanceId:e.instanceId,livePreview:!1,properties:e.properties,customAttributes:Object.fromEntries(new Map(Y))},s=`${x.GIST_VIEW_ENDPOINT[Ue.config.env]}/index.html`;return window.addEventListener("message",Te),window.addEventListener("touchstart",xe),t?(G.includes(t)&&function(e){const t=document.createElement("div");t.id=e,"x-gist-top"===e?document.body.insertBefore(t,document.body.firstChild):document.body.insertAdjacentElement("beforeend",t),i("Top & bottom elements injected into page")}(t),function(e,t,n,s){var a=X(e);if(a){var o=Q(n.instanceId);a.classList.add(o);var r=H(n),c=r.messageWidth+"px";V.includes(e)&&!r.hasCustomWidth&&(c="100%"),G.includes(e)&&(a.style.width=c),z(e)||(a.style.height="0px"),a.innerHTML=function(e,t,n){var s=function(e,t,n){var s=800;return t.messageWidth>s&&(s=t.messageWidth),`\n <div id="gist-embed">\n <style>\n #x-gist-floating-top, #x-gist-floating-top-left, #x-gist-floating-top-right {\n position: fixed;\n top: 0px;\n z-index: 1000000;\n }\n #x-gist-floating-bottom, #x-gist-floating-bottom-left, #x-gist-floating-bottom-right {\n position: fixed;\n bottom: 0px;\n z-index: 1000000;\n }\n #x-gist-bottom, #x-gist-top, #x-gist-floating-top, #x-gist-floating-bottom {\n left: 50%;\n transform: translate(-50%, 0%);\n }\n #x-gist-floating-top-right, #x-gist-floating-bottom-right {\n right: 0px;\n }\n #gist-embed {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container {\n position: relative;\n height: 100%;\n width: 100%;\n }\n #gist-embed-container .gist-frame {\n height: 100%;\n width: 100%;\n border: none;\n }\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n transition: height 0.1s ease-in-out;\n }\n @media (max-width: ${s}px) {\n #x-gist-top.${e},\n #x-gist-bottom.${e},\n #x-gist-floating-top.${e},\n #x-gist-floating-bottom.${e},\n #x-gist-floating-top-left.${e},\n #x-gist-floating-top-right.${e},\n #x-gist-floating-bottom-left.${e},\n #x-gist-floating-bottom-right.${e} {\n width: 100% !important;\n }\n }\n </style>\n <div id="gist-embed-container">\n <iframe id="${e}" class="gist-frame" src="${n}"></iframe>\n </div>\n </div>`}(Q(t.instanceId),n,e);return s}(t,n,r),F(o,s)}else i(`Message could not be embedded, elementId ${e} not found.`)}(t,s,e,n)):function(e,t,n){document.body.insertAdjacentHTML("afterbegin",function(e,t){var n=H(t),s=function(e,t,n){var s=600;return t.messageWidth>s&&(s=t.messageWidth),`\n <div id="gist-embed-message">\n <style>\n #gist-overlay.gist-background {\n position: fixed;\n z-index: 9999999998;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n background-color: ${t.overlayColor};\n visibility: hidden;\n }\n #gist-overlay.gist-background.gist-visible {\n visibility: visible;\n }\n .gist-message {\n width: ${t.messageWidth}px;\n position: absolute;\n border: none;\n opacity: 0;\n transition: opacity 0.3s ease-in-out, height 0.1s ease-in-out;\n z-index: 9999999999;\n left: 50%;\n transform: translateX(-50%);\n }\n .gist-message.gist-visible {\n opacity: 1;\n pointer-events: auto;\n }\n .gist-message.gist-center {\n transform: translate(-50%, -50%);\n top: 50%;\n }\n .gist-message.gist-bottom {\n bottom: 0;\n }\n .gist-message.gist-top {\n top: 0;\n }\n @media (max-width: ${s}px) {\n .gist-message {\n width: 100%;\n }\n }\n </style>\n <div id="gist-overlay" class="gist-background">\n <iframe id="${e}" class="gist-message" src="${n}"></iframe>\n </div>\n </div>`}(Q(t.instanceId),n,e);return s}(e,t)),F(Q(t.instanceId),n)}(s,e,n),e}async function Se(e){i(`Message shown, logging view for: ${e.messageId}`);var t={};null!=e.queueId?(await De(e),t=await async function(e){try{return await T().post(`/api/v1/logs/queue/${e}`)}catch(e){return e.response}}(e.queueId)):t=await async function(e){try{return await T().post(`/api/v1/logs/message/${e}`)}catch(e){return e.response}}(e.messageId),200===t.status?i("Message view logged"):i(`Problem logging message: ${t.status}`)}function Ie(e){return Ue.currentMessages.find((t=>t.instanceId===e))}function $e(e){Ue.currentMessages=Ue.currentMessages.filter((t=>t.instanceId!==e))}function Ee(e,t){$e(e),Ue.currentMessages.push(t)}function xe(){}async function Te(e){if(e.data.gist&&e.origin===x.RENDERER_HOST){var t=e.data.gist.instanceId,n=Ie(t);if(!n)return;var s=H(n);switch(e.data.gist.method){case"routeLoaded":var a=.001*((new Date).getTime()-n.renderStartTime);i(`Engine render for message: ${n.messageId} timer elapsed in ${a.toFixed(3)} seconds`),async function(e){const t=await me(e);if(!t)return!1;u(t)}(n.queueId),n.currentRoute=e.data.gist.parameters.route,n.firstLoad&&(n.overlay?function(e){var t=H(e),n=document.querySelector("#gist-overlay");if(n){n.classList.add("gist-visible");var s=document.querySelector(".gist-message");e.position?s.classList.add("gist-"+e.position):s.classList.add("gist-center"),setTimeout(J,100),t.exitClick&&setTimeout((()=>function(e){var t=document.querySelector("#gist-overlay");t&&t.addEventListener("click",(function(){Ue.dismissMessage(e)}))}(e.instanceId)),1e3)}else B()}(n):(l=X(n.elementId))&&l.classList.add("gist-visible"),Ue.messageShown(n),s.persistent?i("Persistent message shown, skipping logging view"):await Se(n),n.firstLoad=!1),Ee(t,n);break;case"tap":var o=e.data.gist.parameters.action,r=e.data.gist.parameters.name;if(Ue.messageAction(n,o,r),e.data.gist.parameters.system&&!s.persistent){await pe(n);break}try{var c=new URL(o);if(c&&"gist:"===c.protocol)switch(c.href.replace("gist://","").split("?")[0]){case"close":await pe(n),await we(n),await ke(n),await Pe();break;case"showMessage":var d=c.searchParams.get("messageId"),g=c.searchParams.get("properties");d&&(g&&(g=JSON.parse(atob(g))),await Ue.showMessage({messageId:d,properties:g}));break;case"loadPage":(c=c.href.substring(c.href.indexOf("?url=")+5))&&(c.startsWith("mailto:")||c.startsWith("https://")||c.startsWith("http://")||c.startsWith("/")?window.location.href=c:window.location.href=window.location+c)}}catch{}break;case"routeChanged":n.currentRoute=e.data.gist.parameters.route,n.renderStartTime=(new Date).getTime(),Ee(t,n),i(`Route changed to: ${n.currentRoute}`);break;case"sizeChanged":i(`Size Changed Width: ${e.data.gist.parameters.width} - Height: ${e.data.gist.parameters.height}`),n.elementId&&!n.shouldResizeHeight||function(e,t){var n=X(e.elementId?e.elementId:Q(e.instanceId));if(n){var s=n.style;if(t.height>0)if(t.height>window.innerHeight){var i=1-(t.height/window.innerHeight-1);e.shouldScale&&i>=.4?(s.height=`${t.height}px`,s.transform=`translateX(-50%) translateY(-50%) scale(${i})`):s.height=`${window.innerHeight}px`}else s.height=`${t.height}px`}}(n,e.data.gist.parameters);break;case"titleChanged":i(`Overlay title changed to: ${e.data.gist.parameters.title}`),function(e,t){var n=X(Q(e));n&&(n.title=t)}(t,e.data.gist.parameters.title);break;case"eventDispatched":Ue.events.dispatch("eventDispatched",{name:e.data.gist.parameters.name,payload:e.data.gist.parameters.payload});break;case"error":case"routeError":Ue.messageError(n),Ue.overlayInstanceId?ye(!1,n):ve(n)}}var l}async function De(e){i(`Logging user message view locally for: ${e.queueId}`),ie(e)?await async function(e){i(`Marking broadcast ${e} as seen.`);const t=await ae();if(!t)return;const n=await se(t,e);if(!n)return;const{broadcast:s}=n.properties.gist,a=oe(t,e),o=re(t,e);let u=c(a)||0;if(r(a,u+1),1===s.frequency.count)r(o,!1),i(`Marked broadcast ${e} as seen.`);else{let t=new Date;t.setSeconds(t.getSeconds()+s.frequency.delay),r(o,!1,t),i(`Marked broadcast ${e} as seen, broadcast was seen ${u+1} times, next show date is ${t}.`)}}(e.queueId):await async function(e){const t=await le();if(!t)return;const n=c(t)??[];n.push(e),r(t,n)}(e.queueId)}async function ke(e){ie(e)&&(i(`Logging broadcast dismissed locally for: ${e.queueId}`),await async function(e){i(`Marking broadcast ${e} as dismissed.`);const t=await ae();if(!t)return;const n=await se(t,e);if(!n)return;const{broadcast:s}=n.properties.gist;!0!==s.frequency.ignoreDismiss?(r(re(t,e),!1),i(`Marked broadcast ${e} as dismissed and will not show again.`)):i(`Broadcast ${e} is set to ignore dismiss.`)}(e.queueId))}var Ce=(e,t)=>e().then((e=>new Promise((t=>setTimeout(t,e))))(t).then((()=>Ce(e,t)))),Me=!1;let Re=null;async function qe(){Me?await Pe():U()?(i("Queue watcher started"),Me=!0,Ce((()=>new Promise((()=>async function(){if(x.hasActiveSSEConnection())return!x.isSSEConnectionManagedBySDK()&&Re&&(i("Not the main instance, closing our SSE connection."),Ne()),void await Pe();Re&&(i("SSE connection not active, closing it."),Ne()),!x.useSSE()||N()?await Le():await async function(){Ne();const e=null===(t=_())?(i("No user token available for SSE endpoint."),null):x.GIST_QUEUE_REALTIME_API_ENDPOINT[Ue.config.env]+`/api/v3/sse?userToken=${t}&siteId=${Ue.config.siteId}&sessionId=${q()}`;var t;if(null===e)return i("SSE endpoint not available, falling back to polling."),void await Le();i(`Starting SSE queue listener on ${e}`),Re=new EventSource(e),x.setActiveSSEConnection(),Re.addEventListener("connected",(async e=>{try{i("SSE connection received:"),x.setUseSSEFlag(!0);var t=JSON.parse(e.data);t.heartbeat&&(x.setSSEHeartbeat(t.heartbeat),i(`SSE heartbeat set to ${t.heartbeat} seconds`)),x.setActiveSSEConnection()}catch(e){i(`Failed to parse SSE settings: ${e}`)}u(M),await Le()})),Re.addEventListener("messages",(async e=>{try{var t=JSON.parse(e.data);i("SSE message received:"),await de(t),await ne(t),await Pe()}catch(e){i("Failed to parse SSE message"),Ne()}})),Re.addEventListener("error",(async e=>{i("SSE error received:"),Ne()})),Re.addEventListener("heartbeat",(async e=>{i("SSE heartbeat received:"),x.setActiveSSEConnection(),x.setUseSSEFlag(!0)}))}()}()))),1e3)):i("User token not setup, queue not started.")}async function Pe(){var e=await async function(){const e=await ae();return e?(c(e)??[]).filter((t=>{const{broadcast:n}=t.properties.gist,s=c(re(e,t.queueId))??!0,i=c(oe(e,t.queueId))||0,a=0===n.frequency.count;return s&&(a||i<n.frequency.count)})):[]}(),t=await async function(){const e=await ge();if(!e)return[];const t=c(e)??[],n=await async function(){const e=await le();return e?c(e)??[]:[]}();return t.filter((e=>!n.includes(e.queueId)))}(),n=e.concat(t);i(`Messages in local queue: ${n.length}`);var s=n.sort(((e,t)=>e.priority-t.priority));for(const e of s)await Ae(e)}async function Ae(e){var t=H(e);if(t.hasRouteRule){var n=Ue.currentRoute;null==n&&(n=new URL(window.location.href).pathname);var s=t.routeRule;if(i(`Verifying route ${n} against rule: ${s}`),!new RegExp(s).test(n))return i(`Route ${n} does not match rule.`),!1}if(t.hasPosition&&(e.position=t.position),t.persistent||function(e){if(!ie(e))return!1;const{broadcast:t}=e.properties.gist;return 0===t.frequency.delay&&0===t.frequency.count}(e)||!await async function(e){const t=await me(e);return!!t&&null!==c(t)}(e.queueId)){var a;return(a=t.isEmbedded?await he(e,t.elementId):await fe(e))&&async function(e){const t=await me(e);if(!t)return!1;r(t,!0,new Date(Date.now()+5e3))}(e.queueId),a}return i(`Not showing message with queueId ${e.queueId} because its already loading.`),!1}async function Le(){if(U())if(Ue.isDocumentVisible)if(null===c(M)){var e=await async function(){var e;try{if(!C){C=!0;var t={"X-Gist-User-Anonymous":N(),"Content-Language":null!==c(D)?c(D):navigator.language};e=await T().post(`/api/v3/users?sessionId=${q()}`,{},{headers:t})}}catch(t){t.response?e=t.response:i(`Error getting user queue: ${t}`)}finally{C=!1,function(e){if(e&&e.headers){var t=e.headers["x-gist-queue-polling-interval"];t&&t>0&&(k=t)}var n=new Date((new Date).getTime()+1e3*k);r(M,k,n)}(e),function(e){const t="true"===e?.headers?.["x-cio-use-sse"]?.toLowerCase();x.setUseSSEFlag(t)}(e)}return e}(),t=[];e?(200===e.status||204===e.status?(i("200 response, updating local store."),de(t=e.data),ne(t)):304===e.status&&i("304 response, using local store."),await Pe()):i("There was an error while checking message queue.")}else i("Next queue pull scheduled for later.");else i("Document not visible, skipping queue check.");else i("User token reset, skipping queue check.")}function Ne(e=!1){e&&x.removeActiveSSEConnection(),(e||x.isSSEConnectionManagedBySDK())&&x.setUseSSEFlag(!1),Re&&(i("Stopping SSE queue listener..."),Re.close(),Re=null)}const Ue=class{static async setup(e){this.events=new s,this.config={useAnonymousSession:void 0!==e.useAnonymousSession&&e.useAnonymousSession,siteId:e.siteId,dataCenter:e.dataCenter,env:void 0===e.env?"prod":e.env,logging:void 0!==e.logging&&e.logging,experiments:void 0!==e.experiments&&e.experiments},this.currentMessages=[],this.overlayInstanceId=null,this.currentRoute=null,this.isDocumentVisible=!0,this.config.isPreviewSession=function(){const e=new URLSearchParams(window.location.search).get("cioPreviewId");return e&&(sessionStorage.setItem(o,!1),Ue.setUserToken(e),i(`Preview mode enabled with user token: ${e}`)),!d()}(),function(){const e=g();for(let t=e.length-1;t>=0;t--)l(e.key(t))}(),i(`Setup complete on ${this.config.env} environment.`),!this.config.isPreviewSession&&this.config.useAnonymousSession&&W(),await qe(),document.addEventListener("visibilitychange",(async()=>{"hidden"===document.visibilityState?this.isDocumentVisible=!1:(this.isDocumentVisible=!0,await Pe())}),!1)}static async setCurrentRoute(e){this.currentRoute=e,i(`Current route set to: ${e}`),await Pe()}static async setUserToken(e,t){this.config.isPreviewSession||(function(e,t){void 0===t&&(t=new Date).setDate(t.getDate()+30),r(P,e,t),N()&&(u(M),u(A)),i(`Set user token "${e}" with expiry date set to ${t}`)}(e,t),Ne(!0),await qe())}static setUserLocale(e){var t;r(D,t=e),i(`Set user locate to "${t}"`)}static setCustomAttribute(e,t){return function(e,t){return e&&"string"==typeof e?(Y.set(e,t),Z(),i(`Set custom attribute "${e}" to "${t}"`),!0):(i(`Invalid key for custom attribute: ${e}`),!1)}(e,t)}static clearCustomAttributes(){Y.clear(),u(K),i("Cleared all custom attributes")}static removeCustomAttribute(e){return function(e){if(!e||"string"!=typeof e)return i(`Invalid key for custom attribute: ${e}`),!1;const t=Y.has(e);return Y.delete(e),Y.size>0?Z():u(K),i(`Removed custom attribute "${e}"`),t}(e)}static async clearUserToken(){this.config.isPreviewSession||(u(P),i("Cleared user token"),this.config.useAnonymousSession&&W(),Ne(!0),await qe())}static async dismissMessage(e){var t=Ie(e);await pe(t),await we(t),await ke(t),await Pe()}static async embedMessage(e,t){var n=await he(e,t);return n?n.instanceId:null}static async showMessage(e){var t=await fe(e);return t?t.instanceId:null}static messageShown(e){i(`Message shown: ${e.messageId}`),this.events.dispatch("messageShown",e)}static messageDismissed(e){null!==e&&(i(`Message dismissed: ${e.messageId}`),this.events.dispatch("messageDismissed",e))}static messageError(e){i(`Message error: ${e.messageId}`),this.events.dispatch("messageError",e)}static messageAction(e,t,n){i(`Message action: ${e.currentRoute}, ${t} with name ${n} on ${e.instanceId}`),this.events.dispatch("messageAction",{message:e,action:t,name:n})}}},44:(e,t,n)=>{const s=n(998).A;e.exports=s}},t={};function n(s){var i=t[s];if(void 0!==i)return i.exports;var a=t[s]={exports:{}};return e[s](a,a.exports,n),a.exports}return n.d=(e,t)=>{for(var s in t)n.o(t,s)&&!n.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n(44)})()));
@@ -0,0 +1,10 @@
1
+ import globals from 'globals';
2
+ import pluginJs from '@eslint/js';
3
+
4
+ export default [
5
+ { languageOptions: { globals: { ...globals.browser, ...globals.node } } },
6
+ pluginJs.configs.recommended,
7
+ {
8
+ ignores: ['node_modules/*', 'dist/*'],
9
+ },
10
+ ];
@@ -0,0 +1,126 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>Gist for Web</title>
5
+ <meta content="width=device-width, initial-scale=1" name="viewport" />
6
+ <meta charset="utf-8" />
7
+ <link href="styles.css" rel="stylesheet">
8
+ </head>
9
+ <body>
10
+ <div id="banner"></div>
11
+ <div class="row header">
12
+ <h1>Gist for Web</h1>
13
+ </div>
14
+ <div class="row examples">
15
+ <a href="#" class="button" onClick="showHTMLMessage()">Show HTML Message</a>
16
+ <a href="#" class="button" onClick="showSimpleMessage()">Show Simple Message</a>
17
+ <a href="#" class="button" onClick="showMessageWithProperties()">Show Message With Properties</a>
18
+ <a href="#" class="button" onClick="showComplexMessage()">Show Complex Message</a>
19
+ <a href="#" class="button" onClick="embedBanner()">Embed Banner</a>
20
+ <a href="#" class="button" onClick="embedFloatingMessage()">Embed Floating Message</a>
21
+ <a href="#" class="button" onClick="embedHTMLFloatingMessage()">Embed HTML Floating Message</a>
22
+ <a href="#" class="button" onClick="addAnonymousCustomAttribute()">Set Anonymous Custom Attribute</a>
23
+ <a href="#" class="button" onClick="logIn()">Log In</a>
24
+ <a href="#" class="button" onClick="logOut()">Log Out</a>
25
+ </div>
26
+ <div class="row docs">
27
+ <p>More information can be found on our <a target="_blank" href="https://docs.gist.build">docs</a>, if you have any question you can email us at <a target="_blank" href="mailto:support@gist.build">support@gist.build</a></p>
28
+ </div>
29
+ <script src="../dist/gist.js"></script>
30
+ <script type="text/javascript">
31
+ var EncodedTestHTMLMessage = "eNrdWG1v2zYQ/p5fwWkfkgCWZcd2V7i2hy1dVwxpMyAphn0aKPEkcaFIgaT80qL/fUfLSRRFcpVsKwoTdiKRx7vjPc+RPM++e315fv3n77+Q1GZicTRz/4igMpl7ID3XAZQtjgi2WQaWkiil2oCdex+u3/gvveqQpBnMvSWHVa609UikpAWJoivObDpnsOQR+NuXHuGSW06FbyIqYD7sD25VWW4FLH67unxPrCJvr99dkBW3KTm/upoF5WApaOzm9tm1ULEN+XT36lqMDvgxzbjYTMlPGs31iKHS+AY0j1/dyX4+unvsZ2AMTeCNxsXU1IU0ukm0KiTzIyWUnpLv47iipvRCM9C+powXZkqGg3z9UCCjOuFySs4ejeSUMS6TpqFQrX2TUqZWUzIgZ/majPGrk5CeDHpk9+kPT5uXFPM1sAtu7B+cJWBrq2Lc5IJigGIBNbOux2dcQ2S5Qp9x1UUm9xh5qzT/iEGn4jnm/i6M5fHG3/GmFPFBsmaLdOvVzgjPkpqhLc+mZPQomCnwJLVNI1GhjYM1Vxw90M1mLaybV7Zlm+EfAWF/+Uj1jjCj0aiZD44pZLAntr9qzvZHNEGJh8pdj28hw3ELfgkfslJDDtSeTHpkGOvThikJzevcbY18PxQqumn0rCFhBoMfwi/kzLgeu6dQJoKHyLlGBU+kzzEOplmgFXfXrMYdg5cJUF8QJt3IEKAGnhioaaqWoLuEa/IiHHVR3omWL9poOdi2lv1o0sYDU+glbK7cDn5BQxCmhZkdcDM5xbMhBLsCaNthlEJwrnGdNTNu6f4W5GZ4qxEYd0rMilnaCNXWJINIaVoyA0EDLbiEzjuK+zsLdofYLCjP2Zk7xXbnG+NLEglqzNyrHkre/ZFXFamQqyJRl6odBTXJRummPb1hXn1ulZ0eUfJc8OjmbiV9pEbGjTk5fdWia6vP7epGR3MvtTY30yBA1WBNP0FP+mHBBQtudzcT8AwVm8DRFjCDhDLQz2XiYf7jHeTcvZOfC2uVbHM/QP8bItLS3Sn4TdL3qeotrlNuCH4oKZOJ3K6nvPRQ4ggmMQouyXokVSuyUoVgZKMKNwaE2x+/luNfZk/rrPvTa8+sZ3Lok7t4To8vcydNhsef95LqeWH4b8LSlRXDFugadXQT7SDWReTfonN2AOicHSw6owNAZ3Sw6IwPAJ3xwaIzOQB0Jt8iOnuGv9bFpxtO1RmPSqMnXHuqiLxGouEN0MQc2BNZXFVz1VHHNxDr+zLPW1zgZR9vxMYSozIgWF/dYAnf7j19nKwqB/lBi5NjV0JgBZEolQjoRyo77pFdBsccS25VWD9TGrDbUu1q9OO/QkHlDea1t7hENYRLvJBLWKFAOAtoexiV/p99rLqENabGqhfr9QRaveqOXq2r8rp7nAVlkYo1q/vN+B8CSHpg";
32
+ /*
33
+ Dev Setup Options
34
+ { siteId: "siteid", dataCenter: "us", env: "dev", logging: true }
35
+ */
36
+ Gist.setup({ siteId: "a5ec106751ef4b34a0b9", dataCenter: "eu", logging: true, env: "prod", useAnonymousSession: true });
37
+ Gist.setUserToken("ABC123");
38
+ Gist.setCurrentRoute("home");
39
+
40
+ Gist.events.on("messageShown", message => {
41
+ console.log(`onMessageShown: ${message.messageId} with instanceId: ${message.instanceId}`);
42
+ });
43
+
44
+ Gist.events.on("messageDismissed", message => {
45
+ console.log(`onMessageDismissed: ${message.messageId} with instanceId: ${message.instanceId}`);
46
+ });
47
+
48
+ Gist.events.on("messageError", message => {
49
+ console.log(`onMessageError: ${message.messageId} with instanceId: ${message.instanceId}`);
50
+ });
51
+
52
+ Gist.events.on("messageAction", params => {
53
+ console.log(`onMessageAction, Action: ${params.action} with name ${params.name} on route: ${params.message.currentRoute} with instanceId: ${params.message.instanceId}`);
54
+ });
55
+
56
+ function showHTMLMessage() {
57
+ Gist.showMessage(
58
+ {
59
+ messageId: 'html-message',
60
+ position: 'center',
61
+ properties: {
62
+ gist: {
63
+ encodedMessageHtml: EncodedTestHTMLMessage
64
+ }
65
+ }
66
+ }
67
+ );
68
+ }
69
+
70
+ function logIn() {
71
+ Gist.setUserToken("ABC456");
72
+ }
73
+
74
+ function logOut() {
75
+ Gist.clearUserToken();
76
+ }
77
+
78
+ function showComplexMessage() {
79
+ Gist.showMessage({messageId: 'version-2-0', position: 'center'});
80
+ }
81
+
82
+ function showSimpleMessage() {
83
+ Gist.showMessage({messageId: 'welcome', position: 'center'});
84
+ }
85
+
86
+ function showMessageWithProperties() {
87
+ Gist.showMessage(
88
+ {
89
+ messageId: 'artists',
90
+ position: 'center',
91
+ properties: {
92
+ gist: { 'scale': true },
93
+ title: 'Top Artists',
94
+ list: [ { name: 'Beatles', discography: [ 'Please Please Me', 'With The Beatles', 'A Hard Day’s Night', 'Beatles For Sale', 'Help!', 'Rubber Soul', 'Revolver', 'Sgt Pepper’s Lonely Hearts Club Band', 'The Beatles', 'Yellow Submarine', 'Abbey Road', 'Let It Be' ] }, { name: 'The Doors', discography: ['The Doors', 'Strange Days', 'Waiting for the Sun', 'The Soft Parade', 'Absolutely Live', 'Morrison Hotel', 'L.A. Woman', 'Other Voices', 'Full Circle', 'An American Prayer'] }]
95
+ }
96
+ });
97
+ }
98
+
99
+ function embedBanner() {
100
+ // Loads example-banner message in element id "banner".
101
+ Gist.embedMessage({ messageId: "example-banner" }, "banner");
102
+ }
103
+
104
+ function embedFloatingMessage() {
105
+ // Loads example-notice message in a Gist preset position.
106
+ // Available positions are: "x-gist-top", "x-gist-floating-top", "x-gist-bottom", "x-gist-floating-bottom", "x-gist-floating-bottom-left", "x-gist-floating-bottom-right", "x-gist-floating-top-left", "x-gist-floating-top-right".
107
+ Gist.embedMessage({ messageId: "example-notice" }, "x-gist-floating-bottom-right");
108
+ }
109
+
110
+ function embedHTMLFloatingMessage() {
111
+ Gist.embedMessage({
112
+ messageId: 'embed-html-message',
113
+ properties: {
114
+ gist: {
115
+ encodedMessageHtml: EncodedTestHTMLMessage
116
+ }
117
+ }
118
+ }, "x-gist-floating-bottom-right");
119
+ }
120
+
121
+ function addAnonymousCustomAttribute() {
122
+ Gist.setCustomAttribute("cio_anonymous_id", "123456");
123
+ }
124
+ </script>
125
+ </body>
126
+ </html>
@@ -0,0 +1,55 @@
1
+ html, body {
2
+ padding: 0px;
3
+ margin: 0px;
4
+ font-family: Sans-Serif;
5
+ font-weight: 400;
6
+ font-size: 18px;
7
+ line-height: 1.4;
8
+ }
9
+
10
+ .row {
11
+ margin: 0px 16px;
12
+ display: flex;
13
+ }
14
+
15
+ .row.examples {
16
+ flex-wrap: wrap;
17
+ gap: 16px;
18
+ }
19
+
20
+ h1 {
21
+ font-size: 34px;
22
+ line-height: 1.5;
23
+ }
24
+
25
+ .button {
26
+ display: flex;
27
+ font-size: 15px;
28
+ font-weight: bold;
29
+ background-color: #e76f51;
30
+ color: #fff;
31
+ border-radius: 10px;
32
+ min-width: 100px;
33
+ padding: 10px;
34
+ font-style: normal;
35
+ text-decoration: none;
36
+ height: 60px;
37
+ justify-content: center;
38
+ align-items: center;
39
+ padding: 16px;
40
+ }
41
+
42
+ #banner {
43
+ opacity: 0;
44
+ transition: opacity 0.5s ease-in-out;
45
+ }
46
+
47
+ #banner.gist-visible {
48
+ opacity: 1;
49
+ }
50
+
51
+ @media (max-width: 800px) {
52
+ .button {
53
+ width: 100%;
54
+ }
55
+ }
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ declare module 'customerio-gist-web';
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import Gist from './dist/gist.min.js';
2
+ export default Gist;
package/package.json ADDED
@@ -0,0 +1,49 @@
1
+ {
2
+ "name": "customerio-gist-web",
3
+ "version": "0.0.0-test-oidc",
4
+ "description": "Build beautiful in-app flows with no code and deliver them instantly to your app. http://customer.io",
5
+ "private": false,
6
+ "scripts": {
7
+ "start": "npm-run-all --parallel watch:server watch:build",
8
+ "build:prod": "webpack --mode=production --output-filename gist.min.js",
9
+ "watch:build": "webpack --watch --progress --mode=development",
10
+ "watch:server": "http-server"
11
+ },
12
+ "browser": "dist/gist.min.js",
13
+ "exports": {
14
+ "require": "./dist/gist.min.js",
15
+ "import": "./src/index.js"
16
+ },
17
+ "author": "Customer.io (https://customer.io)",
18
+ "license": "SEE LICENSE IN LICENSE",
19
+ "devDependencies": {
20
+ "@eslint/js": "^9.13.0",
21
+ "eslint": "^9.13.0",
22
+ "globals": "^15.11.0",
23
+ "http-server": "^14.1.1",
24
+ "npm-run-all": "^4.1.5",
25
+ "webpack": "^5.91.0",
26
+ "webpack-cli": "^5.1.4"
27
+ },
28
+ "dependencies": {
29
+ "uuid": "^8.3.2"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git://github.com/customerio/gist-web.git"
34
+ },
35
+ "keywords": [
36
+ "gist",
37
+ "in-app",
38
+ "messages",
39
+ "product",
40
+ "messaging",
41
+ "in-product",
42
+ "gist.build",
43
+ "customerio"
44
+ ],
45
+ "bugs": {
46
+ "url": "https://github.com/customerio/gist-web/issues"
47
+ },
48
+ "homepage": "https://github.com/customerio/gist-web"
49
+ }