Skip to content

Instantly share code, notes, and snippets.

View ayyash's full-sized avatar

Ayyash ayyash

View GitHub Profile
@ayyash
ayyash / index.ts
Created October 2, 2022 17:57
Rewriting Execute function
export async function execute(
options: IOptions,
context: BuilderContext,
): Promise<BuilderOutput> {
// read browser options and setup the clientPath
const browserTarget = targetFromTargetString(options.browserTarget);
const browserOptions = (await context.getTargetOptions(browserTarget)) as any;
const clientPath = path.resolve(context.workspaceRoot, browserOptions.outputPath );
@ayyash
ayyash / angular.json
Created October 2, 2022 17:55
Minimun required specs for Angular Prerender
{
"newProjectRoot": "projects",
"projects": {
"cr": {
// ...
"prefix": "cr",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
@ayyash
ayyash / worker.ts
Created October 2, 2022 17:54
The PreRender worker function
export async function PreRender({
indexFile,
clientPath,
serverBundlePath,
route,
}: RenderOptions): Promise<RenderResult> {
const result = {} as RenderResult;
// this is the index.html
@ayyash
ayyash / index.ts
Last active October 2, 2022 17:52
Rewriting _renderUniversal
// in index.ts, simplify
async function _renderUniversal(
routes: string[],
context: BuilderContext,
clientPath: string,
serverPath: string,
indexFile: string
): Promise<BuilderOutput> {
// the server bundle is server/main.js
@ayyash
ayyash / index.ts
Last active September 30, 2022 12:09
Skimmed down version of nguniversal prerender builder
import {
BuilderContext,
BuilderOutput,
createBuilder,
targetFromTargetString,
} from '@angular-devkit/architect';
// import { BrowserBuilderOptions } from '@angular-devkit/build-angular';
// import { normalizeOptimization } from '@angular-devkit/build-angular/src/utils/normalize-optimization';
// import { augmentAppWithServiceWorker } from '@angular-devkit/build-angular/src/utils/service-worker';
import * as fs from 'fs';
// GTM service
declare let dataLayer: any[]; // Declare google tagexport enum EnumGtmSource {
// any source in web is added here
// left side is internal, right side is GTM
ProductsList = 'products list',
ProductsRelatedList = 'products related',
ProjectsList = 'projects list',
// ...etc
}
export enum EnumGtmEvent {
source product - details homepage - navigation Totals
action click drag click
Event name Event count Event count Event count Event Count
Totals xxxx xxxx xxxx xxxx
gr_upload xxxx xxxx xxxx xxxx
Event Trigger Parameters
page_view (web) each time the page loads or the browser history state is changed by the active site. Collected by default via enhanced measurement. page_location (page URL), page_referrer (previous page URL), engagement_time_msec. In addition to the default language, page_location, page_referrer, page_title, screen_resolution
source product - search product - details homepage - campaign Totals
Event name Event count Event count Event count Event Count
Totals xxxx xxxx xxxx xxxx
gr_reveal xxxx xxxx xxxx xxxx

Keybase proof

I hereby claim:

  • I am ayyash on github.
  • I am ayyash (https://keybase.io/ayyash) on keybase.
  • I have a public key ASB222Q-DYxTyDYW6UKnD79RjNCMY8mvd4i3zjPju2tO8Ao

To claim this, I am signing this object: