Last active
November 30, 2019 17:43
-
-
Save mizchi/45543f0e6bafd2bcfba5df7e8bb0b4f2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require('express'); | |
const app = express(); | |
app.use(express.json()); | |
app.use((_req, res, next) => { | |
res.header("Access-Control-Allow-Origin", "*"); | |
res.header( | |
"Access-Control-Allow-Headers", | |
"Origin, X-Requested-With, Content-Type, Accept" | |
); | |
next(); | |
}); | |
app.post("/amp/view", (req, res) => { | |
const u = url.parse(req.query.url); | |
console.log(u); | |
res.send("ok"); | |
}); | |
app.listen(13999) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script> | |
<amp-analytics data-credentials="include"> | |
<script type="application/json"> | |
{ | |
"vars": { | |
"api_key": "dummy" | |
}, | |
"requests": { | |
"view": "http://localhost:13999/amp/view?url=${canonicalUrl}&api_key=${api_key}&id=$RANDOM" | |
}, | |
"triggers": { | |
"view": { | |
"on": "visible", | |
"request": "view" | |
} | |
}, | |
"transport": { | |
"xhrpost": true | |
} | |
} | |
</script> | |
</amp-analytics> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment