feat: implement mobile impressions (#5818)

* add resource link for React Native Text component (#5773)

* add resource link for React Native Text component

---------

Co-authored-by: Ruslan Semagin <pixel.365.24@gmail.com>
Co-authored-by: dsh <daniel.s.holdsworth@gmail.com>
Co-authored-by: Ruslan Semagin <53819609+pixel365@users.noreply.github.com>
Co-authored-by: Suman Kisku <sumankisku1@gmail.com>

* feat: add useful links for Rust (#5781)

* feat: add links about testing in Rust (#5791)

* Patch 1 (#5792)

Update 120-real-time-data.md (#5782)

Add links to pages containing brief explanations on the topics listed here.

Update well-architected framework.

---------

Co-authored-by: devgru-3-2 <95485002+devgru-3-2@users.noreply.github.com>
Co-authored-by: Danrley Senegalha Pires <dan.osp@outlook.com>

* Fix: Standardize using "docker container ls" command when referencing listing containers (#5787)

* Add reference link to React Native ImageBackground component (#5795)

* add reference link to React Native ImageBackground component

---------

Co-authored-by: Ruslan Semagin <pixel.365.24@gmail.com>
Co-authored-by: dsh <daniel.s.holdsworth@gmail.com>
Co-authored-by: Ruslan Semagin <53819609+pixel365@users.noreply.github.com>
Co-authored-by: Suman Kisku <sumankisku1@gmail.com>

* add links to the 'Modules and Crates' node in the Rust roadmap (#5797)

* fix broken go topic (#5800)

* feat: change the description and links in the 'log/slog' node (#5798)

* change the description and links in the 'log/slog' node
---------

Co-authored-by: dsh <daniel.s.holdsworth@gmail.com>

* add links for 'awk' (#5801)

* add links for 'grep' (#5808)

* Update ci-cd.md (#5807)

* Update Property Binding to most recent link (#5774)

Update 101-property-binding.md

* Added video resources for React Components (#5810)

Signed-off-by: Archit Sharma <74408634+iArchitSharma@users.noreply.github.com>

* Update 104-reference-vars.md (#5775)

* fix: return response status code (#5815)

* feat: implement topic link's label (#5817)

* feat: implement mobile impressions

* fix: add to the body

---------

Signed-off-by: Archit Sharma <74408634+iArchitSharma@users.noreply.github.com>
Co-authored-by: Juan Gerardo Eulufi Salazar <juan.eulufi.sa@gmail.com>
Co-authored-by: Ruslan Semagin <pixel.365.24@gmail.com>
Co-authored-by: dsh <daniel.s.holdsworth@gmail.com>
Co-authored-by: Ruslan Semagin <53819609+pixel365@users.noreply.github.com>
Co-authored-by: Suman Kisku <sumankisku1@gmail.com>
Co-authored-by: Yash Deore <152061059+yashdeored@users.noreply.github.com>
Co-authored-by: devgru-3-2 <95485002+devgru-3-2@users.noreply.github.com>
Co-authored-by: Danrley Senegalha Pires <dan.osp@outlook.com>
Co-authored-by: Anthony Pun <apun97@yahoo.com>
Co-authored-by: Sion Kang <siontama@gmail.com>
Co-authored-by: Liliana Santos <liliana.t.santos@hotmail.com>
Co-authored-by: Archit Sharma <74408634+iArchitSharma@users.noreply.github.com>
pull/5821/head
Arik Chakma 4 months ago committed by GitHub
parent 6372990f76
commit caf2f14e54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 12
      src/components/PageSponsor.tsx
  2. 27
      src/lib/is-mobile.ts

@ -4,6 +4,7 @@ import { sponsorHidden } from '../stores/page';
import { useStore } from '@nanostores/react'; import { useStore } from '@nanostores/react';
import { X } from 'lucide-react'; import { X } from 'lucide-react';
import { setViewSponsorCookie } from '../lib/jwt'; import { setViewSponsorCookie } from '../lib/jwt';
import { isMobile } from '../lib/is-mobile';
export type PageSponsorType = { export type PageSponsorType = {
company: string; company: string;
@ -50,6 +51,7 @@ export function PageSponsor(props: PageSponsorProps) {
`${import.meta.env.PUBLIC_API_URL}/v1-get-sponsor`, `${import.meta.env.PUBLIC_API_URL}/v1-get-sponsor`,
{ {
href: window.location.pathname, href: window.location.pathname,
mobile: isMobile() ? 'true' : 'false',
}, },
); );
@ -75,9 +77,15 @@ export function PageSponsor(props: PageSponsorProps) {
}; };
const clickSponsor = async (sponsorId: string) => { const clickSponsor = async (sponsorId: string) => {
const { response, error } = await httpPatch<{ status: 'ok' }>( const clickUrl = new URL(
`${import.meta.env.PUBLIC_API_URL}/v1-view-sponsor/${sponsorId}`, `${import.meta.env.PUBLIC_API_URL}/v1-view-sponsor/${sponsorId}`,
{}, );
const { response, error } = await httpPatch<{ status: 'ok' }>(
clickUrl.toString(),
{
mobile: isMobile() ? true : false,
},
); );
if (error || !response) { if (error || !response) {

@ -0,0 +1,27 @@
export function isAndroid(): boolean {
return (
typeof navigator !== 'undefined' && /android/i.test(navigator.userAgent)
);
}
export function isSmallIOS(): boolean {
return (
typeof navigator !== 'undefined' && /iPhone|iPod/.test(navigator.userAgent)
);
}
export function isLargeIOS(): boolean {
return (
typeof navigator !== 'undefined' &&
(/iPad/.test(navigator.userAgent) ||
(navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1))
);
}
export function isIOS(): boolean {
return isSmallIOS() || isLargeIOS();
}
export function isMobile(): boolean {
return isAndroid() || isIOS();
}
Loading…
Cancel
Save