Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spot ad integration #76

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ VITE_APP_BASE_LINK=https://t.me/test_bot/test
VITE_SENTRY_DSN=https://user@password.sentry.io/projectId
VITE_ANALYTICS_KEY=G-AAAAAAAAA
VITE_ADSGRAM_BLOCK_ID=0000
VITE_SPOT_AD_KEY=spot-123

# Private variables
SENTRY_URL="https://sentry.io"
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/build_dev_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ env:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
VITE_BACKEND_URL: ${{ secrets.VITE_BACKEND_URL }}
VITE_AMPLITUDE_API_KEY: ${{ secrets.VITE_AMPLITUDE_API_KEY }}
VITE_VITE_ANALYTICS_KEY: ${{ secrets.VITE_ANALYTICS_KEY }}
VITE_ANALYTICS_KEY: ${{ secrets.VITE_ANALYTICS_KEY }}
VITE_APP_BASE_LINK: ${{ secrets.VITE_APP_BASE_LINK }}
VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }}
VITE_ADSGRAM_BLOCK_ID: ${{ secrets.VITE_ADSGRAM_BLOCK_ID }}
VITE_SPOT_AD_KEY: ${{secrets.VITE_SPOT_AD_KEY }}

jobs:
build:
Expand Down Expand Up @@ -65,10 +66,11 @@ jobs:
--build-arg SENTRY_URL=$SENTRY_URL \
--build-arg VITE_BACKEND_URL=$VITE_BACKEND_URL \
--build-arg VITE_AMPLITUDE_API_KEY=$VITE_AMPLITUDE_API_KEY \
--build-arg VITE_VITE_ANALYTICS_KEY=$VITE_VITE_ANALYTICS_KEY \
--build-arg VITE_ANALYTICS_KEY=$VITE_ANALYTICS_KEY \
--build-arg VITE_APP_BASE_LINK=$VITE_APP_BASE_LINK \
--build-arg VITE_SENTRY_DSN=$VITE_SENTRY_DSN \
--build-arg VITE_ADSGRAM_BLOCK_ID=$VITE_ADSGRAM_BLOCK_ID \
--build-arg VITE_SPOT_AD_KEY=$VITE_SPOT_AD_KEY \
-t ghcr.io/scalr-dex/scalr-frontend:develop . --push
- name: Trigger Dev Deploy
uses: distributhor/workflow-webhook@v3
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deployflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ jobs:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
VITE_BACKEND_URL: ${{ secrets.VITE_BACKEND_URL }}
VITE_AMPLITUDE_API_KEY: ${{ secrets.VITE_AMPLITUDE_API_KEY }}
VITE_VITE_ANALYTICS_KEY: ${{ secrets.VITE_ANALYTICS_KEY }}
VITE_ANALYTICS_KEY: ${{ secrets.VITE_ANALYTICS_KEY }}
VITE_APP_BASE_LINK: ${{ secrets.VITE_APP_BASE_LINK }}
VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }}
VITE_ADSGRAM_BLOCK_ID: ${{secrets.VITE_ADSGRAM_BLOCK_ID }}
VITE_SPOT_AD_KEY: ${{secrets.VITE_SPOT_AD_KEY }}
shell: bash
- name: Setup Pages
uses: actions/configure-pages@v2
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/workflows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ env:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
VITE_BACKEND_URL: ${{ secrets.VITE_BACKEND_URL }}
VITE_AMPLITUDE_API_KEY: ${{ secrets.VITE_AMPLITUDE_API_KEY }}
VITE_VITE_ANALYTICS_KEY: ${{ secrets.VITE_ANALYTICS_KEY }}
VITE_ANALYTICS_KEY: ${{ secrets.VITE_ANALYTICS_KEY }}
VITE_APP_BASE_LINK: ${{ secrets.VITE_APP_BASE_LINK }}
VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }}
VITE_ADSGRAM_BLOCK_ID: ${{ secrets.VITE_ADSGRAM_BLOCK_ID }}
VITE_SPOT_AD_KEY: ${{secrets.VITE_SPOT_AD_KEY }}

jobs:
build-and-lint-code:
Expand Down
6 changes: 4 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,21 @@ ARG SENTRY_AUTH_TOKEN
ARG SENTRY_URL
ARG VITE_BACKEND_URL
ARG VITE_AMPLITUDE_API_KEY
ARG VITE_VITE_ANALYTICS_KEY
ARG VITE_ANALYTICS_KEY
ARG VITE_APP_BASE_LINK
ARG VITE_SENTRY_DSN
ARG VITE_ADSGRAM_BLOCK_ID
ARG VITE_SPOT_AD_KEY

ENV SENTRY_AUTH_TOKEN=$SENTRY_AUTH_TOKEN
ENV SENTRY_URL=$SENTRY_URL
ENV VITE_BACKEND_URL=$VITE_BACKEND_URL
ENV VITE_AMPLITUDE_API_KEY=$VITE_AMPLITUDE_API_KEY
ENV VITE_VITE_ANALYTICS_KEY=$VITE_VITE_ANALYTICS_KEY
ENV VITE_ANALYTICS_KEY=$VITE_ANALYTICS_KEY
ENV VITE_APP_BASE_LINK=$VITE_APP_BASE_LINK
ENV VITE_SENTRY_DSN=$VITE_SENTRY_DSN
ENV VITE_ADSGRAM_BLOCK_ID=$VITE_ADSGRAM_BLOCK_ID
ENV VITE_SPOT_AD_KEY=$VITE_SPOT_AD_KEY

WORKDIR /app

Expand Down
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@

<!-- AD -->
<script src="scripts/adsgram.min.js"></script>
<script
src="//cdn.skypack.dev/-/spot-ads@v0.1.7-K2GlzdMythzL30OhqnRR/dist=es2019,mode=imports/optimized/spot-ads.js"
type="module"
></script>
</head>
<body>
<noscript>Please, turn on JavaScript to see this page.</noscript>
Expand Down
28 changes: 28 additions & 0 deletions src/components/Tasks/DailyTasks/AdBlock2.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import TaskUi from 'components/Tasks/TaskUi'
import env from 'helpers/env'
import { iconNumberToComponent } from 'type/UserTask'

declare global {
interface Window {
showAd: (apiKey: string, onSuccess: () => void, onError: () => void) => void
}
}

window.showAd = window.showAd || {}

export default function () {
return (
<TaskUi
icon={iconNumberToComponent(0)}
taskText="Watch short video 2"
rewardAmount={500}
onClick={() => {
window.showAd(
env.VITE_SPOT_AD_KEY,
() => alert('Success'),
() => alert('Err')
)
}}
/>
)
}
3 changes: 2 additions & 1 deletion src/helpers/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export default cleanEnv(import.meta.env, {
VITE_AMPLITUDE_API_KEY: str(),
VITE_APP_BASE_LINK: str(),
VITE_SENTRY_DSN: str(),
VITE_ANALYTICS_KEY: str({ default: 'G-EMH5CHPBXL' }),
VITE_ANALYTICS_KEY: str(),
VITE_ADSGRAM_BLOCK_ID: num(),
VITE_SPOT_AD_KEY: str(),
DEV: bool({ default: import.meta.env.DEV }),
})
Loading