diff --git a/examples/Angular/.browserslistrc b/examples/Angular/.browserslistrc deleted file mode 100644 index 427441dc..00000000 --- a/examples/Angular/.browserslistrc +++ /dev/null @@ -1,17 +0,0 @@ -# This file is used by the build system to adjust CSS and JS output to support the specified browsers below. -# For additional information regarding the format and rule options, please see: -# https://github.com/browserslist/browserslist#queries - -# For the full list of supported browsers by the Angular framework, please see: -# https://angular.io/guide/browser-support - -# You can see what browsers were selected by your queries by running: -# npx browserslist - -last 1 Chrome version -last 1 Firefox version -last 2 Edge major versions -last 2 Safari major versions -last 2 iOS major versions -Firefox ESR -not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line. diff --git a/examples/Angular/.editorconfig b/examples/Angular/.editorconfig deleted file mode 100644 index 59d9a3a3..00000000 --- a/examples/Angular/.editorconfig +++ /dev/null @@ -1,16 +0,0 @@ -# Editor configuration, see https://editorconfig.org -root = true - -[*] -charset = utf-8 -indent_style = space -indent_size = 2 -insert_final_newline = true -trim_trailing_whitespace = true - -[*.ts] -quote_type = single - -[*.md] -max_line_length = off -trim_trailing_whitespace = false diff --git a/examples/Angular/.gitignore b/examples/Angular/.gitignore deleted file mode 100644 index de51f68a..00000000 --- a/examples/Angular/.gitignore +++ /dev/null @@ -1,45 +0,0 @@ -# See http://help.github.com/ignore-files/ for more about ignoring files. - -# compiled output -/dist -/tmp -/out-tsc -# Only exists if Bazel was run -/bazel-out - -# dependencies -/node_modules - -# profiling files -chrome-profiler-events*.json - -# IDEs and editors -/.idea -.project -.classpath -.c9/ -*.launch -.settings/ -*.sublime-workspace - -# IDE - VSCode -.vscode/* -!.vscode/settings.json -!.vscode/tasks.json -!.vscode/launch.json -!.vscode/extensions.json -.history/* - -# misc -/.sass-cache -/connect.lock -/coverage -/libpeerconnection.log -npm-debug.log -yarn-error.log -testem.log -/typings - -# System Files -.DS_Store -Thumbs.db diff --git a/examples/Angular/README.md b/examples/Angular/README.md deleted file mode 100644 index 02fedccc..00000000 --- a/examples/Angular/README.md +++ /dev/null @@ -1,27 +0,0 @@ -# Angular - -This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 12.2.4. - -## Development server - -Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files. - -## Code scaffolding - -Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`. - -## Build - -Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory. - -## Running unit tests - -Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io). - -## Running end-to-end tests - -Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities. - -## Further help - -To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page. diff --git a/examples/Angular/angular.json b/examples/Angular/angular.json deleted file mode 100644 index 40cce8c0..00000000 --- a/examples/Angular/angular.json +++ /dev/null @@ -1,106 +0,0 @@ -{ - "$schema": "./node_modules/@angular/cli/lib/config/schema.json", - "version": 1, - "newProjectRoot": "projects", - "projects": { - "Angular": { - "projectType": "application", - "schematics": { - "@schematics/angular:application": { - "strict": true - } - }, - "root": "", - "sourceRoot": "src", - "prefix": "app", - "architect": { - "build": { - "builder": "@angular-devkit/build-angular:browser", - "options": { - "outputPath": "dist/Angular", - "index": "src/index.html", - "main": "src/main.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "tsconfig.app.json", - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "src/styles.css" - ], - "scripts": [] - }, - "configurations": { - "production": { - "budgets": [ - { - "type": "initial", - "maximumWarning": "500kb", - "maximumError": "1mb" - }, - { - "type": "anyComponentStyle", - "maximumWarning": "2kb", - "maximumError": "4kb" - } - ], - "fileReplacements": [ - { - "replace": "src/environments/environment.ts", - "with": "src/environments/environment.prod.ts" - } - ], - "outputHashing": "all" - }, - "development": { - "buildOptimizer": false, - "optimization": false, - "vendorChunk": true, - "extractLicenses": false, - "sourceMap": true, - "namedChunks": true - } - }, - "defaultConfiguration": "production" - }, - "serve": { - "builder": "@angular-devkit/build-angular:dev-server", - "configurations": { - "production": { - "browserTarget": "Angular:build:production" - }, - "development": { - "browserTarget": "Angular:build:development" - } - }, - "defaultConfiguration": "development" - }, - "extract-i18n": { - "builder": "@angular-devkit/build-angular:extract-i18n", - "options": { - "browserTarget": "Angular:build" - } - }, - "test": { - "builder": "@angular-devkit/build-angular:karma", - "options": { - "main": "src/test.ts", - "polyfills": "src/polyfills.ts", - "tsConfig": "tsconfig.spec.json", - "karmaConfig": "karma.conf.js", - "assets": [ - "src/favicon.ico", - "src/assets" - ], - "styles": [ - "src/styles.css" - ], - "scripts": [] - } - } - } - } - }, - "defaultProject": "Angular" -} diff --git a/examples/Angular/countly.d.ts b/examples/Angular/countly.d.ts new file mode 100644 index 00000000..3f1865a2 --- /dev/null +++ b/examples/Angular/countly.d.ts @@ -0,0 +1,4 @@ +declare module 'countly-sdk-web'; +interface Window { + Countly: any; +} diff --git a/examples/Angular/karma.conf.js b/examples/Angular/karma.conf.js deleted file mode 100644 index 369298c0..00000000 --- a/examples/Angular/karma.conf.js +++ /dev/null @@ -1,47 +0,0 @@ -"use strict"; - -/* eslint-disable global-require */ -// Karma configuration file, see link for more information -// https://karma-runner.github.io/1.0/config/configuration-file.html - -module.exports = function(config) { - config.set({ - basePath: "", - frameworks: ["jasmine", "@angular-devkit/build-angular"], - plugins: [ - require("karma-jasmine"), - require("karma-chrome-launcher"), - require("karma-jasmine-html-reporter"), - require("karma-coverage"), - require("@angular-devkit/build-angular/plugins/karma") - ], - client: { - jasmine: { - // you can add configuration options for Jasmine here - // the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html - // for example, you can disable the random execution with `random: false` - // or set a specific seed with `seed: 4321` - }, - clearContext: false // leave Jasmine Spec Runner output visible in browser - }, - jasmineHtmlReporter: { - suppressAll: true // removes the duplicated traces - }, - coverageReporter: { - dir: require("path").join(__dirname, "./coverage/Angular"), - subdir: ".", - reporters: [ - { type: "html" }, - { type: "text-summary" } - ] - }, - reporters: ["progress", "kjhtml"], - port: 9876, - colors: true, - logLevel: config.LOG_INFO, - autoWatch: true, - browsers: ["Chrome"], - singleRun: false, - restartOnFileChange: true - }); -}; diff --git a/examples/Angular/src/main.ts b/examples/Angular/main.ts similarity index 66% rename from examples/Angular/src/main.ts rename to examples/Angular/main.ts index c7b673cf..fdbad9ea 100644 --- a/examples/Angular/src/main.ts +++ b/examples/Angular/main.ts @@ -4,8 +4,20 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; import { AppModule } from './app/app.module'; import { environment } from './environments/environment'; +import Countly from 'countly-sdk-web'; + +window.Countly = Countly; + +Countly.init({ + app_key: "YOUR_APP_KEY", + url: "https://try.count.ly", + debug: true +}); +Countly.track_sessions(); + if (environment.production) { enableProdMode(); + } platformBrowserDynamic().bootstrapModule(AppModule) diff --git a/examples/Angular/package.json b/examples/Angular/package.json deleted file mode 100644 index 7a0be559..00000000 --- a/examples/Angular/package.json +++ /dev/null @@ -1,37 +0,0 @@ -{ - "name": "angular", - "version": "0.0.0", - "scripts": { - "ng": "ng", - "start": "ng serve", - "build": "ng build", - "watch": "ng build --watch --configuration development", - "test": "ng test" - }, - "private": true, - "devDependencies": { - "@angular/animations": "~12.2.0", - "@angular/common": "~12.2.0", - "@angular/compiler": "~12.2.0", - "@angular/core": "~12.2.0", - "@angular/forms": "~12.2.0", - "@angular/platform-browser": "~12.2.0", - "@angular/platform-browser-dynamic": "~12.2.0", - "@angular/router": "~12.2.0", - "rxjs": "~6.6.0", - "tslib": "^2.3.0", - "zone.js": "~0.11.4", - "@angular-devkit/build-angular": "~12.2.4", - "@angular/cli": "~12.2.4", - "@angular/compiler-cli": "~12.2.0", - "@types/jasmine": "~3.8.0", - "@types/node": "^12.11.1", - "jasmine-core": "~3.8.0", - "karma": "~6.3.0", - "karma-chrome-launcher": "~3.1.0", - "karma-coverage": "~2.0.3", - "karma-jasmine": "~4.0.0", - "karma-jasmine-html-reporter": "~1.7.0", - "typescript": "~4.3.5" - } -} \ No newline at end of file diff --git a/examples/Angular/src/app/app.component.css b/examples/Angular/src/app/app.component.css deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/Angular/src/app/app.component.html b/examples/Angular/src/app/app.component.html deleted file mode 100644 index 2ef3764e..00000000 --- a/examples/Angular/src/app/app.component.html +++ /dev/null @@ -1,11 +0,0 @@ - - -
- -
- -

Countly

-
diff --git a/examples/Angular/src/app/app.component.spec.ts b/examples/Angular/src/app/app.component.spec.ts deleted file mode 100644 index 9dc0b3ff..00000000 --- a/examples/Angular/src/app/app.component.spec.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { TestBed } from '@angular/core/testing'; -import { AppComponent } from './app.component'; - -describe('AppComponent', () => { - beforeEach(async () => { - await TestBed.configureTestingModule({ - declarations: [ - AppComponent - ], - }).compileComponents(); - }); - - it('should create the app', () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app).toBeTruthy(); - }); - - it(`should have as title 'Angular'`, () => { - const fixture = TestBed.createComponent(AppComponent); - const app = fixture.componentInstance; - expect(app.title).toEqual('Angular'); - }); - - it('should render title', () => { - const fixture = TestBed.createComponent(AppComponent); - fixture.detectChanges(); - const compiled = fixture.nativeElement as HTMLElement; - expect(compiled.querySelector('.content span')?.textContent).toContain('Angular app is running!'); - }); -}); diff --git a/examples/Angular/src/app/app.component.ts b/examples/Angular/src/app/app.component.ts deleted file mode 100644 index 89e329fb..00000000 --- a/examples/Angular/src/app/app.component.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { Component } from '@angular/core'; - -@Component({ - selector: 'app-root', - templateUrl: './app.component.html', - styleUrls: ['../../../style/style.css'] -}) -export class AppComponent { - title = 'Angular'; -} diff --git a/examples/Angular/src/app/app.module.ts b/examples/Angular/src/app/app.module.ts deleted file mode 100644 index 8dfc1d68..00000000 --- a/examples/Angular/src/app/app.module.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { NgModule } from '@angular/core'; -import { BrowserModule } from '@angular/platform-browser'; - -import { AppComponent } from './app.component'; - -@NgModule({ - declarations: [ - AppComponent - ], - imports: [ - BrowserModule - ], - providers: [], - bootstrap: [AppComponent] -}) -export class AppModule { } diff --git a/examples/Angular/src/assets/.gitkeep b/examples/Angular/src/assets/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/Angular/src/assets/logo.png b/examples/Angular/src/assets/logo.png deleted file mode 100644 index 5f0e72b5..00000000 Binary files a/examples/Angular/src/assets/logo.png and /dev/null differ diff --git a/examples/Angular/src/assets/team_countly.jpg b/examples/Angular/src/assets/team_countly.jpg deleted file mode 100644 index 9d5ff9df..00000000 Binary files a/examples/Angular/src/assets/team_countly.jpg and /dev/null differ diff --git a/examples/Angular/src/environments/environment.prod.ts b/examples/Angular/src/environments/environment.prod.ts deleted file mode 100644 index 3612073b..00000000 --- a/examples/Angular/src/environments/environment.prod.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const environment = { - production: true -}; diff --git a/examples/Angular/src/environments/environment.ts b/examples/Angular/src/environments/environment.ts deleted file mode 100644 index f56ff470..00000000 --- a/examples/Angular/src/environments/environment.ts +++ /dev/null @@ -1,16 +0,0 @@ -// This file can be replaced during build by using the `fileReplacements` array. -// `ng build` replaces `environment.ts` with `environment.prod.ts`. -// The list of file replacements can be found in `angular.json`. - -export const environment = { - production: false -}; - -/* - * For easier debugging in development mode, you can import the following file - * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. - * - * This import should be commented out in production mode because it will have a negative impact - * on performance if an error is thrown. - */ -// import 'zone.js/plugins/zone-error'; // Included with Angular CLI. diff --git a/examples/Angular/src/favicon.ico b/examples/Angular/src/favicon.ico deleted file mode 100644 index 997406ad..00000000 Binary files a/examples/Angular/src/favicon.ico and /dev/null differ diff --git a/examples/Angular/src/index.html b/examples/Angular/src/index.html deleted file mode 100644 index f83e2efd..00000000 --- a/examples/Angular/src/index.html +++ /dev/null @@ -1,49 +0,0 @@ - - - - - Countly Angular Integration - - - - - - - - - diff --git a/examples/Angular/src/polyfills.ts b/examples/Angular/src/polyfills.ts deleted file mode 100644 index 373f538a..00000000 --- a/examples/Angular/src/polyfills.ts +++ /dev/null @@ -1,65 +0,0 @@ -/** - * This file includes polyfills needed by Angular and is loaded before the app. - * You can add your own extra polyfills to this file. - * - * This file is divided into 2 sections: - * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. - * 2. Application imports. Files imported after ZoneJS that should be loaded before your main - * file. - * - * The current setup is for so-called "evergreen" browsers; the last versions of browsers that - * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), - * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. - * - * Learn more in https://angular.io/guide/browser-support - */ - -/*************************************************************************************************** - * BROWSER POLYFILLS - */ - -/** - * IE11 requires the following for NgClass support on SVG elements - */ -// import 'classlist.js'; // Run `npm install --save classlist.js`. - -/** - * Web Animations `@angular/platform-browser/animations` - * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. - * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). - */ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. - -/** - * By default, zone.js will patch all possible macroTask and DomEvents - * user can disable parts of macroTask/DomEvents patch by setting following flags - * because those flags need to be set before `zone.js` being loaded, and webpack - * will put import in the top of bundle, so user need to create a separate file - * in this directory (for example: zone-flags.ts), and put the following flags - * into that file, and then add the following code before importing zone.js. - * import './zone-flags'; - * - * The flags allowed in zone-flags.ts are listed here. - * - * The following flags will work for all browsers. - * - * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame - * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick - * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames - * - * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js - * with the following flag, it will bypass `zone.js` patch for IE/Edge - * - * (window as any).__Zone_enable_cross_context_check = true; - * - */ - -/*************************************************************************************************** - * Zone JS is required by default for Angular itself. - */ -import 'zone.js'; // Included with Angular CLI. - - -/*************************************************************************************************** - * APPLICATION IMPORTS - */ diff --git a/examples/Angular/src/styles.css b/examples/Angular/src/styles.css deleted file mode 100644 index 90d4ee00..00000000 --- a/examples/Angular/src/styles.css +++ /dev/null @@ -1 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ diff --git a/examples/Angular/src/test.ts b/examples/Angular/src/test.ts deleted file mode 100644 index b4dd6032..00000000 --- a/examples/Angular/src/test.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file is required by karma.conf.js and loads recursively all the .spec and framework files - -import 'zone.js/testing'; -import { getTestBed } from '@angular/core/testing'; -import { - BrowserDynamicTestingModule, - platformBrowserDynamicTesting -} from '@angular/platform-browser-dynamic/testing'; - -declare const require: { - context(path: string, deep?: boolean, filter?: RegExp): { - keys(): string[]; - (id: string): T; - }; -}; - -// First, initialize the Angular testing environment. -getTestBed().initTestEnvironment( - BrowserDynamicTestingModule, - platformBrowserDynamicTesting(), - { teardown: { destroyAfterEach: true }}, -); - -// Then we find all the tests. -const context = require.context('./', true, /\.spec\.ts$/); -// And load the modules. -context.keys().map(context); diff --git a/examples/Angular/tsconfig.app.json b/examples/Angular/tsconfig.app.json deleted file mode 100644 index 82d91dc4..00000000 --- a/examples/Angular/tsconfig.app.json +++ /dev/null @@ -1,15 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/app", - "types": [] - }, - "files": [ - "src/main.ts", - "src/polyfills.ts" - ], - "include": [ - "src/**/*.d.ts" - ] -} diff --git a/examples/Angular/tsconfig.json b/examples/Angular/tsconfig.json deleted file mode 100644 index 6df82832..00000000 --- a/examples/Angular/tsconfig.json +++ /dev/null @@ -1,30 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "compileOnSave": false, - "compilerOptions": { - "baseUrl": "./", - "outDir": "./dist/out-tsc", - "forceConsistentCasingInFileNames": true, - "strict": true, - "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true, - "sourceMap": true, - "declaration": false, - "downlevelIteration": true, - "experimentalDecorators": true, - "moduleResolution": "node", - "importHelpers": true, - "target": "es2017", - "module": "es2020", - "lib": [ - "es2018", - "dom" - ] - }, - "angularCompilerOptions": { - "enableI18nLegacyMessageIdFormat": false, - "strictInjectionParameters": true, - "strictInputAccessModifiers": true, - "strictTemplates": true - } -} diff --git a/examples/Angular/tsconfig.spec.json b/examples/Angular/tsconfig.spec.json deleted file mode 100644 index 092345b0..00000000 --- a/examples/Angular/tsconfig.spec.json +++ /dev/null @@ -1,18 +0,0 @@ -/* To learn more about this file see: https://angular.io/config/tsconfig. */ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "outDir": "./out-tsc/spec", - "types": [ - "jasmine" - ] - }, - "files": [ - "src/test.ts", - "src/polyfills.ts" - ], - "include": [ - "src/**/*.spec.ts", - "src/**/*.d.ts" - ] -} diff --git a/examples/README.md b/examples/README.md index 4bce5f47..1979908f 100644 --- a/examples/README.md +++ b/examples/README.md @@ -8,3 +8,37 @@ For all projects you should change 'YOUR_APP_KEY' value with your own applicatio If you have not separated 'examples' folder from the 'COUNTLY-SDK-WEB' project folder nor made some changes to file names in the periphery, any path to countly.js or the plugins must be still correct. But if you did make some changes you should check if the paths, like '../lib/countly.js', are correct or not inside the example files. + +## Genrating Examples + +You can use the create_examples.py to generate example implementations of Countly Web SDK for React or Angular. +It also can create an example that can be used to demonstrate the symbolication for Web SDK. + +To use the script: + +```bash +python create_examples.py +# or python3 create_examples.py +``` + +It would ask for the example you want to create (react/angular/symbolication/all). +After it creates the example(s) you want, you will have to run the following command(s) to serve/run the example(s): + +```bash +# For angular-example +cd angular-example +ng serve +``` + +```bash +# For react-example +cd react-example +npm start +``` + +```bash +# For symbolication-example +cd symbolication-example +npm run build +npm start +``` diff --git a/examples/symbolication/static/index.html b/examples/Symbolication/public/index.html similarity index 90% rename from examples/symbolication/static/index.html rename to examples/Symbolication/public/index.html index 6c66acce..be32d29f 100644 --- a/examples/symbolication/static/index.html +++ b/examples/Symbolication/public/index.html @@ -1,6 +1,6 @@ - +
diff --git a/examples/symbolication/src/index.js b/examples/Symbolication/src/main.js similarity index 95% rename from examples/symbolication/src/index.js rename to examples/Symbolication/src/main.js index be3f7126..274f0fde 100644 --- a/examples/symbolication/src/index.js +++ b/examples/Symbolication/src/main.js @@ -1,4 +1,4 @@ -import Countly from "../../../lib/countly.js" +import Countly from "countly-sdk-web"; Countly.init({ app_key: "YOUR_APP_KEY", diff --git a/examples/create_examples.py b/examples/create_examples.py new file mode 100644 index 00000000..6273ae8a --- /dev/null +++ b/examples/create_examples.py @@ -0,0 +1,63 @@ +import shutil +import os +import platform + +# Creates an example React or Angular or a bundled JS example (or all) +# Depends on the content of React and Angular and Symbolication folders respectively + +def setup_react_example(): + print("Creating React example...") + os.system("npx create-react-app react-example") + + # Remove existing src folder + if os.path.exists("react-example/src"): + shutil.rmtree("react-example/src") + + # Copy contents of React folder over to React example + shutil.copytree("React", "react-example", dirs_exist_ok=True) + + os.chdir("react-example") + # Add countly-sdk-web to dependencies in package.json + os.system("npm install --save countly-sdk-web@latest react-router-dom@5.3.3") + os.chdir("..") + +def setup_angular_example(): + print("Creating Angular example...") + os.system("npx @angular/cli new angular-example --defaults") + + # Copy contents of Angular folder over to Angular example + shutil.copytree("Angular", "angular-example/src", dirs_exist_ok=True) + + os.chdir("angular-example") + # Add countly-sdk-web to dependencies in package.json + os.system("npm install --save countly-sdk-web@latest") + os.chdir("..") + +def setup_symbolication_example(): + print("Creating Symbolication example...") + os.system('npx degit "rollup/rollup-starter-app" symbolication-example') + + # Copy contents of Symbolication folder over to Symbolication example + shutil.copytree("Symbolication/public", "symbolication-example/public", dirs_exist_ok=True) + shutil.copytree("Symbolication/src", "symbolication-example/src", dirs_exist_ok=True) + + os.chdir("symbolication-example") + # Add countly-sdk-web to dependencies in package.json + os.system("npm install --save countly-sdk-web@latest") + os.chdir("..") + +if __name__ == "__main__": + example = input('Select an example to create (react/angular/symbolication/all): ') + if example == "react": + setup_react_example() + elif example == "angular": + setup_angular_example() + elif example == "symbolication": + setup_symbolication_example() + elif example == "all": + setup_react_example() + setup_angular_example() + setup_symbolication_example() + else: + print("Invalid input. Exiting...") + exit(1) diff --git a/examples/react/README.md b/examples/react/README.md deleted file mode 100644 index d6d07a85..00000000 --- a/examples/react/README.md +++ /dev/null @@ -1,31 +0,0 @@ -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). - -## Available Scripts -In the project directory, you can run: - -### `npm start` -Runs the app in the development mode. -Open [http://localhost:3000](http://localhost:3000) to view it in the browser. - -The page will reload if you make edits. -You will also see any lint errors in the console. - -### `npm test` -Launches the test runner in the interactive watch mode. -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. - -### `npm run build` -Builds the app for production to the `build` folder. -It correctly bundles React in production mode and optimizes the build for the best performance. - -The build is minified and the filenames include the hashes. -Your app is ready to be deployed! - -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. - -### Integrating Countly -This project explains how to integrate Countly web sdk using hooks and class based components. -You can try both methods by simply changing the root `App` component export from `index.js`. - -`App-WithEffect.js` uses hooks to integrate the countly SDK -`App-WithRouter.js` uses class based components to integrate the countly SDK diff --git a/examples/react/package.json b/examples/react/package.json deleted file mode 100644 index d1aeaf8c..00000000 --- a/examples/react/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "name": "cly-react", - "version": "0.1.0", - "private": true, - "dependencies": { - "countly-sdk-web": "^23.6.3" - }, - "devDependencies": { - "react": "^18.2.0", - "react-dom": "^18.2.0", - "react-router-dom": "^5.3.3", - "react-scripts": "5.0.1" - }, - "scripts": { - "start": "react-scripts start", - "build": "react-scripts build", - "test": "react-scripts test", - "eject": "react-scripts eject" - }, - "homepage": "", - "eslintConfig": { - "extends": "react-app" - }, - "browserslist": { - "production": [ - ">0.2%", - "not dead", - "not op_mini all" - ], - "development": [ - "last 1 chrome version", - "last 1 firefox version", - "last 1 safari version" - ] - } -} \ No newline at end of file diff --git a/examples/react/public/favicon.ico b/examples/react/public/favicon.ico deleted file mode 100644 index bcd5dfd6..00000000 Binary files a/examples/react/public/favicon.ico and /dev/null differ diff --git a/examples/react/public/index.html b/examples/react/public/index.html deleted file mode 100644 index 9d02fc05..00000000 --- a/examples/react/public/index.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - Countly React Demo - - - -
- - diff --git a/examples/react/public/manifest.json b/examples/react/public/manifest.json deleted file mode 100644 index 080d6c77..00000000 --- a/examples/react/public/manifest.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "short_name": "React App", - "name": "Create React App Sample", - "icons": [ - { - "src": "favicon.ico", - "sizes": "64x64 32x32 24x24 16x16", - "type": "image/x-icon" - }, - { - "src": "logo192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "logo512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "start_url": ".", - "display": "standalone", - "theme_color": "#000000", - "background_color": "#ffffff" -} diff --git a/examples/react/public/robots.txt b/examples/react/public/robots.txt deleted file mode 100644 index e9e57dc4..00000000 --- a/examples/react/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -# https://www.robotstxt.org/robotstxt.html -User-agent: * -Disallow: diff --git a/examples/react/src/index.js b/examples/react/src/index.js index aaf01da9..d5461ab1 100644 --- a/examples/react/src/index.js +++ b/examples/react/src/index.js @@ -11,44 +11,9 @@ window.Countly = Countly; Countly.init({ app_key: 'YOUR_APP_KEY', url: 'YOUR_SERVER_URL', - session_update: 10, - use_session_cookie: true, - debug: false, - require_consent: true, - namespace: "react-demo", - inactivity_time: 1, - offline_mode: false, - // device_id: "cly-device-demo-id" //Set only if you want dont want to use countly generated device_id + debug: true }); -//Since Countly is loaded and available, you can use synchronus or asynchronus calls, does not matter -Countly.q.push(['group_features', { - activity: ["sessions", "events", "views", "location"], - interaction: ["scrolls", "clicks", "crashes"], - whereabouts: ["users"] -}]); - -if (typeof(localStorage) !== "undefined") { - var consents = localStorage.getItem("consents"); - - if(consents){ - Countly.q.push(['add_consent', JSON.parse(consents)]); - } - else{ - var consent = window.confirm("We are going to track you. Do you give your consent ?"); - consents = ["activity", "interaction", "whereabouts"]; - if(consent) { - Countly.q.push(['add_consent', consents]); - localStorage.setItem("consents", JSON.stringify(consents)); - } - else { - Countly.q.push(['remove_consent', consents]); - localStorage.removeItem("consents"); - } - } -} - -Countly.q.push(['enableRatingWidgets', {'widgets': ['widget-id-1','widget-id-2']}]); Countly.q.push(['track_sessions']); Countly.q.push(['track_scrolls']); Countly.q.push(['track_clicks']); diff --git a/examples/symbolication/.babelrc b/examples/symbolication/.babelrc deleted file mode 100644 index 3508558d..00000000 --- a/examples/symbolication/.babelrc +++ /dev/null @@ -1,11 +0,0 @@ -{ - "plugins": ["syntax-dynamic-import"], - "presets": [ - [ - "@babel/preset-env", - { - "modules": false - } - ] - ] -} diff --git a/examples/symbolication/.editorconfig b/examples/symbolication/.editorconfig deleted file mode 100644 index a4b824b5..00000000 --- a/examples/symbolication/.editorconfig +++ /dev/null @@ -1,8 +0,0 @@ -root = true - -[*] -charset = utf-8 -end_of_line = lf -insert_final_newline = true -indent_style = space -indent_size = 2 diff --git a/examples/symbolication/.gitignore b/examples/symbolication/.gitignore deleted file mode 100644 index 16acd49d..00000000 --- a/examples/symbolication/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -dist -package-lock.json diff --git a/examples/symbolication/.yo-rc.json b/examples/symbolication/.yo-rc.json deleted file mode 100644 index 9bf0810a..00000000 --- a/examples/symbolication/.yo-rc.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "sample-app": { - "configuration": { - "config": { - "configName": "config", - "topScope": [ - "const path = require('path');", - "const webpack = require('webpack');", - "\n", - "/*\n * SplitChunksPlugin is enabled by default and replaced\n * deprecated CommonsChunkPlugin. It automatically identifies modules which\n * should be splitted of chunk by heuristics using module duplication count and\n * module category (i. e. node_modules). And splits the chunks…\n *\n * It is safe to remove \"splitChunks\" from the generated configuration\n * and was added as an educational example.\n *\n * https://webpack.js.org/plugins/split-chunks-plugin/\n *\n */", - "/*\n * We've enabled TerserPlugin for you! This minifies your app\n * in order to load faster and run less javascript.\n *\n * https://github.com/webpack-contrib/terser-webpack-plugin\n *\n */", - "const TerserPlugin = require('terser-webpack-plugin');", - "\n" - ], - "webpackOptions": { - "mode": "'development'", - "plugins": [ - "new webpack.ProgressPlugin()" - ], - "module": { - "rules": [ - { - "test": "/\\.(js|jsx)$/", - "include": [ - "path.resolve(__dirname, 'src')" - ], - "loader": "'babel-loader'" - } - ] - }, - "optimization": { - "minimizer": [ - "new TerserPlugin()" - ], - "splitChunks": { - "cacheGroups": { - "vendors": { - "priority": -10, - "test": "/[\\\\/]node_modules[\\\\/]/" - } - }, - "chunks": "'async'", - "minChunks": 1, - "minSize": 30000, - "name": true - } - } - } - }, - "usingDefaults": false - } - } -} diff --git a/examples/symbolication/README.md b/examples/symbolication/README.md deleted file mode 100644 index c16d749c..00000000 --- a/examples/symbolication/README.md +++ /dev/null @@ -1,32 +0,0 @@ -# Countly Web SDK Crash Test Sample App -This project has been created to generate crashes in sourcemapped files to -demonstrate Countly's ability to process stacktraces that occured on uglified -(minified, transpiled etc) Javascript files to point to the correct locations -on their original source files. - -To build the main javascript file (which also produces a sourcemap file), run: - -```bash -npm run build -``` - -You can observe that webpack packed our `src/index.js` file and our -`countly-web-sdk` dependency into a single file `dist/main.js`. It also -produced a sourcemap file `dist/main.js.map` which contains the contents of -all the files it packed into `dist/main.js` along with information on how -original source files are mapped into their final form, so we can later tell -where an error occured on the original source files. - -To symbolicate errors on Countly you need to navigate to `Improve > Errors > -Manage Symbols` on your Countly instance and upload your symbolmap there, -making sure the application version you enter there matches the application -version you pass to the Countly Web SDK in `src/index.js`. - -Then you can navigate to `static/index.html` on your browser and click the -error buttons to fire off some errors and send them to your Countly instance. - -Now, to symbolicate them, navigate to `Improve > Errors > Overview` and find -the error that goes something like `ReferenceError: undefined_function is not -defined` and click on it. Then click the Symbolicate button to symbolicate it -and see that the symbolicated stacktrace lines point to the correct positions -in the original source files. diff --git a/examples/symbolication/package.json b/examples/symbolication/package.json deleted file mode 100644 index 8f95ddbf..00000000 --- a/examples/symbolication/package.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "name": "countly-sdk-web-sample-app", - "version": "1.0.0", - "description": "A sample web app to try Countly SDK features", - "author": "Countly (https://countly.com/)", - "license": "MIT", - "main": "src/index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1", - "build": "webpack" - }, - "devDependencies": { - "@babel/preset-env": "7.21.4", - "@babel/core": "7.23.2", - "babel-loader": "8.2.5", - "babel-plugin-syntax-dynamic-import": "6.18.0", - "webpack": "5.77.0", - "webpack-cli": "4.10.0" - } -} diff --git a/examples/symbolication/webpack.config.js b/examples/symbolication/webpack.config.js deleted file mode 100644 index a5e9003b..00000000 --- a/examples/symbolication/webpack.config.js +++ /dev/null @@ -1,19 +0,0 @@ -const path = require('path'); - -module.exports = { - mode: 'none', - devtool: 'source-map', - module: { - rules: [ - { - test: /\.(js|jsx)$/, - include: [path.resolve(__dirname, 'src')], - loader: 'babel-loader', - }, - ], - }, - output: { - devtoolModuleFilenameTemplate: '[resource-path]', - devtoolFallbackModuleFilenameTemplate: '[absolute-resource-path]', - }, -};