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

fix: add rudderanalytics #18

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"main": "./src/cli/index.js",
"bin": "./src/cli/index.js",
"scripts": {
"init": "TS_NODE_FILES=true ts-node ./src/cli init",
"dev": "TS_NODE_FILES=true NODE_ENV=development ts-node ./src/cli",
"prod": "TS_NODE_FILES=true NODE_ENV=production ts-node ./src/cli prod",
"build": "rm -rf dist && tsc && copyfiles --up 1 \"src/**/*.hbs\" dist/src/ && copyfiles \"README.*\" dist/ && copyfiles \"CHANGELOG.*\" dist/",
Expand Down
8 changes: 4 additions & 4 deletions src/generators/javascript/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,10 @@ For more information on analytics-node, see: https://docs.rudderstack.com/stream
`)
{{/unless}}

{{!-- We use a closure so we can lazy-resolve window.analytics in browser environments. --}}
{{!-- We use a closure so we can lazy-resolve window.rudderanalytics in browser environments. --}}
let analytics: () => ({{#if isBrowser}}any{{else}}Rudder.AnalyticsNode{{/if}} | undefined) = () => {
{{#if isBrowser}}
return window.analytics
return window.rudderanalytics
{{else}}
throw missingAnalyticsNodeError
{{/if}}
Expand All @@ -108,7 +108,7 @@ export interface RudderTyperOptions {
/**
* Underlying analytics instance where analytics calls are forwarded on to.
{{#if isBrowser}}
* Defaults to window.analytics.
* Defaults to window.rudderanalytics.
{{/if}}
*/
analytics{{#if isBrowser}}?{{/if}}: {{#if isBrowser}}any{{else}}Rudder.AnalyticsNode{{/if}}
Expand All @@ -125,7 +125,7 @@ export interface RudderTyperOptions {

{{> setRudderTyperOptionsDocumentation}}
export function setRudderTyperOptions(options: RudderTyperOptions) {
analytics = options.analytics ? () => options.analytics{{#if isBrowser}} || window.analytics{{/if}} : analytics
analytics = options.analytics ? () => options.analytics{{#if isBrowser}} || window.rudderanalytics{{/if}} : analytics
{{#if isDevelopment}}
onViolation = options.onViolation || onViolation
{{/if}}
Expand Down
2 changes: 1 addition & 1 deletion src/generators/javascript/templates/rudder.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
*/
declare global {
interface Window {
analytics: any
rudderanalytics: any
}
}

Expand Down
Loading