Skip to content

Commit

Permalink
[APD-12715] Create Custom event for Google Bidding (#108)
Browse files Browse the repository at this point in the history
* [APD-12715] Migrate to manifest v3

* [APD-12715] Allow running sync without re-login to app

* [APD-12715] Create custom event and a new group with a static adUnitId

* [APD-12715] Creating custom events and new groups

* [APD-12715] Add id for remove event, fix errors

* [APD-12715] Resolve errors from console

* Revert "[APD-12715] Resolve errors from console"

This reverts commit aee656b.

* [APD-12715] Don't create the event if it exists

* [APD-12715] When creating adUnit, check if isThirdPartyBidding is present.

* [APD-12715] Add isThirdPartyBidding to schema.graphql

* [APD-12715] Create bidding adUnit if there is isThirdPartyBidding

* [APD-12715] Build params for creating a base adUnit

* [APD-12715] Remove booleanTranslator for googleOptimizedRefreshRate

* [APD-12715] Build custom adUnit name

* [APD-12715] Remove debugger

* [APD-12715] Don't check events if app is null

* [APD-12715] Fix request for update app

* [APD-12715] Fix app store details

* [APD-12715] Fix decode params

* [APD-12715] Update params for translator

* [APD-12715] Resync, creating a group for mrec

* [APD-12715] Slicing the list of CustomEvents

* [APD-12715] Create and update groups

* [APD-12715] Fix errors

* [APD-12715] Create Custom Events refactoring

* [APD-12715] Remove unused code

* [APD-12715] Edit updateMediationGroup method

* [APD-12715] price to string format, add unique customEvent to the group

* [APD-12715] bump v0.1.43

---------

Co-authored-by: NaLLiFFuNT <[email protected]>
  • Loading branch information
maksimroi and NaLLiFFuNT authored Oct 6, 2023
1 parent 78e2867 commit ff0c0aa
Show file tree
Hide file tree
Showing 27 changed files with 1,389 additions and 1,190 deletions.
4 changes: 2 additions & 2 deletions chrome-extension/background/background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ export class App {
await AuthContext.init(new LocalStorageJsonStorage());
app.api.authContext.init('accountId');
console.debug('[APP] Auth Context loaded');
console.log(`[APP] network status ${window.navigator.onLine ? 'online' : 'offline'}`);
if (!this.state.currentUser && window.navigator.onLine) {
console.log(`[APP] network status ${globalThis.navigator.onLine ? 'online' : 'offline'}`);
if (!this.state.currentUser && globalThis.navigator.onLine) {
await app.run(GetCurrentUserBackgroundJob);
}
app.api.onError.subscribe(e => {
Expand Down
6 changes: 5 additions & 1 deletion chrome-extension/background/jobs/run-sync.tab.job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {App, ExtensionState} from '../background';
import {getExtensionVersion} from '../utils/minimal-version';
import {notify} from '../utils/notifications';
import {IJob} from './job.interface';
import {CustomEventApiService} from "../../../src/core/admob-api/custom-event.api";


export class RunSyncTabJob implements IJob {
Expand All @@ -31,7 +32,8 @@ export class RunSyncTabJob implements IJob {
percent: 0,
lastEvent: null,
hasErrors: false,
isTerminated: false
isTerminated: false,
step: null
};


Expand Down Expand Up @@ -87,6 +89,7 @@ export class RunSyncTabJob implements IJob {
const adMobAccount = this.adMobAccount = currentUser.accounts.find(
acc => acc.email.toLowerCase() === extractedAdmobAccount.email.toLowerCase());

const customEventApi = new CustomEventApiService(fetch.bind(globalThis), console);

logger.info(`Sync with extension. Version ${getExtensionVersion()}`);

Expand Down Expand Up @@ -125,6 +128,7 @@ export class RunSyncTabJob implements IJob {
adMobAccount,
currentUser,
logger,
customEventApi,
id,
SyncRunner.User
);
Expand Down
11 changes: 10 additions & 1 deletion chrome-extension/background/utils/local-storage.proxy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ function loadStoredValues (key, value, exclude: string[]) {
}
}

function storeValues (key, values) {
try {
localStorage.setItem(key, JSON.stringify(values));
} catch (e) {
console.warn(e);
}

}

export function localStorageProxy<T extends Object> (storageKey, value, exclude: string[]): T {
console.debug('[localStorageProxy] start ', deepClone(value));

Expand All @@ -22,7 +31,7 @@ export function localStorageProxy<T extends Object> (storageKey, value, exclude:

const original = deepClone(value);
let timeoutID;
const save = () => localStorage.setItem(storageKey, JSON.stringify(original));
const save = () => storeValues(storageKey, original);
const getter = key => () => original[key];
const setter = key => value => {
original[key] = value;
Expand Down
7 changes: 3 additions & 4 deletions chrome-extension/background/utils/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import uuid from 'uuid';

export function notify (title, message, id?) {
id = id || uuid.v4();
const opt = {

chrome.notifications.create(id, {
type: 'basic',
title: title,
message: message,
iconUrl: 'img/icon/icon-64.png'
};

chrome.notifications.create(id, opt);
});
}

export function notifyError (e: Error) {
Expand Down
2 changes: 1 addition & 1 deletion chrome-extension/common/initSentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export function InitSentry (whereTag, listenStateFromBackground: boolean = false
beforeSend (event, hint?) {
if (hint
&& hint.originalException
&& !window.navigator.onLine
&& !globalThis.navigator.onLine
&& typeof hint.originalException === 'object'
&& hint.originalException.message === 'Network error: Failed to fetch') {
return null;
Expand Down
3 changes: 2 additions & 1 deletion chrome-extension/content-scripts/admob-content-script.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ $(document).ready(function () {
}
modal.show(
title,
`Syncing ${
`
Syncing ${
Number(syncProgress.percent).toFixed(0)
}% ${
Math.min(syncProgress.completedApps + syncProgress.failedApps + 1, syncProgress.totalApps)
Expand Down
20 changes: 7 additions & 13 deletions chrome-extension/manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"manifest_version": 2,
"manifest_version": 3,
"name": "Appodeal",
"short_name": "Appodeal Admob Sync",
"description": "This extension will create and sync Appodeal adunits in your Admob account.",
"minimum_chrome_version": "62",
"version": "20.02.00",
"browser_action": {
"version": "20.03.00",
"action": {
"default_icon": {
"16": "img/icon/icon-16.png"
},
Expand Down Expand Up @@ -58,22 +58,16 @@
}
],
"background": {
"scripts": [
"background.js"
],
"persistent": false
"service_worker": "background.js"
},
"web_accessible_resources": [
"img/*",
"js/vendor/*",
"js/helpers/*"
],
"permissions": [
"tabs",
"cookies",
"storage",
"notifications",
"identity",
"identity"
],
"host_permissions": [
"*://*.appodeal.com/*",
"*://*.admob.com/*"
],
Expand Down
12 changes: 10 additions & 2 deletions chrome-extension/popup/utils/popupClickHandlers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {Actions, TabJobs} from '../../common/actions';


const ADMOB_HOME = 'https://apps.admob.com/logout?continue=https://apps.admob.com/';
const ADMOB_HOME_WITH_RELOGIN = 'https://apps.admob.com/logout?continue=https://apps.admob.com/';
const ADMOB_ACCOUNT_ADD_OR_RECONNECT = 'https://app.appodeal.com/apps/linked_networks#AddAdmobAccount';
const ADMOB_HOME = 'https://apps.admob.com/v2/home';
const ADMOB_DASHBOARD_ROOT = 'https://apps.admob.com/';

async function navigateCurrentTab (url: string): Promise<chrome.tabs.Tab> {
return new Promise(resolve => {
Expand Down Expand Up @@ -38,7 +40,13 @@ export async function onClickStartAdmobAccountSetup () {


export async function startSyncAdmobAccount () {
const tab = await navigateCurrentTab(ADMOB_HOME);
const tabs = await chrome.tabs.query({active: true, currentWindow: true});
const tab = tabs[0];
if (tab.url && tab.url.startsWith(ADMOB_DASHBOARD_ROOT)) {
await chrome.tabs.update(tab.id, {url: ADMOB_HOME});
} else {
await chrome.tabs.update(tab.id, {url: ADMOB_HOME_WITH_RELOGIN});
}
await setCurrentJob(TabJobs.syncAdunits, tab.id);
}

Expand Down
Loading

0 comments on commit ff0c0aa

Please sign in to comment.