-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
1,002 additions
and
337 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
# Changelog | ||
|
||
### Analytics V3 | ||
1. Service now written in Go for resource efficiency and speed. | ||
2. New `GET` `/v3/campaign/:id/interaction/:iID` endpoint to get campaign data for a specific interaction | ||
3. JSON responses are now returned in streamlined Page schema | ||
4. Deprecated V1 API - will continue to function but will be removed in a future release (see Migration Guide) | ||
|
||
### Analytics V2 | ||
1. New endpoints and database schema to handle Interactions, a granular way to track campaign performance | ||
2. New endpoint to get campaign data without creating a visit | ||
|
||
### Analytics V1 | ||
1. Initial release |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,58 @@ | ||
|
||
# Analytics V1 to V2 Migration | ||
# Migration Guide | ||
|
||
This migration guide is a comprehensive guide to the changes you need to make in Notion and in your code to upgrade your analytics version. | ||
|
||
## V2 -> V3 Migration | ||
|
||
### In Notion | ||
V3 uses the exact same database format as V2, so you can keep your existing Notion database and integration. | ||
|
||
### In Code | ||
You need to update any services calling the analytics API. | ||
1. All V2 endpoints have a V3 endpoint that is functionally equivalent, so you can just update the endpoint from /v2/ to /v3/ as shown below. | ||
|
||
| method | old endpoint | new endpoint | | ||
|---|---|---| | ||
| GET | `/v2/campaign/:id` | `/v3/campaign/:id` | | ||
| POST | `/v2/campaign/:id` | `/v3/campaign/:id` | | ||
| POST | `/v2/campaign/:id/interaction` | `/v3/campaign/:id/interaction` | | ||
| POST | `/v2/campaign/:id/interaction/:interactionId` | `/v3/campaign/:id/interaction/:interactionId` | | ||
| POST | `/v2/campaign/:id/visit/:interactionId` | `/v3/campaign/:id/visit/:interactionId` | | ||
|
||
2. If you use JSON responses from the API (If `Public`=`True` for any of your campaigns), then you need to alter your code to use the new response schema as shown below. If you aren't using Public campaigns, then successes will continue returning 204 status codes and you can ignore this step. | ||
|
||
| property name | type | | ||
|---|---| | ||
| `id` | `string` | | ||
| `campaign_id` | `string` | | ||
| `parent_campaigns` | `string[]` | | ||
| `interact` | `string` | | ||
| `public` | `string` | | ||
| `ref_visits` | `number` | | ||
| `visits` | `number` | | ||
| `interactions` | `number` | | ||
|
||
You can find the documentation on the rest of the new endpoints in the README. | ||
|
||
--- | ||
|
||
## V1 -> V2 Migration | ||
|
||
### In Notion | ||
Using your existing Notion database: | ||
1. Create an property of type `Number` named `Interactions`. | ||
2. Create a property of type `Select` named `Interact` with the options `Enabled`, `Disabled`, and `Dynamic`. | ||
3. Ensure you have a property called `CreatedBy` of type `Created by`. | ||
4. Enable your database's `Subtasks` feature (using the `ParentCampaign` and `SubCampaigns` property names respectively) for better visual organization. Alternatively, just ensure the `ParentCampaign` of type `Relation` property exists. | ||
|
||
Then, you can deploy your new Analytics instance (example instructions in README) and start using the new APIs, documented there as well. | ||
### In Code | ||
The only API endpoint in V1 is forward-compatible with V2, so you can just update the endpoint from /v1/ to /v2/ as shown below. | ||
|
||
| method | old endpoint | new endpoint | | ||
|---|---|---| | ||
| POST | `/v1/campaign/:id` | `/v2/campaign/:id` | | ||
|
||
You can find the documentation on the rest of the new endpoints in the README. | ||
|
||
Your new Analytics instance and database format is still compatible with your `redirect` instance, if you are running the two alongside each other. |
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
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Build and Push Docker Image to GHCR | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: Login to GHCR | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build Docker image | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}/analytics:latest | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
|
||
.env | ||
notion/cache.json | ||
.env |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"deno.enable": true, | ||
"deno.suggest.imports.hosts": { | ||
"https://deno.land": true | ||
} | ||
"go.toolsEnvVars": { | ||
"GO111MODULE": "on" | ||
}, | ||
"dotenv.enableAutocloaking": false | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
|
||
FROM denoland/deno:alpine-1.23.1 | ||
|
||
EXPOSE 8000 | ||
|
||
# Use the official Golang image as the base image | ||
FROM golang:1.21-alpine as builder | ||
WORKDIR /app | ||
|
||
COPY deps.ts . | ||
COPY . . | ||
RUN go build ./cmd/analytics | ||
|
||
RUN deno cache deps.ts | ||
RUN deno cache main.ts | ||
# Use slim alpine image for production | ||
FROM alpine:3.18 as production | ||
WORKDIR /app | ||
COPY --from=builder /app/analytics . | ||
EXPOSE 3000 | ||
|
||
CMD ["run", "-A", "main.ts"] | ||
# Run the Go program when the container starts | ||
CMD ["./analytics"] |
Oops, something went wrong.
b734d11
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Failed to deploy: